Skip to content

Commit 5e0bcb0

Browse files
committed
[fix] interact by mouse
1 parent 4fea308 commit 5e0bcb0

File tree

9 files changed

+281
-51
lines changed

9 files changed

+281
-51
lines changed

include/ekg/handler/input.hpp

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

9090
namespace ekg {
9191
ekg::input_info_t &input();
92-
bool fire(std::string_view tag);
92+
bool fired(std::string_view tag);
9393
bool input(std::string_view input);
9494
void bind(std::string_view tag, std::string_view input);
9595
void bind(std::string_view tag, std::vector<std::string_view> inputs);

include/ekg/math/geometry.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,14 @@ namespace ekg {
621621
template<typename t>
622622
using rgba_t =ekg::vec4_t<t>;
623623

624+
template<typename t>
625+
constexpr t arithmetic_normalize(
626+
t x,
627+
t len
628+
) {
629+
return x / len;
630+
}
631+
624632
void ortho(
625633
float *p_mat4x4,
626634
float left,

include/ekg/ui/textbox/textbox.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ namespace ekg {
6161
return index.x == this->a.x && index.y == this->a.y && index.x == this->b.x && index.y == this->b.y;
6262
}
6363

64+
bool operator != (const ekg::vec2_t<size_t> &index) {
65+
return !(*this == index);
66+
}
67+
6468
bool operator > (const ekg::vec2_t<size_t> &index) {
6569
return (index.x > this->a.x && index.y == this->a.y) || (index.y > this->a.y);
6670
}
@@ -89,7 +93,20 @@ namespace ekg {
8993
ekg::scrollbar_t scrollbar {};
9094
std::vector<ekg::textbox_t::cursor_t> cursors {};
9195
std::vector<ekg::textbox_t::select_draw_layer_t> layers_select {};
96+
9297
size_t last_layers_select_size {};
98+
size_t view_line_index {UINT64_MAX};
99+
size_t view_chunk_index {UINT64_MAX};
100+
size_t view_chunk_line_index {UINT64_MAX};
101+
102+
ekg::vec2_t<size_t> picked_left {UINT64_MAX, UINT64_MAX};
103+
ekg::vec2_t<size_t> picked_right {UINT64_MAX, UINT64_MAX};
104+
ekg::vec2_t<size_t> first_pick_pos {};
105+
size_t current_cursor_index {UINT64_MAX};
106+
107+
ekg::timing_t cursor_timing {};
108+
bool set_cursor_static {};
109+
bool unset_cursor_static {};
93110
};
94111

95112
static constexpr ekg::type type {ekg::type::textbox};

include/ekg/ui/textbox/widget.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace ekg::ui {
3838
ekg::property_t &property,
3939
ekg::textbox_t &textbox,
4040
ekg::vec2_t<float> &interact,
41-
size_t &index
41+
ekg::vec2_t<size_t> &index
4242
);
4343

4444
void reload(

src/handler/input.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ekg::input_info_t &ekg::input() {
55
return ekg::p_core->handler_input.input;
66
}
77

8-
bool ekg::fire(std::string_view tag) {
8+
bool ekg::fired(std::string_view tag) {
99
return ekg::p_core->handler_input.get_input_bind_state(tag);
1010
}
1111

src/ui/button/widget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void ekg::ui::event(
184184
&&
185185
check.states.is_highlight
186186
&&
187-
ekg::fire("button-active")
187+
ekg::fired("button-active")
188188
) {
189189
ekg_action(
190190
check.actions,

src/ui/frame/widget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ void ekg::ui::event(
9696
input.was_pressed
9797
&&
9898
(
99-
(frame.drag != ekg::dock::none && ekg::fire("frame-drag"))
99+
(frame.drag != ekg::dock::none && ekg::fired("frame-drag"))
100100
||
101-
(frame.resize != ekg::dock::none && ekg::fire("frame-resize"))
101+
(frame.resize != ekg::dock::none && ekg::fired("frame-resize"))
102102
)
103103
) {
104104

src/ui/scrollbar/widget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void ekg::ui::event(
216216
&&
217217
(property.scroll.is_enabled.x || property.scroll.is_enabled.y)
218218
&&
219-
(ekg::fire("scrollbar-scroll") || ekg::fire("scrollbar-scroll-horizontal"))
219+
(ekg::fired("scrollbar-scroll") || ekg::fired("scrollbar-scroll-horizontal"))
220220
);
221221

222222
ekg::rect_t<float> h_bar {scrollbar.widget.rect_horizontal};
@@ -271,7 +271,7 @@ void ekg::ui::event(
271271
);
272272

273273
ekg::input_info_t &input {ekg::p_core->handler_input.input};
274-
bool is_scroll_fired {ekg::fire("scrollbar-scroll")};
274+
bool is_scroll_fired {ekg::fired("scrollbar-scroll")};
275275

276276
property.scroll.is_scrolling.x = false;
277277
property.scroll.is_scrolling.y = false;
@@ -296,7 +296,7 @@ void ekg::ui::event(
296296
}
297297
#else
298298
bool is_scroll_horizontal_fired {
299-
ekg::fire("scrollbar-scroll-horizontal")
299+
ekg::fired("scrollbar-scroll-horizontal")
300300
};
301301

302302
if (
@@ -351,7 +351,7 @@ void ekg::ui::event(
351351
&&
352352
input.was_pressed
353353
&&
354-
ekg::fire("scrollbar-drag")
354+
ekg::fired("scrollbar-drag")
355355
) {
356356
ekg::rect_t<float> h_bar {scrollbar.widget.rect_horizontal};
357357
h_bar.x += rect_parent.x;

0 commit comments

Comments
 (0)