Skip to content

Commit 246e47a

Browse files
committed
[fix][feature] popup behavior; separator label
1 parent 4b5ea19 commit 246e47a

File tree

9 files changed

+106
-67
lines changed

9 files changed

+106
-67
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# The above copyright notice and this permission notice shall be included in all
1313
# copies or substantial portions of the Software.
14-
#
14+
# 1
1515
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1717
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

include/ekg/core/pools.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ namespace ekg {
232232

233233
template<typename t>
234234
t &make(
235-
t descriptor
235+
t descriptor = {}
236236
) {
237237
switch (t::type) {
238238
case ekg::type::frame: {

include/ekg/ui/label/label.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ namespace ekg {
3535
ekg::rgba_t<uint8_t> background {};
3636
ekg::rgba_t<uint8_t> outline {};
3737
ekg::rgba_t<uint8_t> text_foreground {};
38+
ekg::pixel_thickness_t separator_thickness {1};
3839
};
3940

4041
struct label_t {
@@ -43,6 +44,11 @@ namespace ekg {
4344
public:
4445
ekg::rect_t<float> rect_text {};
4546
};
47+
48+
enum class mode {
49+
text,
50+
separator
51+
};
4652
public:
4753
static constexpr ekg::type type {ekg::type::label};
4854
static ekg::label_t not_found;
@@ -55,6 +61,7 @@ namespace ekg {
5561
ekg::flags_t dock {};
5662
ekg::flags_t dock_text {};
5763
ekg::font font_size {ekg::font::medium};
64+
ekg::label_t::mode mode {ekg::label_t::mode::text};
5865
ekg::at_array_t<ekg::action, ekg::enum_action_size> actions {};
5966
ekg::at_array_t<ekg::layer, ekg::enum_layer_size> layers {};
6067
ekg::label_t::widget_t widget {};

include/ekg/ui/popup/popup.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#define EKG_UI_POPUP_HPP
2626

2727
#include "ekg/ui/frame/frame.hpp"
28+
#include "ekg/ui/label/label.hpp"
2829

2930
namespace ekg {
3031
typedef ekg::frame_color_scheme_t popup_color_scheme_t;
@@ -51,6 +52,7 @@ namespace ekg {
5152
static ekg::popup_t not_found;
5253
static constexpr ekg::type type {ekg::type::popup};
5354
static constexpr ekg::flags_t auto_kill {2 << 2};
55+
static ekg::label_t separator;
5456
public:
5557
ekg::at_t parent_popup_at {};
5658
ekg::at_t property_at {};

src/handler/theme/handler.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void ekg::handler::theme::init() {
3030
ekg::theme_t light_pinky_theme {
3131
.tag = "light-pinky",
3232
.author = "Rina Wilk",
33-
.description = "dim again, dim again, not even a light can undim my life, wasted love, wasted love...",
33+
.description = "wasted love of my life, no love no more love no more"
3434
};
3535

3636
light_pinky_theme.layout_offset = 2.0f;
@@ -82,7 +82,7 @@ void ekg::handler::theme::init() {
8282
ekg::theme_t black_light_pinky_theme {
8383
.tag = "black-light-pinky",
8484
.author = "Rina Wilk",
85-
.description = "yea i loved you alot, but you broken my heart, I can not do nothing, this is obscure, I miss you 2666, but I do not know how to live anymore",
85+
.description = "loved a shitty person God save me"
8686
};
8787

8888
black_light_pinky_theme.layout_offset = 2.0f;
@@ -125,9 +125,10 @@ void ekg::handler::theme::init() {
125125
black_light_pinky_theme.slider_color_scheme.text_foreground = {141, 141, 141, 255};
126126

127127
black_light_pinky_theme.popup_color_scheme = black_light_pinky_theme.frame_color_scheme;
128+
black_light_pinky_theme.popup_color_scheme.popup_mode = true;
128129

129130
this->registry(black_light_pinky_theme.tag) = black_light_pinky_theme;
130-
this->set_current_theme(black_light_pinky_theme.tag);
131+
//this->set_current_theme(black_light_pinky_theme.tag);
131132
}
132133

133134
void ekg::handler::theme::quit() {

src/ui/frame/widget.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ void ekg::ui::reload(
5555
}
5656

5757
if (frame.color_scheme.popup_mode) {
58-
ekg_log_low_level(frame.rect.h)
5958
frame.rect.h = ekg::min<float>(frame.rect.h, frame.color_scheme.max_popup_height);
6059
}
6160

src/ui/label/widget.cpp

Lines changed: 84 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -40,51 +40,62 @@ void ekg::ui::reload(
4040
label.rect
4141
);
4242

43-
ekg::axis pick_axis {
44-
ekg::axis::horizontal
45-
};
46-
47-
ekg::draw::font &draw_font {
48-
ekg::draw::get_font_renderer(label.font_size)
49-
};
50-
51-
label.widget.rect_text.w = draw_font.get_text_width(label.text.get());
52-
label.widget.rect_text.h = draw_font.get_text_height();
53-
54-
ekg::aligned_t aligned_dimension {};
55-
ekg::align_rect_dimension(
56-
pick_axis,
57-
label.widget.rect_text,
58-
ekg::dpi.min_sizes,
59-
aligned_dimension
60-
);
61-
62-
label.rect.scaled_height = ekg::max<ekg::pixel_thickness_t>(1, label.rect.scaled_height);
63-
label.rect.h = aligned_dimension.h * label.rect.scaled_height;
64-
65-
ekg::layout::mask mask {};
66-
mask.preset(
67-
{
68-
aligned_dimension.offset,
69-
aligned_dimension.offset,
70-
label.rect.h
71-
},
72-
pick_axis,
73-
label.rect.w
74-
);
75-
76-
mask.insert(
77-
{
78-
.p_rect = &label.widget.rect_text,
79-
.dock = label.dock_text
43+
switch (label.mode) {
44+
case ekg::label_t::mode::text: {
45+
ekg::axis pick_axis {
46+
ekg::axis::horizontal
47+
};
48+
49+
ekg::draw::font &draw_font {
50+
ekg::draw::get_font_renderer(label.font_size)
51+
};
52+
53+
label.widget.rect_text.w = draw_font.get_text_width(label.text.get());
54+
label.widget.rect_text.h = draw_font.get_text_height();
55+
56+
ekg::aligned_t aligned_dimension {};
57+
ekg::align_rect_dimension(
58+
pick_axis,
59+
label.widget.rect_text,
60+
ekg::dpi.min_sizes,
61+
aligned_dimension
62+
);
63+
64+
label.rect.scaled_height = ekg::max<ekg::pixel_thickness_t>(1, label.rect.scaled_height);
65+
label.rect.h = aligned_dimension.h * label.rect.scaled_height;
66+
67+
ekg::layout::mask mask {};
68+
mask.preset(
69+
{
70+
aligned_dimension.offset,
71+
aligned_dimension.offset,
72+
label.rect.h
73+
},
74+
pick_axis,
75+
label.rect.w
76+
);
77+
78+
mask.insert(
79+
{
80+
.p_rect = &label.widget.rect_text,
81+
.dock = label.dock_text
82+
}
83+
);
84+
85+
mask.docknize();
86+
87+
if (property.widget.should_refresh_size) {
88+
label.rect.w = ekg::max(ekg::dpi.min_sizes, mask.get_rect().w);
89+
property.widget.should_refresh_size = false;
90+
}
91+
92+
break;
8093
}
81-
);
8294

83-
mask.docknize();
84-
85-
if (property.widget.should_refresh_size) {
86-
label.rect.w = ekg::max(ekg::dpi.min_sizes, mask.get_rect().w);
87-
property.widget.should_refresh_size = false;
95+
case ekg::label_t::mode::separator: {
96+
label.rect.h = static_cast<ekg::pixel_t>(label.color_scheme.separator_thickness);
97+
break;
98+
}
8899
}
89100
}
90101

@@ -146,26 +157,38 @@ void ekg::ui::buffering(
146157
ekg::always_parented
147158
);
148159

149-
ekg::draw::rect(
150-
rect_abs,
151-
label.color_scheme.background,
152-
ekg::draw::mode::fill,
153-
label.layers[ekg::layer::bg]
154-
);
155-
156-
ekg::draw::get_font_renderer(label.font_size)
157-
.blit(
158-
label.text.get(),
159-
rect_abs.x + label.widget.rect_text.x, rect_abs.y + label.widget.rect_text.y,
160-
label.color_scheme.text_foreground
160+
switch (label.mode) {
161+
case ekg::label_t::mode::text:
162+
ekg::draw::rect(
163+
rect_abs,
164+
label.color_scheme.background,
165+
ekg::draw::mode::fill,
166+
label.layers[ekg::layer::bg]
161167
);
162168

163-
ekg::draw::rect(
164-
rect_abs,
165-
label.color_scheme.outline,
166-
ekg::draw::mode::outline,
167-
label.layers[ekg::layer::outline]
168-
);
169+
ekg::draw::get_font_renderer(label.font_size)
170+
.blit(
171+
label.text.get(),
172+
rect_abs.x + label.widget.rect_text.x, rect_abs.y + label.widget.rect_text.y,
173+
label.color_scheme.text_foreground
174+
);
175+
176+
ekg::draw::rect(
177+
rect_abs,
178+
label.color_scheme.outline,
179+
ekg::draw::mode::outline,
180+
label.layers[ekg::layer::outline]
181+
);
182+
break;
183+
case ekg::label_t::mode::separator:
184+
ekg::draw::rect(
185+
rect_abs,
186+
label.color_scheme.text_foreground,
187+
ekg::draw::mode::fill,
188+
ekg::at_t::not_found
189+
);
190+
break;
191+
}
169192

170193
ekg_draw_allocator_pass();
171194
}

src/ui/popup/popup.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ ekg::popup_t ekg::popup_t::not_found {
3030
.at = ekg::at_t::not_found
3131
};
3232

33+
ekg::label_t ekg::popup_t::separator {
34+
.dock = ekg::dock::fill | ekg::dock::next,
35+
.mode = ekg::label_t::mode::separator
36+
};
37+
3338
void ekg::show(
3439
ekg::at_t &popup_at,
3540
const ekg::vec2_t<float> &pos,

src/ui/popup/widget.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ void ekg::ui::event(
395395
||
396396
should_force_update_popup_position
397397
) {
398+
ekg::ui::reload(wproperty, descriptor.widget.frame);
399+
398400
ekg::ui::splash_popup_but_bounding(
399401
popup.color_scheme.popup_offset,
400402
rect_position,

0 commit comments

Comments
 (0)