checkpoint on palettes, fix source view overlay margin building/drawing

This commit is contained in:
Ryan Fleury
2024-06-24 14:46:16 -07:00
parent 31c671e3f5
commit 614954b7ef
9 changed files with 178 additions and 112 deletions
+4 -10
View File
@@ -4,16 +4,6 @@
////////////////////////////////
//~ rjf: Basic Widgets
internal UI_Signal
ui_spacer(UI_Size size)
{
UI_Box *parent = ui_top_parent();
ui_set_next_pref_size(parent->child_layout_axis, size);
UI_Box *box = ui_build_box_from_key(0, ui_key_zero());
UI_Signal interact = ui_signal_from_box(box);
return interact;
}
internal void
ui_divider(UI_Size size)
{
@@ -1190,6 +1180,8 @@ ui_scroll_list_item_from_row(UI_ScrollListRowBlockArray *blocks, U64 row)
internal UI_ScrollPt
ui_scroll_bar(Axis2 axis, UI_Size off_axis_size, UI_ScrollPt pt, Rng1S64 idx_range, S64 view_num_indices)
{
ui_push_palette(ui_state->widget_palette_info.scrollbar_palette);
//- rjf: unpack
S64 idx_range_dim = Max(dim_1s64(idx_range), 1);
@@ -1307,6 +1299,8 @@ ui_scroll_bar(Axis2 axis, UI_Size off_axis_size, UI_ScrollPt pt, Rng1S64 idx_ran
ui_scroll_pt_target_idx(&new_pt, new_idx);
}
}
ui_pop_palette();
return new_pt;
}
-1
View File
@@ -68,7 +68,6 @@ struct UI_ScrollListSignal
////////////////////////////////
//~ rjf: Basic Widgets
internal UI_Signal ui_spacer(UI_Size size);
internal void ui_divider(UI_Size size);
internal UI_Signal ui_label(String8 string);
internal UI_Signal ui_labelf(char *fmt, ...);
+24 -3
View File
@@ -720,7 +720,7 @@ ui_box_from_key(UI_Key key)
//~ rjf: Top-Level Building API
internal void
ui_begin_build(OS_Handle window, UI_EventList *events, UI_IconInfo *icon_info, F32 real_dt, F32 animation_dt)
ui_begin_build(OS_Handle window, UI_EventList *events, UI_IconInfo *icon_info, UI_WidgetPaletteInfo *widget_palette_info, F32 real_dt, F32 animation_dt)
{
//- rjf: reset per-build ui state
{
@@ -758,6 +758,7 @@ ui_begin_build(OS_Handle window, UI_EventList *events, UI_IconInfo *icon_info, F
{
ui_state->icon_info.icon_kind_text_map[icon_kind] = push_str8_copy(ui_build_arena(), icon_info->icon_kind_text_map[icon_kind]);
}
MemoryCopyStruct(&ui_state->widget_palette_info, widget_palette_info);
}
//- rjf: do default navigation
@@ -1724,11 +1725,11 @@ ui_layout_position__in_place_rec(UI_Box *root, Axis2 axis)
{
child->fixed_position_animated = child->fixed_position;
}
child->rect.p0.v[axis] = root->rect.p0.v[axis] + child->fixed_position_animated.v[axis] - !(child->flags&(UI_BoxFlag_SkipViewOffX<<axis))*root->view_off.v[axis];
child->rect.p0.v[axis] = root->rect.p0.v[axis] + child->fixed_position_animated.v[axis] - !(child->flags&(UI_BoxFlag_SkipViewOffX<<axis))*floor_f32(root->view_off.v[axis]);
}
else
{
child->rect.p0.v[axis] = root->rect.p0.v[axis] + child->fixed_position.v[axis] - !(child->flags&(UI_BoxFlag_SkipViewOffX<<axis))*root->view_off.v[axis];
child->rect.p0.v[axis] = root->rect.p0.v[axis] + child->fixed_position.v[axis] - !(child->flags&(UI_BoxFlag_SkipViewOffX<<axis))*floor_f32(root->view_off.v[axis]);
}
child->rect.p1.v[axis] = child->rect.p0.v[axis] + child->fixed_size.v[axis];
child->rect.p0.x = floorf(child->rect.p0.x);
@@ -1772,6 +1773,18 @@ ui_layout_root(UI_Box *root, Axis2 axis)
////////////////////////////////
//~ rjf: Box Building API
//- rjf: spacers
internal UI_Signal
ui_spacer(UI_Size size)
{
UI_Box *parent = ui_top_parent();
ui_set_next_pref_size(parent->child_layout_axis, size);
UI_Box *box = ui_build_box_from_key(0, ui_key_zero());
UI_Signal interact = ui_signal_from_box(box);
return interact;
}
//- rjf: tooltips
internal void
@@ -1781,11 +1794,15 @@ ui_tooltip_begin_base(void)
ui_push_parent(ui_root_from_state(ui_state));
ui_push_parent(ui_state->tooltip_root);
ui_push_flags(0);
ui_push_run_flags(0);
ui_push_palette(ui_bottom_palette());
}
internal void
ui_tooltip_end_base(void)
{
ui_pop_palette();
ui_pop_run_flags();
ui_pop_flags();
ui_pop_parent();
ui_pop_parent();
@@ -1795,6 +1812,7 @@ internal void
ui_tooltip_begin(void)
{
ui_tooltip_begin_base();
ui_push_palette(ui_state->widget_palette_info.tooltip_palette);
ui_set_next_squish(0.25f-ui_state->tooltip_open_t*0.25f);
ui_set_next_transparency(1-ui_state->tooltip_open_t);
UI_Flags(UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawBackgroundBlur|UI_BoxFlag_DrawDropShadow)
@@ -1826,6 +1844,7 @@ ui_tooltip_end(void)
ui_row_end();
UI_PrefWidth(ui_px(0, 1)) ui_spacer(ui_em(1.f, 1.f));
ui_column_end();
ui_pop_palette();
ui_tooltip_end_base();
}
@@ -1863,6 +1882,7 @@ ui_begin_ctx_menu(UI_Key key)
ui_push_pref_height(ui_bottom_pref_height());
ui_push_focus_hot(UI_FocusKind_Root);
ui_push_focus_active(UI_FocusKind_Root);
ui_push_palette(ui_state->widget_palette_info.ctx_menu_palette);
B32 is_open = ui_key_match(key, ui_state->ctx_menu_key) && ui_state->ctx_menu_open;
if(is_open != 0)
{
@@ -1891,6 +1911,7 @@ ui_end_ctx_menu(void)
ui_state->is_in_open_ctx_menu = 0;
ui_spacer(ui_em(1.f, 1.f));
}
ui_pop_palette();
ui_pop_focus_active();
ui_pop_focus_hot();
ui_pop_pref_width();
+14 -2
View File
@@ -196,7 +196,7 @@ struct UI_Size
};
////////////////////////////////
//~ rjf: Color Schemes
//~ rjf: Palettes
typedef enum UI_ColorCode
{
@@ -232,6 +232,14 @@ struct UI_Palette
};
};
typedef struct UI_WidgetPaletteInfo UI_WidgetPaletteInfo;
struct UI_WidgetPaletteInfo
{
UI_Palette *tooltip_palette;
UI_Palette *ctx_menu_palette;
UI_Palette *scrollbar_palette;
};
////////////////////////////////
//~ rjf: Scroll Positions
@@ -565,6 +573,7 @@ struct UI_State
//- rjf: build parameters
UI_IconInfo icon_info;
UI_WidgetPaletteInfo widget_palette_info;
OS_Handle window;
UI_EventList *events;
Vec2F32 mouse;
@@ -729,7 +738,7 @@ internal UI_Box * ui_box_from_key(UI_Key key);
////////////////////////////////
//~ rjf: Top-Level Building API
internal void ui_begin_build(OS_Handle window, UI_EventList *events, UI_IconInfo *icon_info, F32 real_dt, F32 animation_dt);
internal void ui_begin_build(OS_Handle window, UI_EventList *events, UI_IconInfo *icon_info, UI_WidgetPaletteInfo *widget_palette_info, F32 real_dt, F32 animation_dt);
internal void ui_end_build(void);
internal void ui_calc_sizes_standalone__in_place_rec(UI_Box *root, Axis2 axis);
internal void ui_calc_sizes_upwards_dependent__in_place_rec(UI_Box *root, Axis2 axis);
@@ -741,6 +750,9 @@ internal void ui_layout_root(UI_Box *root, Axis2 axis);
////////////////////////////////
//~ rjf: Box Tree Building API
//- rjf: spacers
internal UI_Signal ui_spacer(UI_Size size);
//- rjf: tooltips
internal void ui_tooltip_begin_base(void);
internal void ui_tooltip_end_base(void);