|
@@ -24811,7 +24811,6 @@ nk_do_toggle(nk_flags *state,
|
|
|
const struct nk_user_font *font, nk_flags widget_alignment, nk_flags text_alignment)
|
|
|
{
|
|
|
int was_active;
|
|
|
- struct nk_rect allocated_space;
|
|
|
struct nk_rect bounds;
|
|
|
struct nk_rect select;
|
|
|
struct nk_rect cursor;
|
|
@@ -24826,13 +24825,6 @@ nk_do_toggle(nk_flags *state,
|
|
|
r.w = NK_MAX(r.w, font->height + 2 * style->padding.x);
|
|
|
r.h = NK_MAX(r.h, font->height + 2 * style->padding.y);
|
|
|
|
|
|
- allocated_space = r;
|
|
|
-
|
|
|
- if (widget_alignment & NK_WIDGET_ALIGN_RIGHT) {
|
|
|
- r.x = r.x + r.w - font->height - style->padding.x;
|
|
|
- r.w = font->height;
|
|
|
- }
|
|
|
-
|
|
|
/* add additional touch padding for touch screen devices */
|
|
|
bounds.x = r.x - style->touch_padding.x;
|
|
|
bounds.y = r.y - style->touch_padding.y;
|
|
@@ -24842,27 +24834,44 @@ nk_do_toggle(nk_flags *state,
|
|
|
/* calculate the selector space */
|
|
|
select.w = font->height;
|
|
|
select.h = select.w;
|
|
|
- select.y = r.y + r.h/2.0f - select.h/2.0f;
|
|
|
- select.x = r.x;
|
|
|
-
|
|
|
- /* calculate the bounds of the cursor inside the selector */
|
|
|
- cursor.x = select.x + style->padding.x + style->border;
|
|
|
- cursor.y = select.y + style->padding.y + style->border;
|
|
|
- cursor.w = select.w - (2 * style->padding.x + 2 * style->border);
|
|
|
- cursor.h = select.h - (2 * style->padding.y + 2 * style->border);
|
|
|
|
|
|
- label.y = select.y;
|
|
|
- label.h = select.w;
|
|
|
if (widget_alignment & NK_WIDGET_ALIGN_RIGHT) {
|
|
|
+ select.x = r.x + r.w - font->height;
|
|
|
+
|
|
|
/* label in front of the selector */
|
|
|
- label.x = allocated_space.x;
|
|
|
- label.w = allocated_space.w - select.w - style->spacing * 2;
|
|
|
- } else {
|
|
|
+ label.x = r.x;
|
|
|
+ label.w = r.w - select.w - style->spacing * 2;
|
|
|
+ } else if (widget_alignment & NK_WIDGET_ALIGN_CENTERED) {
|
|
|
+ select.x = (r.x + r.w) / 2;
|
|
|
+
|
|
|
+ /* label in front of selector */
|
|
|
+ label.x = r.x;
|
|
|
+ label.w = r.w / 2 - select.w - style->spacing * 2;
|
|
|
+ } else { /* Default: NK_WIDGET_ALIGN_LEFT */
|
|
|
+ select.x = r.x;
|
|
|
+
|
|
|
/* label behind the selector */
|
|
|
label.x = select.x + select.w + style->spacing;
|
|
|
label.w = NK_MAX(r.x + r.w, label.x) - label.x;
|
|
|
}
|
|
|
|
|
|
+ if (widget_alignment & NK_WIDGET_ALIGN_TOP) {
|
|
|
+ select.y = r.y;
|
|
|
+ } else if (widget_alignment & NK_WIDGET_ALIGN_BOTTOM) {
|
|
|
+ select.y = r.y + r.h - select.h - 2 * style->padding.y;
|
|
|
+ } else { /* Default: NK_WIDGET_ALIGN_MIDDLE */
|
|
|
+ select.y = r.y + r.h/2.0f - select.h/2.0f;
|
|
|
+ }
|
|
|
+
|
|
|
+ label.y = select.y;
|
|
|
+ label.h = select.w;
|
|
|
+
|
|
|
+ /* calculate the bounds of the cursor inside the selector */
|
|
|
+ cursor.x = select.x + style->padding.x + style->border;
|
|
|
+ cursor.y = select.y + style->padding.y + style->border;
|
|
|
+ cursor.w = select.w - (2 * style->padding.x + 2 * style->border);
|
|
|
+ cursor.h = select.h - (2 * style->padding.y + 2 * style->border);
|
|
|
+
|
|
|
/* update selector */
|
|
|
was_active = *active;
|
|
|
*active = nk_toggle_behavior(in, bounds, state, *active);
|
|
@@ -30013,6 +30022,8 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
|
|
|
/// - [y]: Minor version with non-breaking API and library changes
|
|
|
/// - [z]: Patch version with no direct changes to the API
|
|
|
///
|
|
|
+/// - 2023/11/26 (5.0.0) - BREAKING CHANGE: Added alignment to check boxes and radio buttons. They
|
|
|
+/// all now require a widget and text alignment parameter.
|
|
|
/// - 2023/10/11 (4.11.0) - Added nk_widget_disable_begin() and nk_widget_disable_end()
|
|
|
/// - 2022/12/23 (4.10.6) - Fix incorrect glyph index in nk_font_bake()
|
|
|
/// - 2022/12/17 (4.10.5) - Fix nk_font_bake_pack() using TTC font offset incorrectly
|