Did some styling updates to the ui, added a range slider and a toggle
This commit is contained in:
parent
30123e47a2
commit
e5ab90fcb1
|
@ -88,6 +88,36 @@ Editor_Update(app_state* State, context* Context, input_queue InputQueue)
|
||||||
Editor_HandleInput(State, State->WindowBounds, InputQueue, Context->Mouse, *Context);
|
Editor_HandleInput(State, State->WindowBounds, InputQueue, Context->Mouse, *Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
Editor_DrawWidgetString(app_state* State, context* Context, render_command_buffer* RenderBuffer, ui_widget Widget, v4 Color)
|
||||||
|
{
|
||||||
|
render_quad_batch_constructor BatchConstructor = PushRenderTexture2DBatch(RenderBuffer,
|
||||||
|
Widget.String.Length,
|
||||||
|
State->Interface.Style.Font->BitmapMemory,
|
||||||
|
State->Interface.Style.Font->BitmapTextureHandle,
|
||||||
|
State->Interface.Style.Font->BitmapWidth,
|
||||||
|
State->Interface.Style.Font->BitmapHeight,
|
||||||
|
State->Interface.Style.Font->BitmapBytesPerPixel,
|
||||||
|
State->Interface.Style.Font->BitmapStride);
|
||||||
|
|
||||||
|
v2 RegisterPosition = Widget.Bounds.Min + State->Interface.Style.Margin;
|
||||||
|
|
||||||
|
switch (Widget.Alignment)
|
||||||
|
{
|
||||||
|
case Align_Left:
|
||||||
|
{
|
||||||
|
RegisterPosition = DrawStringLeftAligned(&BatchConstructor, StringExpand(Widget.String), RegisterPosition, State->Interface.Style.Font, Color);
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case Align_Right:
|
||||||
|
{
|
||||||
|
RegisterPosition = DrawStringRightAligned(&BatchConstructor, StringExpand(Widget.String), RegisterPosition, State->Interface.Style.Font, Color);
|
||||||
|
}break;
|
||||||
|
|
||||||
|
InvalidDefaultCase;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
Editor_DrawWidget(app_state* State, context* Context, render_command_buffer* RenderBuffer, ui_widget Widget)
|
Editor_DrawWidget(app_state* State, context* Context, render_command_buffer* RenderBuffer, ui_widget Widget)
|
||||||
{
|
{
|
||||||
|
@ -108,33 +138,39 @@ Editor_DrawWidget(app_state* State, context* Context, render_command_buffer* Ren
|
||||||
if (ui_WidgetIsFlagSet(Widget, UIWidgetFlag_DrawString) && Widget.String.Length > 0)
|
if (ui_WidgetIsFlagSet(Widget, UIWidgetFlag_DrawString) && Widget.String.Length > 0)
|
||||||
{
|
{
|
||||||
v4 Color = State->Interface.Style.TextColor;
|
v4 Color = State->Interface.Style.TextColor;
|
||||||
render_quad_batch_constructor BatchConstructor = PushRenderTexture2DBatch(RenderBuffer,
|
Editor_DrawWidgetString(State, Context, RenderBuffer, Widget, Color);
|
||||||
Widget.String.Length,
|
}
|
||||||
State->Interface.Style.Font->BitmapMemory,
|
|
||||||
State->Interface.Style.Font->BitmapTextureHandle,
|
if (ui_WidgetIsFlagSet(Widget, UIWidgetFlag_DrawHorizontalFill))
|
||||||
State->Interface.Style.Font->BitmapWidth,
|
{
|
||||||
State->Interface.Style.Font->BitmapHeight,
|
v4 Color = PinkV4; //State->Interface.Style.ButtonColor_Active;
|
||||||
State->Interface.Style.Font->BitmapBytesPerPixel,
|
if (ui_WidgetIdsEqual(Widget.Id, State->Interface.HotWidget))
|
||||||
State->Interface.Style.Font->BitmapStride);
|
|
||||||
|
|
||||||
v2 RegisterPosition = Widget.Bounds.Min + State->Interface.Style.Margin;
|
|
||||||
|
|
||||||
switch (Widget.Alignment)
|
|
||||||
{
|
{
|
||||||
case Align_Left:
|
Color = GreenV4; //State->Interface.Style.ButtonColor_Selected;
|
||||||
{
|
}
|
||||||
RegisterPosition = DrawStringLeftAligned(&BatchConstructor, StringExpand(Widget.String), RegisterPosition, State->Interface.Style.Font, Color);
|
if (ui_WidgetIdsEqual(Widget.Id, State->Interface.ActiveWidget))
|
||||||
}break;
|
{
|
||||||
|
Color = TealV4; //State->Interface.Style.ButtonColor_Selected;
|
||||||
case Align_Right:
|
}
|
||||||
{
|
|
||||||
RegisterPosition = DrawStringRightAligned(&BatchConstructor, StringExpand(Widget.String), RegisterPosition, State->Interface.Style.Font, Color);
|
rect2 HFillBounds = {};
|
||||||
}break;
|
HFillBounds.Min = Widget.Bounds.Min;
|
||||||
|
HFillBounds.Max = {
|
||||||
InvalidDefaultCase;
|
LerpR32(Widget.HorizontalFillPercent, Widget.Bounds.Min.x, Widget.Bounds.Max.x),
|
||||||
|
Widget.Bounds.Max.y
|
||||||
|
};
|
||||||
|
PushRenderQuad2D(RenderBuffer, HFillBounds.Min, HFillBounds.Max, Color);
|
||||||
|
|
||||||
|
if (ui_WidgetIsFlagSet(Widget, UIWidgetFlag_DrawString) && Widget.String.Length > 0)
|
||||||
|
{
|
||||||
|
// TODO(pjs): Mask this text by the horizontal fill
|
||||||
|
// TODO(pjs): add this color to the style
|
||||||
|
v4 TextColor = BlackV4;
|
||||||
|
Editor_DrawWidgetString(State, Context, RenderBuffer, Widget, TextColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (ui_WidgetIsFlagSet(Widget, UIWidgetFlag_DrawOutline))
|
if (ui_WidgetIsFlagSet(Widget, UIWidgetFlag_DrawOutline))
|
||||||
{
|
{
|
||||||
// TODO(pjs): replace these with values from the style
|
// TODO(pjs): replace these with values from the style
|
||||||
|
@ -154,6 +190,11 @@ Editor_DrawWidget(app_state* State, context* Context, render_command_buffer* Ren
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global r32 TestSlider_Value = 5;
|
||||||
|
global r32 TestSlider_Min = 0;
|
||||||
|
global r32 TestSlider_Max = 10;
|
||||||
|
global bool TestToggle = true;
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
TestRender(app_state* State, context* Context, render_command_buffer* RenderBuffer)
|
TestRender(app_state* State, context* Context, render_command_buffer* RenderBuffer)
|
||||||
{
|
{
|
||||||
|
@ -183,6 +224,11 @@ TestRender(app_state* State, context* Context, render_command_buffer* RenderBuff
|
||||||
ui_EndDropdown(&State->Interface);
|
ui_EndDropdown(&State->Interface);
|
||||||
}
|
}
|
||||||
ui_EndRow(&State->Interface);
|
ui_EndRow(&State->Interface);
|
||||||
|
TestSlider_Value = ui_RangeSlider(&State->Interface, MakeString("Test Slider"), TestSlider_Value, TestSlider_Min, TestSlider_Max);
|
||||||
|
|
||||||
|
TestToggle = ui_Toggle(&State->Interface, MakeString("test toggle"), TestToggle);
|
||||||
|
|
||||||
|
ui_Button(&State->Interface, MakeString("Hello"));
|
||||||
|
|
||||||
ui_PopLayout(&State->Interface);
|
ui_PopLayout(&State->Interface);
|
||||||
|
|
||||||
|
@ -195,7 +241,7 @@ Editor_Render(app_state* State, context* Context, render_command_buffer* RenderB
|
||||||
PushRenderOrthographic(RenderBuffer, State->WindowBounds);
|
PushRenderOrthographic(RenderBuffer, State->WindowBounds);
|
||||||
PushRenderClearScreen(RenderBuffer);
|
PushRenderClearScreen(RenderBuffer);
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
TestRender(State, Context, RenderBuffer);
|
TestRender(State, Context, RenderBuffer);
|
||||||
//ui_widget_id IdTwo = TestRender(State, Context, RenderBuffer);
|
//ui_widget_id IdTwo = TestRender(State, Context, RenderBuffer);
|
||||||
//Assert(ui_WidgetIdsEqual(IdOne, IdTwo));
|
//Assert(ui_WidgetIdsEqual(IdOne, IdTwo));
|
||||||
|
|
|
@ -5,14 +5,6 @@
|
||||||
//
|
//
|
||||||
#ifndef INTERFACE_H
|
#ifndef INTERFACE_H
|
||||||
|
|
||||||
// Widget Capabilities
|
|
||||||
// - string
|
|
||||||
// - background
|
|
||||||
// - outline
|
|
||||||
// - active (mouse is interacting)
|
|
||||||
// - hot (mouse could be about to interact)
|
|
||||||
// - retained state - if a toggle is active, or a drop down is open
|
|
||||||
|
|
||||||
enum gs_string_alignment
|
enum gs_string_alignment
|
||||||
{
|
{
|
||||||
Align_Left,
|
Align_Left,
|
||||||
|
@ -188,15 +180,13 @@ DrawStringWithCursor (render_command_buffer* RenderBuffer, gs_string String, s32
|
||||||
return LowerRight;
|
return LowerRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(pjs): remove the need for htis (go thru and remove code that's in the #else block of #ifdef EXTERNAL_RENDERER s
|
|
||||||
#define EXTERNAL_RENDERER
|
|
||||||
|
|
||||||
enum ui_widget_flag
|
enum ui_widget_flag
|
||||||
{
|
{
|
||||||
UIWidgetFlag_DrawBackground,
|
UIWidgetFlag_DrawBackground,
|
||||||
UIWidgetFlag_DrawString,
|
UIWidgetFlag_DrawString,
|
||||||
UIWidgetFlag_DrawOutline,
|
UIWidgetFlag_DrawOutline,
|
||||||
UIWidgetFlag_Clickable,
|
UIWidgetFlag_Clickable,
|
||||||
|
UIWidgetFlag_DrawHorizontalFill,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ui_widget_id
|
struct ui_widget_id
|
||||||
|
@ -223,6 +213,9 @@ struct ui_widget
|
||||||
|
|
||||||
ui_widget* Next;
|
ui_widget* Next;
|
||||||
|
|
||||||
|
// Slider
|
||||||
|
r32 HorizontalFillPercent;
|
||||||
|
|
||||||
// Layout
|
// Layout
|
||||||
ui_widget* Parent;
|
ui_widget* Parent;
|
||||||
|
|
||||||
|
@ -250,6 +243,8 @@ struct ui_widget
|
||||||
struct ui_eval_result
|
struct ui_eval_result
|
||||||
{
|
{
|
||||||
bool Clicked;
|
bool Clicked;
|
||||||
|
bool Held;
|
||||||
|
v2 DragDelta;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct interface_config
|
struct interface_config
|
||||||
|
@ -276,6 +271,7 @@ struct ui_widget_retained_state
|
||||||
{
|
{
|
||||||
ui_widget_id Id;
|
ui_widget_id Id;
|
||||||
bool Value;
|
bool Value;
|
||||||
|
r32 InitialValueR32;
|
||||||
u32 FramesSinceAccess;
|
u32 FramesSinceAccess;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -414,7 +410,7 @@ static ui_widget*
|
||||||
ui_PushLayout(ui_interface* Interface, rect2 Bounds, ui_layout_direction FillDir, gs_string Name)
|
ui_PushLayout(ui_interface* Interface, rect2 Bounds, ui_layout_direction FillDir, gs_string Name)
|
||||||
{
|
{
|
||||||
ui_widget* Result = ui_CreateWidget(Interface, Name);
|
ui_widget* Result = ui_CreateWidget(Interface, Name);
|
||||||
ui_WidgetSetFlag(Result, UIWidgetFlag_DrawOutline);
|
//ui_WidgetSetFlag(Result, UIWidgetFlag_DrawOutline);
|
||||||
|
|
||||||
Result->Bounds = Bounds;
|
Result->Bounds = Bounds;
|
||||||
Result->Margin = Interface->Style.Margin;
|
Result->Margin = Interface->Style.Margin;
|
||||||
|
@ -425,12 +421,12 @@ ui_PushLayout(ui_interface* Interface, rect2 Bounds, ui_layout_direction FillDir
|
||||||
{
|
{
|
||||||
case LayoutDirection_BottomUp:
|
case LayoutDirection_BottomUp:
|
||||||
{
|
{
|
||||||
Result->RowYAt = Bounds.Min.y;
|
Result->RowYAt = Bounds.Min.y + Result->Margin.y;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case LayoutDirection_TopDown:
|
case LayoutDirection_TopDown:
|
||||||
{
|
{
|
||||||
Result->RowYAt = Bounds.Max.y - Result->RowHeight;
|
Result->RowYAt = Bounds.Max.y - (Result->RowHeight + Result->Margin.y);
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,13 +443,10 @@ ui_PushLayout(ui_interface* Interface, rect2 Bounds, ui_layout_direction FillDir
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal ui_eval_result ui_EvaluateWidget(ui_interface* Interface, ui_widget* Widget, rect2 Bounds);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ui_PopLayout(ui_interface* Interface)
|
ui_PopLayout(ui_interface* Interface)
|
||||||
{
|
{
|
||||||
Assert(Interface->ActiveLayout != 0);
|
Assert(Interface->ActiveLayout != 0);
|
||||||
//ui_EvaluateWidget(Interface, Interface->ActiveLayout, Interface->ActiveLayout->Bounds);
|
|
||||||
Interface->ActiveLayout = Interface->ActiveLayout->Parent;
|
Interface->ActiveLayout = Interface->ActiveLayout->Parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,7 +473,7 @@ ui_EndRow(ui_interface* Interface)
|
||||||
{
|
{
|
||||||
Interface->ActiveLayout->DrawHorizontal = false;
|
Interface->ActiveLayout->DrawHorizontal = false;
|
||||||
Interface->ActiveLayout->ColumnWidths = 0;
|
Interface->ActiveLayout->ColumnWidths = 0;
|
||||||
Interface->ActiveLayout->RowYAt -= Interface->ActiveLayout->RowHeight;
|
Interface->ActiveLayout->RowYAt -= (Interface->ActiveLayout->RowHeight + Interface->ActiveLayout->Margin.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static b32
|
static b32
|
||||||
|
@ -489,19 +482,20 @@ ui_TryReserveElementBounds(ui_widget* Widget, rect2* Bounds)
|
||||||
b32 Result = true;
|
b32 Result = true;
|
||||||
if (!Widget->DrawHorizontal)
|
if (!Widget->DrawHorizontal)
|
||||||
{
|
{
|
||||||
Bounds->Min = { Widget->Bounds.Min.x, Widget->RowYAt };
|
Bounds->Min = { Widget->Bounds.Min.x + Widget->Margin.x, Widget->RowYAt };
|
||||||
Bounds->Max = { Widget->Bounds.Max.x, Bounds->Min.y + Widget->RowHeight };
|
Bounds->Max = { Widget->Bounds.Max.x - Widget->Margin.x, Bounds->Min.y + Widget->RowHeight };
|
||||||
|
|
||||||
|
r32 RowOffset = Widget->RowHeight + Widget->Margin.y;
|
||||||
switch (Widget->FillDirection)
|
switch (Widget->FillDirection)
|
||||||
{
|
{
|
||||||
case LayoutDirection_BottomUp:
|
case LayoutDirection_BottomUp:
|
||||||
{
|
{
|
||||||
Widget->RowYAt += Widget->RowHeight;
|
Widget->RowYAt += RowOffset;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case LayoutDirection_TopDown:
|
case LayoutDirection_TopDown:
|
||||||
{
|
{
|
||||||
Widget->RowYAt -= Widget->RowHeight;
|
Widget->RowYAt -= RowOffset;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
InvalidDefaultCase;
|
InvalidDefaultCase;
|
||||||
|
@ -514,13 +508,19 @@ ui_TryReserveElementBounds(ui_widget* Widget, rect2* Bounds)
|
||||||
Assert(Widget->ColumnsCount < Widget->ColumnsMax);
|
Assert(Widget->ColumnsCount < Widget->ColumnsMax);
|
||||||
if (Widget->ColumnWidths != 0)
|
if (Widget->ColumnWidths != 0)
|
||||||
{
|
{
|
||||||
v2 Min = { Widget->Bounds.Min.x, Widget->RowYAt };
|
v2 Min = {
|
||||||
|
Widget->Bounds.Min.x + Widget->Margin.x,
|
||||||
|
Widget->RowYAt
|
||||||
|
};
|
||||||
for (u32 i = 0; i < Widget->ColumnsCount; i++)
|
for (u32 i = 0; i < Widget->ColumnsCount; i++)
|
||||||
{
|
{
|
||||||
Min.x += Widget->ColumnWidths[i];
|
Min.x += Widget->ColumnWidths[i];
|
||||||
}
|
}
|
||||||
Bounds->Min = Min;
|
Bounds->Min = Min;
|
||||||
Bounds->Max = Bounds->Min + v2{ Widget->ColumnWidths[Widget->ColumnsCount], Widget->RowHeight };
|
Bounds->Max = Bounds->Min + v2{
|
||||||
|
Widget->ColumnWidths[Widget->ColumnsCount] - Widget->Margin.x,
|
||||||
|
Widget->RowHeight
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -530,7 +530,7 @@ ui_TryReserveElementBounds(ui_widget* Widget, rect2* Bounds)
|
||||||
Widget->RowYAt
|
Widget->RowYAt
|
||||||
};
|
};
|
||||||
Bounds->Max = {
|
Bounds->Max = {
|
||||||
Bounds->Min.x + ElementWidth - Widget->Margin.x,
|
Bounds->Min.x + ElementWidth - (Widget->Margin.x * 2),
|
||||||
Bounds->Min.y + Widget->RowHeight
|
Bounds->Min.y + Widget->RowHeight
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -584,18 +584,27 @@ ui_EvaluateWidget(ui_interface* Interface, ui_widget* Widget, rect2 Bounds)
|
||||||
{
|
{
|
||||||
if (ui_WidgetIdsEqual(Interface->HotWidget, Widget->Id) && MouseButtonTransitionedDown(Interface->Mouse.LeftButtonState))
|
if (ui_WidgetIdsEqual(Interface->HotWidget, Widget->Id) && MouseButtonTransitionedDown(Interface->Mouse.LeftButtonState))
|
||||||
{
|
{
|
||||||
|
Assert(!ui_WidgetIdsEqual(Interface->ActiveWidget, Widget->Id));
|
||||||
Result.Clicked = true;
|
Result.Clicked = true;
|
||||||
Interface->ActiveWidget = Widget->Id;
|
Interface->ActiveWidget = Widget->Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ui_WidgetIdsEqual(Interface->ActiveWidget, Widget->Id) &&
|
|
||||||
MouseButtonTransitionedUp(Interface->Mouse.LeftButtonState))
|
|
||||||
{
|
|
||||||
Interface->ActiveWidget = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
Interface->HotWidget = Widget->Id;
|
Interface->HotWidget = Widget->Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (MouseButtonHeldDown(Interface->Mouse.LeftButtonState) &&
|
||||||
|
PointIsInRect(Widget->Bounds, Interface->Mouse.DownPos))
|
||||||
|
{
|
||||||
|
Result.Held = true;
|
||||||
|
Result.DragDelta = Interface->Mouse.Pos - Interface->Mouse.DownPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ui_WidgetIdsEqual(Interface->ActiveWidget, Widget->Id) &&
|
||||||
|
MouseButtonTransitionedUp(Interface->Mouse.LeftButtonState))
|
||||||
|
{
|
||||||
|
Interface->ActiveWidget = {};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
|
@ -655,24 +664,29 @@ ui_DrawString(ui_interface* Interface, gs_string String, gs_string_alignment Ali
|
||||||
ui_EvaluateWidget(Interface, Widget);
|
ui_EvaluateWidget(Interface, Widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
static b32
|
internal ui_widget*
|
||||||
ui_Button(ui_interface* Interface, gs_string Text)
|
ui_CreateButtonWidget(ui_interface* Interface, gs_string Text)
|
||||||
{
|
{
|
||||||
ui_widget* Widget = ui_CreateWidget(Interface, Text);
|
ui_widget* Widget = ui_CreateWidget(Interface, Text);
|
||||||
ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable);
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable);
|
||||||
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground);
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground);
|
||||||
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString);
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString);
|
||||||
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawOutline);
|
||||||
|
return Widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal b32
|
||||||
|
ui_Button(ui_interface* Interface, gs_string Text)
|
||||||
|
{
|
||||||
|
ui_widget* Widget = ui_CreateButtonWidget(Interface, Text);
|
||||||
ui_eval_result Result = ui_EvaluateWidget(Interface, Widget);
|
ui_eval_result Result = ui_EvaluateWidget(Interface, Widget);
|
||||||
return Result.Clicked;
|
return Result.Clicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
static b32
|
internal b32
|
||||||
ui_Button(ui_interface* Interface, gs_string Text, rect2 Bounds)
|
ui_Button(ui_interface* Interface, gs_string Text, rect2 Bounds)
|
||||||
{
|
{
|
||||||
ui_widget* Widget = ui_CreateWidget(Interface, Text);
|
ui_widget* Widget = ui_CreateButtonWidget(Interface, Text);
|
||||||
ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable);
|
|
||||||
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground);
|
|
||||||
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString);
|
|
||||||
ui_eval_result Result = ui_EvaluateWidget(Interface, Widget, Bounds);
|
ui_eval_result Result = ui_EvaluateWidget(Interface, Widget, Bounds);
|
||||||
return Result.Clicked;
|
return Result.Clicked;
|
||||||
}
|
}
|
||||||
|
@ -762,6 +776,7 @@ ui_EvaluateDropdown(ui_interface* Interface, ui_widget* Widget, ui_eval_result E
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_widget* Layout = ui_PushLayout(Interface, MenuBounds, Direction, MakeString("WidgetLayout"));
|
ui_widget* Layout = ui_PushLayout(Interface, MenuBounds, Direction, MakeString("WidgetLayout"));
|
||||||
|
Layout->Margin.y = 0;
|
||||||
Layout->WidgetReference = Widget->Id;
|
Layout->WidgetReference = Widget->Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -775,6 +790,7 @@ ui_BeginDropdown(ui_interface* Interface, gs_string Text, rect2 Bounds)
|
||||||
ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable);
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable);
|
||||||
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground);
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground);
|
||||||
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString);
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString);
|
||||||
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawOutline);
|
||||||
ui_eval_result Result = ui_EvaluateWidget(Interface, Widget, Bounds);
|
ui_eval_result Result = ui_EvaluateWidget(Interface, Widget, Bounds);
|
||||||
return ui_EvaluateDropdown(Interface, Widget, Result);
|
return ui_EvaluateDropdown(Interface, Widget, Result);
|
||||||
}
|
}
|
||||||
|
@ -786,6 +802,7 @@ ui_BeginDropdown(ui_interface* Interface, gs_string Text)
|
||||||
ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable);
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable);
|
||||||
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground);
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground);
|
||||||
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString);
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString);
|
||||||
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawOutline);
|
||||||
ui_eval_result Result = ui_EvaluateWidget(Interface, Widget);
|
ui_eval_result Result = ui_EvaluateWidget(Interface, Widget);
|
||||||
return ui_EvaluateDropdown(Interface, Widget, Result);
|
return ui_EvaluateDropdown(Interface, Widget, Result);
|
||||||
}
|
}
|
||||||
|
@ -804,6 +821,79 @@ ui_EndDropdown(ui_interface* Interface)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal r32
|
||||||
|
ui_EvaluateRangeSlider(ui_interface* Interface, ui_widget* Widget, ui_eval_result EvalResult, r32 Value, r32 MinValue, r32 MaxValue)
|
||||||
|
{
|
||||||
|
r32 NewValue = Value;
|
||||||
|
|
||||||
|
ui_widget_retained_state* State = ui_GetRetainedState(Interface, Widget->Id);
|
||||||
|
if (!State)
|
||||||
|
{
|
||||||
|
State = ui_CreateRetainedState(Interface, Widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EvalResult.Clicked)
|
||||||
|
{
|
||||||
|
State->InitialValueR32 = Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EvalResult.Held)
|
||||||
|
{
|
||||||
|
r32 Percent = (Interface->Mouse.Pos.x - Widget->Bounds.Min.x) / Rect2Width(Widget->Bounds);
|
||||||
|
NewValue = LerpR32(Percent, MinValue, MaxValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
NewValue = Clamp(MinValue, NewValue, MaxValue);
|
||||||
|
Widget->HorizontalFillPercent = RemapR32(NewValue, MinValue, MaxValue, 0, 1);
|
||||||
|
return NewValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal ui_widget*
|
||||||
|
ui_CreateRangeSliderWidget(ui_interface* Interface, gs_string Text, r32 Value)
|
||||||
|
{
|
||||||
|
ui_widget* Widget = ui_CreateWidget(Interface, Text);
|
||||||
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable);
|
||||||
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground);
|
||||||
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString);
|
||||||
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawHorizontalFill);
|
||||||
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawOutline);
|
||||||
|
Widget->String = PushStringF(Interface->PerFrameMemory, 128, "%f", Value);
|
||||||
|
return Widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal r32
|
||||||
|
ui_RangeSlider(ui_interface* Interface, gs_string Text, r32 Value, r32 ValueMin, r32 ValueMax)
|
||||||
|
{
|
||||||
|
ui_widget* Widget = ui_CreateRangeSliderWidget(Interface, Text, Value);
|
||||||
|
ui_eval_result Result = ui_EvaluateWidget(Interface, Widget);
|
||||||
|
return ui_EvaluateRangeSlider(Interface, Widget, Result, Value, ValueMin, ValueMax);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
internal r32
|
||||||
|
ui_RangeSlider(ui_interface* Interface, gs_string Text, rect2 Bounds, r32 Value, r32 ValueMin, r32 ValueMax)
|
||||||
|
{
|
||||||
|
ui_widget* Widget = ui_CreateRangeSliderWidget(Interface, Text, Value);
|
||||||
|
ui_eval_result Result = ui_EvaluateWidget(Interface, Widget, Bounds);
|
||||||
|
return ui_EvaluateRangeSlider(Interface, Widget, Result, Value, ValueMin, ValueMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal bool
|
||||||
|
ui_Toggle(ui_interface* Interface, gs_string Text, bool Value)
|
||||||
|
{
|
||||||
|
ui_widget* Widget = ui_CreateWidget(Interface, Text);
|
||||||
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable);
|
||||||
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground);
|
||||||
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawHorizontalFill);
|
||||||
|
ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawOutline);
|
||||||
|
ui_eval_result Eval = ui_EvaluateWidget(Interface, Widget);
|
||||||
|
|
||||||
|
bool Result = Eval.Clicked ? !Value : Value;
|
||||||
|
Widget->HorizontalFillPercent = Result ? 1.0f : 0.0f;
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// OLD
|
// OLD
|
||||||
//
|
//
|
||||||
|
|
|
@ -187,7 +187,7 @@ HandleWindowMessage (MSG Message, window* Window, input_queue* InputQueue, mouse
|
||||||
AddInputEventEntry(InputQueue, KeyCode_MouseLeftButton, false, true,
|
AddInputEventEntry(InputQueue, KeyCode_MouseLeftButton, false, true,
|
||||||
ShiftDown, AltDown, CtrlDown, false);
|
ShiftDown, AltDown, CtrlDown, false);
|
||||||
|
|
||||||
Mouse->LeftButtonState = KeyState_IsDown & ~KeyState_WasDown;
|
Mouse->LeftButtonState |= KeyState_IsDown;
|
||||||
Mouse->DownPos = Mouse->Pos;
|
Mouse->DownPos = Mouse->Pos;
|
||||||
|
|
||||||
// :Win32MouseEventCapture
|
// :Win32MouseEventCapture
|
||||||
|
@ -237,7 +237,7 @@ HandleWindowMessage (MSG Message, window* Window, input_queue* InputQueue, mouse
|
||||||
|
|
||||||
AddInputEventEntry(InputQueue, KeyCode_MouseLeftButton, true, false,
|
AddInputEventEntry(InputQueue, KeyCode_MouseLeftButton, true, false,
|
||||||
ShiftDown, AltDown, CtrlDown, false);
|
ShiftDown, AltDown, CtrlDown, false);
|
||||||
Mouse->LeftButtonState = ~KeyState_IsDown & KeyState_WasDown;
|
Mouse->LeftButtonState &= ~KeyState_IsDown;
|
||||||
|
|
||||||
// :Win32MouseEventCapture
|
// :Win32MouseEventCapture
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
|
@ -593,7 +593,7 @@ WinMain (
|
||||||
|
|
||||||
AddressedDataBufferList_Clear(&OutputData);
|
AddressedDataBufferList_Clear(&OutputData);
|
||||||
|
|
||||||
{ // Mouse Position
|
{ // Mouse
|
||||||
POINT MousePos;
|
POINT MousePos;
|
||||||
GetCursorPos (&MousePos);
|
GetCursorPos (&MousePos);
|
||||||
ScreenToClient(MainWindow.Handle, &MousePos);
|
ScreenToClient(MainWindow.Handle, &MousePos);
|
||||||
|
@ -602,6 +602,15 @@ WinMain (
|
||||||
Context.Mouse.OldPos = Context.Mouse.Pos;
|
Context.Mouse.OldPos = Context.Mouse.Pos;
|
||||||
Context.Mouse.Pos = v2{(r32)MousePos.x, (r32)MainWindow.Height - MousePos.y};
|
Context.Mouse.Pos = v2{(r32)MousePos.x, (r32)MainWindow.Height - MousePos.y};
|
||||||
Context.Mouse.DeltaPos = Context.Mouse.Pos - Context.Mouse.OldPos;
|
Context.Mouse.DeltaPos = Context.Mouse.Pos - Context.Mouse.OldPos;
|
||||||
|
|
||||||
|
if (KeyIsDown(Context.Mouse.LeftButtonState))
|
||||||
|
{
|
||||||
|
SetKeyWasDown(Context.Mouse.LeftButtonState);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetKeyWasUp(Context.Mouse.LeftButtonState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MSG Message;
|
MSG Message;
|
||||||
|
@ -687,7 +696,7 @@ WinMain (
|
||||||
LastFrameEnd = GetWallClock();
|
LastFrameEnd = GetWallClock();
|
||||||
|
|
||||||
|
|
||||||
OutputDebugStringA("-- Frame END -- \n");
|
//OutputDebugStringA("-- Frame END -- \n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,32 +15,32 @@ enum key_code
|
||||||
KeyCode_CapsLock,
|
KeyCode_CapsLock,
|
||||||
KeyCode_LeftShift, KeyCode_RightShift,
|
KeyCode_LeftShift, KeyCode_RightShift,
|
||||||
KeyCode_LeftCtrl, KeyCode_RightCtrl,
|
KeyCode_LeftCtrl, KeyCode_RightCtrl,
|
||||||
KeyCode_Fn,
|
KeyCode_Fn,
|
||||||
KeyCode_Alt,
|
KeyCode_Alt,
|
||||||
KeyCode_PageUp, KeyCode_PageDown,
|
KeyCode_PageUp, KeyCode_PageDown,
|
||||||
KeyCode_Backspace, KeyCode_Delete,
|
KeyCode_Backspace, KeyCode_Delete,
|
||||||
KeyCode_Enter,
|
KeyCode_Enter,
|
||||||
|
|
||||||
// Function Keys
|
// Function Keys
|
||||||
KeyCode_F0, KeyCode_F1, KeyCode_F2, KeyCode_F3, KeyCode_F4, KeyCode_F5, KeyCode_F6, KeyCode_F7,
|
KeyCode_F0, KeyCode_F1, KeyCode_F2, KeyCode_F3, KeyCode_F4, KeyCode_F5, KeyCode_F6, KeyCode_F7,
|
||||||
KeyCode_F8, KeyCode_F9, KeyCode_F10, KeyCode_F11, KeyCode_F12,
|
KeyCode_F8, KeyCode_F9, KeyCode_F10, KeyCode_F11, KeyCode_F12,
|
||||||
|
|
||||||
// Letters
|
// Letters
|
||||||
KeyCode_a, KeyCode_b, KeyCode_c, KeyCode_d, KeyCode_e, KeyCode_f, KeyCode_g, KeyCode_h,
|
KeyCode_a, KeyCode_b, KeyCode_c, KeyCode_d, KeyCode_e, KeyCode_f, KeyCode_g, KeyCode_h,
|
||||||
KeyCode_i, KeyCode_j, KeyCode_k, KeyCode_l, KeyCode_m, KeyCode_n, KeyCode_o, KeyCode_p,
|
KeyCode_i, KeyCode_j, KeyCode_k, KeyCode_l, KeyCode_m, KeyCode_n, KeyCode_o, KeyCode_p,
|
||||||
KeyCode_q, KeyCode_r, KeyCode_s, KeyCode_t, KeyCode_u, KeyCode_v, KeyCode_w, KeyCode_x,
|
KeyCode_q, KeyCode_r, KeyCode_s, KeyCode_t, KeyCode_u, KeyCode_v, KeyCode_w, KeyCode_x,
|
||||||
KeyCode_y, KeyCode_z,
|
KeyCode_y, KeyCode_z,
|
||||||
|
|
||||||
KeyCode_A, KeyCode_B, KeyCode_C, KeyCode_D, KeyCode_E, KeyCode_F, KeyCode_G, KeyCode_H,
|
KeyCode_A, KeyCode_B, KeyCode_C, KeyCode_D, KeyCode_E, KeyCode_F, KeyCode_G, KeyCode_H,
|
||||||
KeyCode_I, KeyCode_J, KeyCode_K, KeyCode_L, KeyCode_M, KeyCode_N, KeyCode_O, KeyCode_P,
|
KeyCode_I, KeyCode_J, KeyCode_K, KeyCode_L, KeyCode_M, KeyCode_N, KeyCode_O, KeyCode_P,
|
||||||
KeyCode_Q, KeyCode_R, KeyCode_S, KeyCode_T, KeyCode_U, KeyCode_V, KeyCode_W, KeyCode_X,
|
KeyCode_Q, KeyCode_R, KeyCode_S, KeyCode_T, KeyCode_U, KeyCode_V, KeyCode_W, KeyCode_X,
|
||||||
KeyCode_Y, KeyCode_Z,
|
KeyCode_Y, KeyCode_Z,
|
||||||
|
|
||||||
// Numbers
|
// Numbers
|
||||||
KeyCode_0, KeyCode_1, KeyCode_2, KeyCode_3, KeyCode_4, KeyCode_5, KeyCode_6, KeyCode_7,
|
KeyCode_0, KeyCode_1, KeyCode_2, KeyCode_3, KeyCode_4, KeyCode_5, KeyCode_6, KeyCode_7,
|
||||||
KeyCode_8, KeyCode_9,
|
KeyCode_8, KeyCode_9,
|
||||||
|
|
||||||
KeyCode_Num0, KeyCode_Num1, KeyCode_Num2, KeyCode_Num3, KeyCode_Num4, KeyCode_Num5,
|
KeyCode_Num0, KeyCode_Num1, KeyCode_Num2, KeyCode_Num3, KeyCode_Num4, KeyCode_Num5,
|
||||||
KeyCode_Num6, KeyCode_Num7, KeyCode_Num8, KeyCode_Num9,
|
KeyCode_Num6, KeyCode_Num7, KeyCode_Num8, KeyCode_Num9,
|
||||||
|
|
||||||
// Symbols
|
// Symbols
|
||||||
|
@ -48,7 +48,7 @@ enum key_code
|
||||||
KeyCode_Ampersand, KeyCode_Star, KeyCode_LeftParen, KeyCode_RightParen, KeyCode_Minus, KeyCode_Plus,
|
KeyCode_Ampersand, KeyCode_Star, KeyCode_LeftParen, KeyCode_RightParen, KeyCode_Minus, KeyCode_Plus,
|
||||||
KeyCode_Equals, KeyCode_Underscore, KeyCode_LeftBrace, KeyCode_RightBrace, KeyCode_LeftBracket,
|
KeyCode_Equals, KeyCode_Underscore, KeyCode_LeftBrace, KeyCode_RightBrace, KeyCode_LeftBracket,
|
||||||
KeyCode_RightBracket, KeyCode_Colon, KeyCode_SemiColon, KeyCode_SingleQuote, KeyCode_DoubleQuote,
|
KeyCode_RightBracket, KeyCode_Colon, KeyCode_SemiColon, KeyCode_SingleQuote, KeyCode_DoubleQuote,
|
||||||
KeyCode_ForwardSlash, KeyCode_Backslash, KeyCode_Pipe, KeyCode_Comma, KeyCode_Period,
|
KeyCode_ForwardSlash, KeyCode_Backslash, KeyCode_Pipe, KeyCode_Comma, KeyCode_Period,
|
||||||
KeyCode_QuestionMark, KeyCode_LessThan, KeyCode_GreaterThan, KeyCode_Tilde, KeyCode_BackQuote,
|
KeyCode_QuestionMark, KeyCode_LessThan, KeyCode_GreaterThan, KeyCode_Tilde, KeyCode_BackQuote,
|
||||||
|
|
||||||
// Arrows
|
// Arrows
|
||||||
|
@ -77,9 +77,9 @@ CharacterFromKeyCode (key_code Code)
|
||||||
case KeyCode_Tab: { Result = '\t'; }break;
|
case KeyCode_Tab: { Result = '\t'; }break;
|
||||||
|
|
||||||
// Letters
|
// Letters
|
||||||
case KeyCode_a: { Result = 'a'; }break;
|
case KeyCode_a: { Result = 'a'; }break;
|
||||||
case KeyCode_b: { Result = 'b'; }break;
|
case KeyCode_b: { Result = 'b'; }break;
|
||||||
case KeyCode_c: { Result = 'c'; }break;
|
case KeyCode_c: { Result = 'c'; }break;
|
||||||
case KeyCode_d: { Result = 'd'; }break;
|
case KeyCode_d: { Result = 'd'; }break;
|
||||||
case KeyCode_e: { Result = 'e'; }break;
|
case KeyCode_e: { Result = 'e'; }break;
|
||||||
case KeyCode_f: { Result = 'f'; }break;
|
case KeyCode_f: { Result = 'f'; }break;
|
||||||
|
@ -92,7 +92,7 @@ CharacterFromKeyCode (key_code Code)
|
||||||
case KeyCode_m: { Result = 'm'; }break;
|
case KeyCode_m: { Result = 'm'; }break;
|
||||||
case KeyCode_n: { Result = 'n'; }break;
|
case KeyCode_n: { Result = 'n'; }break;
|
||||||
case KeyCode_o: { Result = 'o'; }break;
|
case KeyCode_o: { Result = 'o'; }break;
|
||||||
case KeyCode_p: { Result = 'p'; }break;
|
case KeyCode_p: { Result = 'p'; }break;
|
||||||
case KeyCode_q: { Result = 'q'; }break;
|
case KeyCode_q: { Result = 'q'; }break;
|
||||||
case KeyCode_r: { Result = 'r'; }break;
|
case KeyCode_r: { Result = 'r'; }break;
|
||||||
case KeyCode_s: { Result = 's'; }break;
|
case KeyCode_s: { Result = 's'; }break;
|
||||||
|
@ -100,7 +100,7 @@ CharacterFromKeyCode (key_code Code)
|
||||||
case KeyCode_u: { Result = 'u'; }break;
|
case KeyCode_u: { Result = 'u'; }break;
|
||||||
case KeyCode_v: { Result = 'v'; }break;
|
case KeyCode_v: { Result = 'v'; }break;
|
||||||
case KeyCode_w: { Result = 'w'; }break;
|
case KeyCode_w: { Result = 'w'; }break;
|
||||||
case KeyCode_x: { Result = 'x'; }break;
|
case KeyCode_x: { Result = 'x'; }break;
|
||||||
case KeyCode_y: { Result = 'y'; }break;
|
case KeyCode_y: { Result = 'y'; }break;
|
||||||
case KeyCode_z: { Result = 'z'; }break;
|
case KeyCode_z: { Result = 'z'; }break;
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ CharacterFromKeyCode (key_code Code)
|
||||||
case KeyCode_M: { Result = 'M'; }break;
|
case KeyCode_M: { Result = 'M'; }break;
|
||||||
case KeyCode_N: { Result = 'N'; }break;
|
case KeyCode_N: { Result = 'N'; }break;
|
||||||
case KeyCode_O: { Result = 'O'; }break;
|
case KeyCode_O: { Result = 'O'; }break;
|
||||||
case KeyCode_P: { Result = 'P'; }break;
|
case KeyCode_P: { Result = 'P'; }break;
|
||||||
case KeyCode_Q: { Result = 'Q'; }break;
|
case KeyCode_Q: { Result = 'Q'; }break;
|
||||||
case KeyCode_R: { Result = 'R'; }break;
|
case KeyCode_R: { Result = 'R'; }break;
|
||||||
case KeyCode_S: { Result = 'S'; }break;
|
case KeyCode_S: { Result = 'S'; }break;
|
||||||
|
@ -127,7 +127,7 @@ CharacterFromKeyCode (key_code Code)
|
||||||
case KeyCode_U: { Result = 'U'; }break;
|
case KeyCode_U: { Result = 'U'; }break;
|
||||||
case KeyCode_V: { Result = 'V'; }break;
|
case KeyCode_V: { Result = 'V'; }break;
|
||||||
case KeyCode_W: { Result = 'W'; }break;
|
case KeyCode_W: { Result = 'W'; }break;
|
||||||
case KeyCode_X: { Result = 'X'; }break;
|
case KeyCode_X: { Result = 'X'; }break;
|
||||||
case KeyCode_Y: { Result = 'Y'; }break;
|
case KeyCode_Y: { Result = 'Y'; }break;
|
||||||
case KeyCode_Z: { Result = 'Z'; }break;
|
case KeyCode_Z: { Result = 'Z'; }break;
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ CharacterFromKeyCode (key_code Code)
|
||||||
case KeyCode_Num2: { Result = '2'; }break;
|
case KeyCode_Num2: { Result = '2'; }break;
|
||||||
case KeyCode_Num3: { Result = '3'; }break;
|
case KeyCode_Num3: { Result = '3'; }break;
|
||||||
case KeyCode_Num4: { Result = '4'; }break;
|
case KeyCode_Num4: { Result = '4'; }break;
|
||||||
case KeyCode_Num5: { Result = '5'; }break;
|
case KeyCode_Num5: { Result = '5'; }break;
|
||||||
case KeyCode_Num6: { Result = '6'; }break;
|
case KeyCode_Num6: { Result = '6'; }break;
|
||||||
case KeyCode_Num7: { Result = '7'; }break;
|
case KeyCode_Num7: { Result = '7'; }break;
|
||||||
case KeyCode_Num8: { Result = '8'; }break;
|
case KeyCode_Num8: { Result = '8'; }break;
|
||||||
|
@ -181,7 +181,7 @@ CharacterFromKeyCode (key_code Code)
|
||||||
case KeyCode_Backslash: { Result = '\\'; }break;
|
case KeyCode_Backslash: { Result = '\\'; }break;
|
||||||
case KeyCode_Pipe: { Result = '|'; }break;
|
case KeyCode_Pipe: { Result = '|'; }break;
|
||||||
case KeyCode_Comma: { Result = ','; }break;
|
case KeyCode_Comma: { Result = ','; }break;
|
||||||
case KeyCode_Period: { Result = '.'; }break;
|
case KeyCode_Period: { Result = '.'; }break;
|
||||||
case KeyCode_QuestionMark: { Result = '?'; }break;
|
case KeyCode_QuestionMark: { Result = '?'; }break;
|
||||||
case KeyCode_LessThan: { Result = '<'; }break;
|
case KeyCode_LessThan: { Result = '<'; }break;
|
||||||
case KeyCode_GreaterThan: { Result = '>'; }break;
|
case KeyCode_GreaterThan: { Result = '>'; }break;
|
||||||
|
@ -227,6 +227,11 @@ enum key_state_flags
|
||||||
#define KeyWasDown(event) ((event & KeyState_WasDown) > 0)
|
#define KeyWasDown(event) ((event & KeyState_WasDown) > 0)
|
||||||
#define KeyIsDown(event) ((event & KeyState_IsDown) > 0)
|
#define KeyIsDown(event) ((event & KeyState_IsDown) > 0)
|
||||||
|
|
||||||
|
#define SetKeyDown(key) (key |= KeyState_IsDown)
|
||||||
|
#define SetKeyWasDown(key) (key |= KeyState_WasDown)
|
||||||
|
#define SetKeyUp(key) (key &= ~KeyState_IsDown)
|
||||||
|
#define SetKeyWasUp(key) (key &= ~KeyState_WasDown)
|
||||||
|
|
||||||
struct input_entry
|
struct input_entry
|
||||||
{
|
{
|
||||||
key_code Key;
|
key_code Key;
|
||||||
|
@ -266,6 +271,8 @@ struct mouse_state
|
||||||
b32 MiddleButtonState;
|
b32 MiddleButtonState;
|
||||||
b32 RightButtonState;
|
b32 RightButtonState;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cursor_type CursorType;
|
cursor_type CursorType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -327,7 +334,7 @@ KeyTransitionedUp (input Input, key_code Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
AddInputEventEntry (input_queue* Queue, key_code Key,
|
AddInputEventEntry (input_queue* Queue, key_code Key,
|
||||||
b32 WasDown, b32 IsDown, b32 ShiftDown, b32 AltDown, b32 CtrlDown, b32 SysDown)
|
b32 WasDown, b32 IsDown, b32 ShiftDown, b32 AltDown, b32 CtrlDown, b32 SysDown)
|
||||||
{
|
{
|
||||||
Assert(Queue->QueueUsed < Queue->QueueSize);
|
Assert(Queue->QueueUsed < Queue->QueueSize);
|
||||||
|
@ -392,10 +399,10 @@ GetMouseButtonStateAdvanced (b32 ButtonState)
|
||||||
!((ButtonState & KeyState_IsDown) > 0))
|
!((ButtonState & KeyState_IsDown) > 0))
|
||||||
{
|
{
|
||||||
Result= 0;
|
Result= 0;
|
||||||
}
|
}
|
||||||
else if (ButtonState & KeyState_IsDown)
|
else if (ButtonState & KeyState_IsDown)
|
||||||
{
|
{
|
||||||
Result |= KeyState_WasDown;
|
Result |= KeyState_WasDown;
|
||||||
}
|
}
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue