Skip to content

Commit

Permalink
Refactor/cla 122 unify window and main window and rename it to main p…
Browse files Browse the repository at this point in the history
…ane (#91)

* cla-122: merged window and main_window in main_window

* cla-122: renamed demo_window to demo_main_pane to be consistent with main_pane
  • Loading branch information
ebasconp authored Dec 5, 2024
1 parent c04421c commit d21807b
Show file tree
Hide file tree
Showing 18 changed files with 143 additions and 212 deletions.
90 changes: 46 additions & 44 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,53 @@
# CHANGELOG #

* 20241128 Added captionable_control::set_formatted_text template method
* 20241128 Added clsn::system::get_build_id() and clsn::system::get_version()
* 20241127 Fix crash when resetting parent window and mouse grabbed
* 20241126 Demo website created using the Emscripten binaries
* 20241123 Added support for Emscripten!
* 20241109 Created font_manager
* 20241106 Added use of preferred_size to box layouts
* 20241106 Generalized algorithm for box layouts
* 20241104 Improved theming support
* 20241101 Removed section_name from control
* 20241031 Created theme_manager and removed skins
* 20241029 CLSN_ASSERT macro added
* 20241028 removed region from renderer_base::paint()
* 20241206 renamed `main_window` to `main_pane`
* 20241201 0.1.0-alpha released
* 20241128 added `captionable_control::set_formatted_text` template method
* 20241128 added `clsn::system::get_build_id()` and `clsn::system::get_version()`
* 20241127 fix crash when resetting parent window and mouse grabbed
* 20241126 demo website created using the Emscripten binaries
* 20241123 added support for Emscripten!
* 20241109 created font_manager
* 20241106 added use of preferred_size to box layouts
* 20241106 generalized algorithm for box layouts
* 20241104 improved theming support
* 20241101 removed section_name from control
* 20241031 created theme_manager and removed skins
* 20241029 `CLSN_ASSERT` macro added
* 20241028 removed region from `renderer_base::paint()`
* 20241025 added tab_control
* 20241002 added dynamic and static content panes
* 20240917 added doxygen action in github
* 20240916 created demo app
* 20240904 created clsn::ui::dynamic_pane
* 20240826 Renamed list_container to layout_container
* 20240826 Added layouts and refactored containers
* 20240815 Added mono_container class
* 20240815 Added container class
* 20240809 Added Windows support
* 20240809 Added padding_control
* 20240808 Made all project snake_case
* 20240904 created `clsn::ui::dynamic_pane`
* 20240826 renamed list_container to layout_container
* 20240826 added layouts and refactored containers
* 20240815 added mono_container class
* 20240815 added container class
* 20240809 added Windows support
* 20240809 added padding_control
* 20240808 made all project snake_case
* 20240806 flow_container
* 20240731 Created dual_layout_container
* 20240729 Moved do_layout() from renderer_base to control
* 20240726 Added isValidControl() in layout_container
* 20240724 Moved texture to graphics
* 20240723 Painting on a texture instead of default surface
* 20240722 Support for hovering
* 20240720 Renamed default skin to Amatista
* 20240718 Created base DefaultUITheme
* 20240716 Added support for dynamically change theme
* 20240715 Added ui_theme and implemented Light and Dark themes
* 20240710 Added ui_skin and DefaultUISkin
* 20240710 Improved label rendering
* 20240701 Added xy_container
* 20240627 Improved radio_button renderer
* 20240626 Added radio_button
* 20240625 Added check_box rendering
* 20240624 Starting check_box implementation
* 20240620 Implementing container_renderer base class
* 20240620 Using do_layout to calculate position and size
* 20240619 Fixed crash when out of range
* 20240618 Added toggle_button
* 20240618 Added toggle_control
* 20240618 Added window::grabMouse() and window::release_mouse()
* 20240731 created dual_layout_container
* 20240729 moved `do_layout()` from renderer_base to control
* 20240726 added isValidControl() in layout_container
* 20240724 moved texture to graphics
* 20240723 painting on a texture instead of default surface
* 20240722 support for hovering
* 20240720 renamed default skin to Amatista
* 20240718 created base DefaultUITheme
* 20240716 added support for dynamically change theme
* 20240715 added ui_theme and implemented Light and Dark themes
* 20240710 added ui_skin and DefaultUISkin
* 20240710 improved label rendering
* 20240701 added `xy_container`
* 20240627 improved `radio_button_renderer`
* 20240626 added `radio_button`
* 20240625 added `check_box` rendering
* 20240624 starting `check_box` implementation
* 20240620 implementing `container_renderer` base class
* 20240620 using `do_layout` to calculate position and size
* 20240619 fixed crash when out of range
* 20240618 added `toggle_button`
* 20240618 added `toggle_control`
* 20240618 added `window::grabMouse()` and `window::release_mouse()`
44 changes: 21 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,31 @@ http://www.classeine.org

### 0.1.0-alpha (20241130)
#### Controls
- button
- check_box
- dynamic_content_pane
- empty_control
- label
- padding_control
- radio_button
- static_content_pane
- tab_control
- tab_page
- toggle_button
- `button`
- `check_box`
- `dynamic_content_pane`
- `empty_control`
- `label`
- `main_pane` (control that will show the application)
- `padding_control`
- `radio_button`
- `static_content_pane`
- `tab_control`
- `tab_page`
- `toggle_button`

#### Containers
- dual_layout_container
- flow_layout_container
- hbox_layout_container
- vbox_layout_container
- xy_layout_container
- `dual_layout_container`
- `flow_layout_container`
- `hbox_layout_container`
- `vbox_layout_container`
- `xy_layout_container`

#### Managers
- font_manager
- theme_manager
- ui_manager

#### Windows
- main_window
- window
- `font_manager`
- `mouse_manager`
- `theme_manager`
- `ui_manager` (general UI manager)

#### Additional tools
- Properties
Expand Down
2 changes: 1 addition & 1 deletion code/classeine-demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ add_executable(classeine_demo
demo_layout_containers_tab_control.cpp
demo_tab_control.cpp
demo_xy_layout_container.cpp
demo_window.cpp
demo_main_pane.cpp
demo_overlays_control.cpp
)

Expand Down
4 changes: 2 additions & 2 deletions code/classeine-demo/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
// SPDX-FileCopyrightText: © 2024 Ernesto Bascón Pantoja


#include "demo_window.h"
#include "demo_main_pane.h"

void test()
{
clsn::demo::demo_window dw;
clsn::demo::demo_main_pane dw;
dw.set_visible(true);
}

Expand Down
8 changes: 4 additions & 4 deletions code/classeine-demo/demo_action_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// SPDX-FileCopyrightText: © 2024 Ernesto Bascón Pantoja

#include "demo_action_container.h"
#include "demo_window.h"
#include "demo_main_pane.h"

#include "clsn/draw/dimension.h"

Expand All @@ -21,8 +21,8 @@ namespace clsn::demo
using namespace clsn::ui;
using namespace clsn::ui::events;

demo_action_container::demo_action_container(demo_window& demo_window)
: m_demo_window{demo_window}
demo_action_container::demo_action_container(demo_main_pane& demo_main_pane)
: m_demo_main_pane{demo_main_pane}
{
set_preferred_size(dimension{175, 0});

Expand Down Expand Up @@ -56,7 +56,7 @@ namespace clsn::demo

enable_all_except_the_one_with_this_action_name(action_name);

m_demo_window.set_title(action_name + " demo");
m_demo_main_pane.set_title(action_name + " demo");

auto it = m_action_handlers.find(action_name);
if (it == m_action_handlers.end())
Expand Down
8 changes: 4 additions & 4 deletions code/classeine-demo/demo_action_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: © 2024 Ernesto Bascón Pantoja

#include "demo_window.h"
#include "demo_main_pane.h"

#include <clsn/ui/button.h>
#include <clsn/ui/dynamic_content_pane.h>
Expand All @@ -22,10 +22,10 @@ namespace clsn::demo
{
std::unordered_map<std::string, std::function<void()>> m_action_handlers;

demo_window& m_demo_window;
demo_main_pane& m_demo_main_pane;

public:
explicit demo_action_container(demo_window&);
explicit demo_action_container(demo_main_pane&);

private:
template <typename T>
Expand All @@ -38,7 +38,7 @@ namespace clsn::demo

m_action_handlers.insert({std::string{action_name}, [this]()
{
m_demo_window.get_content_pane().set_inner_control(control::make<T>());
m_demo_main_pane.get_content_pane().set_inner_control(control::make<T>());
}});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: © 2024 Ernesto Bascón Pantoja

#include "demo_window.h"
#include "demo_main_pane.h"

#include <clsn/draw/colors.h>
#include <clsn/draw/dimension.h>
Expand All @@ -20,20 +20,20 @@ namespace clsn::demo
using namespace clsn::ui;
using namespace clsn::ui::layouts;

demo_window::demo_window()
demo_main_pane::demo_main_pane()
{
set_caption("Classeine");
set_size({800, 600});

init_container();
}

auto demo_window::get_content_pane() -> dynamic_content_pane&
auto demo_main_pane::get_content_pane() -> dynamic_content_pane&
{
return *m_content_pane;
}

void demo_window::init_container()
void demo_main_pane::init_container()
{
m_action_container = control::make<demo_action_container>(*this);

Expand All @@ -53,7 +53,7 @@ namespace clsn::demo
m_content_pane->set_background_color(clsn::draw::color{128, 0, 64});
}

void demo_window::set_title(const std::string& title)
void demo_main_pane::set_title(const std::string& title)
{
m_label->set_formatted_caption("{} (Build: {})",
title, core::system::get_build_id());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <clsn/ui/forward.h>
#include <clsn/ui/dual_layout_container.h>
#include <clsn/ui/main_window.h>
#include <clsn/ui/main_pane.h>

#include <string>

Expand All @@ -17,14 +17,14 @@ namespace clsn::demo

class demo_action_container;

class demo_window : public main_window<dual_layout_container>
class demo_main_pane : public main_pane<dual_layout_container>
{
std::shared_ptr<demo_action_container> m_action_container;
std::shared_ptr<label> m_label;
std::shared_ptr<dynamic_content_pane> m_content_pane;

public:
demo_window();
demo_main_pane();

void set_title(const std::string& title);

Expand Down
1 change: 0 additions & 1 deletion code/classeine-lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ add_library(classeine_lib
clsn/ui/ui_theme.cpp
clsn/ui/ui_theme_manager.cpp
clsn/ui/vbox_layout_container.cpp
clsn/ui/window.cpp
clsn/ui/xy_layout_container.cpp

clsn/ui/_private/tab_control_view_header_button.cpp
Expand Down
4 changes: 2 additions & 2 deletions code/classeine-lib/clsn/ui/clickable_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <clsn/ui/clickable_control.h>
#include <clsn/ui/ui_manager.h>
#include <clsn/ui/ui_mouse_manager.h>
#include <clsn/ui/window.h>

namespace clsn::ui
{
Expand All @@ -22,7 +21,8 @@ namespace clsn::ui
return m_pressed;
}

void clickable_control::add_action_listener(clsn::core::event_listener<events::action_event> event)
void clickable_control::add_action_listener(
core::event_listener<events::action_event> event)
{
m_action_listeners.add(std::move(event));
}
Expand Down
4 changes: 1 addition & 3 deletions code/classeine-lib/clsn/ui/constrained_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#pragma once

#include <clsn/ui/container.h>
#include <clsn/ui/window.h>

namespace clsn::ui
{
Expand Down Expand Up @@ -112,8 +111,7 @@ namespace clsn::ui
///
/// This function can be overridden to check the validity of a constraint before it is added.
/// By default, it does nothing.
/// @param constraint_ The constraint to be checked.
virtual void check_if_valid_before_adding(const constraint&) const
virtual void check_if_valid_before_adding(const constraint& ) const
{
// Do nothing here
}
Expand Down
9 changes: 1 addition & 8 deletions code/classeine-lib/clsn/ui/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include <clsn/ui/paintable_control.h>
#include <clsn/ui/ui_manager.h>

#include <clsn/ui/window.h>

#include <algorithm>
#include <ranges>

Expand Down Expand Up @@ -41,7 +39,6 @@ namespace clsn::ui
container()
: m_needs_to_paint_the_container{false}
{
load_container_defaults();
init_container_events();
}

Expand Down Expand Up @@ -228,8 +225,6 @@ namespace clsn::ui
{
control::load_defaults();

load_container_defaults();

for (auto& c : get_controls())
{
c.load_defaults();
Expand All @@ -248,7 +243,7 @@ namespace clsn::ui
if (!c.is_visible() || !c.is_enabled())
continue;

auto result = c.get_control_by_position(point);
const auto result = c.get_control_by_position(point);
if (result.has_value())
return result;
}
Expand Down Expand Up @@ -332,8 +327,6 @@ namespace clsn::ui
add_actual_size_changed_listener([this](auto&) { do_layout(); });
}

void load_container_defaults() {}

auto get_theme_background_color() const -> draw::color override
{
return get_theme().get_container_background_color();
Expand Down
Loading

0 comments on commit d21807b

Please sign in to comment.