diff options
Diffstat (limited to 'my_imgui_widgets.cpp')
-rw-r--r-- | my_imgui_widgets.cpp | 271 |
1 files changed, 219 insertions, 52 deletions
diff --git a/my_imgui_widgets.cpp b/my_imgui_widgets.cpp index c8971c2..16be2e1 100644 --- a/my_imgui_widgets.cpp +++ b/my_imgui_widgets.cpp @@ -47,7 +47,7 @@ ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory * sprintf(buf, "Properties: %s###Properties", String->Char); ImGui::Begin(buf); if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) - UI->FocusedWindow = focus_properties; + State->FocusedWindow = focus_properties; ImGui::Text("Transform"); for (int h = 0; h < AmountOf(Layer->Property); h++) { property_channel *Property = &Layer->Property[h]; @@ -127,7 +127,7 @@ ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory * } else { ImGui::Begin("Properties: empty###Properties"); if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) - UI->FocusedWindow = focus_properties; + State->FocusedWindow = focus_properties; ImGui::End(); } } @@ -385,7 +385,7 @@ ImGui_SD_Prompt(project_data *File, project_state *State, ui *UI, memory *Memory sorted_comp_info *SortedCompInfo = &SortedCompArray[File->PrincipalCompIndex]; sorted_layer *SortedLayerInfo = Layer_GetSortedArray(SortedLayerArray, SortedCompArray,File->PrincipalCompIndex); ImGui::Begin("SD prompt input"); - sd_state *SD = &State->SD; + sd_state *SD = &File->UI.SD; int Size = ImGui::GetFontSize(); ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(200, 80, 0, 255)); if (ImGui::Button("Generate!", ImVec2(Size*8, Size*2))) { @@ -447,9 +447,9 @@ ImGui_SD_Prompt(project_data *File, project_state *State, ui *UI, memory *Memory ImGui::Text("Est. time: %.1f sec, %.2f", State->SDTimeEstimate, State->SDPercentDone*100); } ImGui::InputText("Address", SD->ServerAddress, SD_LEN_ADDRESS); - if (State->Initializing && (SD->ServerAddress[0] == '\0')) { - sprintf(SD->Prompt, "%s", "scan, highres, monochrome, traditional medium, (sketch:1.2), flat shading, earth, globe, effects, clouds, lightning, fire"); - sprintf(SD->NegPrompt, "%s", "nsfw, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark"); + if (SD->ServerAddress[0] == '\0' && SD->Prompt[0] == '\0') { + sprintf(SD->Prompt, "%s", "highres"); + sprintf(SD->NegPrompt, "%s", "nsfw, \ntext, \ncropped, \nworst quality, \nlow quality, \nnormal quality, \njpeg artifacts, \nsignature, \nwatermark"); sprintf(SD->ServerAddress, "%s", "http://127.0.0.1:7860"); } if (ImGui::Selectable("txt2img", !SD->Mode)) @@ -710,10 +710,10 @@ ImGui_TransformUI(project_data *File, project_state *State, memory *Memory, ui * ImGui::PopStyleColor(); if (ImGui::IsItemActivated() && !OtherActions) { - UI->InteractTransformMode = 1; + State->InteractTransformMode = 1; } - if (UI->InteractTransformMode == 1 && ImGui::IsItemActive()) + if (State->InteractTransformMode == 1 && ImGui::IsItemActive()) { uint32 side = i; if (side == 0) { @@ -748,13 +748,13 @@ ImGui_TransformUI(project_data *File, project_state *State, memory *Memory, ui * if (ImGui::IsItemActivated() && !OtherActions) { if (InBounds) - UI->InteractTransformMode = 1; + State->InteractTransformMode = 1; else - UI->InteractTransformMode = 2; + State->InteractTransformMode = 2; } // Scale part - if (UI->InteractTransformMode == 1 && ImGui::IsItemActive()) + if (State->InteractTransformMode == 1 && ImGui::IsItemActive()) { // TODO(fox): Corner dragging scale only works in the X // axis. Mostly feels right when dragged how you expect, @@ -780,7 +780,7 @@ ImGui_TransformUI(project_data *File, project_state *State, memory *Memory, ui * } // Rotation part - if (UI->InteractTransformMode == 2 && ImGui::IsItemActive()) + if (State->InteractTransformMode == 2 && ImGui::IsItemActive()) { real32 LocalX = (io.MousePos.x - UI->CompPos.x)/CompScale.x - InteractMin.x - (BoxLength.x/2); real32 LocalY = (io.MousePos.y - UI->CompPos.y)/CompScale.y - InteractMin.y - (BoxLength.y/2); @@ -834,20 +834,20 @@ ImGui_TransformUI(project_data *File, project_state *State, memory *Memory, ui * ImGui::PopID(); } - if (!UI->InteractTransformMode && ImGui::IsMouseClicked(ImGuiMouseButton_Left) && InBounds && !OtherActions) - UI->InteractTransformMode = 3; + if (!State->InteractTransformMode && ImGui::IsMouseClicked(ImGuiMouseButton_Left) && InBounds && !OtherActions) + State->InteractTransformMode = 3; - if (UI->InteractTransformMode == 3) { + if (State->InteractTransformMode == 3) { Interact->Position.x += (real32)io.MouseDelta.x/CompScale.x; Interact->Position.y += (real32)io.MouseDelta.y/CompScale.y; } - if (UI->InteractTransformMode) + if (State->InteractTransformMode) { if (io.MouseDelta.x || io.MouseDelta.y) State->UpdateFrame = true; if (!ImGui::IsMouseDown(ImGuiMouseButton_Left)) - UI->InteractTransformMode = 0; + State->InteractTransformMode = 0; } if (ImGui::IsKeyPressed(ImGuiKey_Escape)) { @@ -1005,7 +1005,7 @@ ImGui_Viewport(project_data *File, project_state *State, ui *UI, memory *Memory, ImGui::Begin("Viewport", &open, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse); if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) - UI->FocusedWindow = focus_viewport; + State->FocusedWindow = focus_viewport; block_composition *MainComp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, File->PrincipalCompIndex); @@ -1062,7 +1062,7 @@ ImGui_Viewport(project_data *File, project_state *State, ui *UI, memory *Memory, if (IsHovered && IsActivated && !ImGui::IsMouseDown(ImGuiMouseButton_Right)) { // Point to zoom in on if Z is held - UI->TempZoomRatio = ImGui_ScreenPointToCompUV(ViewportMin, UI->CompPos, UI->CompZoom, io.MousePos); + State->TempZoomRatio = ImGui_ScreenPointToCompUV(ViewportMin, UI->CompPos, UI->CompZoom, io.MousePos); if (State->Tool == tool_brush && State->Interact_Active != interact_type_brush) { sorted_layer *SortedLayerInfo = Layer_GetSortedArray(SortedLayerArray, SortedCompArray, File->PrincipalCompIndex); @@ -1197,8 +1197,8 @@ ImGui_Viewport(project_data *File, project_state *State, ui *UI, memory *Memory, Distance *= -1; UI->CompZoom.x += (Distance)*(real32)MainComp->Width/MainComp->Height; UI->CompZoom.y += (Distance); - UI->CompPos.x -= ((Distance)*(real32)MainComp->Width/MainComp->Height)*UI->TempZoomRatio.x; - UI->CompPos.y -= Distance*UI->TempZoomRatio.y; + UI->CompPos.x -= ((Distance)*(real32)MainComp->Width/MainComp->Height)*State->TempZoomRatio.x; + UI->CompPos.y -= Distance*State->TempZoomRatio.y; } ImGui::SetCursorScreenPos(ImVec2(ViewportMin.x, ViewportMin.y + ViewportScale.y - ImGui::GetFontSize()*1.5)); @@ -1364,7 +1364,7 @@ ImGui_Timeline_DrawKeySheet(project_data *File, project_state *State, memory *Me ImVec2 Keyframe_ScreenPos(Keyframe_ScreenPos_X, TimelineAbsolutePos.y); - if (UI->BoxSelect) { + if (State->BoxSelect) { real32 Y_Top = (io.MouseClickedPos[0].y < io.MousePos.y) ? io.MouseClickedPos[0].y : io.MousePos.y; real32 Y_Bottom = (io.MouseClickedPos[0].y > io.MousePos.y) ? io.MouseClickedPos[0].y : io.MousePos.y; real32 X_Left = (io.MouseClickedPos[0].x < io.MousePos.x) ? io.MouseClickedPos[0].x : io.MousePos.x; @@ -1416,7 +1416,7 @@ ImGui_Timeline_DrawGraph(project_data *File, project_state *State, memory *Memor ImVec2 TimelineSize, ImVec2 TimelineSizeWithBorder, real32 LayerIncrement, sorted_property_info *SortedPropertyInfo, uint16 *SortedPropertyArray) { // I'm using the draw splitter here to be able to draw the dots on top of the graph lines. - UI->Test.Split(draw_list, 2); + State->Test.Split(draw_list, 2); int h = 0, c = 0, i = 0; while (Block_Loop(Memory, F_Layers, File->Layer_Count, &h, &c, &i)) @@ -1433,9 +1433,9 @@ ImGui_Timeline_DrawGraph(project_data *File, project_state *State, memory *Memor State->Interact_Active == interact_type_keyframe_rotate || State->Interact_Active == interact_type_keyframe_scale)) { - ImGui_WarpMouse(UI, io.MousePos, TimelineAbsolutePos, TimelineAbsolutePos + TimelineSizeWithBorder); + ImGui_WarpMouse(State, io.MousePos, TimelineAbsolutePos, TimelineAbsolutePos + TimelineSizeWithBorder); ImVec2 DragDelta = io.MousePos - ImVec2(State->Interact_Offset[2], State->Interact_Offset[3]); - DragDelta = DragDelta + (ImVec2(UI->Warp_X, UI->Warp_Y) * TimelineSize); + DragDelta = DragDelta + (ImVec2(State->Warp_X, State->Warp_Y) * TimelineSize); if (io.MouseDelta.x || io.MouseDelta.y) { State->UpdateFrame = true; } @@ -1504,7 +1504,7 @@ ImGui_Timeline_DrawGraph(project_data *File, project_state *State, memory *Memor Keyframe_ScreenPos[NewIdx + b] = TimelineAbsolutePos + ImVec2(TimelineMoveSize.x, GraphMoveHeight) + ((ImVec2(1, -1) * Keyframe_LocalPos_Ratio[b] + ImVec2(0, 1)) * ImVec2(TimelineZoomSize.x, GraphZoomHeight)); } - if (UI->BoxSelect) { + if (State->BoxSelect) { real32 Y_Top = (io.MouseClickedPos[0].y < io.MousePos.y) ? io.MouseClickedPos[0].y : io.MousePos.y; real32 Y_Bottom = (io.MouseClickedPos[0].y > io.MousePos.y) ? io.MouseClickedPos[0].y : io.MousePos.y; real32 X_Left = (io.MouseClickedPos[0].x < io.MousePos.x) ? io.MouseClickedPos[0].x : io.MousePos.x; @@ -1521,7 +1521,7 @@ ImGui_Timeline_DrawGraph(project_data *File, project_state *State, memory *Memor } } - UI->Test.SetCurrentChannel(draw_list, 1); + State->Test.SetCurrentChannel(draw_list, 1); ImVec2 ButtonSize(16, 16); @@ -1565,7 +1565,7 @@ ImGui_Timeline_DrawGraph(project_data *File, project_state *State, memory *Memor } ImGui::PopID(); - UI->Test.SetCurrentChannel(draw_list, 0); + State->Test.SetCurrentChannel(draw_list, 0); if (p != 0) { if (PointAddress[0]->Type == interpolation_type_bezier && PointAddress[1]->Type == interpolation_type_bezier) { @@ -1582,7 +1582,7 @@ ImGui_Timeline_DrawGraph(project_data *File, project_state *State, memory *Memor ImGui::PopID(); } - UI->Test.Merge(draw_list); + State->Test.Merge(draw_list); } @@ -1651,9 +1651,9 @@ ImGui_Timeline_DrawPrecomp(project_data *File, project_state *State, memory *Mem // Main interaction ImGui::PushID(i); - if (UI->TimelineMode == timeline_mode_default) { + if (State->TimelineMode == timeline_mode_default) { - if (UI->BoxSelect && UI->TimelineMode == timeline_mode_default) { + if (State->BoxSelect && State->TimelineMode == timeline_mode_default) { bool32 Test = 0; if (io.MouseClickedPos[0].y < io.MousePos.y) Test = (Layer_ScreenPos_Min.y >= io.MouseClickedPos[0].y && Layer_ScreenPos_Min.y <= io.MousePos.y); @@ -1696,7 +1696,7 @@ ImGui_Timeline_DrawPrecomp(project_data *File, project_state *State, memory *Mem Assert(Layer->IsSelected); State->Interact_Active = interact_type_layer_timeadjust; ImVec2 DragDelta = ImGui::GetMouseDragDelta(); - DragDelta = DragDelta + (ImVec2(UI->Warp_X, UI->Warp_Y) * TimelineSize); + DragDelta = DragDelta + (ImVec2(State->Warp_X, State->Warp_Y) * TimelineSize); State->Interact_Offset[0] = (DragDelta.x / TimelineSizeWithBorder.x * UI->TimelinePercentZoomed.x) * Comp->Frame_Count; State->Interact_Offset[1] = b; @@ -1818,7 +1818,7 @@ ImGui_Timeline_DrawPrecomp(project_data *File, project_state *State, memory *Mem Layer_RecursiveDeselect(Memory, SortedCompArray, SortedLayerArray, Layer->Block_Composition_Index, File->PrincipalCompIndex); } ImVec2 DragDelta = ImGui::GetMouseDragDelta(); - DragDelta = DragDelta + (ImVec2(UI->Warp_X, UI->Warp_Y) * TimelineSize); + DragDelta = DragDelta + (ImVec2(State->Warp_X, State->Warp_Y) * TimelineSize); ImVec2 Offset_Old = ImVec2(State->Interact_Offset[0], State->Interact_Offset[1]); ImVec2 Offset_New = (DragDelta / TimelineSizeWithBorder * UI->TimelinePercentZoomed) * ImVec2(Comp->Frame_Count, -LayerIncrement); @@ -1917,7 +1917,7 @@ static void ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI, ImGuiIO io, sorted_comp_info *SortedCompArray, sorted_layer *SortedLayerArray, sorted_property_info *SortedPropertyInfo, uint16 *SortedPropertyArray) { - if (UI->TimelineMode == timeline_mode_graph) + if (State->TimelineMode == timeline_mode_graph) ImGui_GraphInfo(File, State, Memory, UI, io, SortedPropertyInfo, SortedPropertyArray); ImVec2 FramePadding = ImGui::GetStyle().FramePadding; @@ -1927,7 +1927,7 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI, ImGui::Begin("Timeline", NULL); if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) - UI->FocusedWindow = focus_timeline; + State->FocusedWindow = focus_timeline; real32 FontHeight = ImGui::GetFontSize(); @@ -1999,7 +1999,7 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI, TimelineSize, TimelineSizeWithBorder, LayerIncrement, SortedCompArray, SortedLayerArray, SortedPropertyInfo, SortedPropertyArray); - if (UI->TimelineMode == timeline_mode_graph) { + if (State->TimelineMode == timeline_mode_graph) { if (UI->GraphMoveSize.y == 0) { UI->GraphZoomSize = ImVec2(1, UI->TimelinePercentZoomed.y ); @@ -2087,7 +2087,7 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI, } if (BarHeld) { - ImGui_WarpMouse(UI, io.MousePos, TimelineAbsolutePos, TimelineAbsolutePos + TimelineSizeWithBorder, 1); + ImGui_WarpMouse(State, io.MousePos, TimelineAbsolutePos, TimelineAbsolutePos + TimelineSizeWithBorder, 1); } Assert(ActivePercentZoomed->x > BarMinZoom); @@ -2150,7 +2150,7 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI, ActivePercentZoomed->y = Max(ActivePercentZoomed->y, 0.01); if (BarHeld) { - ImGui_WarpMouse(UI, io.MousePos, TimelineAbsolutePos, TimelineAbsolutePos + TimelineSizeWithBorder, 2); + ImGui_WarpMouse(State, io.MousePos, TimelineAbsolutePos, TimelineAbsolutePos + TimelineSizeWithBorder, 2); } ImGui::SetCursorScreenPos(TimelineAbsolutePos); @@ -2184,7 +2184,7 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI, if (LeftClick) { if (IsItemActivated) { - if (!io.KeyShift && UI->TimelineMode == timeline_mode_default) Layer_DeselectAll(File, State, Memory); + if (!io.KeyShift && State->TimelineMode == timeline_mode_default) Layer_DeselectAll(File, State, Memory); if (State->Interact_Active == interact_type_keyframe_move || State->Interact_Active == interact_type_keyframe_rotate || State->Interact_Active == interact_type_keyframe_scale) { @@ -2219,20 +2219,20 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI, State->Interact_Active = interact_type_none; State->Interact_Modifier = 0; } - UI->BoxSelect = true; + State->BoxSelect = true; } if (IsItemActive) { - Assert(UI->BoxSelect); + Assert(State->BoxSelect); draw_list->AddRectFilled(io.MouseClickedPos[0], io.MousePos, IM_COL32(0, 0, 200, 50)); } } else { - UI->Warp_X = 0; - UI->Warp_Y = 0; + State->Warp_X = 0; + State->Warp_Y = 0; } if (IsItemDeactivated) { - UI->BoxSelect = false; + State->BoxSelect = false; } draw_list->PopClipRect(); @@ -2247,6 +2247,140 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI, ImGui::End(); } + +struct key_entry { + ImGuiKey_ KeyIndex; + char *Name; + char *ShiftName; + uint32 Sector; + ImVec2 Offset; + real32 WidthRatio; +}; + +struct shortcut_entry { + ImGuiKey_ Key; + ImGuiModFlags_ Mods; + char *Name; +}; + +#if 0 +static key_entry KeyEntries[] { + { ImGuiKey_Tab, "Tab", "\0", 0, ImVec2(0, 1), 1.5f }, + { ImGuiKey_LeftArrow, "<-", "\0", 2, ImVec2(0, 5), 1.0f }, + { ImGuiKey_RightArrow, "->", "", 2, ImVec2(2, 5), 1.0f }, + { ImGuiKey_UpArrow, "/\\", "", 2, ImVec2(1, 4), 1.0f }, + { ImGuiKey_DownArrow, "\\/", "", 2, ImVec2(1, 5), 1.0f }, + { ImGuiKey_PageUp, "Pg Up", "", 2, ImVec2(2, 0), 1.0f }, + { ImGuiKey_PageDown, "Pg Dn", "", 2, ImVec2(2, 1), 1.0f }, + { ImGuiKey_Home, "Home", "", 2, ImVec2(1, 0), 1.0f }, + { ImGuiKey_End, "End", "", 2, ImVec2(0, 1), 1.0f }, + { ImGuiKey_Insert, "Insert", "", 2, ImVec2(0, 0), 1.0f }, + { ImGuiKey_Delete, "Delete", "", 2, ImVec2(0, 1), 1.0f }, + { ImGuiKey_Backspace, "Backspace", "", 0, ImVec2(13, 1), 2.0f }, + { ImGuiKey_Space, "Space", "", 0, ImVec2(4, 3), 6.5f }, + { ImGuiKey_Enter, "Enter", "", 0, ImVec2(2, 12), 1.5f}, + { ImGuiKey_Escape, "Esc", "", 1, ImVec2(0, 0), 1.0f }, + { ImGuiKey_LeftCtrl, + { ImGuiKey_LeftShift, "L_Shift", "", 0, + { ImGuiKey_LeftAlt, + { ImGuiKey_LeftSuper, + { ImGuiKey_RightCtrl, + { ImGuiKey_RightShift, + { ImGuiKey_RightAlt, + { ImGuiKey_RightSuper, + { ImGuiKey_Menu, + { ImGuiKey_0, "0", ")", 0, ImVec2(10, 0), 1.0f }, + { ImGuiKey_1, "1", "!", 0, ImVec2(1, 0), 1.0f }, + { ImGuiKey_2, "2", "@", 0, ImVec2(2, 0), 1.0f }, + { ImGuiKey_3, "3", "$", 0, ImVec2(3, 0), 1.0f }, + { ImGuiKey_4, "4", "%", 0, ImVec2(4, 0), 1.0f }, + { ImGuiKey_5, "5", "%", 0, ImVec2(5, 0), 1.0f }, + { ImGuiKey_6, "6", "^", 0, ImVec2(6, 0), 1.0f }, + { ImGuiKey_7, "7", "&", 0, ImVec2(7, 0), 1.0f }, + { ImGuiKey_8, "8", "*", 0, ImVec2(8, 0), 1.0f }, + { ImGuiKey_9, "9", "(", 0, ImVec2(9, 0), 1.0f }, + { ImGuiKey_A, "a", "A", 0, ImVec2(1, 2), 1.0f }, + { ImGuiKey_B, "b", "B", 0, ImVec2(5, 3), 1.0f }, + { ImGuiKey_C, "c", "C", 0, ImVec2(3, 3), 1.0f }, + { ImGuiKey_D, "d", "D", 0, ImVec2(3, 2), 1.0f }, + { ImGuiKey_E, "e", "E", 0, ImVec2(0, 2), 1.0f }, + { ImGuiKey_F, "f", "F", 0, ImVec2(4, 2), 1.0f }, + { ImGuiKey_G, "g", "G", 0, ImVec2(5, 2), 1.0f }, + { ImGuiKey_H, "h", "H", 0, ImVec2(6, 2), 1.0f }, + { ImGuiKey_I, "i", "I", 0, ImVec2(0, 7), 1.0f }, + { ImGuiKey_J, "j", "J", 0, ImVec2(7, 2), 1.0f }, + { ImGuiKey_K, "k", "K", 0, ImVec2(8, 2), 1.0f }, + { ImGuiKey_L, "l", "L", 0, ImVec2(9, 2), 1.0f }, + { ImGuiKey_M, "m", "M", 0, ImVec2(7, 3), 1.0f }, + { ImGuiKey_N, "n", "N", 0, ImVec2(6, 3), 1.0f }, + { ImGuiKey_O, "o", "O", 0, ImVec2(8, 1), 1.0f }, + { ImGuiKey_P, "p", "P", 0, ImVec2(9, 1), 1.0f }, + { ImGuiKey_Q, "q", "Q", 0, ImVec2(1, 1), 1.0f }, + { ImGuiKey_R, "r", "R", 0, ImVec2(3, 1), 1.0f }, + { ImGuiKey_S, "s", "S", 0, ImVec2(2, 1), 1.0f }, + { ImGuiKey_T, "t", "T", 0, ImVec2(4, 1), 1.0f }, + { ImGuiKey_U, "u", "U", 0, ImVec2(6, 1), 1.0f }, + { ImGuiKey_V, "v", "V", 0, ImVec2(4, 3), 1.0f }, + { ImGuiKey_W, "w", "W", 0, ImVec2(1, 1), 1.0f }, + { ImGuiKey_X, "x", "X", 0, ImVec2(2, 3), 1.0f }, + { ImGuiKey_Y, "y", "Y", 0, ImVec2(0, 5), 1.0f }, + { ImGuiKey_Z, "z", "Z", 0, ImVec2(1, 3), 1.0f }, + { ImGuiKey_F1, "F1", "", 1, ImVec2(2, 0), 1.0f }, + { ImGuiKey_F2, "F2", "", 1, ImVec2(3, 0), 1.0f }, + { ImGuiKey_F3, "F3", "", 1, ImVec2(4, 0), 1.0f }, + { ImGuiKey_F4, "F4", "", 1, ImVec2(5, 0), 1.0f }, + { ImGuiKey_F5, "F5", "", 1, ImVec2(6.5, 0), 1.0f }, + { ImGuiKey_F6, "F6", "", 1, ImVec2(7.5, 0), 1.0f }, + { ImGuiKey_F7, "F7", "", 1, ImVec2(8.5, 0), 1.0f }, + { ImGuiKey_F8, "F8", "", 1, ImVec2(9.5, 0), 1.0f }, + { ImGuiKey_F9, "F9", "", 1, ImVec2(11, 0), 1.0f }, + { ImGuiKey_F10 "F10","", 1, ImVec2(12, 0), 1.0f }, + { ImGuiKey_F11 "F11","", 1, ImVec2(13, 0), 1.0f }, + { ImGuiKey_F12 "F12","", 1, ImVec2(14, 0), 1.0f }, + { ImGuiKey_Apostrophe, "\'", "\"", 1, ImVec2(11, 2), 1.0f }, + { ImGuiKey_Comma, ",", "<", 0, ImVec2(8, 3), 1.0f }, + { ImGuiKey_Minus, "-", "_", 0, ImVec2(11, 1), 1.0f}; + { ImGuiKey_Period, ".", ">", 0, ImVec2(9, 3), 1.0f }, + { ImGuiKey_Slash, "/", "?", 0, ImVec2(10, 3), 1.0f }, + { ImGuiKey_Semicolon, ";", ":", 0, ImVec2(10, 2), 1.0f }, + { ImGuiKey_Equal, "=", "+", 0, ImVec2(12, 1), 1.0f }, + { ImGuiKey_LeftBracket, "[", "{", 0, ImVec2(0, 10), 1.0f }, + { ImGuiKey_Backslash, "\\","|", 0, ImVec2(0, 12), 1.5f }, + { ImGuiKey_RightBracket,"]", "}", 0, ImVec2(0, 11), 1.0f }, + { ImGuiKey_GraveAccent, "`", "~", 0, ImVec2(0, 0), 1.0f }, + { ImGuiKey_CapsLock, "Caps lock", "", 1, ImVec2(0, 2), 1.75f }; + { ImGuiKey_ScrollLock, + { ImGuiKey_NumLock, + { ImGuiKey_PrintScreen, + { ImGuiKey_Pause, + { ImGuiKey_Keypad0, + { ImGuiKey_Keypad1, + { ImGuiKey_Keypad2, + { ImGuiKey_Keypad3, + { ImGuiKey_Keypad4, + { ImGuiKey_Keypad5, + { ImGuiKey_Keypad6, + { ImGuiKey_Keypad7, + { ImGuiKey_Keypad8, + { ImGuiKey_Keypad9, + { ImGuiKey_KeypadDecimal, + { ImGuiKey_KeypadDivide, + { ImGuiKey_KeypadMultiply, + { ImGuiKey_KeypadSubtract, + { ImGuiKey_KeypadAdd, + { ImGuiKey_KeypadEnter, + { ImGuiKey_KeypadEqual, +}; +#endif + + +static shortcut_entry ShortcutArray[] { + { ImGuiKey_1, ImGuiModFlags_None, "Enable debug UI" }, + { ImGuiKey_2, ImGuiModFlags_None, "Toggle precomp view" } +}; + +static ImVec2 SectorOffset[] = { ImVec2(0, 1.5), ImVec2(0, 0) }; + static void ImGui_Popups(project_data *File, project_state *State, ui *UI, memory *Memory, ImGuiIO io) { @@ -2258,8 +2392,17 @@ ImGui_Popups(project_data *File, project_state *State, ui *UI, memory *Memory, I case popup_saveas: { ImGui::OpenPopup("Save as"); + ImVec2 Size(300, 300); + Assert(0); + ImGui::SetNextWindowPos(ImVec2(300, 800)); + ImGui::SetNextWindowSize(Size); + ImGui::SetKeyboardFocusHere(); + } break; + case popup_keybinds: + { + ImGui::OpenPopup("Keybinds"); ImGui::SetNextWindowPos(ImVec2(300, 800)); - ImGui::SetNextWindowSize(ImVec2(300, 300)); + ImGui::SetNextWindowSize(ImVec2(500, 300)); ImGui::SetKeyboardFocusHere(); } break; default: @@ -2282,6 +2425,15 @@ ImGui_Popups(project_data *File, project_state *State, ui *UI, memory *Memory, I } ImGui::EndPopup(); } + if (ImGui::BeginPopupModal("Keybinds")) { +#if 0 + real32 KeySize = 20; + for (int k = 0; k < AmountOf(KeyEntries); k++) { + key_entry KeyEntry = KeyArray[k]; + ImVec2 Offset_ScreenPos = ImVec2(KeySize, KeySize) * (SectorOffset[KeyEntry.Sector] + + } +#endif + } } static void @@ -2336,13 +2488,13 @@ ImGui_ProcessInputs(project_data *File, project_state *State, ui *UI, memory *Me MainComp->Frame_Start = State->Frame_Current; } if (ImGui::IsKeyPressed(ImGuiKey_Tab)) { - UI->TimelineMode = (UI->TimelineMode == timeline_mode_default) ? timeline_mode_graph : timeline_mode_default; + State->TimelineMode = (State->TimelineMode == timeline_mode_default) ? timeline_mode_graph : timeline_mode_default; UI->GraphZoomSize = ImVec2(0, 0); UI->GraphMoveSize = ImVec2(0, 0); } if (!io.KeyCtrl) { - if (UI->FocusedWindow == focus_timeline) { - if (UI->TimelineMode == timeline_mode_default) { + if (State->FocusedWindow == focus_timeline) { + if (State->TimelineMode == timeline_mode_default) { if (ImGui::IsKeyPressed(ImGuiKey_G)) { Layer_ToggleChannel(File, Memory, 0); Layer_ToggleChannel(File, Memory, 1); @@ -2360,7 +2512,7 @@ ImGui_ProcessInputs(project_data *File, project_state *State, ui *UI, memory *Me Layer_ToggleChannel(File, Memory, 7); } } - } else if (UI->TimelineMode == timeline_mode_graph) { + } else if (State->TimelineMode == timeline_mode_graph) { if (ImGui::IsKeyPressed(ImGuiKey_G)) { State->Interact_Offset[2] = io.MousePos.x; State->Interact_Offset[3] = io.MousePos.y; @@ -2375,7 +2527,7 @@ ImGui_ProcessInputs(project_data *File, project_state *State, ui *UI, memory *Me State->Interact_Active = interact_type_keyframe_scale; } } - } else if (UI->FocusedWindow == focus_viewport) { + } else if (State->FocusedWindow == focus_viewport) { if (ImGui::IsKeyPressed(ImGuiKey_T)) { State->HotkeyInput = hotkey_transform; } @@ -2431,7 +2583,22 @@ ImGui_ProcessInputs(project_data *File, project_state *State, ui *UI, memory *Me } } + if (io.KeyShift && ImGui::IsKeyPressed(ImGuiKey_Slash)) + { + State->ImGuiPopups = popup_keybinds; + } + #if DEBUG + if (ImGui::IsKeyPressed(ImGuiKey_3)) + { + State->ImGuiPopups = popup_keybinds; + } + if (ImGui::IsKeyPressed(ImGuiKey_F)) + { + sprintf(State->DummyName, "test2"); + File_Open(File, State, Memory, State->DummyName); + State->UpdateFrame = true; + } if (ImGui::IsKeyPressed(ImGuiKey_0)) { Debug.ReloadUI ^= 1; @@ -2523,8 +2690,8 @@ ImGui_Menu(project_data *File, project_state *State, ui *UI, memory *Memory, ImG if (ImGui::BeginMenu("Window")) { #if STABLE - if (ImGui::Selectable("Stable Diffusion tools", State->StableEnabled)) - State->StableEnabled ^= 1; + if (ImGui::Selectable("Stable Diffusion tools", UI->StableEnabled)) + UI->StableEnabled ^= 1; ImGui::EndMenu(); #endif } |