diff --git a/src/pp/pp_vis/pp_vis_core.c b/src/pp/pp_vis/pp_vis_core.c index 3fe8f50f..e08b2a09 100644 --- a/src/pp/pp_vis/pp_vis_core.c +++ b/src/pp/pp_vis/pp_vis_core.c @@ -4359,6 +4359,12 @@ void V_TickForever(WaveLaneCtx *lane) + + + + + + @@ -4376,21 +4382,68 @@ void V_TickForever(WaveLaneCtx *lane) UI_Size total_height = UI_FNT(40, 1); UI_Size header_height = UI_FNT(1.3, 1); UI_Size window_padding = UI_FNT(0.5, 1); - UI_Size col0_width = UI_FNT(1.75, 1); - UI_Size col1_width = UI_FNT(30, 1); - UI_Size col2_width = UI_FNT(10, 1); + UI_Size icon_col_width = UI_FNT(1.75, 1); + UI_Size item_col_width = UI_FNT(30, 1); + // UI_Size col2_width = UI_FNT(10, 1); UI_Size scrollbar_width = UI_FNT(1, 1); + UI_Key scissor_key = UI_KeyF("scissor"); UI_Key lister_key = UI_KeyF("lister"); UI_Key scrollbar_key = UI_KeyF("scrollbar"); - UI_Key thumb_key = UI_KeyF("scrollbar-thumb"); - b32 scrollbar_visible = 1; + UI_Key thumb_key = UI_KeyF("scrollbar thumb"); + UI_Key scrollbar_up_key = UI_KeyF("scrollbar up"); + UI_Key scrollbar_down_key = UI_KeyF("scrollbar down"); + UI_Key scrollbar_container_key = UI_KeyF("scrollbar container"); UI_BoxReports scrollbar_reps = UI_ReportsFromKey(scrollbar_key); UI_BoxReports thumb_reps = UI_ReportsFromKey(thumb_key); + UI_BoxReports scissor_reps = UI_ReportsFromKey(scissor_key); + UI_BoxReports lister_reps = UI_ReportsFromKey(lister_key); + UI_BoxReports scrollbar_up_reps = UI_ReportsFromKey(scrollbar_up_key); + UI_BoxReports scrollbar_down_reps = UI_ReportsFromKey(scrollbar_down_key); + UI_BoxReports scrollbar_container_reps = UI_ReportsFromKey(scrollbar_container_key); + f32 lister_start = lister_reps.draw.screen_rect.p0.y; + f32 lister_end = lister_reps.draw.screen_rect.p1.y; + f32 lister_height = MaxF32(lister_end - lister_start, 1); - f32 lister_offset = palette->scroll; + f32 scissor_start = scissor_reps.draw.screen_rect.p0.y; + f32 scissor_end = scissor_reps.draw.screen_rect.p1.y; + f32 scissor_height = MaxF32(scissor_end - scissor_start, 1); + + f32 scrollbar_container_start = scrollbar_container_reps.draw.screen_rect.p0.y; + f32 scrollbar_container_end = scrollbar_container_reps.draw.screen_rect.p1.y; + f32 scrollbar_container_height = MaxF32(scrollbar_container_end - scrollbar_container_start, 1); + + f32 thumb_start = thumb_reps.draw.screen_rect.p0.y; + f32 thumb_end = thumb_reps.draw.screen_rect.p1.y; + f32 thumb_height = MaxF32(thumb_end - thumb_start, 1); + + f32 scroll_height = MaxF32(lister_height - scissor_height, 1); + { + if (thumb_reps.draw.m1.downs) + { + palette->drag_lister = lister_reps.draw.screen_rect; + palette->drag_container = scrollbar_container_reps.draw.screen_rect; + palette->drag_cursor = frame->screen_cursor; + + palette->drag_scroll = palette->scroll; + } + if (thumb_reps.draw.m1.held) + { + f32 delta_ratio = (frame->screen_cursor.y - palette->drag_cursor.y) / (palette->drag_container.p1.y - palette->drag_container.p0.y); + palette->scroll = palette->drag_scroll + delta_ratio * (palette->drag_lister.p1.y - palette->drag_lister.p0.y); + } + palette->scroll = ClampF32(palette->scroll, 0, scroll_height); + } + + f32 scroll_ratio = palette->scroll / scroll_height; + f32 lister_offset = scroll_ratio * scroll_height; + + f32 new_thumb_size_ratio = scissor_height / lister_height; + f32 new_thumb_start = scroll_ratio * scrollbar_container_height - scroll_ratio * thumb_height; + + b32 scrollbar_visible = new_thumb_size_ratio < 1; @@ -4520,7 +4573,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(BorderSize, 0); UI_SetNext(Rounding, 0); UI_SetNext(TextColor, theme.col.hint); - UI_SetNext(Width, col0_width); + UI_SetNext(Width, icon_col_width); UI_SetNext(Height, UI_PIX(size_px * 1.5, 1)); // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_SetNext(FontSize, size_px * theme.h6); @@ -4733,9 +4786,9 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(Width, UI_GROW(1, 0)); UI_SetNext(Height, UI_GROW(1, 0)); UI_SetNext(Flags, UI_BoxFlag_Scissor); - UI_PushCP(UI_BuildRow()); + UI_PushCP(UI_BuildRowEx(scissor_key)); { - // Items & Lister group + // Items & Scrollbar group UI_SetNext(Tint, 0); UI_SetNext(Rounding, 0); UI_PushCP(UI_BuildRow()); @@ -4744,7 +4797,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(BackgroundColor, 0); UI_SetNext(Rounding, 0); UI_SetNext(Width, UI_GROW(1, 0)); - UI_SetNext(Height, UI_GROW(1, 0)); + UI_SetNext(Height, UI_SHRINK(0, 1)); UI_SetNext(FloatingPos, VEC2(0, -lister_offset)); UI_SetNext(Flags, UI_BoxFlag_Floating | UI_BoxFlag_NoFloatingClampY); UI_PushCP(UI_BuildRowEx(lister_key)); @@ -4752,6 +4805,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(Tint, 0); UI_SetNext(Rounding, 0); UI_SetNext(Width, UI_GROW(1, 0)); + UI_SetNext(Height, UI_SHRINK(0, 1)); UI_PushCP(UI_BuildColumn()); { Enum(PaletteItemFlag) @@ -4867,7 +4921,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(BorderColor, item_border_color); UI_SetNext(BorderSize, 1); UI_SetNext(Rounding, UI_RPIX(5)); - // UI_SetNext(Width, col1_width); + // UI_SetNext(Width, item_col_width); UI_SetNext(Width, UI_GROW(1, 0)); // UI_SetNext(Height, UI_PIX(item_size_px, 1)); // UI_SetNext(Height, UI_FNT(1, 0)); @@ -4877,9 +4931,7 @@ void V_TickForever(WaveLaneCtx *lane) { UI_Push(Tag, item->key.v); - // Begin spacer - UI_BuildSpacer(col0_width, Axis_X); - // UI_BuildSpacer(window_padding, Axis_X); + UI_BuildSpacer(icon_col_width, Axis_X); // Command label UI_SetNext(ChildAlignment, UI_Region_Left); @@ -4938,7 +4990,7 @@ void V_TickForever(WaveLaneCtx *lane) // Tweak label { - UI_BuildSpacer(col0_width, Axis_X); + UI_BuildSpacer(icon_col_width, Axis_X); if (is_default) { UI_SetNext(TextColor, theme.col.hint); @@ -4958,7 +5010,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_BuildBox(); } - UI_BuildSpacer(col0_width, Axis_X); + UI_BuildSpacer(icon_col_width, Axis_X); switch (tweak_var.kind) { @@ -5153,8 +5205,7 @@ void V_TickForever(WaveLaneCtx *lane) } } - // End spacer - UI_BuildSpacer(col0_width, Axis_X); + // UI_BuildSpacer(icon_col_width, Axis_X); } UI_PopCP(UI_TopCP()); } @@ -5178,23 +5229,6 @@ void V_TickForever(WaveLaneCtx *lane) //- Scrollbar if (scrollbar_visible) { - UI_Key scrollbar_up = UI_KeyF("scrollbar up"); - UI_Key scrollbar_down = UI_KeyF("scrollbar down"); - - UI_BoxReports up_reps = UI_ReportsFromKey(scrollbar_up); - UI_BoxReports down_reps = UI_ReportsFromKey(scrollbar_down); - - if (thumb_reps.draw.m1.downs) - { - palette->scroll_begin = palette->scroll; - } - if (thumb_reps.draw.m1.held) - { - palette->scroll = palette->scroll_begin + (frame->screen_cursor.y - ui_frame->drag_cursor_pos.y); - } - palette->scroll = MaxF32(palette->scroll, 0); - - f32 thumb_offset = palette->scroll; UI_BuildSpacer(window_padding, Axis_X); UI_SetNext(Width, scrollbar_width); @@ -5202,29 +5236,27 @@ void V_TickForever(WaveLaneCtx *lane) { //- Scrollbar up button { - Vec4 bg = Zi; - Vec4 bd = bg; - bd = LerpSrgb(bg, theme.col.button_active, up_reps.draw.hot); + Vec4 col = theme.col.hint; + Vec4 bd_col = Zi; + col = LerpSrgb(col, theme.col.button_active, scrollbar_up_reps.draw.active); + bd_col = LerpSrgb(bd_col, theme.col.button_active, scrollbar_up_reps.draw.hot); UI_SetNext(ChildAlignment, UI_Region_Center); - UI_SetNext(BackgroundColor, bg); - UI_SetNext(BorderColor, bd); + UI_SetNext(BorderColor, bd_col); UI_SetNext(BorderSize, 1); UI_SetNext(Rounding, UI_RGROW(theme.rounding * 0.5)); - UI_SetNext(TextColor, theme.col.hint); + UI_SetNext(TextColor, col); UI_SetNext(Width, UI_GROW(1, 1)); UI_SetNext(Height, UI_FNT(1.5, 1)); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_SetNext(FontSize, UI_Top(FontSize) * theme.h6); - UI_BuildIconEx(scrollbar_up, theme.icon_font, UI_Icon_ArrowUp2); + UI_BuildIconEx(scrollbar_up_key, theme.icon_font, UI_Icon_ArrowUp2); } //- Scrollbar thumb { // UI_SetNext( - UI_PushCP(UI_BuildBox()); + UI_PushCP(UI_BuildBoxEx(scrollbar_container_key)); { - UI_Size thumb_height = UI_FNT(10, 1); - Vec4 bg = theme.col.button_hot; Vec4 bd = bg; bg = LerpSrgb(bg, theme.col.button_active, thumb_reps.draw.active); @@ -5232,11 +5264,11 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(BackgroundColor, bg); UI_SetNext(Width, UI_GROW(1, 0)); - UI_SetNext(Height, thumb_height); + UI_SetNext(Height, UI_GROW(new_thumb_size_ratio, 1)); UI_SetNext(BorderSize, 1); UI_SetNext(BorderColor, bd); UI_SetNext(Rounding, UI_RGROW(1 * theme.rounding)); - UI_SetNext(FloatingPos, VEC2(0, thumb_offset)); + UI_SetNext(FloatingPos, VEC2(0, new_thumb_start)); UI_SetNext(Anchor, UI_Region_Center); UI_SetNext(Anchor, UI_Region_Top); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse | UI_BoxFlag_Floating); @@ -5248,26 +5280,28 @@ void V_TickForever(WaveLaneCtx *lane) //- Scrollbar down button { - Vec4 bg = Zi; - Vec4 bd = bg; - bd = LerpSrgb(bg, theme.col.button_active, down_reps.draw.hot); + Vec4 col = theme.col.hint; + Vec4 bd_col = Zi; + col = LerpSrgb(col, theme.col.button_active, scrollbar_down_reps.draw.active); + bd_col = LerpSrgb(bd_col, theme.col.button_active, scrollbar_down_reps.draw.hot); UI_SetNext(ChildAlignment, UI_Region_Center); - UI_SetNext(BackgroundColor, bg); - UI_SetNext(BorderColor, bd); + UI_SetNext(BorderColor, bd_col); UI_SetNext(BorderSize, 1); UI_SetNext(Rounding, UI_RGROW(theme.rounding * 0.5)); - UI_SetNext(TextColor, theme.col.hint); + UI_SetNext(TextColor, col); UI_SetNext(Width, UI_GROW(1, 1)); UI_SetNext(Height, UI_FNT(1.5, 1)); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_SetNext(FontSize, UI_Top(FontSize) * theme.h6); - UI_BuildIconEx(scrollbar_down, theme.icon_font, UI_Icon_ArrowDown2); + UI_BuildIconEx(scrollbar_down_key, theme.icon_font, UI_Icon_ArrowDown2); } } UI_PopCP(UI_TopCP()); } } UI_PopCP(UI_TopCP()); + + UI_BuildDivider(UI_PIX(1, 1), divider_color, Axis_Y); } UI_PopCP(UI_TopCP()); @@ -5345,8 +5379,8 @@ void V_TickForever(WaveLaneCtx *lane) UI_PopCP(UI_TopCP()); // UI_BuildSpacer(window_padding, Axis_Y); + // UI_BuildDivider(UI_PIX(1, 1), divider_color, Axis_Y); - UI_BuildDivider(UI_PIX(1, 1), divider_color, Axis_Y); UI_BuildSpacer(header_height, Axis_Y); } UI_PopCP(UI_TopCP()); @@ -5371,778 +5405,6 @@ void V_TickForever(WaveLaneCtx *lane) - - - - - - - - - - - - - - - - - - - - - - // ////////////////////////////// - // //- Build command palette - - // V_Palette *palette = &frame->palette; - - // { - // f32 ease_rate = TweakFloat("Debug palette ease rate", 20, 1, 100) * frame->dt; - // f32 ease_in_target = TweakFloat("Debug palette ease-in target", 1.3, 0, 2); - // f32 pref_show = palette->is_showing ? ease_in_target : 0; - // palette->show = SaturateF32(LerpF32(palette->show, pref_show, ease_rate)); - // } - - // if (palette->is_showing || palette->show > 0.001) - // { - // f32 item_size_px = UI_FNT(1.5, 1).v; - // f32 tweak_size_px = UI_FNT(1.25, 1).v; - - // palette->key = UI_KeyF("command palette"); - // UI_Checkpoint palette_cp = UI_PushCP(UI_NilKey); - // { - // UI_Push(Tag, palette->key.v); - // UI_Key titlebar_key = UI_KeyF("title bar"); - // UI_BoxReports titlebar_reps = UI_ReportsFromKey(titlebar_key); - // UI_BoxReports palette_reps = UI_ReportsFromKey(palette->key); - - // Vec4 window_background_color = theme.col.window_bg; - // Vec4 window_border_color = theme.col.window_bd; - // Vec4 titlebar_color = Zi; - // Vec4 titlebar_border_color = Zi; - // Vec4 divider_color = theme.col.divider; - // if (titlebar_reps.draw.m1.held) - // { - // Vec2 drag_offset = SubVec2(ui_frame->drag_cursor_pos, palette_reps.drag.screen_anchor); - // palette->pos = SubVec2(frame->screen_cursor, drag_offset); - // } - // window_border_color = LerpSrgb(window_border_color, theme.col.button_active, titlebar_reps.draw.hot); - - // f32 scale = LerpF32(0.85, 1, palette->show); - // UI_Push(Tint, VEC4(1, 1, 1, palette->show)); - // UI_SetNext(Scale, VEC2(scale, scale)); - - // UI_Push(BackgroundColor, window_background_color); - // UI_Push(BorderColor, window_border_color); - // // UI_Push(BorderSize, theme.window_bd_sz); - // UI_Push(BorderSize, 1); - // UI_Push(Rounding, UI_RGROW(0.06 * theme.rounding)); - // UI_Push(Width, UI_FNT(40, 0)); - // UI_Push(Height, UI_SHRINK(0, 0)); - // UI_Push(ChildLayoutAxis, Axis_Y); - // UI_Push(FloatingPos, palette->pos); - // UI_SetNext(Anchor, UI_Region_Center); - // UI_SetNext(Flags, UI_BoxFlag_Floating | (UI_BoxFlag_CaptureMouse * !!palette->is_showing)); - // UI_PushCP(UI_BuildBoxEx(palette->key)); - // { - // // Title bar - // UI_PushCP(UI_NilKey); - // { - // UI_Push(BackgroundColor, titlebar_color); - // UI_Push(BorderColor, titlebar_border_color); - // UI_Push(Rounding, UI_RPIX(0)); - // UI_Push(ChildLayoutAxis, Axis_X); - // UI_Push(Width, UI_GROW(1, 0)); - // UI_Push(Height, UI_FNT(2, 1)); - // UI_SetNext(Flags, UI_BoxFlag_DrawText | (UI_BoxFlag_CaptureMouse * !!palette->is_showing)); - // UI_PushCP(UI_BuildBoxEx(titlebar_key)); - // { - // UI_Push(Width, UI_GROW(1, 0)); - // UI_Push(BorderColor, 0); - - // // Left title box - // UI_BuildRow(); - - // // Title box - // UI_SetNext(FontSize, UI_Top(FontSize) * theme.h3); - // UI_SetNext(ChildAlignment, UI_Region_Center); - // UI_SetNext(Width, UI_SHRINK(0, 1)); - // UI_SetNext(Text, Lit("Debug Palette")); - // UI_SetNext(Flags, UI_BoxFlag_DrawText); - // UI_BuildBox(); - - // // Right title box - // UI_BuildRow(); - // } - // UI_PopCP(UI_TopCP()); - // } - // UI_PopCP(UI_TopCP()); - // } - - // ////////////////////////////// - // //- Build searchbox - - // b32 is_searching = 0; - // String search_text = Zi; - // { - // UI_Size search_height = UI_PIX(item_size_px * 1.25, 1); - - // UI_SetNext(ChildAlignment, UI_Region_Left); - // UI_PushCP(UI_BuildRow()); - // { - // //- Search icon - // { - // f32 size_px = UI_Top(FontSize) * 1.25; - - // UI_SetNext(Rounding, UI_RGROW(0.75 * theme.rounding)); - // UI_SetNext(ChildAlignment, UI_Region_Center); - // UI_SetNext(BackgroundColor, 0); - // // UI_SetNext(BorderColor, reset_bd); - // UI_SetNext(BorderSize, 0); - // UI_SetNext(Rounding, 0); - // UI_SetNext(TextColor, theme.col.hint); - // UI_SetNext(Width, UI_PIX(size_px * 1.5, 1)); - // UI_SetNext(Height, UI_PIX(size_px * 1.5, 1)); - // // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_SetNext(FontSize, size_px * theme.h6); - // UI_BuildIcon(theme.icon_font, UI_Icon_Search); - // // UI_BuildRow(); - // } - - // //- Search box - // { - // UI_Key search_box = UI_KeyF("search box"); - // UI_BoxReport search_report = UI_ReportsFromKey(search_box).draw; - // V_TextboxState *search_state = &palette->search_state; - - // b32 has_focus = UI_MatchKey(search_box, prev_frame->keyboard_focus_box); - - // // FIXME: Remove this - // has_focus = 1; - - // // if (search_report.m1.downs) - // if (search_report.m1.downs) - // { - // has_focus = 1; - // V.text_input_ns = frame->time_ns; - // } - - // if (search_report.is_hot) - // { - // WND_SetCursor(window_frame, WND_CursorKind_Text); - // } - - // if (has_focus) - // { - // frame->keyboard_focus_box = search_box; - // if (text_input_deltas.first) - // { - // V.text_input_ns = frame->time_ns; - // V_ApplyTextboxDeltas(search_state, text_input_deltas); - // } - // } - - - - - - // // // FIXME: Remove this - // // if (frame->held_buttons[Button_B] && !prev_frame->held_buttons[Button_B]) - // // { - // // V_TextboxDelta delta = Zi; - // // // delta.kind = V_DeltaKind_ - // // delta.text = Lit("Hi"); - // // // delta.range = RNGI64(I64Max, I64Max); - - // // // delta.start = search_state->start; - // // // delta.end = search_state->end; - - // // // delta.start = 0; - // // // delta.end = 1; - - // // delta.flags |= V_TextboxDeltaFlag_UpdateText; - - // // V_ApplyTextboxDelta(search_state, delta); - // // } - - - - - - // search_text = V_StringFromTextbox(frame->arena, search_state); - // is_searching = search_text.len != 0; - - - // String display_text = search_text; - // Vec4 display_text_color = Color_White; - // if (!is_searching) - // { - // display_text_color = theme.col.hint; - // display_text = Lit(" Search..."); - // } - - // // Vec4 raah_color = Color_Black; - // Vec4 raah_color = Zi; - - // UI_SetNext(Height, search_height); - // UI_SetNext(Width, UI_GROW(1, 0)); - // UI_SetNext(BackgroundColor, raah_color); - // // UI_SetNext(BorderColor, item_border_color); - // UI_SetNext(BorderSize, 0); - // // UI_SetNext(Rounding, UI_RPIX(5)); - // UI_SetNext(ChildAlignment, UI_Region_Left); - // UI_SetNext(TextColor, display_text_color); - // UI_SetNext(Text, display_text); - // UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_CaptureMouse); - // UI_PushCP(UI_BuildRowEx(search_box)); - // { - // f32 font_size = UI_Top(FontSize); - // GC_FontKey font = UI_Top(Font); - - // //- Text caret/selection - // if (has_focus) - // { - // UI_Key caret_box = UI_KeyF("search caret"); - // UI_Key selection_box = UI_KeyF("search selection"); - - - // UI_Size caret_width = UI_PIX(1, 1); - // UI_Size caret_height = UI_PIX(search_height.v, 1); - - - // Vec4 selection_color = VEC4(0, 0.25, 0.75, 0.5); - - // Vec4 caret_color = VEC4(1, 1, 1, 0.75); - // // caret_color.a = AbsF32(SinF32(SecondsFromNs(frame->time_ns - V.text_input_ns) * 4)); - // // caret_color.a = SinF32(SecondsFromNs(frame->time_ns - V.text_input_ns)) > 0.5 ? 1 : 0; - // // caret_color.a = (CosF32(SecondsFromNs(frame->time_ns - V.text_input_ns) * 5) + 1) * 0.5; - // caret_color.a *= AbsF32(CosF32(SecondsFromNs(frame->time_ns - V.text_input_ns) * 3)); - - // f32 start_offset_px = 0; - // f32 end_offset_px = 0; - - // // caret_offset_px = TweakFloat("RAAAAAAAAAAAAAAAAAAAH", 0, 0, 100); - - // // caret_offset_px = - - - - - // // FIXME: Remove this, use UI computed run - // if (search_text.len > 0) - // { - // String32 codepoints = String32FromString(frame->arena, search_text); - // GC_Run run = GC_RunFromString32(frame->arena, codepoints, font, font_size); - - // // FIXME: Don't use rect idx - // // FIXME: Selection - // // FIXME: Offset & scissor - // for (i64 rect_idx = 0; rect_idx < (i64)run.rects_count; ++rect_idx) - // { - // if (rect_idx < search_state->start) - // { - // GC_RunRect rect = run.rects[rect_idx]; - // start_offset_px = rect.baseline_pos + rect.advance; - // } - // if (rect_idx < search_state->end) - // { - // GC_RunRect rect = run.rects[rect_idx]; - // end_offset_px = rect.baseline_pos + rect.advance; - // } - // if (rect_idx >= search_state->start && rect_idx >= search_state->end) - // { - // break; - // } - // } - // } - - - - - - - - - // // { - // // i64 offset_ - // // } - - // // Selection - // { - // f32 min = MinF32(start_offset_px, end_offset_px); - // f32 max = MaxF32(start_offset_px, end_offset_px); - - // UI_SetNext(Width, UI_PIX(max - min, 1)); - // UI_SetNext(Height, caret_height); - // UI_SetNext(FloatingPos, VEC2(min, 0)); - // UI_SetNext(Anchor, UI_Region_Left); - // UI_SetNext(Flags, UI_BoxFlag_Floating, UI_BoxFlag_CaptureMouse); - // UI_SetNext(BorderSize, 0); - // UI_SetNext(BackgroundColor, selection_color); - // UI_SetNext(FontSize, font_size); - // UI_BuildBoxEx(selection_box); - // } - - // // Caret - // { - // UI_SetNext(Width, caret_width); - // UI_SetNext(Height, caret_height); - // UI_SetNext(FloatingPos, VEC2(end_offset_px, 0)); - // UI_SetNext(Anchor, UI_Region_Left); - // UI_SetNext(Flags, UI_BoxFlag_Floating, UI_BoxFlag_CaptureMouse); - // UI_SetNext(BorderSize, 0); - // UI_SetNext(BackgroundColor, caret_color); - // UI_SetNext(FontSize, font_size); - // UI_BuildBoxEx(caret_box); - // } - // } - - - - // } - // UI_PopCP(UI_TopCP()); - // } - // } - // UI_PopCP(UI_TopCP()); - // } - - // ////////////////////////////// - // //- Build palette items list - - // f32 window_padding = theme.window_padding; - // UI_SetNext(Tint, 0); - // UI_SetNext(Rounding, 0); - // UI_PushCP(UI_BuildRow()); - // { - // UI_BuildSpacer(UI_PIX(window_padding, 1), Axis_X); - // { - // UI_SetNext(Tint, 0); - // UI_SetNext(Rounding, 0); - // UI_SetNext(Width, UI_GROW(1, 0)); - // UI_PushCP(UI_BuildColumn()); - // { - // Enum(PaletteItemFlag) - // { - // PaletteItemFlag_None = 0, - // PaletteItemFlag_IsCmd = (1 << 0), - // PaletteItemFlag_IsTweakVar = (2 << 0), - // }; - - // Struct(PaletteItem) - // { - // PaletteItem *next; - // PaletteItem *prev; - - // UI_Key key; - // PaletteItemFlag flags; - - // V_Hotkey hotkeys[8]; - // String display_name; - - // V_CmdDesc cmd_desc; - // TweakVar tweak_var; - // }; - // PaletteItem *first_item = 0; - // PaletteItem *last_item = 0; - - // ////////////////////////////// - // //- Push command items - - // { - // for (u64 cmd_desc_idx = 0; cmd_desc_idx < countof(V_cmd_descs); ++cmd_desc_idx) - // { - // V_CmdDesc cmd_desc = V_cmd_descs[cmd_desc_idx]; - // if (!(cmd_desc.flags & V_CmdDescFlag_HideFromPalette)) - // { - // PaletteItem *item = PushStruct(frame->arena, PaletteItem); - // { - // item->key = UI_KeyF("cmd palette item %F", FmtString(cmd_desc.name)); - // item->display_name = cmd_desc.display_name; - // item->flags |= PaletteItemFlag_IsCmd; - // item->cmd_desc = cmd_desc; - // // FIXME: Attach active shortcuts instead of default hotkeys - // CopyStructs(item->hotkeys, cmd_desc.default_hotkeys, MinU32(countof(item->hotkeys), countof(cmd_desc.default_hotkeys))); - // } - // DllQueuePush(first_item, last_item, item); - // } - // } - // } - - // ////////////////////////////// - // //- Push tweak variables - - // TweakVarArray tweak_vars = GetAllTweakVars(frame->arena); - - // { - // for (i64 tweak_idx = 0; tweak_idx < tweak_vars.count; ++tweak_idx) - // { - // TweakVar tweak_var = tweak_vars.v[tweak_idx]; - // PaletteItem *item = PushStruct(frame->arena, PaletteItem); - // { - // item->key = UI_KeyF("tweak var palette item %F", FmtString(tweak_var.name)); - // item->display_name = tweak_var.name; - // item->flags |= PaletteItemFlag_IsTweakVar; - // item->tweak_var = tweak_var; - // } - // DllQueuePush(first_item, last_item, item); - // } - // } - - // ////////////////////////////// - // //- Build items - - // for (PaletteItem *item = first_item; item; item = item->next) - // { - // f32 spacing = 20; - - // // Divider - // UI_BuildDivider(UI_PIX(1, 1), divider_color, Axis_Y); - - // UI_BoxReport item_rep = UI_ReportsFromKey(item->key).draw; - // if (item_rep.m1.presses) - // { - // if (item->flags & PaletteItemFlag_IsCmd) - // { - // String cmd_name = item->cmd_desc.name; - // V_PushVisCmd(cmd_name); - // } - // } - - // // Vec4 item_color = theme.col.window_bg; - // Vec4 item_color = Zi; - // // Vec4 item_color = theme.col.hint; - // Vec4 item_border_color = Zi; - // if (item->flags & PaletteItemFlag_IsCmd) - // { - // item_color = LerpSrgb(item_color, theme.col.button_hot, item_rep.hot); - // item_color = LerpSrgb(item_color, theme.col.button_active, item_rep.active); - // item_border_color = LerpSrgb(item_border_color, theme.col.button_active, item_rep.hot); - // } - // else - // { - // item_border_color = LerpSrgb(item_border_color, theme.col.button_active, item_rep.hot); - // } - - // UI_SetNext(Tint, 0); - // UI_PushCP(UI_BuildRow()); - // { - // UI_SetNext(BackgroundColor, item_color); - // UI_SetNext(BorderColor, item_border_color); - // UI_SetNext(BorderSize, 1); - // UI_SetNext(Rounding, UI_RPIX(5)); - // UI_SetNext(Width, UI_GROW(1, 0)); - // UI_SetNext(Height, UI_PIX(item_size_px, 1)); - // UI_SetNext(ChildAlignment, UI_Region_Left); - // UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_CaptureMouse); - // UI_PushCP(UI_BuildRowEx(item->key)); - // { - // UI_Push(Tag, item->key.v); - - // // Begin spacer - // UI_BuildSpacer(col0_width, Axis_X); - - // // Command label - // UI_SetNext(ChildAlignment, UI_Region_Left); - // UI_BuildLabel(item->display_name); - - // // Middle spacer - // UI_BuildSpacer(UI_GROW(1, 0), Axis_X); - - // // Tweak - // if (item->flags & PaletteItemFlag_IsTweakVar) - // { - // TweakVar tweak_var = item->tweak_var; - // String old_tweak_str = tweak_var.value; - // String new_tweak_str = tweak_var.value; - // b32 is_default = MatchString(new_tweak_str, tweak_var.initial); - - // // Reset button - // if (!is_default) - // { - // UI_BuildSpacer(UI_PIX(spacing * 0.5, 1), Axis_X); - // UI_Key reset_key = UI_KeyF("reset"); - // UI_BoxReport reset_rep = UI_ReportsFromKey(reset_key).draw; - - // if (reset_rep.m1.downs > 0) - // { - // new_tweak_str = tweak_var.initial; - // } - // if (reset_rep.is_hot) - // { - // WND_SetCursor(window_frame, WND_CursorKind_Hand); - // } - - // Vec4 reset_bg = Zi; - // // reset_bg = LerpSrgb(reset_bg, theme.col.button_hot, reset_rep.hot); - // // reset_bg = LerpSrgb(reset_bg, theme.col.button_active, reset_rep.active); - - // Vec4 reset_bd = Zi; - // // reset_bd = LerpSrgb(reset_bd, theme.col.button_active, reset_rep.hot); - // // reset_bd = LerpSrgb(reset_bd, theme.col.text, reset_rep.hot); - - // Vec4 reset_text_col = theme.col.hint; - // reset_text_col = LerpSrgb(reset_text_col, theme.col.text, reset_rep.hot); - - // UI_SetNext(Rounding, UI_RGROW(0.75 * theme.rounding)); - // UI_SetNext(ChildAlignment, UI_Region_Bottom); - // UI_SetNext(BackgroundColor, reset_bg); - // UI_SetNext(BorderColor, reset_bd); - // UI_SetNext(BorderSize, 0); - // UI_SetNext(TextColor, reset_text_col); - // UI_SetNext(Width, UI_SHRINK(0, 1)); - // UI_SetNext(Height, UI_SHRINK(0, 1)); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_SetNext(FontSize, UI_Top(FontSize) * theme.h6); - // UI_BuildIconEx(reset_key, theme.icon_font, UI_Icon_Loop2); - // } - - // // Tweak label - // { - // UI_BuildSpacer(col0_width, Axis_X); - // if (is_default) - // { - // UI_SetNext(TextColor, theme.col.hint); - // } - // else - // { - // UI_SetNext(TextColor, Color_White); - // } - // UI_SetNext(FontSize, UI_Top(FontSize) * theme.h5); - // UI_SetNext(ChildAlignment, UI_Region_Left); - // UI_SetNext(Width, UI_SHRINK(0, 1)); - // UI_SetNext(Height, UI_SHRINK(0, 1)); - // UI_SetNext(Text, new_tweak_str); - // UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_NoTextTruncation); - // UI_SetNext(BackgroundColor, 0); - // UI_SetNext(BorderColor, 0); - // UI_BuildBox(); - // } - - // UI_BuildSpacer(col0_width, Axis_X); - - // switch (tweak_var.kind) - // { - // // Boolean tweak - // case TweakKind_Bool: - // { - // UI_Key cb_key = UI_KeyF("tweak checkbox"); - // UI_BoxReport cb_rep = UI_ReportsFromKey(cb_key).draw; - - // b32 tweak_bool = CR_BoolFromString(new_tweak_str); - // if (cb_rep.m1.downs) - // { - // tweak_bool = !tweak_bool; - // new_tweak_str = StringFromBool(frame->arena, tweak_bool); - // } - - // // Tweak checkbox - // Vec4 cb_bg_color = Zi; - // Vec4 cb_border_color = theme.col.window_bd; - // cb_bg_color = LerpSrgb(cb_bg_color, theme.col.positive, tweak_bool); - // cb_border_color = LerpSrgb(cb_border_color, theme.col.button_active, cb_rep.hot); - - // UI_SetNext(BackgroundColor, cb_bg_color); - // UI_SetNext(BorderColor, cb_border_color); - // UI_SetNext(Rounding, UI_RGROW(theme.rounding)); - // UI_SetNext(BorderSize, 1); - // UI_SetNext(Width, UI_FNT(1.25, 1)); - // UI_SetNext(Height, UI_FNT(1.25, 1)); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_PushCP(UI_BuildRowEx(cb_key)); - // { - // } - // UI_PopCP(UI_TopCP()); - // } break; - - // // Float tweak - // case TweakKind_Float: - // { - // UI_Key slider_key = UI_KeyF("tweak slider"); - // UI_Key marker_key = UI_KeyF("tweak slider marker"); - - // UI_BoxReports slider_reps = UI_ReportsFromKey(slider_key); - // UI_BoxReports marker_reps = UI_ReportsFromKey(marker_key); - - // b32 is_hot = slider_reps.draw.is_hot || marker_reps.draw.is_hot; - // b32 is_active = slider_reps.draw.m1.held || marker_reps.draw.m1.held; - // f32 hot = MaxF32(slider_reps.draw.hot, marker_reps.draw.hot); - - // Vec2 slider_pos = slider_reps.draw.screen_rect.p0; - // Vec2 slider_dims = DimsFromRng2(slider_reps.draw.screen_rect); - // Vec2 marker_dims = DimsFromRng2(marker_reps.draw.screen_rect); - // Vec2 half_marker_dims = MulVec2(marker_dims, 0.5); - - // f64 range_min = tweak_var.range.min; - // f64 range_max = tweak_var.range.max; - // if (range_max <= range_min) - // { - // range_max = range_min + 1; - // } - - // f64 tweak_float = CR_FloatFromString(new_tweak_str); - // { - // if (is_active) - // { - // f64 initial_slider_pos = slider_reps.drag.screen_rect.p0.x; - // f64 initial_marker_width = DimsFromRng2(marker_reps.drag.screen_rect).x; - // f64 initial_slider_width = DimsFromRng2(slider_reps.drag.screen_rect).x - initial_marker_width; - // f64 initial_cursor = ui_frame->drag_cursor_pos.x; - // f64 initial_ratio = slider_reps.drag.misc; - - // f64 virtual_slider_start = initial_cursor - (initial_slider_width * initial_ratio); - // f64 virtual_slider_end = virtual_slider_start + initial_slider_width; - // f64 virtual_cursor_ratio = (frame->screen_cursor.x - virtual_slider_start) / (virtual_slider_end - virtual_slider_start); - - // tweak_float = LerpF64(range_min, range_max, virtual_cursor_ratio); - // tweak_float = ClampF64(tweak_float, range_min, range_max); - // if (frame->screen_cursor.x != prev_frame->screen_cursor.x) - // { - // new_tweak_str = StringFromFloat(frame->arena, tweak_float, tweak_var.precision); - // } - // } - // if (is_hot) - // { - // WND_SetCursor(window_frame, WND_CursorKind_HorizontalResize); - // } - // } - // f32 ratio = 0; - // ratio = (tweak_float - range_min) / (range_max - range_min); - // ratio = ClampF32(ratio, 0, 1); - - // Vec4 slider_bg_color = theme.col.window_bg; - // Vec4 slider_border_color = theme.col.window_bd; - // Vec4 slider_progress_color = theme.col.positive; - // Vec4 marker_bg_color = slider_progress_color; - // slider_border_color = LerpSrgb(slider_border_color, theme.col.button_active, hot); - // marker_bg_color = LerpSrgb(marker_bg_color, theme.col.text, hot); - - // UI_SetNext(BackgroundColor, slider_bg_color); - // UI_SetNext(BorderColor, slider_border_color); - // UI_SetNext(Rounding, UI_RGROW(theme.rounding)); - // UI_SetNext(BorderSize, 1); - // UI_SetNext(Width, UI_FNT(10, 1)); - // UI_SetNext(Height, UI_PIX(tweak_size_px * 0.75, 1)); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_SetNext(Misc, ratio); - // UI_PushCP(UI_BuildRowEx(slider_key)); - // { - // f32 marker_pos = ratio * (slider_dims.x - marker_dims.x); - - // // Slider progress - // { - // UI_SetNext(BackgroundColor, slider_progress_color); - // // UI_SetNext(Rounding, UI_RGROW(theme.rounding)); - // UI_SetNext(Rounding, 0); - // UI_SetNext(BorderColor, 0); - // UI_SetNext(BorderSize, 1); - // UI_SetNext(Width, UI_PIX(marker_pos + half_marker_dims.x, 0)); - // UI_SetNext(Height, UI_PIX(tweak_size_px * 0.75, 1)); - // UI_BuildBox(); - // } - - // // Slider marker - // { - // UI_SetNext(BackgroundColor, marker_bg_color); - // UI_SetNext(BorderColor, slider_border_color); - // UI_SetNext(Rounding, UI_RGROW(theme.rounding)); - // UI_SetNext(BorderSize, 1); - // UI_SetNext(Width, UI_PIX(tweak_size_px, 1)); - // UI_SetNext(Height, UI_PIX(tweak_size_px, 1)); - // // UI_SetNext(Anchor, UI_Region_Center); - // // UI_SetNext(FloatingPos, VEC2(marker_pos, (marker_size_px * 0.5))); - // UI_SetNext(FloatingPos, VEC2(marker_pos, -marker_dims.y * 0.125)); - // UI_SetNext(Flags, UI_BoxFlag_Floating | UI_BoxFlag_NoFloatingClamp | UI_BoxFlag_CaptureMouse); - // UI_BuildBoxEx(marker_key); - // } - // } - // UI_PopCP(UI_TopCP()); - // } break; - // } - - // if (!MatchString(old_tweak_str, new_tweak_str)) - // { - // TweakVar new_tweak_var = tweak_var; - // new_tweak_var.value = new_tweak_str; - // TweakEx(frame->arena, new_tweak_var, 1); - // } - // } - - // // Command hotkey buttons - // for (u64 i = 0; i < countof(item->hotkeys); ++i) - // { - // UI_Key hotkey_key = UI_KeyF("hotkey%F", FmtUint(i)); - // UI_BoxReport hotkey_rep = UI_ReportsFromKey(hotkey_key).draw; - - // Vec4 hotkey_color = Zi; - // Vec4 hotkey_border_color = Zi; - // { - // Vec4 hovered_color = Rgb32(0x103c4c); - // Vec4 pressed_color = hovered_color; - // pressed_color.w = 0.2; - // f32 hotkey_hot = hotkey_rep.hot; - // f32 hotkey_active = hotkey_rep.active; - // f32 hotkey_hovered = hotkey_rep.hovered; - // hotkey_color = LerpSrgb(hotkey_color, hovered_color, hotkey_hot); - // hotkey_color = LerpSrgb(hotkey_color, pressed_color, hotkey_active * hotkey_hovered); - // hotkey_border_color = LerpSrgb(hotkey_border_color, Rgb32(0x0078a6), hotkey_hot); - // } - - // V_Hotkey hotkey = item->hotkeys[i]; - // if (hotkey.button == Button_None) - // { - // break; - // } - // else - // { - // UI_BuildSpacer(UI_PIX(10, 1), Axis_X); - - // String hotkey_name = V_StringFromHotkey(UI_FrameArena(), hotkey); - // UI_SetNext(BackgroundColor, hotkey_color); - // UI_SetNext(BorderColor, hotkey_border_color); - // UI_SetNext(Text, hotkey_name); - // UI_SetNext(Width, UI_SHRINK(theme.text_padding_x, 1)); - // UI_SetNext(Height, UI_GROW(1, 0)); - // UI_SetNext(Rounding, UI_RPIX(5)); - // UI_SetNext(BorderSize, 1); - // UI_SetNext(ChildAlignment, UI_Region_Center); - // UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_CaptureMouse); - // UI_PushCP(UI_BuildRowEx(hotkey_key)); - // { - // } - // UI_PopCP(UI_TopCP()); - // } - // } - - // // End spacer - // UI_BuildSpacer(col0_width, Axis_X); - // } - // UI_PopCP(UI_TopCP()); - // } - // UI_PopCP(UI_TopCP()); - // } - // } - // UI_PopCP(UI_TopCP()); - // } - // UI_BuildSpacer(UI_PIX(window_padding, 1), Axis_X); - // } - // UI_PopCP(UI_TopCP()); - - // UI_BuildSpacer(UI_PIX(window_padding, 1), Axis_Y); - // } - // // UI_PopCP(UI_TopCP()); - // UI_PopCP(palette_cp); - // } - - - - - - - - - - @@ -6409,6 +5671,7 @@ void V_TickForever(WaveLaneCtx *lane) i32 tile_idx = P_TileIdxFromTilePos(tile_pos); UI_BuildLabelF("Camera pos: %F", FmtFloat2(frame->camera_pos)); UI_BuildLabelF("Camera zoom: %F", FmtFloat(frame->camera_zoom)); + UI_BuildLabelF("Cursor pos: %F", FmtFloat2(frame->screen_cursor)); UI_BuildLabelF("Cursor world pos: %F", FmtFloat2(frame->world_cursor)); UI_BuildLabelF("Cursor tile pos: %F", FmtFloat2(tile_pos)); UI_BuildLabelF("Cursor tile idx: %F", FmtSint(tile_idx)); diff --git a/src/pp/pp_vis/pp_vis_core.h b/src/pp/pp_vis/pp_vis_core.h index d7027bf5..a57f163b 100644 --- a/src/pp/pp_vis/pp_vis_core.h +++ b/src/pp/pp_vis/pp_vis_core.h @@ -212,8 +212,23 @@ Struct(V_Palette) UI_Key key; b32 is_showing; f32 show; + f32 scroll; - f32 scroll_begin; + // f32 scroll_begin; + + + + + // f32 drag_thumb_offset; + // f32 drag_scrollbar_container_start; + // f32 drag_scrollbar_container_end; + + Rng2 drag_lister; + Rng2 drag_container; + Vec2 drag_cursor; + f32 drag_scroll; + + V_TextboxState search_state; }; diff --git a/src/pp/pp_vis/pp_vis_gpu.g b/src/pp/pp_vis/pp_vis_gpu.g index 4014afeb..c51dd06e 100644 --- a/src/pp/pp_vis/pp_vis_gpu.g +++ b/src/pp/pp_vis/pp_vis_gpu.g @@ -1113,10 +1113,10 @@ ComputeShader(V_CompositeCS) Vec4 grid_color = 0; if (is_in_world) { - b32 debug_draw = !!frame.show_console; + b32 draw_grid = frame.show_console || frame.is_editing; // Grid outline - if (frame.show_console) + if (draw_grid) { const Vec4 line_color = LinearFromSrgb(Vec4(1, 1, 1, 0.1)); Vec2 line_screen_p0 = mul(frame.af.world_to_screen, Vec3(floor(world_pos), 1)); @@ -1133,7 +1133,7 @@ ComputeShader(V_CompositeCS) } // Axis - if (frame.show_console) + if (draw_grid) { const Vec4 x_axis_color = LinearFromSrgb(Vec4(0.75, 0, 0, 1)); const Vec4 y_axis_color = LinearFromSrgb(Vec4(0, 0.75, 0, 1)); @@ -1152,7 +1152,7 @@ ComputeShader(V_CompositeCS) } // World bounds - if (frame.show_console || frame.is_editing) + if (draw_grid || frame.is_editing) { const Vec4 bounds_color = LinearFromSrgb(Vec4(0.75, 0.75, 0, 1)); f32 bounds_dist = 100000;