Skip to content

Commit

Permalink
[ref][update] individual-theme-scheme based system
Browse files Browse the repository at this point in the history
  • Loading branch information
MrsRina committed Feb 1, 2025
1 parent 95c81b7 commit 6a5181d
Show file tree
Hide file tree
Showing 17 changed files with 555 additions and 354 deletions.
3 changes: 2 additions & 1 deletion devlog/commit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,5 @@
-- Added properties, stack, and new IO features.
-- Added bitwise op on `io/memory.hpp` template.
-- Added properties overload operator for casting widget and descriptor.
-- Refactored and optimized input-service with addressed input bind without useless hash queries.
-- Refactored and optimized input-service with addressed input bind without useless hash queries.
-- New individual-theme-scheme system for service theme.
114 changes: 34 additions & 80 deletions include/ekg/service/theme.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,21 @@
#include <vector>
#include <string_view>
#include <map>
#include "ekg/util/geometry.hpp"

namespace ekg::service {
struct theme_scheme_t {
#include "ekg/ui/button/button.hpp"
#include "ekg/ui/checkbox/checkbox.hpp"
#include "ekg/ui/combobox/combobox.hpp"
#include "ekg/ui/frame/frame.hpp"
#include "ekg/ui/label/label.hpp"
#include "ekg/ui/listbox/listbox.hpp"
#include "ekg/ui/menu/menu.hpp"
#include "ekg/ui/popup/popup.hpp"
#include "ekg/ui/scrollbar/scrollbar.hpp"
#include "ekg/ui/slider/slider.hpp"
#include "ekg/ui/textbox/textbox.hpp"

namespace ekg {
struct theme_t {
public:
std::string_view name {};
std::string_view author {};
Expand All @@ -42,82 +53,25 @@ namespace ekg::service {
bool symmetric_layout {};
float min_widget_size {5};

ekg::vec4 frame_background {};
ekg::vec4 frame_border {};
ekg::vec4 frame_outline {};
int32_t frame_activity_offset {};

ekg::vec4 button_background {};
ekg::vec4 button_string {};
ekg::vec4 button_outline {};
ekg::vec4 button_activity {};
ekg::vec4 button_highlight {};

ekg::vec4 checkbox_background {};
ekg::vec4 checkbox_string {};
ekg::vec4 checkbox_outline {};
ekg::vec4 checkbox_activity {};
ekg::vec4 checkbox_highlight {};

ekg::vec4 slider_background {};
ekg::vec4 slider_bar_background {};
ekg::vec4 slider_string {};
ekg::vec4 slider_outline {};
ekg::vec4 slider_activity {};
ekg::vec4 slider_activity_bar {};
ekg::vec4 slider_bar_outline {};
ekg::vec4 slider_highlight {};
int32_t slider_bar_thickness {};
int32_t slider_target_thickness {};

ekg::vec4 label_string {};
ekg::vec4 label_outline {};
ekg::vec4 label_background {};

ekg::vec4 popup_background {};
ekg::vec4 popup_string {};
ekg::vec4 popup_outline {};
ekg::vec4 popup_highlight {};
ekg::vec4 popup_separator {};
int64_t popup_drop_animation_delay {};

ekg::vec4 textbox_string {};
ekg::vec4 textbox_background {};
ekg::vec4 textbox_outline {};
ekg::vec4 textbox_cursor {};
ekg::vec4 textbox_select {};

ekg::vec4 scrollbar_background {};
ekg::vec4 scrollbar_outline {};
ekg::vec4 scrollbar_activity {};
ekg::vec4 scrollbar_highlight {};
int32_t scrollbar_pixel_thickness {};
float scrollbar_min_bar_size {};

ekg::vec4 listbox_header_background {};
ekg::vec4 listbox_header_highlight_outline {};
ekg::vec4 listbox_header_highlight {};
ekg::vec4 listbox_header_outline {};
ekg::vec4 listbox_header_string {};
ekg::vec4 listbox_item_background {};
ekg::vec4 listbox_item_highlight_outline {};
ekg::vec4 listbox_item_highlight {};
ekg::vec4 listbox_item_focused {};
ekg::vec4 listbox_item_focused_outline {};
ekg::vec4 listbox_item_string {};
ekg::vec4 listbox_item_outline {};
ekg::vec4 listbox_outline {};
ekg::vec4 listbox_background {};
ekg::vec4 listbox_line_separator {};
ekg::vec4 listbox_drag_background {};
ekg::vec4 listbox_drag_outline {};
float listbox_subitem_offset_space {4.0f};
ekg::button_theme_t button {};
ekg::checkbox_theme_t checkbox {};
ekg::combobox_theme_t combobox {};
ekg::frame_theme_t frame {};
ekg::label_theme_t label {};
ekg::listbox_theme_t listbox {};
ekg::menu_theme_t menu {};
ekg::popup_theme_t popup {};
ekg::scrollbar_theme_t scrollbar {};
ekg::slider_theme_t slider {};
ekg::textbox_theme_t textbox {};
};
}

namespace ekg::service {
class theme {
protected:
std::map<std::string_view, ekg::service::theme_scheme_t> theme_scheme_map {};
ekg::service::theme_scheme_t current_theme_scheme {};
std::map<std::string_view, ekg::theme_t> theme_map {};
ekg::theme_t current_theme {};
public:
/**
* Initialize default themes (dark, light, pinky etc) and update global theme scheme.
Expand All @@ -130,27 +84,27 @@ namespace ekg::service {
* Returns all mapped schemes from theme service.
* Note: Use property register/deregister methods; may be unsafe.
**/
std::map<std::string_view, ekg::service::theme_scheme_t> &get_theme_scheme_map();
std::map<std::string_view, ekg::theme_t> &get_theme_map();

/**
* Set the current theme global.
* Note: You must set a registered theme.
*
* Returns true if exists, else false.
**/
bool set_current_theme_scheme(std::string_view name);
bool set_current_theme(std::string_view name);

/**
* Returns the current theme scheme global loaded.
**/
ekg::service::theme_scheme_t &get_current_theme_scheme();
ekg::theme_t &get_current_theme();

/**
* Dynamic registry one theme scheme on memory, you must not repeat themes name.
* Note: May you want save theme scheme in a file, use `ekg::service::theme::save`
* method to do that.
**/
void add(ekg::service::theme_scheme_t theme_scheme);
void add(ekg::theme_t theme);

/**
* Local save one theme scheme to a file.
Expand All @@ -162,7 +116,7 @@ namespace ekg::service {
* Read one theme scheme from a file and load it to memory; may replacing one
* if already exists.
**/
void read(std::string_view path, ekg::service::theme_scheme_t *p_theme_scheme);
void read(std::string_view path, ekg::theme_t *p_theme);
};
}

Expand Down
12 changes: 6 additions & 6 deletions include/ekg/ui/abstract.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@

#include "ekg/ui/properties.hpp"

namespace ekg {
enum type {
abstract,
frame
namespace ekg::ui {
struct states_t {
public:
bool is_hover {};
bool is_absolute {};
};
};

namespace ekg::ui {
class abstract {
public:
ekg::properties_t properties {};
ekg::ui::states_t states {};
public:

};
Expand Down
21 changes: 21 additions & 0 deletions include/ekg/ui/button/button.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef EKG_UI_BUTTON_HPP
#define EKG_UI_BUTTON_HPP

#include "ekg/math/geometry.hpp"

namespace ekg {
struct button_theme_t {
public:
ekg::vec4<float> background {};
ekg::vec4<float> string {};
ekg::vec4<float> outline {};
ekg::vec4<float> activity {};
ekg::vec4<float> highlight {};
};

struct button_t {
public:
};
}

#endif
21 changes: 21 additions & 0 deletions include/ekg/ui/checkbox/checkbox.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef EKG_UI_CHECKBOX_HPP
#define EKG_UI_CHECKBOX_HPP

#include "ekg/math/geometry.hpp"

namespace ekg {
struct checkbox_theme_t {
public:
ekg::vec4<float> background {};
ekg::vec4<float> string {};
ekg::vec4<float> outline {};
ekg::vec4<float> activity {};
ekg::vec4<float> highlight {};
};

struct checkbox_t {
public:
};
}

#endif
16 changes: 16 additions & 0 deletions include/ekg/ui/combobox/combobox.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef EKG_UI_COMBOBOX_HPP
#define EKG_UI_COMBOBOX_HPP

#include "ekg/math/geometry.hpp"

namespace ekg {
struct combobox_theme_t {
public:
};

struct combobox_t {
public:
};
}

#endif
20 changes: 20 additions & 0 deletions include/ekg/ui/frame/frame.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef EKG_UI_FRAME_HPP
#define EKG_UI_FRAME_HPP

#include "ekg/math/geometry.hpp"

namespace ekg {
struct frame_theme_t {
public:
ekg::vec4<float> background {};
ekg::vec4<float> border {};
ekg::vec4<float> outline {};
int32_t activity_offset {};
};

struct frame_t {
public:
};
}

#endif
19 changes: 19 additions & 0 deletions include/ekg/ui/label/label.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef EKG_UI_LABEL_HPP
#define EKG_UI_LABEL_HPP

#include "ekg/math/geometry.hpp"

namespace ekg {
struct label_theme_t {
public:
ekg::vec4<float> string {};
ekg::vec4<float> outline {};
ekg::vec4<float> background {};
};

struct label_t {
public:
};
}

#endif
35 changes: 35 additions & 0 deletions include/ekg/ui/listbox/listbox.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef EKG_UI_LISTBOX_HPP
#define EKG_UI_LISTBOX_HPP

#include "ekg/math/geometry.hpp"

namespace ekg {
struct listbox_theme_t {
public:
ekg::vec4<float> header_background {};
ekg::vec4<float> header_highlight_outline {};
ekg::vec4<float> header_highlight {};
ekg::vec4<float> header_outline {};
ekg::vec4<float> header_string {};
ekg::vec4<float> item_background {};
ekg::vec4<float> item_highlight_outline {};
ekg::vec4<float> item_highlight {};
ekg::vec4<float> item_focused {};
ekg::vec4<float> item_focused_outline {};
ekg::vec4<float> item_string {};
ekg::vec4<float> item_outline {};
ekg::vec4<float> outline {};
ekg::vec4<float> background {};
ekg::vec4<float> line_separator {};
ekg::vec4<float> drag_background {};
ekg::vec4<float> drag_outline {};

float subitem_offset_space {4.0f};
};

struct listbox_t {
public:
};
}

#endif
16 changes: 16 additions & 0 deletions include/ekg/ui/menu/menu.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef EKG_UI_MENU_HPP
#define EKG_UI_MENU_HPP

#include "ekg/math/geometry.hpp"

namespace ekg {
struct menu_theme_t {
public:
};

struct menu_t {
public:
};
}

#endif
22 changes: 22 additions & 0 deletions include/ekg/ui/popup/popup.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef EKG_UI_POPUP_HPP
#define EKG_UI_POPUP_HPP

#include "ekg/math/geometry.hpp"

namespace ekg {
struct popup_theme_t {
public:
ekg::vec4<float> background {};
ekg::vec4<float> string {};
ekg::vec4<float> outline {};
ekg::vec4<float> highlight {};
ekg::vec4<float> separator {};
int64_t drop_animation_delay {};
};

struct popup_t {
public:
};
}

#endif
Loading

0 comments on commit 6a5181d

Please sign in to comment.