Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 68 additions & 43 deletions include/ekg/core/pools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,30 @@
#include "ekg/ui/frame/frame.hpp"
#include "ekg/ui/frame/widget.hpp"

#include "ekg/ui/label/label.hpp"
#include "ekg/ui/label/widget.hpp"

namespace ekg::core {
void registry(ekg::property_t &property);
}

#define ekg_abstract_todo(ekg_abstract_todo_at_type, ekg_abstract_todo_at, ekg_abstract_todo_todo) \
switch (ekg_abstract_todo_at_type) { \
case ekg::type::button: { \
ekg::button_t &descriptor { \
ekg::query<ekg::button_t>(ekg_abstract_todo_at) \
}; \
if (descriptor == ekg::button_t::not_found) { \
break; \
} \
ekg_abstract_todo_todo \
break; \
} \
case ekg::type::frame: { \
ekg::frame_t &descriptor { \
ekg::query<ekg::frame_t>(ekg_abstract_todo_at) \
#define ekg_core_declare_widget_case_todo(descriptor_t, widget_descriptor_at, ekg_core_widget_todo) \
case descriptor_t::type: { \
descriptor_t &descriptor { \
ekg::query<descriptor_t>(widget_descriptor_at) \
}; \
if (descriptor == ekg::frame_t::not_found) { \
if (descriptor == descriptor_t::not_found) { \
break; \
} \
ekg_abstract_todo_todo \
ekg_core_widget_todo \
break; \
} \
}

#define ekg_core_abstract_todo(widget_descriptor_type, widget_descriptor_at, ekg_core_widget_todo) \
switch (widget_descriptor_type) { \
ekg_core_declare_widget_case_todo(ekg::frame_t, widget_descriptor_at, ekg_core_widget_todo); \
ekg_core_declare_widget_case_todo(ekg::button_t, widget_descriptor_at, ekg_core_widget_todo); \
ekg_core_declare_widget_case_todo(ekg::label_t, widget_descriptor_at, ekg_core_widget_todo); \
}

#define ekg_registry_widget(widget_descriptor_t, register_widget_pool, register_property_pool, is_container, register_settings) \
Expand Down Expand Up @@ -122,6 +120,9 @@ namespace ekg {

ekg::pool<ekg::property_t> frame_property {};
ekg::pool<ekg::frame_t> frame {};

ekg::pool<ekg::property_t> label_property {};
ekg::pool<ekg::label_t> label {};
} pools;

template<typename t>
Expand Down Expand Up @@ -151,6 +152,10 @@ namespace ekg {
return ekg::io::any_static_cast<t>(
&ekg::pools.frame_property.query(at)
);
case ekg::type::label:
return ekg::io::any_static_cast<t>(
&ekg::pools.label_property.query(at)
);
}
case ekg::type::button:
return ekg::io::any_static_cast<t>(
Expand All @@ -160,6 +165,10 @@ namespace ekg {
return ekg::io::any_static_cast<t>(
&ekg::pools.frame.query(at)
);
case ekg::type::label:
return ekg::io::any_static_cast<t>(
&ekg::pools.label.query(at)
);
}

return t::not_found;
Expand All @@ -170,6 +179,47 @@ namespace ekg {
t descriptor
) {
switch (t::type) {
case ekg::type::frame: {
ekg_registry_widget(
ekg::frame_t,
ekg::pools.frame,
ekg::pools.frame_property,
true,
{
property.widget.is_childnizate = true;
property.widget.is_children_docknizable = true;
widget.color_scheme = global_theme.frame_color_scheme;
}
);
}

case ekg::type::button: {
ekg_registry_widget(
ekg::button_t,
ekg::pools.button,
ekg::pools.button_property,
false,
{
property.widget.is_childnizate = false;
property.widget.is_children_docknizable = false;
widget.color_scheme = global_theme.button_color_scheme;
}
);
}

case ekg::type::label: {
ekg_registry_widget(
ekg::label_t,
ekg::pools.label,
ekg::pools.label_property,
true,
{
property.widget.is_childnizate = false;
property.widget.is_children_docknizable = false;
widget.color_scheme = global_theme.label_color_scheme;
}
);
}
case ekg::type::stack: {
ekg::stack_t &stack {
ekg::pools.stack.push_back(
Expand All @@ -195,32 +245,7 @@ namespace ekg {
ekg::io::any_static_cast<ekg::sampler_t>(&descriptor)
)
);
case ekg::type::button: {
ekg_registry_widget(
ekg::button_t,
ekg::pools.button,
ekg::pools.button_property,
false,
{
property.widget.is_childnizate = false;
property.widget.is_children_docknizable = false;
widget.color_scheme = global_theme.button_color_scheme;
}
);
}
case ekg::type::frame: {
ekg_registry_widget(
ekg::frame_t,
ekg::pools.frame,
ekg::pools.frame_property,
true,
{
property.widget.is_childnizate = true;
property.widget.is_children_docknizable = true;
widget.color_scheme = global_theme.frame_color_scheme;
}
);
}}

return t::not_found;
}
Expand Down
2 changes: 2 additions & 0 deletions include/ekg/handler/theme.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "ekg/ui/button/button.hpp"
#include "ekg/ui/frame/frame.hpp"
#include "ekg/ui/label/label.hpp"

namespace ekg {
struct theme_t {
Expand All @@ -38,6 +39,7 @@ namespace ekg {
ekg::pixel_t layout_margin_thickness {2};
ekg::button_color_scheme_t button_color_scheme {};
ekg::frame_color_scheme_t frame_color_scheme {};
ekg::label_color_scheme_t label_color_scheme {};
};

ekg::theme_t &theme(std::string_view tag = "");
Expand Down
3 changes: 2 additions & 1 deletion include/ekg/io/descriptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ namespace ekg {
stack = 4,
button = 5,
scrollbar = 6,
frame = 7
frame = 7,
label = 8
};
}

Expand Down
4 changes: 2 additions & 2 deletions include/ekg/io/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ namespace ekg {
no_auto_set_viewport_when_resize = 2 << 1
};

constexpr size_t enum_layer_size {8};
enum class layer {
bg,
outline,
Expand All @@ -46,14 +45,15 @@ namespace ekg {
text_fg,
text_outline
};
constexpr size_t enum_layer_size {static_cast<size_t>(ekg::layer::text_outline)+1};

constexpr size_t enum_action_size {8};
enum class action {
hover,
active,
press,
release
};
constexpr size_t enum_action_size {static_cast<size_t>(ekg::action::release)+1};

template<typename t, size_t s>
struct at_array_t {
Expand Down
8 changes: 4 additions & 4 deletions include/ekg/ui/button/button.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ namespace ekg {
ekg::flags_t box {ekg::dock::none};
ekg::flags_t dock {ekg::dock::left};
ekg::button_t::check_t::widget_t widget {};
ekg::at_array_t<ekg::layer, 12> layers {};
ekg::at_array_t<ekg::action, 12> actions {};
ekg::at_array_t<ekg::layer, ekg::enum_layer_size> layers {};
ekg::at_array_t<ekg::action, ekg::enum_action_size> actions {};
};

static ekg::button_t not_found;
Expand All @@ -75,8 +75,8 @@ namespace ekg {
std::string tag {};
ekg::flags_t dock {ekg::dock::left | ekg::dock::fill};
ekg::rect_t<float> rect {};
ekg::at_array_t<ekg::layer, 12> layers {};
ekg::at_array_t<ekg::action, 12> actions {};
ekg::at_array_t<ekg::layer, ekg::enum_layer_size> layers {};
ekg::at_array_t<ekg::action, ekg::enum_action_size> actions {};
std::vector<ekg::button_t::check_t> checks {};
ekg::button_color_scheme_t color_scheme {};
public:
Expand Down
67 changes: 67 additions & 0 deletions include/ekg/ui/label/label.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* MIT License
*
* Copyright (c) 2022-2025 Rina Wilk / [email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef EKG_UI_LABEL_HPP
#define EKG_UI_LABEL_HPP

#include "ekg/io/descriptor.hpp"
#include "ekg/math/geometry.hpp"
#include "ekg/io/event.hpp"
#include "ekg/io/font.hpp"

namespace ekg {
struct label_color_scheme_t {
public:
ekg::rgba_t<uint8_t> background {};
ekg::rgba_t<uint8_t> outline {};
ekg::rgba_t<uint8_t> text_foreground {};
};

struct label_t {
public:
struct widget_t {
public:
ekg::rect_t<float> rect_text {};
};
public:
static constexpr ekg::type type {ekg::type::label};
static ekg::label_t not_found;
public:
ekg::at_t property_at {};
public:
std::string tag {};
ekg::rect_t<float> rect {};
ekg::value<std::string> text {};
ekg::flags_t dock {};
ekg::flags_t dock_text {};
ekg::font font_size {ekg::font::medium};
ekg::at_array_t<ekg::action, ekg::enum_action_size> actions {};
ekg::at_array_t<ekg::layer, ekg::enum_layer_size> layers {};
ekg::label_t::widget_t widget {};
ekg::label_color_scheme_t color_scheme {};
public:
ekg_descriptor(ekg::label_t);
};
}

#endif
62 changes: 62 additions & 0 deletions include/ekg/ui/label/widget.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* MIT License
*
* Copyright (c) 2022-2025 Rina Wilk / [email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef EKG_UI_LABEL_WIDGET_HPP
#define EKG_UI_LABEL_WIDGET_HPP

#include "ekg/ui/property.hpp"
#include "ekg/ui/label/label.hpp"

namespace ekg::ui {
void reload(
ekg::property_t &property,
ekg::label_t &label
);

void event(
ekg::property_t &property,
ekg::label_t &label,
const ekg::io::stage &stage
);

void high_frequency(
ekg::property_t &property,
ekg::label_t &label
);

void pass(
ekg::property_t &property,
ekg::label_t &label
);

void buffering(
ekg::property_t &property,
ekg::label_t &label
);

void unmap(
ekg::label_t &label
);
}

#endif
Loading
Loading