mirror of
https://github.com/Immediate-Mode-UI/Nuklear.git
synced 2026-11-30 16:48:10 +01:00
Fixed slider behavior and drawing
Slider is still comming back to haunt me. They never worked like I wanted them to, but hopefully this is now finally fixed. Previously if you declared a slider not beginning with 0 it would break and not work. This behavior is now fixed.
This commit is contained in:
+5
-4
@@ -1,16 +1,17 @@
|
||||
# Changelog
|
||||
[date](x.yy.zz)-[description]
|
||||
[date][x.yy.zz]-[description]
|
||||
|
||||
- [date]: current date on which the change has been pushed
|
||||
- (x.yy.zz): Numerical version string representation. Each version number on the right
|
||||
- [x.yy.zz]: Numerical version string representation. Each version number on the right
|
||||
resets back to zero if version on the left is incremented.
|
||||
- [x]: Major version with major API and library changes (extremly rare, maybe never)
|
||||
- [yy]: Minor version with minor API and library changes (breaking changes will be extra noted)
|
||||
- [x]: Major version with API and library breaking (extremly rare, maybe never)
|
||||
- [yy]: Minor version with non-breaking API and library changes
|
||||
- [zz]: Bug fix version with no direct changes to API
|
||||
- [description]: small descriptions listing changes
|
||||
|
||||
Changes:
|
||||
--------
|
||||
- 2017/14/11 (1.32.1) - Fixed slider behavior and drawing
|
||||
- 2017/14/11 (1.32.0) - Added flag to put scaler into the bottom left corner
|
||||
- 2017/13/11 (1.31.0) - Added additional row layouting method to combine both
|
||||
dynamic and static widgets.
|
||||
|
||||
@@ -689,7 +689,7 @@ enum nk_panel_flags {
|
||||
NK_WINDOW_TITLE = NK_FLAG(6), /* Forces a header at the top at the window showing the title */
|
||||
NK_WINDOW_SCROLL_AUTO_HIDE = NK_FLAG(7), /* Automatically hides the window scrollbar if no user interaction: also requires delta time in `nk_context` to be set each frame */
|
||||
NK_WINDOW_BACKGROUND = NK_FLAG(8), /* Always keep window in the background */
|
||||
NK_WINDOW_SCALE_LEFT = NK_FLAG(9), /* Puts window scaler in the left-ottom corner instead right-bottom*/
|
||||
NK_WINDOW_SCALE_LEFT = NK_FLAG(9) /* Puts window scaler in the left-ottom corner instead right-bottom*/
|
||||
};
|
||||
|
||||
/* context */
|
||||
@@ -13431,8 +13431,8 @@ nk_slider_behavior(nk_flags *state, struct nk_rect *logical_cursor,
|
||||
if (left_mouse_down && left_mouse_click_in_cursor)
|
||||
{
|
||||
float ratio = 0;
|
||||
const float d = in->mouse.pos.x - (visual_cursor->x + visual_cursor->w / 2.0f);
|
||||
const float pxstep = (bounds.w - (2 * style->padding.x)) / slider_steps;
|
||||
const float d = in->mouse.pos.x - (visual_cursor->x+visual_cursor->w*0.5f);
|
||||
const float pxstep = bounds.w / slider_steps;
|
||||
|
||||
/* only update value if the next slider step is reached */
|
||||
*state = NK_WIDGET_STATE_ACTIVE;
|
||||
@@ -13442,7 +13442,7 @@ nk_slider_behavior(nk_flags *state, struct nk_rect *logical_cursor,
|
||||
slider_value = NK_CLAMP(slider_min, slider_value, slider_max);
|
||||
ratio = (slider_value - slider_min)/slider_step;
|
||||
logical_cursor->x = bounds.x + (logical_cursor->w * ratio);
|
||||
in->mouse.buttons[NK_BUTTON_LEFT].clicked_pos.x = logical_cursor->x + logical_cursor->w/2.0f;
|
||||
in->mouse.buttons[NK_BUTTON_LEFT].clicked_pos.x = logical_cursor->x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13572,6 +13572,10 @@ nk_do_slider(nk_flags *state,
|
||||
bounds.w = bounds.w - (2*button.w + 2*style->spacing.x);
|
||||
}
|
||||
|
||||
/* remove one cursor size to support visual cursor */
|
||||
bounds.x += style->cursor_size.x*0.5f;
|
||||
bounds.w -= style->cursor_size.x;
|
||||
|
||||
/* make sure the provided values are correct */
|
||||
slider_max = NK_MAX(min, max);
|
||||
slider_min = NK_MIN(min, max);
|
||||
@@ -13580,10 +13584,6 @@ nk_do_slider(nk_flags *state,
|
||||
slider_steps = slider_range / step;
|
||||
cursor_offset = (slider_value - slider_min) / step;
|
||||
|
||||
/* remove one cursor size to support visual cursor */
|
||||
bounds.x += style->cursor_size.x*0.5f;
|
||||
bounds.w -= style->cursor_size.x;
|
||||
|
||||
/* calculate cursor
|
||||
Basically you have two cursors. One for visual representation and interaction
|
||||
and one for updating the actual cursor value. */
|
||||
@@ -13595,7 +13595,7 @@ nk_do_slider(nk_flags *state,
|
||||
visual_cursor.h = style->cursor_size.y;
|
||||
visual_cursor.w = style->cursor_size.x;
|
||||
visual_cursor.y = (bounds.y + bounds.h*0.5f) - visual_cursor.h*0.5f;
|
||||
visual_cursor.x = (logical_cursor.x + logical_cursor.w*0.5f) - visual_cursor.w*0.5f;
|
||||
visual_cursor.x = logical_cursor.x - visual_cursor.w*0.5f;
|
||||
|
||||
slider_value = nk_slider_behavior(state, &logical_cursor, &visual_cursor,
|
||||
in, style, bounds, slider_min, slider_max, slider_value, step, slider_steps);
|
||||
@@ -18161,6 +18161,13 @@ nk_layout_row_template_end(struct nk_context *ctx)
|
||||
struct nk_window *win;
|
||||
struct nk_panel *layout;
|
||||
|
||||
int i = 0;
|
||||
int variable_count = 0;
|
||||
int min_variable_count = 0;
|
||||
float min_fixed_width = 0.0f;
|
||||
float total_fixed_width = 0.0f;
|
||||
float max_variable_width = 0.0f;
|
||||
|
||||
NK_ASSERT(ctx);
|
||||
NK_ASSERT(ctx->current);
|
||||
NK_ASSERT(ctx->current->layout);
|
||||
@@ -18171,13 +18178,6 @@ nk_layout_row_template_end(struct nk_context *ctx)
|
||||
layout = win->layout;
|
||||
NK_ASSERT(layout->row.type == NK_LAYOUT_TEMPLATE);
|
||||
if (layout->row.type != NK_LAYOUT_TEMPLATE) return;
|
||||
|
||||
{int i = 0;
|
||||
int variable_count = 0;
|
||||
int min_variable_count = 0;
|
||||
float min_fixed_width = 0.0f;
|
||||
float total_fixed_width = 0.0f;
|
||||
float max_variable_width = 0.0f;
|
||||
for (i = 0; i < layout->row.columns; ++i) {
|
||||
float width = layout->row.templates[i];
|
||||
if (width >= 0.0f) {
|
||||
@@ -18204,7 +18204,7 @@ nk_layout_row_template_end(struct nk_context *ctx)
|
||||
float *width = &layout->row.templates[i];
|
||||
*width = (*width >= 0.0f)? *width: (*width < -1.0f && !enough_space)? -(*width): var_width;
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
NK_API void
|
||||
@@ -20552,7 +20552,6 @@ nk_group_scrolled_offset_begin(struct nk_context *ctx,
|
||||
win->layout = panel.layout;
|
||||
ctx->current = win;
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
NK_API void
|
||||
|
||||
+22260
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user