Pulled more old ui code out and replaced it with the layout based ui
This commit is contained in:
parent
cb98100a94
commit
5922a4bf27
124
src/interface.h
124
src/interface.h
|
@ -20,10 +20,10 @@ DrawCharacter_ (render_quad_batch_constructor* BatchConstructor, r32 MinX, r32 M
|
|||
s32 AlignedMaxX = AlignedMinX + (CodepointInfo.Width);
|
||||
s32 AlignedMaxY = AlignedMinY + (CodepointInfo.Height);
|
||||
|
||||
PushQuad2DOnBatch(BatchConstructor,
|
||||
v2{(r32)AlignedMinX, (r32)AlignedMinY}, v2{(r32)AlignedMaxX, (r32)AlignedMinY},
|
||||
v2{(r32)AlignedMaxX, (r32)AlignedMaxY}, v2{(r32)AlignedMinX, (r32)AlignedMaxY},
|
||||
CodepointInfo.UVMin, CodepointInfo.UVMax,
|
||||
PushQuad2DOnBatch(BatchConstructor,
|
||||
v2{(r32)AlignedMinX, (r32)AlignedMinY}, v2{(r32)AlignedMaxX, (r32)AlignedMinY},
|
||||
v2{(r32)AlignedMaxX, (r32)AlignedMaxY}, v2{(r32)AlignedMinX, (r32)AlignedMaxY},
|
||||
CodepointInfo.UVMin, CodepointInfo.UVMax,
|
||||
Color);
|
||||
}
|
||||
|
||||
|
@ -33,12 +33,12 @@ DrawCharacterLeftAligned (render_quad_batch_constructor* BatchConstructor, char
|
|||
s32 GlyphDataIndex = GetIndexForCodepoint(Font, C);
|
||||
codepoint_bitmap CodepointInfo = Font.CodepointValues[GlyphDataIndex];
|
||||
|
||||
// NOTE(Peter):
|
||||
// NOTE(Peter):
|
||||
r32 MinX = Position.x + CodepointInfo.XOffset;
|
||||
r32 MinY = Position.y + CodepointInfo.YOffset;
|
||||
DrawCharacter_(BatchConstructor, MinX, MinY, CodepointInfo, Color);
|
||||
|
||||
// NOTE(Peter):
|
||||
// NOTE(Peter):
|
||||
v2 PointAfterCharacter = v2{Position.x + CodepointInfo.Width, Position.y};
|
||||
return PointAfterCharacter;
|
||||
}
|
||||
|
@ -49,12 +49,12 @@ DrawCharacterRightAligned (render_quad_batch_constructor* BatchConstructor, char
|
|||
s32 GlyphDataIndex = GetIndexForCodepoint(Font, C);
|
||||
codepoint_bitmap CodepointInfo = Font.CodepointValues[GlyphDataIndex];
|
||||
|
||||
// NOTE(Peter):
|
||||
// NOTE(Peter):
|
||||
r32 MinX = Position.x - (CodepointInfo.XOffset + CodepointInfo.Width);
|
||||
r32 MinY = Position.y + CodepointInfo.YOffset + CodepointInfo.YOffset;
|
||||
DrawCharacter_(BatchConstructor, MinX, MinY, CodepointInfo, Color);
|
||||
|
||||
// NOTE(Peter):
|
||||
// NOTE(Peter):
|
||||
v2 PointAfterCharacter = v2{Position.x-(CodepointInfo.Width + CodepointInfo.XOffset), Position.y};
|
||||
return PointAfterCharacter;
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ DrawStringWithCursor (render_command_buffer* RenderBuffer, string String, s32 Cu
|
|||
{
|
||||
RegisterPosition = DrawStringLeftAligned(&BatchConstructor,
|
||||
String.Length - CursorPosition,
|
||||
String.Memory + CursorPosition,
|
||||
String.Memory + CursorPosition,
|
||||
RegisterPosition, Font, Color);
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ DrawStringWithCursor (render_command_buffer* RenderBuffer, string String, s32 Cu
|
|||
{
|
||||
RegisterPosition = DrawStringRightAligned(&BatchConstructor,
|
||||
String.Length - CursorPosition,
|
||||
String.Memory + CursorPosition,
|
||||
String.Memory + CursorPosition,
|
||||
RegisterPosition, Font, Color);
|
||||
}
|
||||
}
|
||||
|
@ -265,12 +265,12 @@ ui_TryReserveElementBounds(ui_layout* Layout, rect* Bounds)
|
|||
{
|
||||
Assert(Layout->RowElementsCount < Layout->RowDivisions);
|
||||
r32 ElementWidth = Width(Layout->Bounds) / Layout->RowDivisions;
|
||||
Bounds->Min = {
|
||||
Bounds->Min = {
|
||||
Layout->Bounds.Min.x + (ElementWidth * Layout->RowElementsCount) + Layout->Margin.x,
|
||||
Layout->RowYAt
|
||||
};
|
||||
Bounds->Max = {
|
||||
Bounds->Min.x + ElementWidth - Layout->Margin.x,
|
||||
Bounds->Max = {
|
||||
Bounds->Min.x + ElementWidth - Layout->Margin.x,
|
||||
Bounds->Min.y + Layout->RowHeight
|
||||
};
|
||||
Layout->RowElementsCount++;
|
||||
|
@ -291,6 +291,17 @@ ui_ReserveTextLineBounds(ui_interface Interface, string Text, ui_layout* Layout)
|
|||
return Bounds;
|
||||
}
|
||||
|
||||
static rect
|
||||
ui_ReserveElementBounds(ui_layout* Layout)
|
||||
{
|
||||
rect Bounds = {0};
|
||||
if (!ui_TryReserveElementBounds(Layout, &Bounds))
|
||||
{
|
||||
InvalidCodePath;
|
||||
}
|
||||
return Bounds;
|
||||
}
|
||||
|
||||
//
|
||||
// Drawing Functions
|
||||
//
|
||||
|
@ -311,7 +322,7 @@ internal void
|
|||
ui_DrawString(ui_interface* Interface, string String, rect Bounds, v4 Color, string_alignment Alignment = Align_Left)
|
||||
{
|
||||
DEBUG_TRACK_FUNCTION;
|
||||
render_quad_batch_constructor BatchConstructor = PushRenderTexture2DBatch(Interface->RenderBuffer,
|
||||
render_quad_batch_constructor BatchConstructor = PushRenderTexture2DBatch(Interface->RenderBuffer,
|
||||
String.Length,
|
||||
Interface->Style.Font->BitmapMemory,
|
||||
Interface->Style.Font->BitmapTextureHandle,
|
||||
|
@ -335,6 +346,19 @@ ui_DrawString(ui_interface* Interface, string String, rect Bounds, v4 Color, str
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ui_LayoutDrawString(ui_interface* Interface, ui_layout* Layout, string String, v4 Color, string_alignment Alignment = Align_Left)
|
||||
{
|
||||
rect Bounds = {0};
|
||||
if (!ui_TryReserveElementBounds(Layout, &Bounds))
|
||||
{
|
||||
// TODO(NAME): Not invalid, just haven't implemented yet.
|
||||
// This is the case where Layout is in row mode without a fixed number of elements
|
||||
InvalidCodePath;
|
||||
}
|
||||
ui_DrawString(Interface, String, Bounds, Color, Alignment);
|
||||
}
|
||||
|
||||
static void
|
||||
ui_TextBox(ui_interface* Interface, rect Bounds, string Text, v4 BGColor, v4 TextColor)
|
||||
{
|
||||
|
@ -370,18 +394,30 @@ ui_Button(ui_interface* Interface, string Text, rect Bounds)
|
|||
}
|
||||
|
||||
static b32
|
||||
ui_LayoutButton(ui_interface* Interface, string Text, ui_layout* Layout)
|
||||
ui_LayoutButton(ui_interface* Interface, ui_layout* Layout, string Text, v4 BGColor, v4 HoverColor, v4 SelectColor)
|
||||
{
|
||||
rect ButtonBounds = {0};
|
||||
if (!ui_TryReserveElementBounds(Layout, &ButtonBounds))
|
||||
{
|
||||
ButtonBounds = ui_ReserveTextLineBounds(*Interface, Text, Layout);
|
||||
}
|
||||
|
||||
return ui_Button(Interface, Text, ButtonBounds, BGColor, HoverColor, SelectColor);
|
||||
}
|
||||
|
||||
static b32
|
||||
ui_LayoutButton(ui_interface* Interface, ui_layout* Layout, string Text)
|
||||
{
|
||||
v4 BGColor = Interface->Style.ButtonColor_Inactive;
|
||||
v4 HoverColor = Interface->Style.ButtonColor_Active;
|
||||
v4 SelectedColor = Interface->Style.ButtonColor_Selected;
|
||||
return ui_Button(Interface, Text, ButtonBounds, BGColor, HoverColor, SelectedColor);
|
||||
return ui_LayoutButton(Interface, Layout, Text, BGColor, HoverColor, SelectedColor);
|
||||
}
|
||||
|
||||
inline v4
|
||||
ui_GetListItemBGColor(interface_config Style, u32 ElementIndex)
|
||||
{
|
||||
v4 Result = Style.ListBGColors[ElementIndex % LIST_BG_COLORS_COUNT];
|
||||
return Result;
|
||||
}
|
||||
|
||||
static b32
|
||||
|
@ -396,7 +432,7 @@ ui_LayoutListEntry(ui_interface* Interface, ui_layout* Layout, string Text, u32
|
|||
// Punting this till I have a use case
|
||||
InvalidCodePath;
|
||||
}
|
||||
v4 BGColor = Interface->Style.ListBGColors[Index % LIST_BG_COLORS_COUNT];
|
||||
v4 BGColor = ui_GetListItemBGColor(Interface->Style, Index);
|
||||
v4 HoverColor = Interface->Style.ListBGHover;
|
||||
v4 SelectedColor = Interface->Style.ListBGSelected;
|
||||
return ui_Button(Interface, Text, Bounds, BGColor, HoverColor, SelectedColor);
|
||||
|
@ -406,52 +442,6 @@ ui_LayoutListEntry(ui_interface* Interface, ui_layout* Layout, string Text, u32
|
|||
// OLD
|
||||
//
|
||||
|
||||
struct slider_result
|
||||
{
|
||||
r32 Percent;
|
||||
r32 Advance;
|
||||
};
|
||||
|
||||
internal slider_result
|
||||
EvaluateSlider (render_command_buffer* RenderBuffer, v2 Min, v2 Max, string Label, r32 Percent, interface_config Config, mouse_state Mouse)
|
||||
{
|
||||
slider_result Result = {};
|
||||
|
||||
v4 BGColor = Config.ButtonColor_Inactive;
|
||||
v4 FillColor = Config.ButtonColor_Selected;
|
||||
|
||||
r32 DisplayPercent = Percent;
|
||||
|
||||
if (PointIsInRange(Mouse.Pos, Min, Max))
|
||||
{
|
||||
BGColor = Config.ButtonColor_Active;
|
||||
}
|
||||
|
||||
if (MouseButtonTransitionedDown(Mouse.LeftButtonState))
|
||||
{
|
||||
if (PointIsInRange(Mouse.DownPos, Min, Max))
|
||||
{
|
||||
r32 TempFillPercent = (Mouse.Pos.y - Min.y) / (Max.y - Min.y);
|
||||
|
||||
DisplayPercent = GSClamp(0.0f, TempFillPercent, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
r32 FillHeight = ((Max.y - Min.y) - 4) * DisplayPercent;
|
||||
|
||||
PushRenderQuad2D(RenderBuffer, Min, Max, BGColor);
|
||||
PushRenderQuad2D(RenderBuffer, Min + v2{2, 2}, v2{Max.x - 2, Min.y + 2 + FillHeight}, FillColor);
|
||||
|
||||
// TODO(Peter): display the actual value of the slider
|
||||
|
||||
DrawString(RenderBuffer, Label, Config.Font, Min, Config.TextColor);
|
||||
|
||||
Result.Percent = DisplayPercent;
|
||||
Result.Advance = (Max.y - Min.y) + Config.Margin.y;
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
enum selection_state
|
||||
{
|
||||
Selection_None,
|
||||
|
@ -517,7 +507,7 @@ EvaluateColorChannelSlider (render_command_buffer* RenderBuffer, v4 ChannelMask,
|
|||
v4 LeftColor = ChannelMask * 0;
|
||||
LeftColor.a = 1.f;
|
||||
v4 RightColor = ChannelMask;
|
||||
PushQuad2DOnBatch(&Batch,
|
||||
PushQuad2DOnBatch(&Batch,
|
||||
Min, v2{Max.x, Min.y}, Max, v2{Min.x, Max.y},
|
||||
v2{0, 0}, v2{1, 0}, v2{1, 1}, v2{0, 1},
|
||||
LeftColor, RightColor, RightColor, LeftColor);
|
||||
|
@ -555,7 +545,7 @@ EvaluateColorPicker (render_command_buffer* RenderBuffer, v4* Value, v2 PanelMin
|
|||
PushRenderQuad2D(RenderBuffer, PanelMin, PanelMax, v4{.5f, .5f, .5f, 1.f});
|
||||
|
||||
v2 TitleMin = v2{PanelMin.x + 5, PanelMax.y - (Config.Font->PixelHeight + 5)};
|
||||
DrawString(RenderBuffer, MakeStringLiteral("Color Picker"), Config.Font,
|
||||
DrawString(RenderBuffer, MakeStringLiteral("Color Picker"), Config.Font,
|
||||
TitleMin, WhiteV4);
|
||||
|
||||
v2 SliderDim = v2{(PanelMax.x - PanelMin.x) - 20, 32};
|
||||
|
@ -587,7 +577,7 @@ struct search_lister_result
|
|||
typedef string search_lister_get_list_item_at_offset(u8* ListMemory, s32 ListLength, string SearchString, s32 Offset);
|
||||
|
||||
internal search_lister_result
|
||||
EvaluateSearchLister (ui_interface* Interface, v2 TopLeft, v2 Dimension, string Title,
|
||||
EvaluateSearchLister (ui_interface* Interface, v2 TopLeft, v2 Dimension, string Title,
|
||||
string* ItemList, s32* ListLUT, s32 ListLength,
|
||||
s32 HotItem,
|
||||
string* SearchString, s32 SearchStringCursorPosition)
|
||||
|
|
|
@ -174,7 +174,7 @@ OPERATION_RENDER_PROC(UpdateDragAnimationClip)
|
|||
NewStartFrame = AnimationBlock->Range.Max - 1;
|
||||
}
|
||||
}
|
||||
AnimationBlock->Range.Min = NewStartFrame;
|
||||
AnimationBlock->Range.Min = NewStartFrame;
|
||||
}
|
||||
else if (GSAbs(Mouse.DownPos.x - ClipInitialEndFrameXPosition) < CLICK_ANIMATION_BLOCK_EDGE_MAX_SCREEN_DISTANCE)
|
||||
{
|
||||
|
@ -257,7 +257,7 @@ SelectAndBeginDragAnimationBlock(gs_list_handle BlockHandle, frame_range Visible
|
|||
FOLDHAUS_INPUT_COMMAND_PROC(AddAnimationBlockCommand)
|
||||
{
|
||||
panel_and_bounds ActivePanel = GetPanelContainingPoint(Mouse.Pos, &State->PanelSystem, State->WindowBounds);
|
||||
frame_range Range = State->AnimationSystem.PlayableRange;
|
||||
frame_range Range = State->AnimationSystem.PlayableRange;
|
||||
u32 MouseDownFrame = GetFrameFromPointInAnimationPanel(Mouse.Pos, ActivePanel.Bounds, Range);
|
||||
gs_list_handle NewBlockHandle = AddAnimationBlock(MouseDownFrame, MouseDownFrame + SecondsToFrames(3, State->AnimationSystem), 4, State->SelectedAnimationLayer, &State->AnimationSystem);
|
||||
SelectAnimationBlock(NewBlockHandle, State);
|
||||
|
@ -301,7 +301,7 @@ DrawFrameBar (animation_system* AnimationSystem, render_command_buffer* RenderBu
|
|||
PushRenderQuad2D(RenderBuffer, RectExpand(BarBounds), v4{.16f, .16f, .16f, 1.f});
|
||||
|
||||
// Mouse clicked inside frame nubmer bar -> change current frame on timeline
|
||||
if (MouseButtonTransitionedDown(Mouse.LeftButtonState) &&
|
||||
if (MouseButtonTransitionedDown(Mouse.LeftButtonState) &&
|
||||
PointIsInRange(Mouse.DownPos, RectExpand(BarBounds)))
|
||||
{
|
||||
StartDragTimeMarker(BarBounds, VisibleFrames, State);
|
||||
|
@ -322,7 +322,7 @@ DrawFrameBar (animation_system* AnimationSystem, render_command_buffer* RenderBu
|
|||
|
||||
// Time Slider
|
||||
if (FrameIsInRange(AnimationSystem->CurrentFrame, VisibleFrames))
|
||||
{
|
||||
{
|
||||
r32 FrameAtPercentVisibleRange = FrameToPercentRange(AnimationSystem->CurrentFrame, VisibleFrames);
|
||||
r32 SliderX = GSLerp(BarBounds.Min.x, BarBounds.Max.x, FrameAtPercentVisibleRange);
|
||||
|
||||
|
@ -348,7 +348,7 @@ DrawTimelineRangeBar (animation_system* AnimationSystem, animation_timeline_stat
|
|||
r32 BarWidth = Width(BarBounds);
|
||||
PushRenderQuad2D(RenderBuffer, RectExpand(BarBounds), v4{.16f, .16f, .16f, 1.f});
|
||||
|
||||
r32 PlayableFrames = (r32)GetFrameCount(AnimationSystem->PlayableRange);
|
||||
r32 PlayableFrames = (r32)GetFrameCount(AnimationSystem->PlayableRange);
|
||||
v2 SliderBarDim = v2{25, BarHeight};
|
||||
|
||||
// Convert Frames To Pixels
|
||||
|
@ -357,7 +357,7 @@ DrawTimelineRangeBar (animation_system* AnimationSystem, animation_timeline_stat
|
|||
v2 RangeMinSliderMin = v2{BarBounds.Min.x + (VisibleMinPercentPlayable * Width(BarBounds)), BarBounds.Min.y};
|
||||
v2 RangeMaxSliderMin = v2{BarBounds.Min.x + (VisibleMaxPercentPlayable * Width(BarBounds)) - 25, BarBounds.Min.y};
|
||||
|
||||
if (MouseButtonHeldDown(Mouse.LeftButtonState) ||
|
||||
if (MouseButtonHeldDown(Mouse.LeftButtonState) ||
|
||||
MouseButtonTransitionedUp(Mouse.LeftButtonState))
|
||||
{
|
||||
v2 MouseDragOffset = Mouse.Pos - Mouse.DownPos;
|
||||
|
@ -385,7 +385,7 @@ DrawTimelineRangeBar (animation_system* AnimationSystem, animation_timeline_stat
|
|||
Result.Min = VisibleMinPercentPlayable * VisibleFrameCount;
|
||||
Result.Max = VisibleMaxPercentPlayable * VisibleFrameCount;
|
||||
|
||||
if (MouseButtonTransitionedUp(Mouse.LeftButtonState))
|
||||
if (MouseButtonTransitionedUp(Mouse.LeftButtonState))
|
||||
{
|
||||
TimelineState->VisibleRange = Result;
|
||||
}
|
||||
|
@ -488,9 +488,9 @@ DrawAnimationTimeline (animation_system* AnimationSystem, animation_timeline_sta
|
|||
// If either end is in the range, we should draw it
|
||||
b32 RangeIsVisible = (FrameIsInRange(AnimationBlockAt.Range.Min, AdjustedViewRange) ||
|
||||
FrameIsInRange(AnimationBlockAt.Range.Max, AdjustedViewRange));
|
||||
// If neither end is in the range, but the ends surround the visible range,
|
||||
// If neither end is in the range, but the ends surround the visible range,
|
||||
// we should still draw it.
|
||||
RangeIsVisible |= (AnimationBlockAt.Range.Min <= AdjustedViewRange.Min &&
|
||||
RangeIsVisible |= (AnimationBlockAt.Range.Min <= AdjustedViewRange.Min &&
|
||||
AnimationBlockAt.Range.Max>= AdjustedViewRange.Max);
|
||||
if (RangeIsVisible)
|
||||
{
|
||||
|
@ -589,15 +589,15 @@ AnimationTimeline_Render(panel Panel, rect PanelBounds, render_command_buffer* R
|
|||
ui_layout TitleBarLayout = ui_CreateLayout(*Interface, TitleBarBounds);
|
||||
ui_StartRow(&TitleBarLayout, 3);
|
||||
{
|
||||
if (ui_LayoutButton(Interface, MakeStringLiteral("Pause"), &TitleBarLayout))
|
||||
if (ui_LayoutButton(Interface, &TitleBarLayout, MakeStringLiteral("Pause")))
|
||||
{
|
||||
State->AnimationSystem.TimelineShouldAdvance = true;
|
||||
}
|
||||
if (ui_LayoutButton(Interface, MakeStringLiteral("Play"), &TitleBarLayout))
|
||||
if (ui_LayoutButton(Interface, &TitleBarLayout, MakeStringLiteral("Play")))
|
||||
{
|
||||
State->AnimationSystem.TimelineShouldAdvance = false;
|
||||
}
|
||||
if (ui_LayoutButton(Interface, MakeStringLiteral("Stop"), &TitleBarLayout))
|
||||
if (ui_LayoutButton(Interface, &TitleBarLayout, MakeStringLiteral("Stop")))
|
||||
{
|
||||
State->AnimationSystem.TimelineShouldAdvance = false;
|
||||
State->AnimationSystem.CurrentFrame = 0;
|
||||
|
|
|
@ -29,71 +29,56 @@ GSMetaTag(panel_type_hierarchy);
|
|||
internal void
|
||||
HierarchyView_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context, mouse_state Mouse)
|
||||
{
|
||||
r32 PanelWidth = PanelBounds.Max.x - PanelBounds.Min.x;
|
||||
r32 PanelHeight = PanelBounds.Max.y - PanelBounds.Min.y;
|
||||
ui_layout Layout = ui_CreateLayout(State->Interface_, PanelBounds);
|
||||
v4 ListItemHover = State->Interface_.Style.ListBGHover;
|
||||
v4 ListItemSelected = State->Interface_.Style.ListBGSelected;
|
||||
|
||||
v4 LineBGColors[] = {
|
||||
{ .16f, .16f, .16f, 1.f },
|
||||
{ .18f, .18f, .18f, 1.f },
|
||||
};
|
||||
|
||||
// TODO(Peter): use the new ui system
|
||||
interface_list List = {};
|
||||
List.LineBGColors = LineBGColors;
|
||||
List.LineBGColorsCount = sizeof(LineBGColors) / sizeof(LineBGColors[0]);
|
||||
List.LineBGHoverColor = v4{ .22f, .22f, .22f, 1.f };
|
||||
List.ListBounds = PanelBounds;
|
||||
List.ListElementDimensions = v2{
|
||||
Width(PanelBounds),
|
||||
(r32)(State->Interface.Font->PixelHeight + 8),
|
||||
};
|
||||
|
||||
v2 TextOffset = v2{10, 4};
|
||||
string TempString = MakeString(PushArray(&State->Transient, char, 256), 0, 256);
|
||||
|
||||
u32 LineCount = (u32)(PanelHeight / List.ListElementDimensions.y) + 1;
|
||||
for (u32 i = 0; i < LineCount; i++)
|
||||
u32 LineCount = (u32)(Height(PanelBounds) / Layout.RowHeight) + 1;
|
||||
u32 LinesDrawn = 0;
|
||||
u32 AssembliesToDraw = GSMin(LineCount, State->ActiveAssemblyIndecies.Used);
|
||||
for (; LinesDrawn < AssembliesToDraw; LinesDrawn++)
|
||||
{
|
||||
rect ElementBounds = DrawListElementBackground(&List, Mouse, RenderBuffer);
|
||||
rect Bounds = ui_ReserveElementBounds(&Layout);
|
||||
v4 ListItemBGColor = ui_GetListItemBGColor(State->Interface_.Style, LinesDrawn);
|
||||
ui_FillRect(&State->Interface_, Bounds, ListItemBGColor);
|
||||
gs_list_handle AssemblyHandle = *State->ActiveAssemblyIndecies.GetElementAtIndex(LinesDrawn);
|
||||
assembly Assembly = *State->AssemblyList.GetElementWithHandle(AssemblyHandle);
|
||||
PrintF(&TempString, "%S", Assembly.Name);
|
||||
|
||||
if (i < State->ActiveAssemblyIndecies.Used)
|
||||
ui_layout ItemLayout = ui_CreateLayout(State->Interface_, Bounds);
|
||||
ui_StartRow(&ItemLayout, 2);
|
||||
{
|
||||
gs_list_handle AssemblyHandle = *State->ActiveAssemblyIndecies.GetElementAtIndex(i);
|
||||
assembly Assembly = *State->AssemblyList.GetElementWithHandle(AssemblyHandle);
|
||||
PrintF(&TempString, "%S", Assembly.Name);
|
||||
|
||||
DrawString(RenderBuffer, TempString, State->Interface.Font, ElementBounds.Min + TextOffset, WhiteV4);
|
||||
|
||||
PrintF(&TempString, "X");
|
||||
|
||||
v2 XLowerRight = v2{ElementBounds.Max.x - 25, ElementBounds.Min.y + TextOffset.y};
|
||||
v2 XLowerLeft = DrawString(RenderBuffer, TempString, State->Interface.Font, XLowerRight, WhiteV4, Align_Right);
|
||||
|
||||
if (MouseButtonTransitionedUp(Mouse.LeftButtonState)
|
||||
&& PointIsInRange(Mouse.Pos, XLowerLeft, ElementBounds.Max))
|
||||
ui_LayoutDrawString(&State->Interface_, &ItemLayout, TempString, State->Interface_.Style.TextColor);
|
||||
if (ui_LayoutButton(&State->Interface_, &ItemLayout, MakeStringLiteral("X"), ListItemBGColor, ListItemHover, ListItemSelected))
|
||||
{
|
||||
UnloadAssembly(AssemblyHandle.Index, State, Context);
|
||||
}
|
||||
}
|
||||
else if (i == State->ActiveAssemblyIndecies.Used)
|
||||
ui_EndRow(&ItemLayout);
|
||||
}
|
||||
|
||||
if (LinesDrawn < LineCount)
|
||||
{
|
||||
v4 ListItemBGColor = ui_GetListItemBGColor(State->Interface_.Style, LinesDrawn++);
|
||||
PrintF(&TempString, "+ Add Assembly");
|
||||
if (ui_LayoutButton(&State->Interface_, &Layout, TempString, ListItemBGColor, ListItemHover, ListItemSelected))
|
||||
{
|
||||
PrintF(&TempString, "+ Add Assembly");
|
||||
v2 TextMinX = ElementBounds.Min + TextOffset;
|
||||
DrawString(RenderBuffer, TempString, State->Interface.Font, TextMinX, WhiteV4);
|
||||
|
||||
if (MouseButtonTransitionedUp(Mouse.LeftButtonState)
|
||||
&& PointIsInRange(Mouse.Pos, ElementBounds.Min, ElementBounds.Max))
|
||||
char FilePath[256];
|
||||
b32 Success = Context.PlatformGetFilePath(FilePath, 256, "Foldhaus Files\0*.fold\0\0");
|
||||
if (Success)
|
||||
{
|
||||
char FilePath[256];
|
||||
b32 Success = Context.PlatformGetFilePath(FilePath, 256, "Foldhaus Files\0*.fold\0\0");
|
||||
if (Success)
|
||||
{
|
||||
LoadAssembly(State, Context, FilePath);
|
||||
}
|
||||
LoadAssembly(State, Context, FilePath);
|
||||
}
|
||||
}
|
||||
|
||||
List.ListElementsCount++;
|
||||
for (; LinesDrawn < LineCount; LinesDrawn++)
|
||||
{
|
||||
rect Bounds = ui_ReserveElementBounds(&Layout);
|
||||
ListItemBGColor = ui_GetListItemBGColor(State->Interface_.Style, LinesDrawn);
|
||||
ui_FillRect(&State->Interface_, Bounds, ListItemBGColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue