diff --git a/src/pp/pp_vis/pp_vis_core.c b/src/pp/pp_vis/pp_vis_core.c index f44d6c6f..23007685 100644 --- a/src/pp/pp_vis/pp_vis_core.c +++ b/src/pp/pp_vis/pp_vis_core.c @@ -3773,7 +3773,6 @@ void V_TickForever(WaveLaneCtx *lane) //- Build console panel if (panel->flags & V_PanelFlag_Console) - ProfZoneDF("Build console panel") { Vec4 level_colors[LogLevel_COUNT][2] = Zi; SetBytes(level_colors, 0xFF, sizeof(level_colors)); @@ -3871,6 +3870,198 @@ void V_TickForever(WaveLaneCtx *lane) + ////////////////////////////// + //- Build spawner panel + + + + + + + if (panel->flags & V_PanelFlag_Spawn) + { + UI_Size window_padding = UI_Fnt(0.60, 1); + Vec4 divider_color = VEC4(0.35, 0.35, 0.35, 1); + + UI_PushDF(Parent, UI_BuildRow()) + { + UI_BuildSpacer(window_padding, Axis_X); + UI_PushDF(Parent, UI_BuildColumn()) + { + UI_BuildSpacer(window_padding, Axis_Y); + + //- Header + { + UI_SetNext(Text, Lit("Spawn")); + UI_SetNext(ChildAlignment, UI_Region_Center); + UI_SetNext(FontSize, UI_Top(FontSize) * theme.h3); + UI_SetNext(Height, UI_Shrink(0, 1)); + UI_SetNext(Flags, UI_BoxFlag_DrawText); + UI_BuildRow(); + } + + // UI_BuildSpacer(window_padding, Axis_Y); + // UI_BuildDivider(UI_Px(1, 0), theme.col.divider, Axis_Y); + UI_BuildSpacer(window_padding, Axis_Y); + + //- Tiles + { + for (P_TileKind tile_kind = 0; tile_kind < P_TileKind_COUNT; ++tile_kind) + { + UI_BuildDivider(UI_Px(1, 0), divider_color, Axis_Y); + + String tile_name = P_NameFromTileKind(tile_kind); + UI_Key tile_box = UI_KeyF("Tile %F", FmtString(tile_name)); + + if (UI_Downs(tile_box, Button_M1)) + { + frame->edit_mode = V_EditMode_Tile; + frame->equipped_tile = tile_kind; + } + + Vec4 bg_color = Zi; + bg_color = LerpSrgb(bg_color, theme.col.button_hot, UI_Hot(tile_box)); + bg_color = LerpSrgb(bg_color, theme.col.button_active, UI_Active(tile_box)); + + b32 is_selected = ( + frame->edit_mode == V_EditMode_Tile && + tile_kind == frame->equipped_tile + ); + + Vec4 border_color = Zi; + // border_color = LerpSrgb(border_color, theme.col.button_selected, UI_Misc(tile_box)); + border_color = LerpSrgb(border_color, theme.col.button_active, UI_Hot(tile_box)); + + UI_SetNext(BackgroundColor, bg_color); + UI_SetNext(BorderColor, border_color); + UI_SetNext(BorderSize, 1); + UI_SetNext(Width, UI_Grow(1, 0)); + UI_SetNext(Height, UI_Shrink(UI_Fnt(0.25, 0).v, 0)); + UI_SetNext(Misc, is_selected); + UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); + UI_SetNext(ChildAlignment, UI_Region_Left); + UI_PushDF(Parent, UI_BuildRowEx(tile_box)) + { + UI_BuildSpacer(UI_Fnt(0.25, 0), Axis_X); + + // Tile sprite + { + String sheet_name = StringF(frame->arena, "tile/%F.ase", FmtString(tile_name)); + ResourceKey sheet_resource = ResourceKeyFromStore(&P_Resources, sheet_name); + SPR_SheetKey sheet = SPR_SheetKeyFromResource(sheet_resource); + + UI_SetNext(ChildAlignment, UI_Region_Center); + UI_SetNext(Width, UI_Fnt(2.5, 0)); + UI_SetNext(Height, UI_Fnt(2.5, 0)); + UI_SetNext(SpriteSheet, sheet); + UI_BuildRow(); + } + + UI_BuildSpacer(UI_Fnt(0.5, 0), Axis_X); + + // Tile name + { + UI_SetNext(ChildAlignment, UI_Region_Center); + UI_SetNext(Text, tile_name); + UI_SetNext(Flags, UI_BoxFlag_DrawText); + UI_SetNext(Width, UI_Shrink(4, 0)); + UI_SetNext(Height, UI_Shrink(2, 0)); + UI_BuildRow(); + } + } + } + } + + //- Prefabs + + { + for (P_PrefabKind prefab_kind = 0; prefab_kind < P_PrefabKind_COUNT; ++prefab_kind) + { + String prefab_name = P_NameFromPrefabKind(prefab_kind); + P_PrefabFlag prefab_flags = P_FlagsFromPrefabKind(prefab_kind); + if (!AnyBit(prefab_flags, P_PrefabFlag_HideFromEditor)) + { + UI_BuildDivider(UI_Px(1, 0), divider_color, Axis_Y); + + UI_Key prefab_box = UI_KeyF("Prefab %F", FmtString(prefab_name)); + + if (UI_Downs(prefab_box, Button_M1)) + { + frame->edit_mode = V_EditMode_Prefab; + frame->equipped_prefab = prefab_kind; + } + + Vec4 bg_color = Zi; + bg_color = LerpSrgb(bg_color, theme.col.button_hot, UI_Hot(prefab_box)); + bg_color = LerpSrgb(bg_color, theme.col.button_active, UI_Active(prefab_box)); + + b32 is_selected = ( + frame->edit_mode == V_EditMode_Prefab && + prefab_kind == frame->equipped_prefab + ); + + Vec4 border_color = Zi; + // border_color = LerpSrgb(border_color, theme.col.button_selected, UI_Misc(prefab_box)); + border_color = LerpSrgb(border_color, theme.col.button_active, UI_Hot(prefab_box)); + + UI_SetNext(BackgroundColor, bg_color); + UI_SetNext(BorderColor, border_color); + UI_SetNext(BorderSize, 1); + UI_SetNext(Width, UI_Grow(1, 0)); + UI_SetNext(Height, UI_Shrink(UI_Fnt(0.25, 0).v, 0)); + UI_SetNext(Misc, is_selected); + UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); + UI_SetNext(ChildAlignment, UI_Region_Left); + UI_PushDF(Parent, UI_BuildRowEx(prefab_box)) + { + UI_BuildSpacer(UI_Fnt(0.25, 0), Axis_X); + + // Prefab sprite + { + String sheet_name = StringF(frame->arena, "prefab/%F.ase", FmtString(prefab_name)); + ResourceKey sheet_resource = ResourceKeyFromStore(&P_Resources, sheet_name); + SPR_SheetKey sheet = SPR_SheetKeyFromResource(sheet_resource); + + UI_SetNext(ChildAlignment, UI_Region_Center); + UI_SetNext(Width, UI_Fnt(2.5, 0)); + UI_SetNext(Height, UI_Fnt(2.5, 0)); + UI_SetNext(SpriteSheet, sheet); + UI_BuildRow(); + } + + UI_BuildSpacer(UI_Fnt(0.5, 0), Axis_X); + + // Prefab name + { + UI_SetNext(ChildAlignment, UI_Region_Center); + UI_SetNext(Text, prefab_name); + UI_SetNext(Flags, UI_BoxFlag_DrawText); + UI_SetNext(Width, UI_Shrink(4, 0)); + UI_SetNext(Height, UI_Shrink(2, 0)); + UI_BuildRow(); + } + } + } + } + } + UI_BuildSpacer(window_padding, Axis_Y); + } + UI_BuildSpacer(window_padding, Axis_X); + } + } + + + + + + + + + + + + + @@ -3888,7 +4079,6 @@ void V_TickForever(WaveLaneCtx *lane) ////////////////////////////// //- Build profiler panel - if (!TweakBool("Hide profiler", 0)) if (panel->flags & V_PanelFlag_Profiler) ProfZoneDF("Build profiler panel") { @@ -4487,273 +4677,247 @@ void V_TickForever(WaveLaneCtx *lane) u32 lane_idx = 2; UI_Key track_box = UI_KeyF("vis track %F", FmtUint(vis_track->id)); - Vec2 track_dims_rate = VEC2(Inf, 15); + Vec2 track_dims_rate = VEC2(Inf, 10); UI_SetNext(Height, track_height); UI_SetNext(DimsRate, track_dims_rate); UI_PushDF(Tag, track_box.v) - UI_PushDF(Parent, UI_BuildRowEx(track_box)) + UI_PushDF(Parent, UI_BuildColumnEx(track_box)) { - // UI_BuildSpacer(window_padding, Axis_X); + // UI_BuildSpacer(window_padding, Axis_Y); + // UI_BuildSpacer(window_padding, Axis_Y); - UI_SetNext(DimsRate, track_dims_rate); UI_SetNext(Height, track_height); - UI_PushDF(Parent, UI_BuildColumnEx(UI_KeyF("track area"))) + UI_PushDF(Parent, UI_BuildRow()) { - UI_BuildSpacer(window_padding, Axis_Y); + // UI_BuildSpacer(window_padding, Axis_X); + // UI_BuildSpacer(window_padding, Axis_X); - // UI_BuildSpacer(window_padding, Axis_Y); - // UI_BuildSpacer(track_padding, Axis_Y); - // UI_BuildSpacer(track_padding, Axis_Y); - // UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_Y); - - //- Wave/lane info + UI_SetNext(DimsRate, track_dims_rate); + UI_SetNext(Height, track_height); + UI_PushDF(Parent, UI_BuildColumnEx(UI_KeyF("track area"))) { - // UI_SetNext(Height, zone_height); - UI_SetNext(Height, UI_Shrink(0, 1)); - // UI_SetNext(BackgroundColor, VEC4(0.15, 0.15, 0.15, 0.15)); - // UI_SetNext(BackgroundColor, profiler_color); - UI_SetNext(BackgroundColor, Color_Transparent); - // UI_SetNext(Text, wave_name); - UI_PushDF(Parent, UI_BuildRow()) - { - UI_PushDF(Height, UI_Shrink(0, 1)) - UI_PushDF(Width, UI_Shrink(0, 1)) - UI_PushDF(FontSize, UI_Top(FontSize) * theme.h4) - UI_PushDF(Flags, UI_BoxFlag_DrawText) - { - UI_PushDF(Text, Lit(" Async ")) - // UI_PushDF(TextColor, theme.col.hint) - UI_BuildBox(); + UI_BuildSpacer(window_padding, Axis_Y); - UI_PushDF(Text, Lit("Lane 0")) - UI_PushDF(TextColor, theme.col.hint) - UI_BuildBox(); + // UI_BuildSpacer(window_padding, Axis_Y); + // UI_BuildSpacer(track_padding, Axis_Y); + // UI_BuildSpacer(track_padding, Axis_Y); + // UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_Y); + + //- Wave/lane info + { + // UI_SetNext(Height, zone_height); + UI_SetNext(Height, UI_Shrink(0, 1)); + // UI_SetNext(BackgroundColor, VEC4(0.15, 0.15, 0.15, 0.15)); + // UI_SetNext(BackgroundColor, profiler_color); + UI_SetNext(BackgroundColor, Color_Transparent); + // UI_SetNext(Text, wave_name); + UI_PushDF(Parent, UI_BuildRow()) + { + UI_PushDF(Height, UI_Shrink(0, 1)) + UI_PushDF(Width, UI_Shrink(0, 1)) + UI_PushDF(FontSize, UI_Top(FontSize) * theme.h4) + UI_PushDF(Flags, UI_BoxFlag_DrawText) + { + UI_PushDF(Text, Lit(" Async ")) + // UI_PushDF(TextColor, theme.col.hint) + UI_BuildBox(); + + UI_PushDF(Text, Lit("Lane 0")) + UI_PushDF(TextColor, theme.col.hint) + UI_BuildBox(); + } } } - } - - UI_SetNext(Height, track_height); - UI_SetNext(DimsRate, track_dims_rate); - UI_SetNext(Rounding, UI_Rpx(5 * theme.rounding)); - UI_SetNext(BackgroundColor, profiler_color); - UI_SetNext(BorderColor, theme.col.window_bd); - UI_SetNext(BorderSize, 1); - UI_SetNext(Flags, UI_BoxFlag_Scissor); - UI_PushDF(Parent, UI_BuildRowEx(UI_KeyF("zone rows"))) - { - // UI_BuildSpacer(window_padding, Axis_Y); UI_SetNext(Height, track_height); - UI_PushDF(Parent, UI_BuildColumn()) + UI_SetNext(DimsRate, track_dims_rate); + UI_SetNext(Rounding, UI_Rpx(5 * theme.rounding)); + UI_SetNext(BackgroundColor, profiler_color); + UI_SetNext(BorderColor, theme.col.window_bd); + UI_SetNext(BorderSize, 1); + UI_SetNext(Flags, UI_BoxFlag_Scissor); + UI_PushDF(Parent, UI_BuildRowEx(UI_KeyF("zone rows"))) { + // UI_BuildSpacer(window_padding, Axis_Y); - // UI_BuildSpacer(UI_Px(10, 0), Axis_Y); - // UI_BuildSpacer(UI_Grow(1, 0), Axis_Y); - - //- Zone rows - UI_Key *zone_row_boxes = PushStructs(frame->arena, UI_Key, vis_track->rows_count); - for (u64 zone_row_box_idx = 0; zone_row_box_idx < vis_track->rows_count; ++zone_row_box_idx) + UI_SetNext(Height, track_height); + UI_PushDF(Parent, UI_BuildColumn()) { - UI_Key zone_row_box = UI_KeyF("zone row %F", FmtUint(zone_row_box_idx)); - zone_row_boxes[zone_row_box_idx] = zone_row_box; - // UI_SetNext(Height, zone_height); - UI_SetNext(Height, zone_height); - UI_PushDF(Parent, UI_BuildRowEx(zone_row_box)) + + // UI_BuildSpacer(UI_Px(10, 0), Axis_Y); + // UI_BuildSpacer(UI_Grow(1, 0), Axis_Y); + + //- Zone rows + UI_Key *zone_row_boxes = PushStructs(frame->arena, UI_Key, vis_track->rows_count); + for (u64 zone_row_box_idx = 0; zone_row_box_idx < vis_track->rows_count; ++zone_row_box_idx) { - } - } - - // End-of-rows padding - UI_BuildSpacer(window_padding, Axis_Y); - - //- Zones - for (VisZone *zone = vis_track->first_zone; zone; zone = zone->next) - { - UI_Key zone_row_box = zone_row_boxes[zone->depth - 1]; - b32 can_hover = profiler->unsnap; - - UI_Key zone_box = UI_KeyF("Zone %F", FmtUint(zone->id)); - b32 is_hovered = can_hover && UI_HoveredAbsolute(zone_box) && UI_HotAbsolute(main_box); - if (is_hovered) - { - hovered_zone_box = zone_box; - hovered_zone = zone; - } - f32 zone_hovered = can_hover * UI_Hovered(zone_box) * UI_Hot(main_box); - - f64 zone_offset_px = zone->start_px - view_start_px; - f64 zone_len_px = zone->end_px - zone->start_px; - - Vec2 zone_pos = VEC2(zone_offset_px, 0); - UI_Size zone_width = UI_Px(zone_len_px, 1); - - Vec4 zone_color = zone->color; - Vec4 zone_color_bd = zone_color; - - zone_color_bd = MulVec4(zone_color_bd, 0.65); - zone_color_bd.a = 1; - - Vec4 zone_text_color = UI_Top(TextColor); - zone_text_color.a *= 0.75; - - Vec4 zone_line_color = Zi; - - // b32 is_collapsed = zone->is_collapsed; - b32 is_collapsed = zone->collapsed_count > 0; - // b32 is_collapsed = zone->collapsed_count > 0 || zone_len_px <= min_zone_width_px; - - // UI_Size collapsed_line_size = UI_Px(2, 1); - UI_Size collapsed_line_size = UI_Px(1.5, 1); - // Vec4 collapsed_text_color = theme.col.positive; - // Vec4 collapsed_line_color = theme.col.negative; - // Vec4 collapsed_line_color = SrgbFromHsv(TweakFloat("RAAAAAAAAAH H", 100, 0, 360), TweakFloat("RAAAAAAAAAH S", 0.50, 0, 1), TweakFloat("RAAAAAAAAAH V", 1.00, 0, 1)); - // Vec4 collapsed_line_color = Color_Black; - // Vec4 collapsed_line_color = theme.col.hint; - // Vec4 collapsed_text_color = theme.col.positive; - // Vec4 collapsed_text_color = SrgbFromHsv(TweakFloat("RAAAAAAAAAH H", 100, 0, 360), TweakFloat("RAAAAAAAAAH S", 0.50, 0, 1), TweakFloat("RAAAAAAAAAH V", 1.00, 0, 1)); - - // Vec4 collapsed_line_color = SrgbFromHsv(32, 1, 0.5); - // Vec4 collapsed_text_color = SrgbFromHsv(32, 1, 1); - - // Vec4 collapsed_line_color = SrgbFromHsv(64, 1, 0.5); - // Vec4 collapsed_text_color = SrgbFromHsv(64, 1, 0.75); - - // collapsed_text_color = LerpSrgb(collapsed_text_color, Color_White, zone_hovered); - // collapsed_line_color = LerpSrgb(collapsed_line_color, Color_White, zone_hovered); - - - - - - String zone_text = zone->name; - if (is_collapsed) - { - zone_text = StringF(frame->arena, "%F", FmtUint(zone->collapsed_count)); - zone_text_color = collapsed_text_color; - zone_line_color = collapsed_line_color; - - // zone_color = VEC4(0, 0, 0, 0); - // zone_color = VEC4(1, 0, 1, 1); - // zone_color = VEC4(0.15, 0.15, 0.15, 0.5); - // zone_color = VEC4(0.20, 0.20, 0.20, 0.5); - - - zone_color = VEC4(0.25, 0.25, 0.25, 0.5); - - - // if (zone->collapsed_count > 1) - // { - // zone_color = VEC4(0.25, 0.25, 0.25, 0.5); - // } - // else - // { - // zone_color = Color_White; - // } - - - - // zone_color = VEC4(0.4, 0.4, 0.4, 0.5); - zone_color_bd = VEC4(0, 0, 0, 0); - - // zone_color = LerpSrgb(zone_color, Color_Transparent, zone_hovered); - + UI_Key zone_row_box = UI_KeyF("zone row %F", FmtUint(zone_row_box_idx)); + zone_row_boxes[zone_row_box_idx] = zone_row_box; + // UI_SetNext(Height, zone_height); + UI_SetNext(Height, zone_height); + UI_PushDF(Parent, UI_BuildRowEx(zone_row_box)) + { + } } - if (zone_len_px < zone_name_hide_threshold_px) + // End-of-rows padding + // TODO: We want this, but seems to maybe cause 1px vertical overlap on zones? + // UI_BuildSpacer(window_padding, Axis_Y); + // UI_BuildSpacer(UI_Px(zone_height.v * 1, 0), Axis_Y); + + //- Zones + for (VisZone *zone = vis_track->first_zone; zone; zone = zone->next) { - zone_text.len = 0; - } + UI_Key zone_row_box = zone_row_boxes[zone->depth - 1]; + b32 can_hover = profiler->unsnap; - zone_color_bd = LerpSrgb(zone_color_bd, Color_White, zone_hovered * !is_collapsed); - zone_text_color = LerpSrgb(zone_text_color, Color_White, zone_hovered); - zone_line_color = LerpSrgb(zone_line_color, Color_White, zone_hovered); + UI_Key zone_box = UI_KeyF("Zone %F", FmtUint(zone->id)); + b32 is_hovered = can_hover && UI_HoveredAbsolute(zone_box) && UI_HotAbsolute(main_box); + if (is_hovered) + { + hovered_zone_box = zone_box; + hovered_zone = zone; + } + f32 zone_hovered = can_hover * UI_Hovered(zone_box) * UI_Hot(main_box); + + f64 zone_offset_px = zone->start_px - view_start_px; + f64 zone_len_px = zone->end_px - zone->start_px; + + Vec2 zone_pos = VEC2(zone_offset_px, 0); + UI_Size zone_width = UI_Px(zone_len_px, 1); + + Vec4 zone_color = zone->color; + Vec4 zone_color_bd = zone_color; + + zone_color_bd = MulVec4(zone_color_bd, 0.65); + zone_color_bd.a = 1; + + Vec4 zone_text_color = UI_Top(TextColor); + zone_text_color.a *= 0.75; + + Vec4 zone_line_color = Zi; + + // b32 is_collapsed = zone->is_collapsed; + b32 is_collapsed = zone->collapsed_count > 0; + // b32 is_collapsed = zone->collapsed_count > 0 || zone_len_px <= min_zone_width_px; + + // UI_Size collapsed_line_size = UI_Px(2, 1); + UI_Size collapsed_line_size = UI_Px(1.5, 1); + // Vec4 collapsed_text_color = theme.col.positive; + // Vec4 collapsed_line_color = theme.col.negative; + // Vec4 collapsed_line_color = SrgbFromHsv(TweakFloat("RAAAAAAAAAH H", 100, 0, 360), TweakFloat("RAAAAAAAAAH S", 0.50, 0, 1), TweakFloat("RAAAAAAAAAH V", 1.00, 0, 1)); + // Vec4 collapsed_line_color = Color_Black; + // Vec4 collapsed_line_color = theme.col.hint; + // Vec4 collapsed_text_color = theme.col.positive; + // Vec4 collapsed_text_color = SrgbFromHsv(TweakFloat("RAAAAAAAAAH H", 100, 0, 360), TweakFloat("RAAAAAAAAAH S", 0.50, 0, 1), TweakFloat("RAAAAAAAAAH V", 1.00, 0, 1)); + + // Vec4 collapsed_line_color = SrgbFromHsv(32, 1, 0.5); + // Vec4 collapsed_text_color = SrgbFromHsv(32, 1, 1); + + // Vec4 collapsed_line_color = SrgbFromHsv(64, 1, 0.5); + // Vec4 collapsed_text_color = SrgbFromHsv(64, 1, 0.75); + + // collapsed_text_color = LerpSrgb(collapsed_text_color, Color_White, zone_hovered); + // collapsed_line_color = LerpSrgb(collapsed_line_color, Color_White, zone_hovered); - f32 collapsed_zones_per_px = zone->collapsed_count / zone_len_px; - // f32 zag_intensity = 50 / collapsed_zones_per_px; - // zag_intensity = MaxF32(zag_intensity, 5); - // f32 top_zag_information_density = 10; - f32 top_zag_information_density = zone_collapse_threshold_px; - // f32 zag_intensity = SmoothstepF32(0, top_zag_information_density, collapsed_zones_per_px); - // f32 zag_intensity = 1; - f32 zag_intensity = 0.3; - // f32 zag_intensity = TweakFloat("RAAAAAAAAAAAAAH", 1, 0, 1); - f32 period_max = 20; - f32 period_min = 5; - f32 zag_period = LerpF32(period_max, period_min, zag_intensity); - f32 amplitude_max = UI_Top(FontSize) * 0.15; - f32 amplitude_min = UI_Top(FontSize) * 0.05; - f32 zag_amplitude = LerpF32(amplitude_max, amplitude_min, zag_intensity); - - UI_SetNext(Width, zone_width); - UI_SetNext(Height, UI_Grow(1, 0)); - UI_SetNext(BackgroundColor, zone_color); - UI_SetNext(BorderColor, zone_color_bd); - UI_SetNext(BorderSize, 1); - UI_SetNext(FloatingPos, zone_pos); - UI_SetNext(ChildAlignment, UI_Region_Center); - UI_SetNext( - Flags, - UI_BoxFlag_Floating | - UI_BoxFlag_DontClampFloatingX | - UI_BoxFlag_DontClampFloatingY | - UI_BoxFlag_CaptureMouse | - UI_BoxFlag_Scissor - ); - UI_SetNext(Parent, zone_row_box); - // UI_PushDF(OrFlags, UI_Top(OrFlags) | (UI_BoxFlag_DontTruncateText * !!(is_collapsed))) - // UI_PushDF(OmitFlags, UI_Top(OmitFlags) | (UI_BoxFlag_Scissor * !!(is_collapsed))) - // UI_PushDF(ZagPeriod, UI_Top(FontSize) * 1) - // UI_PushDF(ZagPeriod, (collapsed_zones_per_px * UI_Top(FontSize)) * 0.1) - // UI_PushDF(ZagPeriod, collapsed_zones_per_px / (UI_Top(FontSize) * 1)) - UI_PushDF(ZagPeriod, zag_period) - UI_PushDF(ZagThickness, 1.5) - UI_PushDF(ZagRoundness, 1) - UI_PushDF(ZagAmplitude, zag_amplitude) - UI_PushDF(Parent, UI_BuildRowEx(zone_box)) - { + String zone_text = zone->name; if (is_collapsed) { - // Left zag - UI_SetNext(Width, UI_Grow(1, 0)); - UI_SetNext(ZagColor, zone_line_color); - UI_BuildBox(); - } - else - { - UI_SetNext(Width, UI_Px(3, 1)); - UI_BuildBox(); + zone_text = StringF(frame->arena, "%F", FmtUint(zone->collapsed_count)); + zone_text_color = collapsed_text_color; + zone_line_color = collapsed_line_color; + + // zone_color = VEC4(0, 0, 0, 0); + // zone_color = VEC4(1, 0, 1, 1); + // zone_color = VEC4(0.15, 0.15, 0.15, 0.5); + // zone_color = VEC4(0.20, 0.20, 0.20, 0.5); + + + zone_color = VEC4(0.25, 0.25, 0.25, 0.5); + + + // if (zone->collapsed_count > 1) + // { + // zone_color = VEC4(0.25, 0.25, 0.25, 0.5); + // } + // else + // { + // zone_color = Color_White; + // } + + + + // zone_color = VEC4(0.4, 0.4, 0.4, 0.5); + zone_color_bd = VEC4(0, 0, 0, 0); + + // zone_color = LerpSrgb(zone_color, Color_Transparent, zone_hovered); + } - if (zone_text.len > 0) + if (zone_len_px < zone_name_hide_threshold_px) { - // Zone name - // if (zone_len_px > zone_collapse_threshold_px * 3) - { - if (is_collapsed) - { - UI_SetNext(Width, UI_Shrink(0, 1)); - UI_SetNext(ChildAlignment, UI_Region_Center); - } - else - { - UI_SetNext(ChildAlignment, UI_Region_Left); - UI_SetNext(Width, UI_Grow(1, 0)); - } - UI_SetNext(FontSize, UI_Top(FontSize) * theme.h5); - UI_SetNext(TextColor, zone_text_color); - UI_SetNext(Text, zone_text); - UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_DontTruncateText); - UI_BuildRow(); - } + zone_text.len = 0; + } - // Right collapsed lines + zone_color_bd = LerpSrgb(zone_color_bd, Color_White, zone_hovered * !is_collapsed); + zone_text_color = LerpSrgb(zone_text_color, Color_White, zone_hovered); + zone_line_color = LerpSrgb(zone_line_color, Color_White, zone_hovered); + + + f32 collapsed_zones_per_px = zone->collapsed_count / zone_len_px; + // f32 zag_intensity = 50 / collapsed_zones_per_px; + // zag_intensity = MaxF32(zag_intensity, 5); + + // f32 top_zag_information_density = 10; + f32 top_zag_information_density = zone_collapse_threshold_px; + // f32 zag_intensity = SmoothstepF32(0, top_zag_information_density, collapsed_zones_per_px); + // f32 zag_intensity = 1; + f32 zag_intensity = 0.3; + // f32 zag_intensity = TweakFloat("RAAAAAAAAAAAAAH", 1, 0, 1); + + f32 period_max = 20; + f32 period_min = 5; + f32 zag_period = LerpF32(period_max, period_min, zag_intensity); + + f32 amplitude_max = UI_Top(FontSize) * 0.15; + f32 amplitude_min = UI_Top(FontSize) * 0.05; + f32 zag_amplitude = LerpF32(amplitude_max, amplitude_min, zag_intensity); + + UI_SetNext(Width, zone_width); + UI_SetNext(Height, UI_Grow(1, 0)); + UI_SetNext(BackgroundColor, zone_color); + UI_SetNext(BorderColor, zone_color_bd); + UI_SetNext(BorderSize, 1); + UI_SetNext(FloatingPos, zone_pos); + UI_SetNext(ChildAlignment, UI_Region_Center); + UI_SetNext( + Flags, + UI_BoxFlag_Floating | + UI_BoxFlag_DontClampFloatingX | + UI_BoxFlag_DontClampFloatingY | + UI_BoxFlag_CaptureMouse | + UI_BoxFlag_Scissor + ); + UI_SetNext(Parent, zone_row_box); + // UI_PushDF(OrFlags, UI_Top(OrFlags) | (UI_BoxFlag_DontTruncateText * !!(is_collapsed))) + // UI_PushDF(OmitFlags, UI_Top(OmitFlags) | (UI_BoxFlag_Scissor * !!(is_collapsed))) + // UI_PushDF(ZagPeriod, UI_Top(FontSize) * 1) + // UI_PushDF(ZagPeriod, (collapsed_zones_per_px * UI_Top(FontSize)) * 0.1) + // UI_PushDF(ZagPeriod, collapsed_zones_per_px / (UI_Top(FontSize) * 1)) + UI_PushDF(ZagPeriod, zag_period) + UI_PushDF(ZagThickness, 1.5) + UI_PushDF(ZagRoundness, 1) + UI_PushDF(ZagAmplitude, zag_amplitude) + UI_PushDF(Parent, UI_BuildRowEx(zone_box)) + { if (is_collapsed) { + // Left zag UI_SetNext(Width, UI_Grow(1, 0)); UI_SetNext(ZagColor, zone_line_color); UI_BuildBox(); @@ -4763,16 +4927,58 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(Width, UI_Px(3, 1)); UI_BuildBox(); } + + if (zone_text.len > 0) + { + // Zone name + // if (zone_len_px > zone_collapse_threshold_px * 3) + { + if (is_collapsed) + { + UI_SetNext(Width, UI_Shrink(0, 1)); + UI_SetNext(ChildAlignment, UI_Region_Center); + } + else + { + UI_SetNext(ChildAlignment, UI_Region_Left); + UI_SetNext(Width, UI_Grow(1, 0)); + } + UI_SetNext(FontSize, UI_Top(FontSize) * theme.h5); + UI_SetNext(TextColor, zone_text_color); + UI_SetNext(Text, zone_text); + UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_DontTruncateText); + UI_BuildRow(); + } + + // Right collapsed lines + if (is_collapsed) + { + UI_SetNext(Width, UI_Grow(1, 0)); + UI_SetNext(ZagColor, zone_line_color); + UI_BuildBox(); + } + else + { + UI_SetNext(Width, UI_Px(3, 1)); + UI_BuildBox(); + } + } } } } + + // UI_BuildSpacer(window_padding, Axis_Y); } - // UI_BuildSpacer(window_padding, Axis_Y); + UI_BuildSpacer(window_padding, Axis_Y); } - UI_BuildSpacer(window_padding, Axis_Y); + // UI_BuildSpacer(window_padding, Axis_X); + // UI_BuildSpacer(window_padding, Axis_X); } + + // UI_BuildSpacer(window_padding, Axis_Y); + // UI_BuildSpacer(window_padding, Axis_Y); } } } @@ -5037,7 +5243,7 @@ void V_TickForever(WaveLaneCtx *lane) if (!V.root_panel) { - V_Panel *subroot_row_panel = 0; + V_Panel *subroot_panel = 0; //- Root panel { @@ -5056,20 +5262,20 @@ void V_TickForever(WaveLaneCtx *lane) V_Panel *parent = V.root_panel; V_Panel *panel = PushStruct(perm, V_Panel); panel->parent = parent; - panel->axis = Axis_Y; + panel->axis = Axis_X; DllQueuePush(parent->first, parent->last, panel); panel->box = UI_KeyF("test raah subroot row panel"); panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v)); panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); panel->pct = 1; panel->is_organizational = 1; - subroot_row_panel = panel; + subroot_panel = panel; } } //- Test profiler panel { - V_Panel *parent = subroot_row_panel; + V_Panel *parent = subroot_panel; V_Panel *panel = PushStruct(perm, V_Panel); panel->parent = parent; panel->axis = Axis_X; @@ -5078,12 +5284,28 @@ void V_TickForever(WaveLaneCtx *lane) panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v)); panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); panel->flags |= V_PanelFlag_Profiler; + panel->flags |= V_PanelFlag_Ignore; panel->pct = 2; } + //- Test console panel + { + V_Panel *parent = subroot_panel; + V_Panel *panel = PushStruct(perm, V_Panel); + panel->parent = parent; + panel->axis = Axis_X; + DllQueuePush(parent->first, parent->last, panel); + panel->box = UI_KeyF("test raah console panel"); + panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v)); + panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); + // panel->flags |= V_PanelFlag_Console; + panel->flags |= V_PanelFlag_Spawn; + panel->pct = 0.25; + } + //- Vis screen panel { - V_Panel *parent = subroot_row_panel; + V_Panel *parent = subroot_panel; V_Panel *panel = PushStruct(perm, V_Panel); panel->parent = parent; panel->axis = Axis_X; @@ -5093,21 +5315,6 @@ void V_TickForever(WaveLaneCtx *lane) panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); panel->pct = 1; } - - - //- Test console panel - { - V_Panel *parent = subroot_row_panel; - V_Panel *panel = PushStruct(perm, V_Panel); - panel->parent = parent; - panel->axis = Axis_X; - DllQueuePush(parent->first, parent->last, panel); - panel->box = UI_KeyF("test raah console panel"); - panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v)); - panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); - panel->flags |= V_PanelFlag_Console; - panel->pct = 0.25; - } } @@ -5360,1682 +5567,6 @@ void V_TickForever(WaveLaneCtx *lane) } - - - - - - - - - - - - - - - - - - - - - - // ////////////////////////////// - // //- Init test layout - - // // TODO: Remove this - - // if (!V.root_panel) - // { - // { - // V_Panel *panel = PushStruct(perm, V_Panel); - // panel->key = UI_RandKey(); // TODO: Don't use random keys for panels - // panel->axis = Axis_X; - // panel->pref_ratio = 1; - // panel->is_organizing_panel = 1; - // V.root_panel = panel; - // ++V.panels_count; - // } - - // { - // V_Panel *panel = PushStruct(perm, V_Panel); - // panel->parent = V.root_panel; - // panel->key = UI_RandKey(); // TODO: Don't use random keys - // panel->axis = !panel->parent->axis; - // panel->pref_ratio = 0.15; - // panel->is_editor_panel = 1; - // DllQueuePush(panel->parent->first, panel->parent->last, panel); - // ++panel->parent->count; - // ++V.panels_count; - - // { - // V_Window *window = PushStruct(perm, V_Window); - // window->panel = panel; - // window->key = UI_RandKey(); // TODO: Don't use random keys - // // window->is_tile_window = 1; - // DllQueuePushNP(panel->first_window, panel->last_window, window, next_in_panel, prev_in_panel); - // ++panel->windows_count; - // ++V.windows_count; - // } - // { - // V_Window *window = PushStruct(perm, V_Window); - // window->panel = panel; - // window->key = UI_RandKey(); // TODO: Don't use random keys - // window->is_tile_window = 1; - // DllQueuePushNP(panel->first_window, panel->last_window, window, next_in_panel, prev_in_panel); - // ++panel->windows_count; - // ++V.windows_count; - // } - // { - // V_Window *window = PushStruct(perm, V_Window); - // window->panel = panel; - // window->key = UI_RandKey(); // TODO: Don't use random keys - // window->is_prefab_window = 1; - // DllQueuePushNP(panel->first_window, panel->last_window, window, next_in_panel, prev_in_panel); - // ++panel->windows_count; - // ++V.windows_count; - // } - // panel->active_window_idx = 2; - // } - - // { - // V_Panel *panel = PushStruct(perm, V_Panel); - // panel->parent = V.root_panel; - // panel->key = vis_screen_box; - // panel->axis = !panel->parent->axis; - // DllQueuePush(panel->parent->first, panel->parent->last, panel); - // ++panel->parent->count; - // ++V.panels_count; - - // panel->pref_ratio = 0.85; - // panel->is_vis_ui_panel = 1; - - // // { - // // V_Window *window = PushStruct(perm, V_Window); - // // window->panel = panel; - // // window->key = UI_RandKey(); // TODO: Don't use random keys - // // window->is_viewport_window = 1; - // // DllQueuePushNP(panel->first_window, panel->last_window, window, next_in_panel, prev_in_panel); - // // ++panel->windows_count; - // // ++V.windows_count; - // // } - // } - - // // { - // // V_Panel *panel = PushStruct(perm, V_Panel); - // // panel->parent = V.root_panel; - // // panel->key = UI_RandKey(); // TODO: Don't use random keys - // // panel->axis = !panel->parent->axis; - // // DllQueuePush(panel->parent->first, panel->parent->last, panel); - // // ++panel->parent->count; - // // ++V.panels_count; - - // // { - // // V_Window *window = PushStruct(perm, V_Window); - // // window->panel = panel; - // // window->key = UI_RandKey(); // TODO: Don't use random keys - // // // window->is_tile_window = 1; - // // DllQueuePushNP(panel->first_window, panel->last_window, window, next_in_panel, prev_in_panel); - // // ++panel->windows_count; - // // ++V.windows_count; - // // } - // // { - // // V_Window *window = PushStruct(perm, V_Window); - // // window->panel = panel; - // // window->key = UI_RandKey(); // TODO: Don't use random keys - // // window->is_tile_window = 1; - // // DllQueuePushNP(panel->first_window, panel->last_window, window, next_in_panel, prev_in_panel); - // // ++panel->windows_count; - // // ++V.windows_count; - // // } - // // panel->active_window_idx = 1; - // // } - // } - - - - - - - - - // ////////////////////////////// - // //- Build panels - - // UI_PushDF(Parent, vis_root_box) - // // if (show_editor_ui && frame->is_editing) - // { - // Struct(PanelDfsNode) { PanelDfsNode *next; b32 visited; V_Panel *panel; UI_Checkpoint cp; }; - // PanelDfsNode *first_panel_dfs = PushStruct(frame->arena, PanelDfsNode); - // first_panel_dfs->panel = V.root_panel; - // f32 divider_size = 10; - - // i64 prune_windows_count = 0; - // V_Window **prune_windows = PushStructsNoZero(frame->arena, V_Window *, V.windows_count); - - // ////////////////////////////// - // //- Walk panel tree - - // while (first_panel_dfs) - // { - // PanelDfsNode *panel_dfs = first_panel_dfs; - // V_Panel *panel = panel_dfs->panel; - // if (!panel_dfs->visited) - // { - // panel_dfs->visited = 1; - - // f32 panel_size = 0; - // if (panel->axis == Axis_X) - // { - // panel_size = DimsFromRng2(UI_Rect(panel->key)).x; - // } - // else - // { - // panel_size = DimsFromRng2(UI_Rect(panel->key)).y; - // } - - // // Push children to dfs stack - // V_Panel *resize_panel = 0; - // for (V_Panel *child = panel->last; child; child = child->prev) - // { - // if (!V_ShouldSkipPanel(child)) - // { - // PanelDfsNode *n = PushStruct(frame->arena, PanelDfsNode); - // n->panel = child; - // SllStackPush(first_panel_dfs, n); - // if (child->resizing) - // { - // resize_panel = child; - // } - // } - // } - - // // Apply resize - // if (resize_panel) - // { - // Vec2 drag_pos = UI_DragCursorPos(); - // Vec2 drag_anchor = UI_DragAnchor(resize_panel->divider_key); - // f32 drag_offset = drag_pos.v[panel->axis] - drag_anchor.v[panel->axis]; - - // f32 child_pref_size = 0; - // child_pref_size += frame->screen_cursor.v[panel->axis]; - // child_pref_size -= drag_anchor.v[panel->axis]; - // // child_pref_size -= divider_rep.last_cursor_down_anchor_offset.v[panel->axis]; - // child_pref_size -= drag_offset; - - // f32 ratio_diff = (child_pref_size / panel_size) - resize_panel->pref_ratio; - // f32 min_ratio = 0.05; - // { - // ratio_diff += MaxF32(min_ratio - (resize_panel->pref_ratio + ratio_diff), 0); - // ratio_diff -= MaxF32(min_ratio - (resize_panel->next->pref_ratio - ratio_diff), 0); - // } - - // resize_panel->next->pref_ratio -= ratio_diff; - // resize_panel->pref_ratio += ratio_diff; - // resize_panel->resizing = 0; - // } - - // // Constrain child raitos - // f32 ratio_accum = 0; - // if (panel_size != 0) - // { - // ratio_accum += (MaxF32(panel->count - 1, 0) * divider_size) / panel_size; - // } - // for (V_Panel *child = panel->last; child; child = child->prev) - // { - // if (!V_ShouldSkipPanel(child)) - // { - // child->pref_ratio = MaxF32(child->pref_ratio, 0.01); - // ratio_accum += child->pref_ratio; - // } - // } - // for (V_Panel *child = panel->last; child; child = child->prev) - // { - // if (!V_ShouldSkipPanel(child)) - // { - // child->pref_ratio += (1.0 - ratio_accum) / panel->count; - // } - // } - - // UI_SetNext(AxisSize, UI_Grow(panel->pref_ratio, 0), .axis = !panel->axis); - // UI_SetNext(AxisSize, UI_Grow(1, 0), .axis = panel->axis); - // if (panel->axis == Axis_X) - // { - // UI_BuildRowEx(panel->key); - // } - // else - // { - // UI_BuildColumnEx(panel->key); - // } - // UI_Push(Tag, panel->key.v); - // panel_dfs->cp = UI_PushCp(panel->key); - - // if (!panel->is_organizing_panel && !panel->is_vis_ui_panel) - // { - // i64 new_active_window_idx = panel->active_window_idx; - // UI_PushCp(UI_BuildColumn()); - // { - // UI_Push(Tint, VEC4(1, 1, 1, 0.90 * UI_Exists(panel->key))); - - // i64 active_window_idx = ClampI64(panel->active_window_idx, 0, MaxI64(panel->windows_count - 1, 0)); - - // ////////////////////////////// - // //- Build tab row - - // f32 tab_spacing = UI_Fnt(0.25, 0).v; - // V_Window *active_window = 0; - // V_Window *close_window = 0; - // { - // UI_Key tab_row_key = UI_KeyF("tab row"); - - // UI_SetNext(Width, UI_Grow(1, 0)); - // UI_SetNext(Height, UI_Shrink(0, 1)); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_PushCp(UI_BuildRowEx(tab_row_key)); - - // ////////////////////////////// - // //- Prep drawable tabs - - // Enum(DrawableTabKind) - // { - // DrawableTabKind_Window, - // DrawableTabKind_NewTab, - // DrawableTabKind_Ghost, - // }; - - // Struct(DrawableTab) - // { - // DrawableTab *next; - // DrawableTab *prev; - // DrawableTabKind kind; - // UI_Key key; - // V_Window *window; - // i64 window_idx; - // }; - - // DrawableTab *first_drawable_tab = 0; - // DrawableTab *last_drawable_tab = 0; - // { - // // Push window tabs - // i64 window_idx = 0; - // for (V_Window *window = panel->first_window; window; window = window->next_in_panel) - // { - // DrawableTab *tab = PushStruct(frame->arena, DrawableTab); - // tab->key = window->key; - // tab->kind = DrawableTabKind_Window; - // tab->window = window; - // tab->window_idx = window_idx; - // DllQueuePush(first_drawable_tab, last_drawable_tab, tab); - // window_idx += 1; - // } - - // // Insert ghost tab - // if (V.dragging_window && UI_HotAbsolute(panel->key)) - // { - // DrawableTab *left = 0; - // DrawableTab *right = first_drawable_tab; - // for (DrawableTab *sibling = first_drawable_tab; sibling; sibling = sibling->next) - // { - // f32 zone = CenterFromRng2(UI_Rect(sibling->key)).x; - // if (frame->screen_cursor.x <= zone) - // { - // break; - // } - // left = sibling; - // right = sibling->next; - // } - - // b32 skip = (left && left->window == V.dragging_window) || (right && right->window == V.dragging_window); - // if (!skip) - // { - // DrawableTab *tab = PushStruct(frame->arena, DrawableTab); - // tab->key = UI_KeyF("ghost"); - // tab->kind = DrawableTabKind_Ghost; - // DllQueueInsert(first_drawable_tab, last_drawable_tab, left, tab); - // } - // } - - // // Push new tab button - // { - // DrawableTab *tab = PushStruct(frame->arena, DrawableTab); - // tab->key = UI_KeyF("new tab"); - // tab->kind = DrawableTabKind_NewTab; - // DllQueuePush(first_drawable_tab, last_drawable_tab, tab); - // } - // } - - // ////////////////////////////// - // //- Build tabs - - // for (DrawableTab *tab = first_drawable_tab; tab; tab = tab->next) - // { - // UI_Push(Tag, tab->key.v); - // if (tab == first_drawable_tab) - // { - // UI_BuildSpacer(UI_Px(tab_spacing, 0), Axis_X); - // } - - // switch (tab->kind) - // { - // ////////////////////////////// - // //- Build window tab - - // case DrawableTabKind_Window: - // { - // V_Window *window = tab->window; - // { - // if (UI_Downs(tab->key, Button_M1) > 0) - // { - // new_active_window_idx = tab->window_idx; - // } - - // if (V.dragging_window == 0) - // { - // f32 drag_threshold = 20; - // if (UI_Held(tab->key, Button_M1)) - // { - // Vec2 drag_start = ui_frame->drag_cursor_pos; - // if (Vec2Len(SubVec2(frame->screen_cursor, drag_start)) > drag_threshold) - // { - // V.dragging_window = window; - // } - // } - // } - - // b32 is_dragging = window == V.dragging_window; - // if (is_dragging && UI_Ups(tab->key, Button_M1) > 0) - // { - // V.dragging_window = 0; - // } - - // Vec4 bg_color = theme.col.window_bg; - // Vec4 border_color = theme.col.window_bd; - // if (tab->window_idx == active_window_idx) - // { - // active_window = window; - // border_color = theme.col.button_active; - // } - - // bg_color = LerpSrgb(bg_color, theme.col.button_hot, UI_Hot(tab->key)); - // bg_color = LerpSrgb(bg_color, theme.col.button_active, UI_Active(tab->key) * is_dragging); - // border_color = LerpSrgb(border_color, theme.col.button_active, UI_Misc(tab->key)); - - // String tab_name = Zi; - // if (window->is_tile_window) - // { - // tab_name = Lit("Tiles"); - // } - // else if (window->is_prefab_window) - // { - // tab_name = Lit("Prefabs"); - // } - // else - // { - // tab_name = Lit("Unknown"); - // } - - // UI_SetNext(BackgroundColor, bg_color); - // UI_SetNext(BorderColor, border_color); - // UI_SetNext(BorderSize, 1); - // UI_SetNext(Width, UI_Shrink(0, 1)); - // UI_SetNext(Height, UI_Shrink(0, 0)); - // UI_SetNext(ChildAlignment, UI_Region_Left); - // UI_SetNext(Misc, window == active_window); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_PushCp(UI_BuildRowEx(tab->key)); - // { - // UI_BuildSpacer(UI_Px(tab_spacing, 0), Axis_X); - - // // Build tab title - // { - // UI_SetNext(ChildAlignment, UI_Region_Center); - // UI_SetNext(Flags, UI_BoxFlag_DrawText); - // UI_SetNext(Text, tab_name); - // UI_SetNext(Width, UI_Shrink(0, 0)); - // UI_SetNext(Height, UI_Shrink(2, 0)); - // UI_BuildRow(); - // } - - // UI_BuildSpacer(UI_Px(tab_spacing, 0), Axis_X); - - // // Build tab close button - // { - // UI_Key close_key = UI_KeyF("close"); - - // Vec4 close_color = Zi; - // close_color = LerpSrgb(close_color, theme.col.button_hot, UI_Hot(close_key)); - // close_color = LerpSrgb(close_color, theme.col.button_active, UI_Active(close_key)); - // Vec4 close_border_color = LerpSrgb(VEC4(0, 0, 0, 0), theme.col.button_active, UI_Hot(close_key)); - - // UI_SetNext(BackgroundColor, close_color); - // UI_SetNext(BorderColor, close_border_color); - // UI_SetNext(BorderSize, 2); - // UI_SetNext(ChildAlignment, UI_Region_Center); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_SetNext(Width, UI_Shrink(0, 0)); - // UI_SetNext(Height, UI_Grow(1, 0)); - // UI_PushCp(UI_BuildRowEx(close_key)); - // { - // UI_BuildSpacer(UI_Px(tab_spacing * 2, 0), Axis_X); - - // UI_SetNext(Width, UI_Shrink(0, 1)); - // UI_SetNext(Height, UI_Shrink(0, 1)); - // UI_SetNext(FontSize, UI_Top(FontSize) * theme.micro); - // UI_BuildIcon(theme.icon_font, UI_Icon_Cross); - - // UI_BuildSpacer(UI_Px(tab_spacing * 2, 0), Axis_X); - // } - // UI_PopCp(UI_TopCp()); - - // if (UI_Presses(close_key, Button_M1)) - // { - // prune_windows[prune_windows_count] = window; - // prune_windows_count += 1; - // } - // } - // } - // UI_PopCp(UI_TopCp()); - // } - // UI_Pop(Tag); - // } break; - - // ////////////////////////////// - // //- Build ghost tab - - // case DrawableTabKind_Ghost: - // { - // Vec4 bg_color = Zi; - // bg_color = LerpSrgb(bg_color, theme.col.button_hot, UI_Exists(tab->key)); - // bg_color.w *= 0.5; - // Vec4 border_color = LerpSrgb(VEC4(0, 0, 0, 0), theme.col.button_active, UI_Exists(tab->key)); - - // // UI_SetNext(Anchor, UI_Region_Center); - // UI_SetNext(Anchor, UI_Region_TopRight); - - // UI_SetNext(Scale, VEC2(UI_Exists(tab->key), 1)); - // UI_SetNext(BackgroundColor, bg_color); - // UI_SetNext(BorderColor, border_color); - // UI_SetNext(BorderSize, 2); - // // UI_SetNext(Width, UI_Px(30, 0)); - // UI_SetNext(Width, UI_Px(100, 0)); - // UI_SetNext(Height, UI_Grow(1, 0)); - // UI_SetNext(ChildAlignment, UI_Region_Center); - // // UI_SetNext(FontSize, theme.font_size * 1.5); - // UI_PushCp(UI_BuildRowEx(tab->key)); - // { - // } - // UI_PopCp(UI_TopCp()); - // } break; - - // ////////////////////////////// - // //- Build new tab button - - // case DrawableTabKind_NewTab: - // { - // UI_Key key = UI_KeyF("new tab"); - - // Vec4 bg_color = Zi; - // bg_color = LerpSrgb(bg_color, theme.col.button_hot, UI_Hot(key)); - // bg_color = LerpSrgb(bg_color, theme.col.button_active, UI_Active(key)); - // bg_color.w *= 0.5; - // Vec4 border_color = LerpSrgb(VEC4(0, 0, 0, 0), theme.col.button_active, UI_Hot(key)); - - // UI_SetNext(BackgroundColor, bg_color); - // UI_SetNext(BorderColor, border_color); - // UI_SetNext(BorderSize, 2); - // UI_SetNext(Width, UI_Shrink(10, 0)); - // UI_SetNext(Height, UI_Grow(1, 0)); - // UI_SetNext(ChildAlignment, UI_Region_Center); - // // UI_SetNext(FontSize, theme.font_size * 1.5); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_PushCp(UI_BuildRowEx(key)); - // { - // UI_SetNext(Width, UI_Shrink(0, 1)); - // UI_SetNext(Height, UI_Shrink(0, 1)); - // UI_SetNext(FontSize, UI_Top(FontSize) * theme.micro); - // UI_BuildIcon(theme.icon_font, UI_Icon_Plus); - // } - // UI_PopCp(UI_TopCp()); - // } - // } - // UI_BuildSpacer(UI_Px(tab_spacing, 0), Axis_X); - // } - // UI_PopCp(UI_TopCp()); - // } - - // ////////////////////////////// - // //- Build active window - - // if (active_window) - // { - // Vec4 window_bg_color = theme.col.window_bg; - // Vec4 window_border_color = theme.col.window_bd; - - // V_Window *window = active_window; - // UI_SetNext(BackgroundColor, window_bg_color); - // UI_SetNext(BorderColor, window_border_color); - // UI_SetNext(BorderSize, 1); - // UI_SetNext(Width, UI_Grow(1, 0)); - // UI_SetNext(Height, UI_Grow(1, 0)); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_PushCp(UI_BuildColumn()); - // { - // UI_Push(Tag, window->key.v); - - // ////////////////////////////// - // //- Build tile window - - // if (window->is_tile_window) - // { - // for (P_TileKind tile_kind = 0; tile_kind < P_TileKind_COUNT; ++tile_kind) - // { - // String tile_name = P_NameFromTileKind(tile_kind); - // UI_Key key = UI_KeyF("Tile %F", FmtString(tile_name)); - - // if (UI_Downs(key, Button_M1)) - // { - // frame->edit_mode = V_EditMode_Tile; - // frame->equipped_tile = tile_kind; - // } - - // Vec4 bg_color = Zi; - // bg_color = LerpSrgb(bg_color, theme.col.button_hot, UI_Hot(key)); - // bg_color = LerpSrgb(bg_color, theme.col.button_active, UI_Active(key)); - - // b32 is_selected = ( - // frame->edit_mode == V_EditMode_Tile && - // tile_kind == frame->equipped_tile - // ); - - // Vec4 border_color = Zi; - // border_color = LerpSrgb(border_color, theme.col.button_selected, UI_Misc(key)); - // border_color = LerpSrgb(border_color, theme.col.button_active, UI_Hot(key)); - - // UI_SetNext(BackgroundColor, bg_color); - // UI_SetNext(BorderColor, border_color); - // UI_SetNext(BorderSize, 1); - // UI_SetNext(Width, UI_Grow(1, 0)); - // UI_SetNext(Height, UI_Shrink(UI_Fnt(0.25, 0).v, 0)); - // UI_SetNext(Misc, is_selected); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_SetNext(ChildAlignment, UI_Region_Left); - // UI_PushCp(UI_BuildRowEx(key)); - // { - // UI_BuildSpacer(UI_Fnt(0.25, 0), Axis_X); - - // // Tile sprite - // { - // String sheet_name = StringF(frame->arena, "tile/%F.ase", FmtString(tile_name)); - // ResourceKey sheet_resource = ResourceKeyFromStore(&P_Resources, sheet_name); - // SPR_SheetKey sheet = SPR_SheetKeyFromResource(sheet_resource); - - // UI_SetNext(ChildAlignment, UI_Region_Center); - // UI_SetNext(Width, UI_Fnt(2.5, 0)); - // UI_SetNext(Height, UI_Fnt(2.5, 0)); - // UI_SetNext(SpriteSheet, sheet); - // UI_BuildRow(); - // } - - // UI_BuildSpacer(UI_Fnt(0.5, 0), Axis_X); - - // // Tile name - // { - // UI_SetNext(ChildAlignment, UI_Region_Center); - // UI_SetNext(Text, tile_name); - // UI_SetNext(Flags, UI_BoxFlag_DrawText); - // UI_SetNext(Width, UI_Shrink(4, 0)); - // UI_SetNext(Height, UI_Shrink(2, 0)); - // UI_BuildRow(); - // } - // } - // UI_PopCp(UI_TopCp()); - // } - // } - - // ////////////////////////////// - // //- Build prefab window - - // if (window->is_prefab_window) - // { - // for (P_PrefabKind prefab_kind = 0; prefab_kind < P_PrefabKind_COUNT; ++prefab_kind) - // { - // String prefab_name = P_NameFromPrefabKind(prefab_kind); - // P_PrefabFlag prefab_flags = P_FlagsFromPrefabKind(prefab_kind); - // if (!AnyBit(prefab_flags, P_PrefabFlag_HideFromEditor)) - // { - // UI_Key key = UI_KeyF("Prefab %F", FmtString(prefab_name)); - - // if (UI_Downs(key, Button_M1)) - // { - // frame->edit_mode = V_EditMode_Prefab; - // frame->equipped_prefab = prefab_kind; - // } - - // Vec4 bg_color = Zi; - // bg_color = LerpSrgb(bg_color, theme.col.button_hot, UI_Hot(key)); - // bg_color = LerpSrgb(bg_color, theme.col.button_active, UI_Active(key)); - - // b32 is_selected = ( - // frame->edit_mode == V_EditMode_Prefab && - // prefab_kind == frame->equipped_prefab - // ); - - // Vec4 border_color = Zi; - // border_color = LerpSrgb(border_color, theme.col.button_selected, UI_Misc(key)); - // border_color = LerpSrgb(border_color, theme.col.button_active, UI_Hot(key)); - - // UI_SetNext(BackgroundColor, bg_color); - // UI_SetNext(BorderColor, border_color); - // UI_SetNext(BorderSize, 1); - // UI_SetNext(Width, UI_Grow(1, 0)); - // UI_SetNext(Height, UI_Shrink(UI_Fnt(0.25, 0).v, 0)); - // UI_SetNext(Misc, is_selected); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_SetNext(ChildAlignment, UI_Region_Left); - // UI_PushCp(UI_BuildRowEx(key)); - // { - // UI_BuildSpacer(UI_Fnt(0.25, 0), Axis_X); - - // // Prefab sprite - // { - // String sheet_name = StringF(frame->arena, "prefab/%F.ase", FmtString(prefab_name)); - // ResourceKey sheet_resource = ResourceKeyFromStore(&P_Resources, sheet_name); - // SPR_SheetKey sheet = SPR_SheetKeyFromResource(sheet_resource); - - // UI_SetNext(ChildAlignment, UI_Region_Center); - // UI_SetNext(Width, UI_Fnt(2.5, 0)); - // UI_SetNext(Height, UI_Fnt(2.5, 0)); - // UI_SetNext(SpriteSheet, sheet); - // UI_BuildRow(); - // } - - // UI_BuildSpacer(UI_Fnt(0.5, 0), Axis_X); - - // // Prefab name - // { - // UI_SetNext(ChildAlignment, UI_Region_Center); - // UI_SetNext(Text, prefab_name); - // UI_SetNext(Flags, UI_BoxFlag_DrawText); - // UI_SetNext(Width, UI_Shrink(4, 0)); - // UI_SetNext(Height, UI_Shrink(2, 0)); - // UI_BuildRow(); - // } - // } - // UI_PopCp(UI_TopCp()); - // } - // } - // } - // } - // UI_PopCp(UI_TopCp()); - // } - // } - // UI_PopCp(UI_TopCp()); - // panel->active_window_idx = new_active_window_idx; - // } - // } - // else - // { - // UI_PopCp(panel_dfs->cp); - // SllStackPop(first_panel_dfs); - - // ////////////////////////////// - // //- Build panel divider - - // if (panel->next != 0) - // { - // panel->divider_key = UI_KeyF("Divider"); - - // Vec4 active_color = theme.col.button_active; - // Vec4 hot_color = LerpSrgb(theme.col.button_hot, theme.col.button_active, 0.25); - - // Vec4 bg_color = Zi; - // bg_color = LerpSrgb(bg_color, hot_color, UI_Hot(panel->divider_key)); - // bg_color = LerpSrgb(bg_color, active_color, UI_Active(panel->divider_key)); - - // Vec4 border_color = Zi; - // f32 visible_size = 2.0; - - // UI_SetNext(BackgroundColor, bg_color); - // UI_SetNext(BorderColor, border_color); - // UI_SetNext(BorderSize, MaxF32((divider_size / 2.0) - (visible_size / 2.0), 0)); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_SetNext(AxisSize, UI_Grow(1, 1), .axis = panel->axis); - // UI_SetNext(AxisSize, UI_Px(divider_size, 1), .axis = !panel->axis); - // UI_BuildBoxEx(panel->divider_key); - - // if (UI_HotAbsolute(panel->divider_key) || UI_Held(panel->divider_key, Button_M1)) - // { - // if (panel->axis == Axis_X) - // { - // WND_SetCursor(window_frame, WND_CursorKind_VerticalResize); - // } - // else - // { - // WND_SetCursor(window_frame, WND_CursorKind_HorizontalResize); - // } - // } - - // if (UI_Held(panel->divider_key, Button_M1)) - // { - // panel->resizing = 1; - // } - // } - - // UI_Pop(Tag); - // } - // } - - // ////////////////////////////// - // //- Prune windows - - // for (i64 prune_window_idx = 0; prune_window_idx < prune_windows_count; ++prune_window_idx) - // { - // V_Window *window = prune_windows[prune_window_idx]; - // V_Panel *panel = window->panel; - - // if (window == V.dragging_window) - // { - // V.dragging_window = 0; - // } - - // // TODO: Add window to freelist - // // TODO: Remove panel if windowless - // DllQueueRemoveNP(panel->first_window, panel->last_window, window, next_in_panel, prev_in_panel); - // panel->windows_count -= 1; - // } - // } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ////////////////////////////// - // //- Init test layout - - // // TODO: Remove this - - // if (!V.root_panel) - // { - // { - // V_Panel *panel = PushStruct(perm, V_Panel); - // panel->key = UI_RandKey(); // TODO: Don't use random keys for panels - // panel->axis = Axis_X; - // panel->pref_ratio = 1; - // panel->is_organizing_panel = 1; - // V.root_panel = panel; - // ++V.panels_count; - // } - - // { - // V_Panel *panel = PushStruct(perm, V_Panel); - // panel->parent = V.root_panel; - // panel->key = UI_RandKey(); // TODO: Don't use random keys - // panel->axis = !panel->parent->axis; - // panel->pref_ratio = 0.15; - // panel->is_editor_panel = 1; - // DllQueuePush(panel->parent->first, panel->parent->last, panel); - // ++panel->parent->count; - // ++V.panels_count; - - // { - // V_Window *window = PushStruct(perm, V_Window); - // window->panel = panel; - // window->key = UI_RandKey(); // TODO: Don't use random keys - // // window->is_tile_window = 1; - // DllQueuePushNP(panel->first_window, panel->last_window, window, next_in_panel, prev_in_panel); - // ++panel->windows_count; - // ++V.windows_count; - // } - // { - // V_Window *window = PushStruct(perm, V_Window); - // window->panel = panel; - // window->key = UI_RandKey(); // TODO: Don't use random keys - // window->is_tile_window = 1; - // DllQueuePushNP(panel->first_window, panel->last_window, window, next_in_panel, prev_in_panel); - // ++panel->windows_count; - // ++V.windows_count; - // } - // { - // V_Window *window = PushStruct(perm, V_Window); - // window->panel = panel; - // window->key = UI_RandKey(); // TODO: Don't use random keys - // window->is_prefab_window = 1; - // DllQueuePushNP(panel->first_window, panel->last_window, window, next_in_panel, prev_in_panel); - // ++panel->windows_count; - // ++V.windows_count; - // } - // panel->active_window_idx = 2; - // } - - // { - // V_Panel *panel = PushStruct(perm, V_Panel); - // panel->parent = V.root_panel; - // panel->key = vis_screen_box; - // panel->axis = !panel->parent->axis; - // DllQueuePush(panel->parent->first, panel->parent->last, panel); - // ++panel->parent->count; - // ++V.panels_count; - - // panel->pref_ratio = 0.85; - // panel->is_vis_ui_panel = 1; - - // // { - // // V_Window *window = PushStruct(perm, V_Window); - // // window->panel = panel; - // // window->key = UI_RandKey(); // TODO: Don't use random keys - // // window->is_viewport_window = 1; - // // DllQueuePushNP(panel->first_window, panel->last_window, window, next_in_panel, prev_in_panel); - // // ++panel->windows_count; - // // ++V.windows_count; - // // } - // } - - // // { - // // V_Panel *panel = PushStruct(perm, V_Panel); - // // panel->parent = V.root_panel; - // // panel->key = UI_RandKey(); // TODO: Don't use random keys - // // panel->axis = !panel->parent->axis; - // // DllQueuePush(panel->parent->first, panel->parent->last, panel); - // // ++panel->parent->count; - // // ++V.panels_count; - - // // { - // // V_Window *window = PushStruct(perm, V_Window); - // // window->panel = panel; - // // window->key = UI_RandKey(); // TODO: Don't use random keys - // // // window->is_tile_window = 1; - // // DllQueuePushNP(panel->first_window, panel->last_window, window, next_in_panel, prev_in_panel); - // // ++panel->windows_count; - // // ++V.windows_count; - // // } - // // { - // // V_Window *window = PushStruct(perm, V_Window); - // // window->panel = panel; - // // window->key = UI_RandKey(); // TODO: Don't use random keys - // // window->is_tile_window = 1; - // // DllQueuePushNP(panel->first_window, panel->last_window, window, next_in_panel, prev_in_panel); - // // ++panel->windows_count; - // // ++V.windows_count; - // // } - // // panel->active_window_idx = 1; - // // } - // } - - // ////////////////////////////// - // //- Build panels - - // UI_PushDF(Parent, vis_root_box) - // // if (show_editor_ui && frame->is_editing) - // { - // Struct(PanelDfsNode) { PanelDfsNode *next; b32 visited; V_Panel *panel; UI_Checkpoint cp; }; - // PanelDfsNode *first_panel_dfs = PushStruct(frame->arena, PanelDfsNode); - // first_panel_dfs->panel = V.root_panel; - // f32 divider_size = 10; - - // i64 prune_windows_count = 0; - // V_Window **prune_windows = PushStructsNoZero(frame->arena, V_Window *, V.windows_count); - - // ////////////////////////////// - // //- Walk panel tree - - - - - - - - - - // // FIXME: Remove this - // #define V_ShouldSkipPanel(panel) (panel->is_editor_panel && (hide_editor_ui || !frame->is_editing)) - - - - - - - - - // while (first_panel_dfs) - // { - // PanelDfsNode *panel_dfs = first_panel_dfs; - // V_Panel *panel = panel_dfs->panel; - // if (!panel_dfs->visited) - // { - // panel_dfs->visited = 1; - - // f32 panel_size = 0; - // if (panel->axis == Axis_X) - // { - // panel_size = DimsFromRng2(UI_Rect(panel->key)).x; - // } - // else - // { - // panel_size = DimsFromRng2(UI_Rect(panel->key)).y; - // } - - // // Push children to dfs stack - // V_Panel *resize_panel = 0; - // for (V_Panel *child = panel->last; child; child = child->prev) - // { - // if (!V_ShouldSkipPanel(child)) - // { - // PanelDfsNode *n = PushStruct(frame->arena, PanelDfsNode); - // n->panel = child; - // SllStackPush(first_panel_dfs, n); - // if (child->resizing) - // { - // resize_panel = child; - // } - // } - // } - - // // Apply resize - // if (resize_panel) - // { - // Vec2 drag_pos = UI_DragCursorPos(); - // Vec2 drag_anchor = UI_DragAnchor(resize_panel->divider_key); - // f32 drag_offset = drag_pos.v[panel->axis] - drag_anchor.v[panel->axis]; - - // f32 child_pref_size = 0; - // child_pref_size += frame->screen_cursor.v[panel->axis]; - // child_pref_size -= drag_anchor.v[panel->axis]; - // // child_pref_size -= divider_rep.last_cursor_down_anchor_offset.v[panel->axis]; - // child_pref_size -= drag_offset; - - // f32 ratio_diff = (child_pref_size / panel_size) - resize_panel->pref_ratio; - // f32 min_ratio = 0.05; - // { - // ratio_diff += MaxF32(min_ratio - (resize_panel->pref_ratio + ratio_diff), 0); - // ratio_diff -= MaxF32(min_ratio - (resize_panel->next->pref_ratio - ratio_diff), 0); - // } - - // resize_panel->next->pref_ratio -= ratio_diff; - // resize_panel->pref_ratio += ratio_diff; - // resize_panel->resizing = 0; - // } - - // // Constrain child raitos - // f32 ratio_accum = 0; - // if (panel_size != 0) - // { - // ratio_accum += (MaxF32(panel->count - 1, 0) * divider_size) / panel_size; - // } - // for (V_Panel *child = panel->last; child; child = child->prev) - // { - // if (!V_ShouldSkipPanel(child)) - // { - // child->pref_ratio = MaxF32(child->pref_ratio, 0.01); - // ratio_accum += child->pref_ratio; - // } - // } - // for (V_Panel *child = panel->last; child; child = child->prev) - // { - // if (!V_ShouldSkipPanel(child)) - // { - // child->pref_ratio += (1.0 - ratio_accum) / panel->count; - // } - // } - - // UI_SetNext(AxisSize, UI_Grow(panel->pref_ratio, 0), .axis = !panel->axis); - // UI_SetNext(AxisSize, UI_Grow(1, 0), .axis = panel->axis); - // if (panel->axis == Axis_X) - // { - // UI_BuildRowEx(panel->key); - // } - // else - // { - // UI_BuildColumnEx(panel->key); - // } - // UI_Push(Tag, panel->key.v); - // panel_dfs->cp = UI_PushCp(panel->key); - - // if (!panel->is_organizing_panel && !panel->is_vis_ui_panel) - // { - // i64 new_active_window_idx = panel->active_window_idx; - // UI_PushCp(UI_BuildColumn()); - // { - // UI_Push(Tint, VEC4(1, 1, 1, 0.90 * UI_Exists(panel->key))); - - // i64 active_window_idx = ClampI64(panel->active_window_idx, 0, MaxI64(panel->windows_count - 1, 0)); - - // ////////////////////////////// - // //- Build tab row - - // f32 tab_spacing = UI_Fnt(0.25, 0).v; - // V_Window *active_window = 0; - // V_Window *close_window = 0; - // { - // UI_Key tab_row_key = UI_KeyF("tab row"); - - // UI_SetNext(Width, UI_Grow(1, 0)); - // UI_SetNext(Height, UI_Shrink(0, 1)); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_PushCp(UI_BuildRowEx(tab_row_key)); - - // ////////////////////////////// - // //- Prep drawable tabs - - // Enum(DrawableTabKind) - // { - // DrawableTabKind_Window, - // DrawableTabKind_NewTab, - // DrawableTabKind_Ghost, - // }; - - // Struct(DrawableTab) - // { - // DrawableTab *next; - // DrawableTab *prev; - // DrawableTabKind kind; - // UI_Key key; - // V_Window *window; - // i64 window_idx; - // }; - - // DrawableTab *first_drawable_tab = 0; - // DrawableTab *last_drawable_tab = 0; - // { - // // Push window tabs - // i64 window_idx = 0; - // for (V_Window *window = panel->first_window; window; window = window->next_in_panel) - // { - // DrawableTab *tab = PushStruct(frame->arena, DrawableTab); - // tab->key = window->key; - // tab->kind = DrawableTabKind_Window; - // tab->window = window; - // tab->window_idx = window_idx; - // DllQueuePush(first_drawable_tab, last_drawable_tab, tab); - // window_idx += 1; - // } - - // // Insert ghost tab - // if (V.dragging_window && UI_HotAbsolute(panel->key)) - // { - // DrawableTab *left = 0; - // DrawableTab *right = first_drawable_tab; - // for (DrawableTab *sibling = first_drawable_tab; sibling; sibling = sibling->next) - // { - // f32 zone = CenterFromRng2(UI_Rect(sibling->key)).x; - // if (frame->screen_cursor.x <= zone) - // { - // break; - // } - // left = sibling; - // right = sibling->next; - // } - - // b32 skip = (left && left->window == V.dragging_window) || (right && right->window == V.dragging_window); - // if (!skip) - // { - // DrawableTab *tab = PushStruct(frame->arena, DrawableTab); - // tab->key = UI_KeyF("ghost"); - // tab->kind = DrawableTabKind_Ghost; - // DllQueueInsert(first_drawable_tab, last_drawable_tab, left, tab); - // } - // } - - // // Push new tab button - // { - // DrawableTab *tab = PushStruct(frame->arena, DrawableTab); - // tab->key = UI_KeyF("new tab"); - // tab->kind = DrawableTabKind_NewTab; - // DllQueuePush(first_drawable_tab, last_drawable_tab, tab); - // } - // } - - // ////////////////////////////// - // //- Build tabs - - // for (DrawableTab *tab = first_drawable_tab; tab; tab = tab->next) - // { - // UI_Push(Tag, tab->key.v); - // if (tab == first_drawable_tab) - // { - // UI_BuildSpacer(UI_Px(tab_spacing, 0), Axis_X); - // } - - // switch (tab->kind) - // { - // ////////////////////////////// - // //- Build window tab - - // case DrawableTabKind_Window: - // { - // V_Window *window = tab->window; - // { - // if (UI_Downs(tab->key, Button_M1) > 0) - // { - // new_active_window_idx = tab->window_idx; - // } - - // if (V.dragging_window == 0) - // { - // f32 drag_threshold = 20; - // if (UI_Held(tab->key, Button_M1)) - // { - // Vec2 drag_start = ui_frame->drag_cursor_pos; - // if (Vec2Len(SubVec2(frame->screen_cursor, drag_start)) > drag_threshold) - // { - // V.dragging_window = window; - // } - // } - // } - - // b32 is_dragging = window == V.dragging_window; - // if (is_dragging && UI_Ups(tab->key, Button_M1) > 0) - // { - // V.dragging_window = 0; - // } - - // Vec4 bg_color = theme.col.window_bg; - // Vec4 border_color = theme.col.window_bd; - // if (tab->window_idx == active_window_idx) - // { - // active_window = window; - // border_color = theme.col.button_active; - // } - - // bg_color = LerpSrgb(bg_color, theme.col.button_hot, UI_Hot(tab->key)); - // bg_color = LerpSrgb(bg_color, theme.col.button_active, UI_Active(tab->key) * is_dragging); - // border_color = LerpSrgb(border_color, theme.col.button_active, UI_Misc(tab->key)); - - // String tab_name = Zi; - // if (window->is_tile_window) - // { - // tab_name = Lit("Tiles"); - // } - // else if (window->is_prefab_window) - // { - // tab_name = Lit("Prefabs"); - // } - // else - // { - // tab_name = Lit("Unknown"); - // } - - // UI_SetNext(BackgroundColor, bg_color); - // UI_SetNext(BorderColor, border_color); - // UI_SetNext(BorderSize, 1); - // UI_SetNext(Width, UI_Shrink(0, 1)); - // UI_SetNext(Height, UI_Shrink(0, 0)); - // UI_SetNext(ChildAlignment, UI_Region_Left); - // UI_SetNext(Misc, window == active_window); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_PushCp(UI_BuildRowEx(tab->key)); - // { - // UI_BuildSpacer(UI_Px(tab_spacing, 0), Axis_X); - - // // Build tab title - // { - // UI_SetNext(ChildAlignment, UI_Region_Center); - // UI_SetNext(Flags, UI_BoxFlag_DrawText); - // UI_SetNext(Text, tab_name); - // UI_SetNext(Width, UI_Shrink(0, 0)); - // UI_SetNext(Height, UI_Shrink(2, 0)); - // UI_BuildRow(); - // } - - // UI_BuildSpacer(UI_Px(tab_spacing, 0), Axis_X); - - // // Build tab close button - // { - // UI_Key close_key = UI_KeyF("close"); - - // Vec4 close_color = Zi; - // close_color = LerpSrgb(close_color, theme.col.button_hot, UI_Hot(close_key)); - // close_color = LerpSrgb(close_color, theme.col.button_active, UI_Active(close_key)); - // Vec4 close_border_color = LerpSrgb(VEC4(0, 0, 0, 0), theme.col.button_active, UI_Hot(close_key)); - - // UI_SetNext(BackgroundColor, close_color); - // UI_SetNext(BorderColor, close_border_color); - // UI_SetNext(BorderSize, 2); - // UI_SetNext(ChildAlignment, UI_Region_Center); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_SetNext(Width, UI_Shrink(0, 0)); - // UI_SetNext(Height, UI_Grow(1, 0)); - // UI_PushCp(UI_BuildRowEx(close_key)); - // { - // UI_BuildSpacer(UI_Px(tab_spacing * 2, 0), Axis_X); - - // UI_SetNext(Width, UI_Shrink(0, 1)); - // UI_SetNext(Height, UI_Shrink(0, 1)); - // UI_SetNext(FontSize, UI_Top(FontSize) * theme.micro); - // UI_BuildIcon(theme.icon_font, UI_Icon_Cross); - - // UI_BuildSpacer(UI_Px(tab_spacing * 2, 0), Axis_X); - // } - // UI_PopCp(UI_TopCp()); - - // if (UI_Presses(close_key, Button_M1)) - // { - // prune_windows[prune_windows_count] = window; - // prune_windows_count += 1; - // } - // } - // } - // UI_PopCp(UI_TopCp()); - // } - // UI_Pop(Tag); - // } break; - - // ////////////////////////////// - // //- Build ghost tab - - // case DrawableTabKind_Ghost: - // { - // Vec4 bg_color = Zi; - // bg_color = LerpSrgb(bg_color, theme.col.button_hot, UI_Exists(tab->key)); - // bg_color.w *= 0.5; - // Vec4 border_color = LerpSrgb(VEC4(0, 0, 0, 0), theme.col.button_active, UI_Exists(tab->key)); - - // // UI_SetNext(Anchor, UI_Region_Center); - // UI_SetNext(Anchor, UI_Region_TopRight); - - // UI_SetNext(Scale, VEC2(UI_Exists(tab->key), 1)); - // UI_SetNext(BackgroundColor, bg_color); - // UI_SetNext(BorderColor, border_color); - // UI_SetNext(BorderSize, 2); - // // UI_SetNext(Width, UI_Px(30, 0)); - // UI_SetNext(Width, UI_Px(100, 0)); - // UI_SetNext(Height, UI_Grow(1, 0)); - // UI_SetNext(ChildAlignment, UI_Region_Center); - // // UI_SetNext(FontSize, theme.font_size * 1.5); - // UI_PushCp(UI_BuildRowEx(tab->key)); - // { - // } - // UI_PopCp(UI_TopCp()); - // } break; - - // ////////////////////////////// - // //- Build new tab button - - // case DrawableTabKind_NewTab: - // { - // UI_Key key = UI_KeyF("new tab"); - - // Vec4 bg_color = Zi; - // bg_color = LerpSrgb(bg_color, theme.col.button_hot, UI_Hot(key)); - // bg_color = LerpSrgb(bg_color, theme.col.button_active, UI_Active(key)); - // bg_color.w *= 0.5; - // Vec4 border_color = LerpSrgb(VEC4(0, 0, 0, 0), theme.col.button_active, UI_Hot(key)); - - // UI_SetNext(BackgroundColor, bg_color); - // UI_SetNext(BorderColor, border_color); - // UI_SetNext(BorderSize, 2); - // UI_SetNext(Width, UI_Shrink(10, 0)); - // UI_SetNext(Height, UI_Grow(1, 0)); - // UI_SetNext(ChildAlignment, UI_Region_Center); - // // UI_SetNext(FontSize, theme.font_size * 1.5); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_PushCp(UI_BuildRowEx(key)); - // { - // UI_SetNext(Width, UI_Shrink(0, 1)); - // UI_SetNext(Height, UI_Shrink(0, 1)); - // UI_SetNext(FontSize, UI_Top(FontSize) * theme.micro); - // UI_BuildIcon(theme.icon_font, UI_Icon_Plus); - // } - // UI_PopCp(UI_TopCp()); - // } - // } - // UI_BuildSpacer(UI_Px(tab_spacing, 0), Axis_X); - // } - // UI_PopCp(UI_TopCp()); - // } - - // ////////////////////////////// - // //- Build active window - - // if (active_window) - // { - // Vec4 window_bg_color = theme.col.window_bg; - // Vec4 window_border_color = theme.col.window_bd; - - // V_Window *window = active_window; - // UI_SetNext(BackgroundColor, window_bg_color); - // UI_SetNext(BorderColor, window_border_color); - // UI_SetNext(BorderSize, 1); - // UI_SetNext(Width, UI_Grow(1, 0)); - // UI_SetNext(Height, UI_Grow(1, 0)); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_PushCp(UI_BuildColumn()); - // { - // UI_Push(Tag, window->key.v); - - // ////////////////////////////// - // //- Build tile window - - // if (window->is_tile_window) - // { - // for (P_TileKind tile_kind = 0; tile_kind < P_TileKind_COUNT; ++tile_kind) - // { - // String tile_name = P_NameFromTileKind(tile_kind); - // UI_Key key = UI_KeyF("Tile %F", FmtString(tile_name)); - - // if (UI_Downs(key, Button_M1)) - // { - // frame->edit_mode = V_EditMode_Tile; - // frame->equipped_tile = tile_kind; - // } - - // Vec4 bg_color = Zi; - // bg_color = LerpSrgb(bg_color, theme.col.button_hot, UI_Hot(key)); - // bg_color = LerpSrgb(bg_color, theme.col.button_active, UI_Active(key)); - - // b32 is_selected = ( - // frame->edit_mode == V_EditMode_Tile && - // tile_kind == frame->equipped_tile - // ); - - // Vec4 border_color = Zi; - // border_color = LerpSrgb(border_color, theme.col.button_selected, UI_Misc(key)); - // border_color = LerpSrgb(border_color, theme.col.button_active, UI_Hot(key)); - - // UI_SetNext(BackgroundColor, bg_color); - // UI_SetNext(BorderColor, border_color); - // UI_SetNext(BorderSize, 1); - // UI_SetNext(Width, UI_Grow(1, 0)); - // UI_SetNext(Height, UI_Shrink(UI_Fnt(0.25, 0).v, 0)); - // UI_SetNext(Misc, is_selected); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_SetNext(ChildAlignment, UI_Region_Left); - // UI_PushCp(UI_BuildRowEx(key)); - // { - // UI_BuildSpacer(UI_Fnt(0.25, 0), Axis_X); - - // // Tile sprite - // { - // String sheet_name = StringF(frame->arena, "tile/%F.ase", FmtString(tile_name)); - // ResourceKey sheet_resource = ResourceKeyFromStore(&P_Resources, sheet_name); - // SPR_SheetKey sheet = SPR_SheetKeyFromResource(sheet_resource); - - // UI_SetNext(ChildAlignment, UI_Region_Center); - // UI_SetNext(Width, UI_Fnt(2.5, 0)); - // UI_SetNext(Height, UI_Fnt(2.5, 0)); - // UI_SetNext(SpriteSheet, sheet); - // UI_BuildRow(); - // } - - // UI_BuildSpacer(UI_Fnt(0.5, 0), Axis_X); - - // // Tile name - // { - // UI_SetNext(ChildAlignment, UI_Region_Center); - // UI_SetNext(Text, tile_name); - // UI_SetNext(Flags, UI_BoxFlag_DrawText); - // UI_SetNext(Width, UI_Shrink(4, 0)); - // UI_SetNext(Height, UI_Shrink(2, 0)); - // UI_BuildRow(); - // } - // } - // UI_PopCp(UI_TopCp()); - // } - // } - - // ////////////////////////////// - // //- Build prefab window - - // if (window->is_prefab_window) - // { - // for (P_PrefabKind prefab_kind = 0; prefab_kind < P_PrefabKind_COUNT; ++prefab_kind) - // { - // String prefab_name = P_NameFromPrefabKind(prefab_kind); - // P_PrefabFlag prefab_flags = P_FlagsFromPrefabKind(prefab_kind); - // if (!AnyBit(prefab_flags, P_PrefabFlag_HideFromEditor)) - // { - // UI_Key key = UI_KeyF("Prefab %F", FmtString(prefab_name)); - - // if (UI_Downs(key, Button_M1)) - // { - // frame->edit_mode = V_EditMode_Prefab; - // frame->equipped_prefab = prefab_kind; - // } - - // Vec4 bg_color = Zi; - // bg_color = LerpSrgb(bg_color, theme.col.button_hot, UI_Hot(key)); - // bg_color = LerpSrgb(bg_color, theme.col.button_active, UI_Active(key)); - - // b32 is_selected = ( - // frame->edit_mode == V_EditMode_Prefab && - // prefab_kind == frame->equipped_prefab - // ); - - // Vec4 border_color = Zi; - // border_color = LerpSrgb(border_color, theme.col.button_selected, UI_Misc(key)); - // border_color = LerpSrgb(border_color, theme.col.button_active, UI_Hot(key)); - - // UI_SetNext(BackgroundColor, bg_color); - // UI_SetNext(BorderColor, border_color); - // UI_SetNext(BorderSize, 1); - // UI_SetNext(Width, UI_Grow(1, 0)); - // UI_SetNext(Height, UI_Shrink(UI_Fnt(0.25, 0).v, 0)); - // UI_SetNext(Misc, is_selected); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_SetNext(ChildAlignment, UI_Region_Left); - // UI_PushCp(UI_BuildRowEx(key)); - // { - // UI_BuildSpacer(UI_Fnt(0.25, 0), Axis_X); - - // // Prefab sprite - // { - // String sheet_name = StringF(frame->arena, "prefab/%F.ase", FmtString(prefab_name)); - // ResourceKey sheet_resource = ResourceKeyFromStore(&P_Resources, sheet_name); - // SPR_SheetKey sheet = SPR_SheetKeyFromResource(sheet_resource); - - // UI_SetNext(ChildAlignment, UI_Region_Center); - // UI_SetNext(Width, UI_Fnt(2.5, 0)); - // UI_SetNext(Height, UI_Fnt(2.5, 0)); - // UI_SetNext(SpriteSheet, sheet); - // UI_BuildRow(); - // } - - // UI_BuildSpacer(UI_Fnt(0.5, 0), Axis_X); - - // // Prefab name - // { - // UI_SetNext(ChildAlignment, UI_Region_Center); - // UI_SetNext(Text, prefab_name); - // UI_SetNext(Flags, UI_BoxFlag_DrawText); - // UI_SetNext(Width, UI_Shrink(4, 0)); - // UI_SetNext(Height, UI_Shrink(2, 0)); - // UI_BuildRow(); - // } - // } - // UI_PopCp(UI_TopCp()); - // } - // } - // } - // } - // UI_PopCp(UI_TopCp()); - // } - // } - // UI_PopCp(UI_TopCp()); - // panel->active_window_idx = new_active_window_idx; - // } - // } - // else - // { - // UI_PopCp(panel_dfs->cp); - // SllStackPop(first_panel_dfs); - - // ////////////////////////////// - // //- Build panel divider - - // if (panel->next != 0) - // { - // panel->divider_key = UI_KeyF("Divider"); - - // Vec4 active_color = theme.col.button_active; - // Vec4 hot_color = LerpSrgb(theme.col.button_hot, theme.col.button_active, 0.25); - - // Vec4 bg_color = Zi; - // bg_color = LerpSrgb(bg_color, hot_color, UI_Hot(panel->divider_key)); - // bg_color = LerpSrgb(bg_color, active_color, UI_Active(panel->divider_key)); - - // Vec4 border_color = Zi; - // f32 visible_size = 2.0; - - // UI_SetNext(BackgroundColor, bg_color); - // UI_SetNext(BorderColor, border_color); - // UI_SetNext(BorderSize, MaxF32((divider_size / 2.0) - (visible_size / 2.0), 0)); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_SetNext(AxisSize, UI_Grow(1, 1), .axis = panel->axis); - // UI_SetNext(AxisSize, UI_Px(divider_size, 1), .axis = !panel->axis); - // UI_BuildBoxEx(panel->divider_key); - - // if (UI_HotAbsolute(panel->divider_key) || UI_Held(panel->divider_key, Button_M1)) - // { - // if (panel->axis == Axis_X) - // { - // WND_SetCursor(window_frame, WND_CursorKind_VerticalResize); - // } - // else - // { - // WND_SetCursor(window_frame, WND_CursorKind_HorizontalResize); - // } - // } - - // if (UI_Held(panel->divider_key, Button_M1)) - // { - // panel->resizing = 1; - // } - // } - - // UI_Pop(Tag); - // } - // } - - // ////////////////////////////// - // //- Prune windows - - // for (i64 prune_window_idx = 0; prune_window_idx < prune_windows_count; ++prune_window_idx) - // { - // V_Window *window = prune_windows[prune_window_idx]; - // V_Panel *panel = window->panel; - - // if (window == V.dragging_window) - // { - // V.dragging_window = 0; - // } - - // // TODO: Add window to freelist - // // TODO: Remove panel if windowless - // DllQueueRemoveNP(panel->first_window, panel->last_window, window, next_in_panel, prev_in_panel); - // panel->windows_count -= 1; - // } - // } - - - - - - - - - - - - - - - - - - -