From 4deeb2470e386efd966196d93b4b4bfd2a770eeb Mon Sep 17 00:00:00 2001 From: Peter Slattery Date: Sat, 20 Feb 2021 14:14:39 -0800 Subject: [PATCH] added a brightness slider to the assembly debug panel's all red, green, blue, and white modes. --- .../panels/foldhaus_panel_assembly_debug.h | 69 +++++++++++-------- .../engine/assembly/foldhaus_assembly_debug.h | 12 ++-- src/app/interface.h | 9 +++ 3 files changed, 58 insertions(+), 32 deletions(-) diff --git a/src/app/editor/panels/foldhaus_panel_assembly_debug.h b/src/app/editor/panels/foldhaus_panel_assembly_debug.h index 5bdb699..2f4f1a2 100644 --- a/src/app/editor/panels/foldhaus_panel_assembly_debug.h +++ b/src/app/editor/panels/foldhaus_panel_assembly_debug.h @@ -59,39 +59,52 @@ AssemblyDebug_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* Ren ui_EndLabeledDropdown(Interface); InterfaceAssert(Interface->PerFrameMemory); - if (State->AssemblyDebugState.Override == ADS_Override_TagWhite || - State->AssemblyDebugState.Override == ADS_Override_TagStripWhite) + switch (State->AssemblyDebugState.Override) { - ui_LabeledTextEntry(Interface, MakeString("Tag Name"), &State->AssemblyDebugState.TagName); - ui_LabeledTextEntry(Interface, MakeString("Tag Value"), &State->AssemblyDebugState.TagValue); - - if (State->AssemblyDebugState.Override == ADS_Override_TagStripWhite) + case ADS_Override_TagWhite: + case ADS_Override_TagStripWhite: { + ui_LabeledTextEntry(Interface, MakeString("Tag Name"), &State->AssemblyDebugState.TagName); + ui_LabeledTextEntry(Interface, MakeString("Tag Value"), &State->AssemblyDebugState.TagValue); + + if (State->AssemblyDebugState.Override == ADS_Override_TagStripWhite) + { + State->AssemblyDebugState.TargetAssembly = ui_LabeledTextEntryU64(Interface, MakeString("Assembly"), State->AssemblyDebugState.TargetAssembly); + + State->AssemblyDebugState.TargetStrip = ui_LabeledTextEntryU64(Interface, MakeString("Strip"), State->AssemblyDebugState.TargetStrip); + } + }break; + + case ADS_Override_ChannelWhite: + { + u64 Board = 0; + u64 Strip = 0; + Board = ui_LabeledTextEntryU64(Interface, MakeString("Board"), Board); + Strip = ui_LabeledTextEntryU64(Interface, MakeString("Strip"), Strip); + + State->AssemblyDebugState.TargetChannel = FSC(Board, Strip); + }break; + + case ADS_Override_AllRed: + case ADS_Override_AllGreen: + case ADS_Override_AllBlue: + case ADS_Override_AllWhite: + { + State->AssemblyDebugState.Brightness = (u8)ui_LabeledRangeSlider(Interface, MakeString("Brightness"), (r32)State->AssemblyDebugState.Brightness, 0, 255); + }break; + + default: + { + InterfaceAssert(Interface->PerFrameMemory); + State->AssemblyDebugState.TargetAssembly = ui_LabeledTextEntryU64(Interface, MakeString("Assembly"), State->AssemblyDebugState.TargetAssembly); + InterfaceAssert(Interface->PerFrameMemory); + State->AssemblyDebugState.TargetStrip = ui_LabeledTextEntryU64(Interface, MakeString("Strip"), State->AssemblyDebugState.TargetStrip); - } - } - else if (State->AssemblyDebugState.Override == ADS_Override_ChannelWhite) - { - u64 Board = 0; - u64 Strip = 0; - Board = ui_LabeledTextEntryU64(Interface, MakeString("Board"), Board); - Strip = ui_LabeledTextEntryU64(Interface, MakeString("Strip"), Strip); - - State->AssemblyDebugState.TargetChannel = FSC(Board, Strip); - } - else - { - InterfaceAssert(Interface->PerFrameMemory); - - State->AssemblyDebugState.TargetAssembly = ui_LabeledTextEntryU64(Interface, MakeString("Assembly"), State->AssemblyDebugState.TargetAssembly); - - InterfaceAssert(Interface->PerFrameMemory); - - State->AssemblyDebugState.TargetStrip = ui_LabeledTextEntryU64(Interface, MakeString("Strip"), State->AssemblyDebugState.TargetStrip); - - InterfaceAssert(Interface->PerFrameMemory); + + InterfaceAssert(Interface->PerFrameMemory); + }break; } ui_RangeSlider(Interface, MakeString("Test"), .5f, 0, 1); diff --git a/src/app/engine/assembly/foldhaus_assembly_debug.h b/src/app/engine/assembly/foldhaus_assembly_debug.h index 9a1cc12..07a3685 100644 --- a/src/app/engine/assembly/foldhaus_assembly_debug.h +++ b/src/app/engine/assembly/foldhaus_assembly_debug.h @@ -51,6 +51,8 @@ struct assembly_debug_state pixel TargetColor; u32 TargetChannel; + + u8 Brightness; }; internal assembly_debug_state @@ -107,6 +109,8 @@ AssemblyDebug_OverrideOutput(assembly_debug_state State, assembly_array Assembli assembly Assembly = Assemblies.Values[State.TargetAssembly]; led_buffer LedBuffer = LedSystem.Buffers[Assembly.LedBufferIndex]; + u8 V = State.Brightness; + switch (State.Override) { case ADS_Override_Strip: @@ -133,17 +137,17 @@ AssemblyDebug_OverrideOutput(assembly_debug_state State, assembly_array Assembli case ADS_Override_AllRed: { - AssemblyDebug_OverrideWithColor(Assembly, LedBuffer, pixel{255, 0, 0}); + AssemblyDebug_OverrideWithColor(Assembly, LedBuffer, pixel{V, 0, 0}); }break; case ADS_Override_AllGreen: { - AssemblyDebug_OverrideWithColor(Assembly, LedBuffer, pixel{0, 255, 0}); + AssemblyDebug_OverrideWithColor(Assembly, LedBuffer, pixel{0, V, 0}); }break; case ADS_Override_AllBlue: { - AssemblyDebug_OverrideWithColor(Assembly, LedBuffer, pixel{0, 0, 255}); + AssemblyDebug_OverrideWithColor(Assembly, LedBuffer, pixel{0, 0, V}); }break; case ADS_Override_AllOff: @@ -153,7 +157,7 @@ AssemblyDebug_OverrideOutput(assembly_debug_state State, assembly_array Assembli case ADS_Override_AllWhite: { - AssemblyDebug_OverrideWithColor(Assembly, LedBuffer, pixel{255, 255, 255}); + AssemblyDebug_OverrideWithColor(Assembly, LedBuffer, pixel{V, V, V}); }break; case ADS_Override_TagWhite: diff --git a/src/app/interface.h b/src/app/interface.h index 60c640a..f0942a7 100644 --- a/src/app/interface.h +++ b/src/app/interface.h @@ -1564,6 +1564,15 @@ ui_LabeledToggle(ui_interface* Interface, gs_string Label, bool Value) return Result; } +internal r32 +ui_LabeledRangeSlider(ui_interface* Interface, gs_string Label, r32 Value, r32 ValueMin, r32 ValueMax) +{ + ui_BeginLabelRow(Interface, Label); + r32 Result = ui_RangeSlider(Interface, Label, Value, ValueMin, ValueMax); + ui_EndRow(Interface); + return Result; +} + internal void ui_LabeledTextEntry(ui_interface* Interface, gs_string Label, gs_string* Value) {