summaryrefslogtreecommitdiff
path: root/src/gui/floatinput.cpp
diff options
context:
space:
mode:
authoraura <nw@moneybot.cc>2026-03-17 12:04:30 +0100
committeraura <nw@moneybot.cc>2026-03-17 12:04:30 +0100
commita156bc15880e9e250c9c40f0dde431e077109dc1 (patch)
tree64b6461b0d0e9cad6ff7fdcfba563e103fad9067 /src/gui/floatinput.cpp
parent991352b0d2767e6bd1a46f554db4ac9d208c13ad (diff)
multi select
Diffstat (limited to 'src/gui/floatinput.cpp')
-rw-r--r--src/gui/floatinput.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/gui/floatinput.cpp b/src/gui/floatinput.cpp
index 5746758..5ce92fe 100644
--- a/src/gui/floatinput.cpp
+++ b/src/gui/floatinput.cpp
@@ -166,6 +166,7 @@ void gui_floatinput_input_bound( GUI_FLOATINPUT* input ) {
if( !gui_mbutton_down( GUI_MBTNLEFT ) )
return;
+ F32 oldval = *input->pval;
I32 x = gui_relx( input );
I32 w = gui_floatinput_content_w( input );
@@ -182,6 +183,8 @@ void gui_floatinput_input_bound( GUI_FLOATINPUT* input ) {
F32 nval = min + (max - min) * progress;
F32 rmn = remainderf( nval, input->step );
*input->pval = nval - rmn;
+ if( oldval != *input->pval )
+ input->lastchange = *input->pval - oldval;
}
void gui_floatinput_input_unbound( GUI_FLOATINPUT* input ) {
@@ -191,6 +194,7 @@ void gui_floatinput_input_unbound( GUI_FLOATINPUT* input ) {
I32 mx, my;
gui_cursor_pos( &mx, &my );
+ F32 oldval = *input->pval;
I32 dx = mx - input->lastmx;
if( dx )
*input->pval += dx * input->step;
@@ -205,6 +209,8 @@ void gui_floatinput_input_unbound( GUI_FLOATINPUT* input ) {
F32 rmn = remainderf( *input->pval, input->step );
*input->pval -= rmn;
+ if( oldval != *input->pval )
+ input->lastchange = *input->pval - oldval;
}
void gui_floatinput_input_scroll( GUI_FLOATINPUT* input ) {
@@ -229,6 +235,7 @@ void gui_floatinput_input_scroll( GUI_FLOATINPUT* input ) {
F32 rmn = remainderf( nval, input->step );
*input->pval = nval - rmn;
+ input->lastchange = *input->pval - oldval;
if( input->cb )
input->cb( input );
}
@@ -261,13 +268,15 @@ void gui_floatinput_input_fn( void* ptr ) {
return;
}
- if( !input->held ) {
+ if( !input->held && !input->heldoutbounds ) {
U8 fine = !!m2;
I32 split_y = y + 1 + ( h - 2 ) / 2;
U8 inc = my < split_y;
F32 step = fine ? 0.1f : 1.f;
+ F32 val = *input->pval;
*input->pval += inc ? step : -step;
gui_floatinput_clamp_and_snap( input );
+ input->lastchange = *input->pval - val;
if( input->cb )
input->cb( input );
input->held = 1;
@@ -320,6 +329,7 @@ struct GUI_FLOATINPUT* gui_floatinput( I32 x, I32 y, I32 w, const char* title, F
input->input_fn = gui_floatinput_input_fn;
input->draw_fn = gui_floatinput_draw_fn;
+ input->lastchange = 0;
input->cb = 0;
input->pval = pval;
input->min = min;