Skip to content

Commit bc3f455

Browse files
committed
[fix][update] fixed container pixel align docknization with a custom theme field; now all triggers are working on scrollbar
1 parent ba21e69 commit bc3f455

File tree

16 files changed

+85
-48
lines changed

16 files changed

+85
-48
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ test/cmake-build-cache
99
lib/
1010
.sublime-project.sublime-workspace
1111
*.sublime-workspace
12+
1213
ekg-ui-library.sublime-workspace
1314
ekg-sandbox
15+
ekg-docs
1416
ekg-cmake-install
1517
a.out # idk wha damn is this

.hdoc.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ compile_commands = "cmake-build/compile_commands.json"
1010

1111
[pages]
1212

13-
homepage = "docs/homepage.md"
13+
homepage = "ekg-docs/readme.md"
1414
paths = [
15-
"docs/gettingstarted.md",
16-
"docs/devlog.md"
17-
]
15+
"ekg-docs/model/*.md",
16+
"ekg-docs/tutorial/*.md"
17+
]

include/ekg/io/design.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ namespace ekg {
2323
std::string_view description {};
2424
std::string_view path {};
2525
public:
26-
bool symmetric_layout {};
27-
float min_widget_size {5};
28-
float layout_offset {2.0f};
26+
ekg::pixel_t layout_offset {2.0f};
27+
ekg::pixel_thickness_t layout_margin_thickness {2};
2928

3029
ekg::button_theme_t button {};
3130
ekg::checkbox_theme_t checkbox {};

include/ekg/math/floating_point.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
namespace ekg {
88
constexpr float pi {3.1415927f};
9-
constexpr float pixel {1.0000000f};
10-
constexpr float pixel_div_2 {0.5000000f};
119

1210
constexpr bool fequalsf(float compare, float compared) {
1311
return (

include/ekg/math/geometry.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
#include <string>
77

88
namespace ekg {
9+
typedef int32_t pixel_thickness_t;
10+
typedef float pixel_t;
11+
12+
constexpr float one_pixel {1.0000000f};
13+
constexpr float half_pixel {0.5000000f};
14+
915
enum dock {
1016
none = 2 << 1,
1117
free = 2 << 2,
@@ -26,6 +32,12 @@ namespace ekg {
2632
horizontal = 2 << 14
2733
};
2834

35+
template<typename t>
36+
struct vec1_t {
37+
public:
38+
t x {};
39+
};
40+
2941
template<typename t>
3042
struct vec2_t {
3143
union {

include/ekg/ui/frame/frame.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace ekg {
1212
ekg::vec4_t<float> background {};
1313
ekg::vec4_t<float> border {};
1414
ekg::vec4_t<float> outline {};
15-
float margin_actions_offset {};
15+
ekg::pixel_thickness_t actions_margin_pixel_thickness {};
1616

1717
/**
1818
* [0] ekg::frame_t;

include/ekg/ui/scrollbar/scrollbar.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace ekg {
1313
ekg::vec4_t<float> outline {};
1414
ekg::vec4_t<float> highlight {};
1515
ekg::vec4_t<float> active {};
16-
int32_t pixel_thickness {};
16+
ekg::pixel_thickness_t pixel_thickness {};
1717
float min_bar_size {};
1818

1919
/**

include/ekg/ui/types.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ namespace ekg::ui {
3939
**/
4040
ekg::vec4_t<bool> is_scrolling {};
4141

42+
/**
43+
* The nearest-bar pixel-thicnkess;
44+
**/
45+
ekg::pixel_thickness_t nearest_scroll_bar_thickness {};
46+
4247
bool is_active {};
4348
bool is_focused {};
4449

src/layout/docknize.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -260,27 +260,32 @@ void ekg::layout::docknize_widget(
260260

261261
ekg::rect_t<float> container_rect {abs_parent_rect};
262262
ekg::theme_t &current_global_theme {ekg::theme()};
263-
float initial_offset {static_cast<float>(current_global_theme.scrollbar.pixel_thickness)};
263+
264+
float margin {static_cast<float>(current_global_theme.layout_margin_thickness) * 2.0f};
265+
container_rect.w -= margin;
266+
container_rect.h -= margin;
267+
268+
/**
269+
* Pixel correction to make margin aligned and symmetric.
270+
**/
271+
container_rect.w -= (
272+
static_cast<ekg::pixel_thickness_t>(abs_parent_rect.w - container_rect.w)
273+
-
274+
current_global_theme.layout_margin_thickness
275+
);
264276

265277
if (
266278
p_widget_parent->states.is_scrolling.z
267279
||
268280
p_widget_parent->states.is_scrolling.w
269281
) {
270-
initial_offset *= static_cast<float>(!current_global_theme.symmetric_layout);
271-
container_rect.w -= initial_offset * static_cast<float>(p_widget_parent->states.is_scrolling.z);
272-
container_rect.h -= initial_offset * static_cast<float>(p_widget_parent->states.is_scrolling.w);
273-
}
274-
275-
initial_offset = (
276-
static_cast<float>(current_global_theme.scrollbar.pixel_thickness)
277-
*
278-
static_cast<float>(current_global_theme.symmetric_layout)
279-
);
282+
float nearest_scroll_bar_thickness {
283+
static_cast<float>(p_widget_parent->states.nearest_scroll_bar_thickness)
284+
};
280285

281-
float container_size_offset {(initial_offset + current_global_theme.layout_offset) * 2.0f};
282-
container_rect.w -= container_size_offset;
283-
container_rect.h -= container_size_offset;
286+
container_rect.w -= nearest_scroll_bar_thickness * static_cast<float>(p_widget_parent->states.is_scrolling.w);
287+
container_rect.h -= nearest_scroll_bar_thickness * static_cast<float>(p_widget_parent->states.is_scrolling.z);
288+
}
284289

285290
ekg::ui::abstract *p_widgets {};
286291
ekg::flags_t flags {};
@@ -291,8 +296,8 @@ void ekg::layout::docknize_widget(
291296
int32_t count {};
292297

293298
ekg::rect_t<float> parent_offset {
294-
current_global_theme.layout_offset + initial_offset,
295-
current_global_theme.layout_offset + initial_offset,
299+
margin,
300+
margin,
296301
0.0f,
297302
0.0f
298303
};
@@ -334,7 +339,7 @@ void ekg::layout::docknize_widget(
334339
);
335340

336341
float align {};
337-
float imperfect_pixel_max_bounding {pixel_perfect_projection.x + ekg::pixel * 5.0f};
342+
float imperfect_pixel_max_bounding {pixel_perfect_projection.x + ekg::one_pixel * 5.0f};
338343
float projected_pixel_perfect_width {pixel_perfect_projection.x + pixel_perfect_projection.w};
339344
float unsolved_pixel_position {};
340345

src/service/theme.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ void ekg::service::theme::init() {
6060
.description = "Pasted dark-theme... mwm",
6161
};
6262

63-
dark_theme.symmetric_layout = true;
6463
dark_theme.frame.background = ekg::color<int32_t>(43, 43, 43, 255);
6564
dark_theme.frame.outline = ekg::color<int32_t>(190, 190, 190, 0);
6665
dark_theme.frame.outline = ekg::color<int32_t>(30, 40, 60, 100);
67-
dark_theme.frame.margin_actions_offset = 18;
66+
dark_theme.frame.actions_margin_pixel_thickness = 18;
6867
dark_theme.button.background = ekg::color<int32_t>(85, 85, 85, 50);
6968
dark_theme.button.text = ekg::color<int32_t>(202, 202, 202, 255);
7069
dark_theme.button.outline = ekg::color<int32_t>(202, 207, 222, 0);
@@ -132,11 +131,10 @@ void ekg::service::theme::init() {
132131
.description = "Pasted light-theme... moow",
133132
};
134133

135-
light_theme.symmetric_layout = true;
136134
light_theme.frame.background = ekg::color<int32_t>(242, 242, 242, 255);
137135
light_theme.frame.outline = ekg::color<int32_t>(190, 190, 190, 0);
138136
light_theme.frame.outline = ekg::color<int32_t>(202, 207, 222, 150);
139-
light_theme.frame.margin_actions_offset = 18;
137+
light_theme.frame.actions_margin_pixel_thickness = 18;
140138
light_theme.button.text = ekg::color<int32_t>(141, 141, 141, 255);
141139
light_theme.button.background = ekg::color<int32_t>(204, 204, 204, 50);
142140
light_theme.button.active = ekg::color<int32_t>(44, 166, 255, 100);
@@ -204,11 +202,10 @@ void ekg::service::theme::init() {
204202
.description = "Pasted light-theme... moow",
205203
};
206204

207-
light_pinky_theme.symmetric_layout = true;
208205
light_pinky_theme.frame.background = ekg::color<int32_t>(242, 242, 242, 255);
209206
light_pinky_theme.frame.outline = ekg::color<int32_t>(190, 190, 190, 0);
210207
light_pinky_theme.frame.outline = ekg::color<int32_t>(202, 207, 222, 150);
211-
light_pinky_theme.frame.margin_actions_offset = 18;
208+
light_pinky_theme.frame.actions_margin_pixel_thickness = 18;
212209
light_pinky_theme.button.text = ekg::color<int32_t>(141, 141, 141, 255);
213210
light_pinky_theme.button.background = ekg::color<int32_t>(204, 204, 204, 50);
214211
light_pinky_theme.button.active = ekg::color<int32_t>(245, 169, 184, 100);
@@ -276,11 +273,10 @@ void ekg::service::theme::init() {
276273
.description = "Pasted dark-theme... mooo mwm",
277274
};
278275

279-
dark_pinky_theme.symmetric_layout = true;
280276
dark_pinky_theme.frame.background = ekg::color<int32_t>(43, 43, 43, 255);
281277
dark_pinky_theme.frame.outline = ekg::color<int32_t>(190, 190, 190, 0);
282278
dark_pinky_theme.frame.outline = ekg::color<int32_t>(30, 40, 60, 100);
283-
dark_pinky_theme.frame.margin_actions_offset = 18;
279+
dark_pinky_theme.frame.actions_margin_pixel_thickness = 18;
284280
dark_pinky_theme.button.background = ekg::color<int32_t>(85, 85, 85, 50);
285281
dark_pinky_theme.button.text = ekg::color<int32_t>(202, 202, 202, 255);
286282
dark_pinky_theme.button.outline = ekg::color<int32_t>(202, 207, 222, 0);

0 commit comments

Comments
 (0)