2323 */
2424#include " ekg/ui/popup/widget.hpp"
2525#include " ekg/ui/frame/widget.hpp"
26+ #include " ekg/core/runtime.hpp"
27+ #include " ekg/core/pools.hpp"
28+ #include " ekg/core/context.hpp"
29+
30+ void ekg::ui::splash_popup_but_bounding (
31+ float &popup_offset,
32+ ekg::rect_t <float > &rect_widget,
33+ ekg::rect_t <float > &rect_parent,
34+ ekg::rect_t <float > &rect_child
35+ ) {
36+ ekg::rect_t <float > preview {};
37+
38+ preview.w = rect_parent.x + rect_parent.w + popup_offset;
39+ rect_child.x = preview.w ;
40+
41+ if (preview.w + rect_child.w > ekg::dpi.viewport .w ) {
42+ rect_child.x = rect_parent.x - rect_parent.w - popup_offset;
43+ }
44+
45+ preview.h = rect_widget.y ;
46+ rect_child.y = preview.h ;
47+
48+ if (preview.h + rect_child.h > ekg::dpi.viewport .h ) {
49+ preview.h += rect_child.h ;
50+ rect_child.y = rect_widget.y - (preview.h - ekg::dpi.viewport .h );
51+ }
52+ }
2653
2754void ekg::ui::reload (
2855 ekg::property_t &property,
@@ -37,6 +64,96 @@ void ekg::ui::event(
3764 const ekg::io::stage &stage
3865) {
3966 ekg::ui::event (property, popup.widget .frame , stage);
67+ popup.rect = popup.widget .frame .rect ;
68+
69+ switch (stage) {
70+ case ekg::io::stage::post : {
71+ ekg::input_info_t &input {ekg::p_core->handler_input .input };
72+ ekg::vec2_t <float > interact {static_cast <ekg::vec2_t <float >>(input.interact )};
73+
74+ if (
75+ !input.has_motion
76+ &&
77+ !input.was_pressed
78+ &&
79+ !input.was_released
80+ ) {
81+ break ;
82+ }
83+
84+ bool exists {};
85+ bool preview_popup {};
86+ ekg::rect_t <float > rect_position {};
87+
88+ for (ekg::popup_t ::link_t &link : popup.links ) {
89+ exists = false ;
90+
91+ ekg_core_widget_call (
92+ link.widget_at .flags ,
93+ link.widget_at ,
94+ {
95+ ekg::property_t &wproperty {ekg::query<ekg::property_t >(descriptor.property_at )};
96+ if (wproperty.states .is_highlight ) {
97+ preview_popup = true ;
98+ rect_position = wproperty.widget .rect ;
99+ }
100+
101+ exists = true ;
102+ }
103+ );
104+
105+ // @TODO: ref this thanks
106+ if (!exists) {
107+ for (ekg::at_t &at : property.children ) {
108+ ekg_core_widget_call (
109+ at.flags ,
110+ at,
111+ {
112+ if (descriptor.tag == link.tag ) {
113+ exists = true ;
114+ link.widget_at = at;
115+ }
116+ }
117+ );
118+
119+ if (exists) {
120+ break ;
121+ }
122+ }
123+
124+ continue ;
125+ }
126+
127+ ekg_core_unique_widget_call (
128+ ekg::popup_t ,
129+ link.popup_at .flags ,
130+ link.popup_at ,
131+ {
132+ ekg::property_t &wproperty {ekg::query<ekg::property_t >(descriptor.property_at )};
133+
134+ descriptor.parent_popup_at = popup.at ;
135+ wproperty.states .is_visible = false ;
136+
137+ if (preview_popup) {
138+ wproperty.states .is_visible = true ;
139+
140+ splash_popup_but_bounding (
141+ popup.color_scheme .popup_offset ,
142+ rect_position,
143+ popup.rect ,
144+ descriptor.widget .frame .rect
145+ );
146+ }
147+ }
148+ );
149+ }
150+
151+ break ;
152+ }
153+
154+ default :
155+ break ;
156+ }
40157}
41158
42159void ekg::ui::high_frequency (
0 commit comments