Skip to content

Commit

Permalink
[ref] listbox
Browse files Browse the repository at this point in the history
  • Loading branch information
MrsRina committed Aug 3, 2024
1 parent 3db9b5f commit 70e10ee
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 144 deletions.
84 changes: 10 additions & 74 deletions devlog/todo.txt
Original file line number Diff line number Diff line change
@@ -1,76 +1,3 @@
/* listbox with with no container */

ui_listbox concept:

auto p = ekg::listbox("oi meow mumu", {"meow meoiw meowm meowm meow meow", "cazt"});
p->insert_at(0, "meow").insert("meow").insert("meow").insert("meow");

// meow // gato
// meow // gato
// meow // gato
// meow // gato
// meow // gato

p->insert_at(1, "gato").insert("gato").insert("gato").insert("gato")

// if not inserted
// meow // <empty>
// meow // <empty>
// meow // <empty>
// meow // <empty>
// meow // <empty>

// when selecting etc.

// to disable the multi-column on listbox, set a different mode:
p->set_mode(ekg::mode::singlecolumn);

// to enable
p->set_mode(ekg::mode::multicolumn);

/* listbox with with container */

ui_listbox_container concept:

auto p = ekg::listbox_cointainer("oi meow mumu", {"meow meoiw meowm meowm meow meow", "cazt"});
p->insert_at(0, ekg::imut_label("meow")).insert(ekg::imut_label("meow")).insert(ekg::imut_label("meow")).insert(ekg::imut_label("meow"));

// meow // gato
// meow // gato
// meow // gato
// meow // gato
// meow // gato

p->insert_at(1, ekg::imut_label("gato")).insert(ekg::imut_label("gato")).insert(ekg::imut_label("gato")).insert(ekg::imut_label("gato"))

// if not inserted
// meow // <empty>
// meow // <empty>
// meow // <empty>
// meow // <empty>
// meow // <empty>

// when selecting etc.

// to disable the multi-column on listbox, set a different mode:
p->set_mode(ekg::mode::singlecolumn);

// to enable
p->set_mode(ekg::mode::multicolumn);

/* item */

ekg::item &a {p->item(0)};

a.insert("one");
a.insert({"two", ekg::attr::disable});
a.at(0).set_attr(ekg::attr::disable);
a.at(1).set_attr(ekg::attr::enable);

a.insert("oi").insert("oi")

// remove `ekg::ui::item`

/* DPI, UI, and Scale */

The current stupid system of EKG for scalling is actually useless; the scaled height factors at each widget,
Expand All @@ -80,4 +7,13 @@ So 800x600 will be the same as 1920x1080 indifferent of font-size.
How? idk, i will use the mother/parent frame as base/factor and the height font too as base.
So the layout service will get the perfect sized DPI and scale.
Some day I do this.


/* Slider must be rewrite the part of docking text value! */

Slider contains a glitch were you can drag with no maximum limit.

/* Textbox is not updating newer text! */

stupid ticking glitch.

/* stupid scorlling glitch */
6 changes: 3 additions & 3 deletions include/ekg/ui/listbox/ui_listbox_widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ namespace ekg::ui {
ekg::rect widget_absolute_rect_scissor,
ekg::rect scrollable_rect,
ekg::rect content_scissor_bounding,
float header_relative_x,
float bottom_place,
float scrolling_cropy,
bool is_scroll_on_top,
float normalized_horizontal_scroll,
bool is_header_targeted,
bool is_column_header_top,
ekg::draw::font_renderer &f_renderer
Expand All @@ -61,6 +59,8 @@ namespace ekg::ui {
ekg::rect rect_original_dragging_targeted_header {};

float column_header_height {};
float header_relative_x {};

bool was_hovered {};
bool was_selected {};
bool must_update_items {};
Expand Down
10 changes: 10 additions & 0 deletions include/ekg/ui/scrollbar/ui_scrollbar_embedded_widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ namespace ekg::ui {
void reset_scroll();

void check_axis_states();

/**
* Returns the normalized vertical value, based in child-height.
**/
float get_normalized_vertical_scroll();

/**
* Returns the normalized horizontal value, based in child-width.
**/
float get_normalized_horizontal_scroll();
public: // virtuals
void on_reload();

Expand Down
8 changes: 7 additions & 1 deletion include/ekg/util/geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#define ekg_pi (3.141592653589793238462643383279502884)

/*
* The STL std:::min, and std::max implementation,
* The STL std:::min and std::max implementation,
* are not suitable to perform the required comparions inside of EKG
* without making the code confuse.
*
Expand Down Expand Up @@ -264,6 +264,12 @@ namespace ekg {
**/
uint64_t get_index_by_scroll(float scroll, float dimension, uint64_t size);

/**
* Get a index n-size by normalized-scroll amount.
* Note: You must have a compatible scroll-size with the n-index-size.
**/
uint64_t get_index_by_normalized_scroll(float normalized, uint64_t size);

bool rect_collide_rect(const ekg::rect &a, const ekg::rect &b);
bool rect_collide_vec(const ekg::rect &rect, const ekg::vec4 &vec);
bool rect_collide_vec_precisely(const ekg::rect &rect, const ekg::vec4 &vec);
Expand Down
Loading

0 comments on commit 70e10ee

Please sign in to comment.