diff options
author | Fox Caminiti <fox@foxcam.net> | 2022-11-28 21:46:43 -0500 |
---|---|---|
committer | Fox Caminiti <fox@foxcam.net> | 2022-11-28 21:46:43 -0500 |
commit | 7a5e57b5c806437b0fbd2ab0c08d616d5dec0090 (patch) | |
tree | 511ca8e173b8bfc17eead7dfa8576bb5dffa7ecb | |
parent | 6eb627210eb2b77bcde7ca75d9bcb5b50d240f64 (diff) |
fancy keybind UI added, major brush regression
-rwxr-xr-x | build.sh | 1 | ||||
-rw-r--r-- | createcalls.cpp | 19 | ||||
-rw-r--r-- | debug.h | 2 | ||||
-rw-r--r-- | keybinds.h | 203 | ||||
-rw-r--r-- | main.cpp | 1 | ||||
-rw-r--r-- | main.h | 3 | ||||
-rw-r--r-- | my_imgui_widgets.cpp | 406 | ||||
-rw-r--r-- | prenderer.cpp | 39 |
8 files changed, 379 insertions, 295 deletions
@@ -124,4 +124,5 @@ mkdir bin/real_"$ARCHNAME".app cp -r lib/mac_app_template/Contents bin/real_"$ARCHNAME".app xattr -cr bin/real_"$ARCHNAME".app dylibbundler -od -b -x bin/real_"$ARCHNAME".app/Contents/MacOS/real -d bin/real_"$ARCHNAME".app/Contents/libs +rm lib/mac_app_template/Contents/MacOS/real fi diff --git a/createcalls.cpp b/createcalls.cpp index d1f6448..a984454 100644 --- a/createcalls.cpp +++ b/createcalls.cpp @@ -659,13 +659,20 @@ Layer_TraverseForPoint(project_data *File, project_state *State, memory *Memory, v2 PointUV = {0, 0}; int OuterWidth = Comp->Width, OuterHeight = Comp->Height; int InnerWidth = 0, InnerHeight = 0; - for (int i = 1; i <= Recursions; i++) { - block_layer *InnerLayer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, RecursionIdx[i]); - layer_transforms T = Layer_GetTransforms(InnerLayer); - Layer_GetDimensions(Memory, InnerLayer, &InnerWidth, &InnerHeight); + if (Recursions == 0) { + block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, State->Brush.LayerToPaint_Index); + layer_transforms T = Layer_GetTransforms(Layer); + Layer_GetDimensions(Memory, Layer, &InnerWidth, &InnerHeight); PointUV = T_CompUVToLayerUV(T, OuterWidth, OuterHeight, InnerWidth, InnerHeight, State->TempZoomRatio); - OuterWidth = InnerWidth; - OuterHeight = InnerHeight; + } else { + for (int i = 1; i <= Recursions; i++) { + block_layer *InnerLayer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, RecursionIdx[i]); + layer_transforms T = Layer_GetTransforms(InnerLayer); + Layer_GetDimensions(Memory, InnerLayer, &InnerWidth, &InnerHeight); + PointUV = T_CompUVToLayerUV(T, OuterWidth, OuterHeight, InnerWidth, InnerHeight, State->TempZoomRatio); + OuterWidth = InnerWidth; + OuterHeight = InnerHeight; + } } return PointUV * V2(InnerWidth, InnerHeight); } @@ -27,7 +27,7 @@ struct debug_temp struct project_debug { debug_temp Temp; - bool32 ToggleWindow = 1; + bool32 ToggleWindow = 0; bool32 ReloadUI = true; bool32 NoThreading = 0; uint64 PixelCountTransparent; diff --git a/keybinds.h b/keybinds.h new file mode 100644 index 0000000..4cddb29 --- /dev/null +++ b/keybinds.h @@ -0,0 +1,203 @@ +enum key_mode { + key_mode_all, + key_mode_viewport, + key_mode_timeline, + key_mode_graph, + key_mode_brush, + key_mode_count, +}; + +enum key_mods { + Mod_None, + Mod_Ctrl, + Mod_Alt, + Mod_Shift, + Mod_CtrlShift +}; + +struct shortcut_entry { + ImGuiKey_ Key; + key_mods Mods; + key_mode Mode; + char *Name; +}; + +static shortcut_entry ShortcutArray[] { + { ImGuiKey_None, Mod_None, key_mode_all, "Many actions/modes are escapable with the Esc key." }, + { ImGuiKey_None, Mod_None, key_mode_all, "Undo isn't fully implemented yet; beware crashes." }, + { ImGuiKey_Q, Mod_None, key_mode_all, "Quit (instantly!)" }, + { ImGuiKey_W, Mod_None, key_mode_all, "Step back one frame" }, + { ImGuiKey_E, Mod_None, key_mode_all, "Step forward one frame" }, + { ImGuiKey_V, Mod_None, key_mode_all, "Move tool" }, + { ImGuiKey_B, Mod_None, key_mode_all, "Brush tool" }, + { ImGuiKey_Space, Mod_None, key_mode_all, "Play scene" }, + { ImGuiKey_Delete, Mod_None, key_mode_all, "Delete selection (WIP)" }, + { ImGuiKey_S, Mod_Ctrl, key_mode_all, "Save" }, + { ImGuiKey_S, Mod_CtrlShift, key_mode_all, "Save as" }, + { ImGuiKey_C, Mod_Ctrl, key_mode_all, "Copy" }, + { ImGuiKey_P, Mod_Ctrl, key_mode_all, "Paste" }, + { ImGuiKey_Z, Mod_Ctrl, key_mode_all, "Undo" }, + { ImGuiKey_Z, Mod_Ctrl, key_mode_all, "Redo" }, + { ImGuiKey_Slash, Mod_Shift, key_mode_all, "Open help" }, + + { ImGuiKey_None, Mod_None, key_mode_viewport, "Hold right click to pan." }, + { ImGuiKey_None, Mod_None, key_mode_viewport, "Hold Z and drag left click to zoom." }, + { ImGuiKey_None, Mod_None, key_mode_viewport, "Press Enter or ctrl+click to commit a transform." }, + { ImGuiKey_T, Mod_None, key_mode_viewport, "Transform selected layers" }, + + { ImGuiKey_Tab, Mod_None, key_mode_timeline, "Switch between timeline and graph" }, + { ImGuiKey_2, Mod_None, key_mode_timeline, "Toggle precomp view" }, + { ImGuiKey_G, Mod_None, key_mode_timeline, "Toggle position keyframes" }, + { ImGuiKey_A, Mod_None, key_mode_timeline, "Toggle anchor point keyframes" }, + { ImGuiKey_R, Mod_None, key_mode_timeline, "Toggle roation keyframes" }, + { ImGuiKey_S, Mod_None, key_mode_timeline, "Toggle scale keyframes" }, + { ImGuiKey_T, Mod_None, key_mode_timeline, "Toggle time remapping keyframes" }, + { ImGuiKey_T, Mod_Shift, key_mode_timeline, "Toggle opacity keyframes" }, + { ImGuiKey_B, Mod_None, key_mode_timeline, "Mark frame start" }, + { ImGuiKey_N, Mod_None, key_mode_timeline, "Mark frame end" }, + + { ImGuiKey_G, Mod_None, key_mode_graph, "Enter keyframe moving mode" }, + { ImGuiKey_X, Mod_None, key_mode_graph, "Constrain to X axis" }, + { ImGuiKey_Y, Mod_None, key_mode_graph, "Constrain to Y axis" }, + + { ImGuiKey_None, Mod_None, key_mode_brush, "Hold alt and drag to adjust size/hardness." }, + { ImGuiKey_X, Mod_None, key_mode_brush, "Swap FG and BG colors" }, +}; + + +struct key_entry { + ImGuiKey_ KeyIndex; + char *Name; + char *ShiftName; + uint32 Sector; + ImVec2 Offset; + real32 WidthRatio; +}; + +// dumb typing exercise +static key_entry KeyEntries[] { + { ImGuiKey_Tab, "Tab", "\0", 0, ImVec2(0, 1), 1.5f }, + { ImGuiKey_LeftArrow, "<-", "\0", 2, ImVec2(0, 4), 1.0f }, + { ImGuiKey_RightArrow, "->", "", 2, ImVec2(2, 4), 1.0f }, + { ImGuiKey_UpArrow, "/\\", "", 2, ImVec2(1, 3), 1.0f }, + { ImGuiKey_DownArrow, "\\/", "", 2, ImVec2(1, 4), 1.0f }, + { ImGuiKey_PageUp, "Up", "", 2, ImVec2(2, 0), 1.0f }, + { ImGuiKey_PageDown, "Dn", "", 2, ImVec2(2, 1), 1.0f }, + { ImGuiKey_Home, "Home", "", 2, ImVec2(1, 0), 1.0f }, + { ImGuiKey_End, "End", "", 2, ImVec2(1, 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, 0), 2.0f }, + { ImGuiKey_Space, "Space", "", 0, ImVec2(3.75, 4), 6.5f }, + { ImGuiKey_Enter, "Enter", "", 0, ImVec2(12, 2), 2.25f}, + { ImGuiKey_Escape, "Esc", "", 1, ImVec2(0, 0), 1.0f }, + { ImGuiKey_LeftCtrl, "Ctrl", "", 0, ImVec2(0, 4), 1.25f }, + { ImGuiKey_LeftShift, "Shift", "", 0, ImVec2(0, 3), 2.5f }, + { ImGuiKey_LeftAlt, "Alt", "", 0, ImVec2(1.25, 4), 1.25 }, + { ImGuiKey_LeftSuper, "Sp", "", 0, ImVec2(2.5, 4), 1.25f }, + { ImGuiKey_RightCtrl, "Ctrl", "", 0, ImVec2(13.75, 4), 1.25f }, + { ImGuiKey_RightShift, "Shift", "", 0, ImVec2(11, 3), 2.5f }, + { ImGuiKey_RightAlt, "Alt", "", 0, ImVec2(11.25, 4), 1.25 }, + { ImGuiKey_RightSuper, "Sp", "", 0, ImVec2(10.25, 4), 1.0f }, + { ImGuiKey_Menu, "Menu", "", 0, ImVec2(12.5, 4), 1.25 }, + { 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(3, 1), 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(8, 1), 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(9, 1), 1.0f }, + { ImGuiKey_P, "p", "P", 0, ImVec2(10, 1), 1.0f }, + { ImGuiKey_Q, "q", "Q", 0, ImVec2(1, 1), 1.0f }, + { ImGuiKey_R, "r", "R", 0, ImVec2(4, 1), 1.0f }, + { ImGuiKey_S, "s", "S", 0, ImVec2(2, 2), 1.0f }, + { ImGuiKey_T, "t", "T", 0, ImVec2(5, 1), 1.0f }, + { ImGuiKey_U, "u", "U", 0, ImVec2(7, 1), 1.0f }, + { ImGuiKey_V, "v", "V", 0, ImVec2(4, 3), 1.0f }, + { ImGuiKey_W, "w", "W", 0, ImVec2(2, 1), 1.0f }, + { ImGuiKey_X, "x", "X", 0, ImVec2(2, 3), 1.0f }, + { ImGuiKey_Y, "y", "Y", 0, ImVec2(6, 1), 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, "'", "\"", 0, ImVec2(11, 2), 1.0f }, + { ImGuiKey_Comma, ",", "<", 0, ImVec2(8, 3), 1.0f }, + { ImGuiKey_Minus, "-", "_", 0, ImVec2(11, 0), 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, 0), 1.0f }, + { ImGuiKey_LeftBracket, "[", "{", 0, ImVec2(11, 1), 1.0f }, + { ImGuiKey_Backslash, "\\","|", 0, ImVec2(13, 1), 1.5f }, + { ImGuiKey_RightBracket, "]", "}", 0, ImVec2(12, 1), 1.0f }, + { ImGuiKey_GraveAccent, "`", "~", 0, ImVec2(0, 0), 1.0f }, + { ImGuiKey_CapsLock, "Caps", "", 0, ImVec2(0, 2), 1.75f }, + { ImGuiKey_ScrollLock, "\0", "", 0, ImVec2(0, 0), 1.0f }, // unused + { ImGuiKey_NumLock, "\0", "", 0, ImVec2(0, 0), 1.0f }, // + { ImGuiKey_PrintScreen, "\0", "", 0, ImVec2(0, 0), 1.0f }, // + { ImGuiKey_Pause, "\0", "", 0, ImVec2(0, 0), 1.0f }, // + { ImGuiKey_Keypad0, "0", "", 3, ImVec2(0, 4), 2.0f }, + { ImGuiKey_Keypad1, "1", "", 3, ImVec2(0, 3), 1.0f }, + { ImGuiKey_Keypad2, "2", "", 3, ImVec2(1, 3), 1.0f }, + { ImGuiKey_Keypad3, "3", "", 3, ImVec2(2, 3), 1.0f }, + { ImGuiKey_Keypad4, "4", "", 3, ImVec2(0, 2), 1.0f }, + { ImGuiKey_Keypad5, "5", "", 3, ImVec2(1, 2), 1.0f }, + { ImGuiKey_Keypad6, "6", "", 3, ImVec2(2, 2), 1.0f }, + { ImGuiKey_Keypad7, "7", "", 3, ImVec2(0, 1), 1.0f }, + { ImGuiKey_Keypad8, "8", "", 3, ImVec2(1, 1), 1.0f }, + { ImGuiKey_Keypad9, "9", "", 3, ImVec2(2, 1), 1.0f }, + { ImGuiKey_KeypadDecimal, ".", "", 3, ImVec2(2, 4), 1.0f }, + { ImGuiKey_KeypadDivide, "/", "", 3, ImVec2(1, 0), 1.0f }, + { ImGuiKey_KeypadMultiply, "*", "", 3, ImVec2(2, 0), 1.0f }, + { ImGuiKey_KeypadSubtract, "-", "", 3, ImVec2(3, 0), 1.0f }, + { ImGuiKey_KeypadAdd, "+", "", 3, ImVec2(3, 1), -2.0f }, // long keys! + { ImGuiKey_KeypadEnter, "Ent", "", 3, ImVec2(3, 3), -2.0f }, + { ImGuiKey_KeypadEqual, "", "", 3, ImVec2(0, 0), 1.0f } // unused +}; + +static char *KeyModeTitles[] = { + "All", + "Viewport", + "Timeline", + "Graph", + "Brush" +}; + +static char *KeyModText[] = { + "ERROR", + "Ctrl", + "Alt", + "Shift", + "Ctrl + Shift" +}; + +static ImVec2 SectorOffset[4] = { ImVec2(0, 1.5), ImVec2(0, 0) , ImVec2(15.5, 1.5), ImVec2(19, 1.5) }; + @@ -601,6 +601,7 @@ int main(int argc, char *argv[]) { // loaded from disk or memory. io.IniFilename = NULL; ImGui::LoadIniSettingsFromMemory(ImGuiPrefs); + // // ImGui::SaveIniSettingsToDisk("imgui.ini"); ImGui::StyleColorsDark(); @@ -387,6 +387,7 @@ struct project_state bool32 RerouteEffects; // Allows shift+space hotkey to gain focus on the effects panel. ImDrawListSplitter Test; + ImDrawListSplitter Split_KeybindUI; int32 Warp_X = 0; int32 Warp_Y = 0; @@ -423,8 +424,10 @@ struct ui v4 AltColor = {0, 0, 0, 1}; bool32 IsPrimary; +#if STABLE sd_state SD; bool32 StableEnabled = 0; +#endif ImU32 LayerColors[16] = { 0xff8b1f1f, diff --git a/my_imgui_widgets.cpp b/my_imgui_widgets.cpp index 3264e89..4bdedea 100644 --- a/my_imgui_widgets.cpp +++ b/my_imgui_widgets.cpp @@ -907,7 +907,7 @@ ImGui_TransformUI(project_data *File, project_state *State, memory *Memory, ui * History_Entry_Commit(Memory, "Transform layers"); while (Block_Loop(Memory, F_Layers, File->Layer_Count, &h, &c, &i)) { block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, i); - if (Layer->IsSelected) { + if (Layer->IsSelected == 1) { if (io.KeyCtrl) { layer_transforms T = Layer_GetTransforms(Layer); Transform_ApplyInteractive(*(interact_transform *)&State->Interact_Offset[0], &T.x, &T.y, &T.rotation, &T.scale); @@ -976,7 +976,7 @@ ImGui_LayerViewportUI(project_state *State, memory *Memory, ui *UI, ImDrawList * layer_transforms T = Layer_GetTransforms(Layer); - if (State->Interact_Active == interact_type_viewport_transform && Layer->IsSelected) { + if (State->Interact_Active == interact_type_viewport_transform && Layer->IsSelected == 1) { Transform_ApplyInteractive(*(interact_transform *)&State->Interact_Offset[0], &T.x, &T.y, &T.rotation, &T.scale); } @@ -1076,6 +1076,14 @@ ImGui_Viewport(project_data *File, project_state *State, ui *UI, memory *Memory, draw_list->AddRect(ViewportMin, ViewportMax, IM_COL32(255, 255, 255, 255)); draw_list->AddRect(CompPosMin, CompPosMax, IM_COL32(255, 255, 255, 55)); + real32 FontSize = ImGui::GetFontSize(); + ImGui::SetCursorScreenPos(ImVec2(ViewportMax.x - FontSize*2, ViewportMin.y + ViewportScale.y - FontSize*3.0)); + ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 80)); + if (ImGui::Button("?")) + State->ImGuiPopups = popup_keybinds; + ImGui::PopStyleColor(); + + // Actual composition texture draw_list->PushClipRect(ViewportMin, ViewportMax, true); draw_list->AddImage((void *)(intptr_t)textureID, CompPosMin, CompPosMax); @@ -1098,7 +1106,7 @@ ImGui_Viewport(project_data *File, project_state *State, ui *UI, memory *Memory, ImGui::InvisibleButton("canvas", ViewportScale, ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight); bool32 IsHovered = ImGui::IsItemHovered(); -#if 0 +#if 1 bool32 IsActive = ImGui::IsItemActive(); bool32 IsActivated = ImGui::IsItemActivated(); bool32 IsDeactivated = ImGui::IsItemDeactivated(); @@ -1144,7 +1152,7 @@ ImGui_Viewport(project_data *File, project_state *State, ui *UI, memory *Memory, Layer->Block_Source_Index = i; Layer->x.CurrentValue = MainComp->Width / 2; Layer->y.CurrentValue = MainComp->Height / 2; - int TopOffset = 0; + int TopOffset = (File->Layer_Count == 1) ? 11 : 0; sorted_comp_info SortedCompInfo = SortedCompArray[File->PrincipalCompIndex]; if (SortedCompInfo.LayerCount) { @@ -1262,7 +1270,7 @@ ImGui_Viewport(project_data *File, project_state *State, ui *UI, memory *Memory, UI->CompPos.y -= Distance*State->TempZoomRatio.y; } - ImGui::SetCursorScreenPos(ImVec2(ViewportMin.x, ViewportMin.y + ViewportScale.y - ImGui::GetFontSize()*1.5)); + ImGui::SetCursorScreenPos(ImVec2(ViewportMin.x, ViewportMin.y + ViewportScale.y - FontSize*1.5)); ImGui::Text("%.1f", 100.0f * (UI->CompZoom.x / MainComp->Width)); if (State->MsgTime > 0) { @@ -2064,7 +2072,7 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI, ImVec2 Val_Min(0, 0); ImVec2 Val_Max(40, LayerIncrement); - DebugWatchVar("Selection", &State->RecentSelectionType, d_int); + // DebugWatchVar("Selection", &State->RecentSelectionType, d_int); // ImVec2 *ActivePercentZoomed = (UI->TimelineMode != timeline_mode_graph) ? &UI->TimelinePercentZoomed : &UI->GraphPercentZoomed; // ImVec2 *ActivePercentOffset = (UI->TimelineMode != timeline_mode_graph) ? &UI->TimelinePercentOffset : &UI->GraphPercentOffset; @@ -2315,189 +2323,7 @@ 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; -}; - -// dumb typing exercise -static key_entry KeyEntries[] { - { ImGuiKey_Tab, "Tab", "\0", 0, ImVec2(0, 1), 1.5f }, - { ImGuiKey_LeftArrow, "<-", "\0", 2, ImVec2(0, 4), 1.0f }, - { ImGuiKey_RightArrow, "->", "", 2, ImVec2(2, 4), 1.0f }, - { ImGuiKey_UpArrow, "/\\", "", 2, ImVec2(1, 3), 1.0f }, - { ImGuiKey_DownArrow, "\\/", "", 2, ImVec2(1, 4), 1.0f }, - { ImGuiKey_PageUp, "Up", "", 2, ImVec2(2, 0), 1.0f }, - { ImGuiKey_PageDown, "Dn", "", 2, ImVec2(2, 1), 1.0f }, - { ImGuiKey_Home, "Home", "", 2, ImVec2(1, 0), 1.0f }, - { ImGuiKey_End, "End", "", 2, ImVec2(1, 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, 0), 2.0f }, - { ImGuiKey_Space, "Space", "", 0, ImVec2(3.75, 4), 6.5f }, - { ImGuiKey_Enter, "Enter", "", 0, ImVec2(12, 2), 2.25f}, - { ImGuiKey_Escape, "Esc", "", 1, ImVec2(0, 0), 1.0f }, - { ImGuiKey_LeftCtrl, "Ctrl", "", 0, ImVec2(0, 4), 1.25f }, - { ImGuiKey_LeftShift, "Shift", "", 0, ImVec2(0, 3), 2.5f }, - { ImGuiKey_LeftAlt, "Alt", "", 0, ImVec2(1.25, 4), 1.25 }, - { ImGuiKey_LeftSuper, "Sp", "", 0, ImVec2(2.5, 4), 1.25f }, - { ImGuiKey_RightCtrl, "Ctrl", "", 0, ImVec2(13.75, 4), 1.25f }, - { ImGuiKey_RightShift, "Shift", "", 0, ImVec2(11, 3), 2.5f }, - { ImGuiKey_RightAlt, "Alt", "", 0, ImVec2(11.25, 4), 1.25 }, - { ImGuiKey_RightSuper, "Sp", "", 0, ImVec2(10.25, 4), 1.0f }, - { ImGuiKey_Menu, "Menu", "", 0, ImVec2(12.5, 4), 1.25 }, - { 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(3, 1), 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(8, 1), 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(9, 1), 1.0f }, - { ImGuiKey_P, "p", "P", 0, ImVec2(10, 1), 1.0f }, - { ImGuiKey_Q, "q", "Q", 0, ImVec2(1, 1), 1.0f }, - { ImGuiKey_R, "r", "R", 0, ImVec2(4, 1), 1.0f }, - { ImGuiKey_S, "s", "S", 0, ImVec2(2, 2), 1.0f }, - { ImGuiKey_T, "t", "T", 0, ImVec2(5, 1), 1.0f }, - { ImGuiKey_U, "u", "U", 0, ImVec2(7, 1), 1.0f }, - { ImGuiKey_V, "v", "V", 0, ImVec2(4, 3), 1.0f }, - { ImGuiKey_W, "w", "W", 0, ImVec2(2, 1), 1.0f }, - { ImGuiKey_X, "x", "X", 0, ImVec2(2, 3), 1.0f }, - { ImGuiKey_Y, "y", "Y", 0, ImVec2(6, 1), 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, "'", "\"", 0, ImVec2(11, 2), 1.0f }, - { ImGuiKey_Comma, ",", "<", 0, ImVec2(8, 3), 1.0f }, - { ImGuiKey_Minus, "-", "_", 0, ImVec2(11, 0), 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, 0), 1.0f }, - { ImGuiKey_LeftBracket, "[", "{", 0, ImVec2(11, 1), 1.0f }, - { ImGuiKey_Backslash, "\\","|", 0, ImVec2(13, 1), 1.5f }, - { ImGuiKey_RightBracket,"]", "}", 0, ImVec2(12, 1), 1.0f }, - { ImGuiKey_GraveAccent, "`", "~", 0, ImVec2(0, 0), 1.0f }, - { ImGuiKey_CapsLock, "Caps", "", 0, ImVec2(0, 2), 1.75f }, - { ImGuiKey_ScrollLock, "\0", "", 0, ImVec2(0, 0), 1.0f }, // unused - { ImGuiKey_NumLock, "\0", "", 0, ImVec2(0, 0), 1.0f }, // - { ImGuiKey_PrintScreen, "\0", "", 0, ImVec2(0, 0), 1.0f }, // - { ImGuiKey_Pause, "\0", "", 0, ImVec2(0, 0), 1.0f }, // - { ImGuiKey_Keypad0, "0", "", 3, ImVec2(0, 4), 2.0f }, - { ImGuiKey_Keypad1, "1", "", 3, ImVec2(0, 3), 1.0f }, - { ImGuiKey_Keypad2, "2", "", 3, ImVec2(1, 3), 1.0f }, - { ImGuiKey_Keypad3, "3", "", 3, ImVec2(2, 3), 1.0f }, - { ImGuiKey_Keypad4, "4", "", 3, ImVec2(0, 2), 1.0f }, - { ImGuiKey_Keypad5, "5", "", 3, ImVec2(1, 2), 1.0f }, - { ImGuiKey_Keypad6, "6", "", 3, ImVec2(2, 2), 1.0f }, - { ImGuiKey_Keypad7, "7", "", 3, ImVec2(0, 1), 1.0f }, - { ImGuiKey_Keypad8, "8", "", 3, ImVec2(1, 1), 1.0f }, - { ImGuiKey_Keypad9, "9", "", 3, ImVec2(2, 1), 1.0f }, - { ImGuiKey_KeypadDecimal, ".", "", 3, ImVec2(2, 4), 1.0f }, - { ImGuiKey_KeypadDivide, "/", "", 3, ImVec2(1, 0), 1.0f }, - { ImGuiKey_KeypadMultiply, "*", "", 3, ImVec2(2, 0), 1.0f }, - { ImGuiKey_KeypadSubtract, "-", "", 3, ImVec2(3, 0), 1.0f }, - { ImGuiKey_KeypadAdd, "+", "", 3, ImVec2(3, 1), -2.0f }, // long keys! - { ImGuiKey_KeypadEnter, "Ent", "", 3, ImVec2(3, 3), -2.0f }, - { ImGuiKey_KeypadEqual, "", "", 3, ImVec2(0, 0), 1.0f } // unused -}; - -enum key_mode { - key_mode_all, - key_mode_viewport, - key_mode_timeline, - key_mode_graph, - key_mode_brush, -}; - -static char *Modes[] = { - "All", - "Viewport", - "Timeline", - "Graph", - "Brush" -}; - -struct shortcut_entry { - ImGuiKey_ Key; - ImGuiModFlags_ Mods; - key_mode Mode; - char *Name; -}; - -static shortcut_entry ShortcutArray[] { - { ImGuiKey_None, ImGuiModFlags_None, key_mode_all, "Many actions/modes are escapable with the Esc key." }, - { ImGuiKey_None, ImGuiModFlags_None, key_mode_all, "Undo isn't fully implemented yet; beware crashes." }, - { ImGuiKey_Q, ImGuiModFlags_None, key_mode_all, "Quit (instantly!)" }, - { ImGuiKey_W, ImGuiModFlags_None, key_mode_all, "Step back one frame" }, - { ImGuiKey_E, ImGuiModFlags_None, key_mode_all, "Step forward one frame" }, - { ImGuiKey_V, ImGuiModFlags_None, key_mode_all, "Move tool" }, - { ImGuiKey_B, ImGuiModFlags_None, key_mode_all, "Brush tool" }, - { ImGuiKey_Space, ImGuiModFlags_None, key_mode_all, "Play scene" }, - { ImGuiKey_Delete, ImGuiModFlags_None, key_mode_all, "Delete selection (WIP)" }, - { ImGuiKey_S, ImGuiModFlags_None, key_mode_all, "Save" }, - { ImGuiKey_S, ImGuiModFlags_Shift, key_mode_all, "Save as" }, - { ImGuiKey_C, ImGuiModFlags_None, key_mode_all, "Copy" }, - { ImGuiKey_P, ImGuiModFlags_None, key_mode_all, "Paste" }, - { ImGuiKey_Z, ImGuiModFlags_None, key_mode_all, "Undo" }, - { ImGuiKey_Z, ImGuiModFlags_Shift, key_mode_all, "Redo" }, - - { ImGuiKey_None, ImGuiModFlags_None, key_mode_viewport, "Hold right click to pan." }, - { ImGuiKey_None, ImGuiModFlags_None, key_mode_viewport, "Hold Z and drag left click to zoom." }, - { ImGuiKey_None, ImGuiModFlags_None, key_mode_viewport, "Press Enter or ctrl+click to commit a transform." }, - { ImGuiKey_T, ImGuiModFlags_None, key_mode_viewport, "Transform selected layers" }, - - { ImGuiKey_Tab, ImGuiModFlags_None, key_mode_timeline, "Switch between timeline and graph" }, - { ImGuiKey_2, ImGuiModFlags_None, key_mode_timeline, "Toggle precomp view" }, - { ImGuiKey_G, ImGuiModFlags_None, key_mode_timeline, "Toggle position keyframes" }, - { ImGuiKey_A, ImGuiModFlags_None, key_mode_timeline, "Toggle anchor point keyframes" }, - { ImGuiKey_R, ImGuiModFlags_None, key_mode_timeline, "Toggle roation keyframes" }, - { ImGuiKey_S, ImGuiModFlags_None, key_mode_timeline, "Toggle scale keyframes" }, - { ImGuiKey_T, ImGuiModFlags_None, key_mode_timeline, "Toggle time remapping keyframes" }, - { ImGuiKey_T, ImGuiModFlags_Shift, key_mode_timeline, "Toggle opacity keyframes" }, - { ImGuiKey_B, ImGuiModFlags_None, key_mode_timeline, "Mark frame start" }, - { ImGuiKey_N, ImGuiModFlags_None, key_mode_timeline, "Mark frame end" }, - - { ImGuiKey_G, ImGuiModFlags_None, key_mode_graph, "Enter keyframe moving mode" }, - { ImGuiKey_X, ImGuiModFlags_None, key_mode_graph, "Constrain to X axis" }, - { ImGuiKey_Y, ImGuiModFlags_None, key_mode_graph, "Constrain to Y axis" }, - - { ImGuiKey_None, ImGuiModFlags_None, key_mode_brush, "Hold alt and drag to adjust size/hardness." }, - { ImGuiKey_X, ImGuiModFlags_None, key_mode_brush, "Swap FG and BG colors" }, -}; - -static ImVec2 SectorOffset[4] = { ImVec2(0, 1.5), ImVec2(0, 0) , ImVec2(15.5, 1.5), ImVec2(19, 1.5) }; +#include "keybinds.h" static void ImGui_Key_GetUIInfo(key_entry KeyEntry, real32 KeySize, ImVec2 *Offset_ScreenPos, ImVec2 *KeyScreenSize) { @@ -2520,6 +2346,113 @@ ImGui_Key_GetUIInfo(key_entry KeyEntry, real32 KeySize, ImVec2 *Offset_ScreenPos } static void +ImGui_KeybindUI(project_data *File, project_state *State, ui *UI, memory *Memory, ImGuiIO io) +{ + real32 KeySize = ImGui::GetFontSize()*2; + real32 KeyboardWidth = KeySize * 23.5; + real32 KeyboardHeight = KeySize * 7; + ImVec2 WindowSize = ImGui::GetWindowSize(); + ImVec2 WindowMinAbs = ImGui::GetWindowPos(); + ImVec2 WindowMaxAbs = WindowMinAbs + WindowSize; + ImVec2 KeyboardPos((WindowSize.x - KeyboardWidth) / 2, KeySize*2); + ImDrawList* draw_list = ImGui::GetWindowDrawList(); + ImVec2 SectorOffset[4] = { ImVec2(0, 1.25), ImVec2(0,0), ImVec2(15.25, 1.25), ImVec2(19.5, 1.25) }; + + ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(190, 0, 50, 180)); + if (ImGui::Button("X")) + ImGui::CloseCurrentPopup(); + ImGui::PopStyleColor(); + + State->Split_KeybindUI.Split(draw_list, 2); + State->Split_KeybindUI.SetCurrentChannel(draw_list, 1); + + // keyboard + ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 180)); + for (int k = 0; k < AmountOf(KeyEntries); k++) { + key_entry KeyEntry = KeyEntries[k]; + ImVec2 Offset_ScreenPos(0,0); + ImVec2 KeyScreenSize(0,0); + ImGui_Key_GetUIInfo(KeyEntry, KeySize, &Offset_ScreenPos, &KeyScreenSize); + if (KeyEntry.Name[0] != '\0') { + ImGui::PushID(k); + ImGui::SetCursorScreenPos(WindowMinAbs + KeyboardPos + Offset_ScreenPos); + ImGui::Button(KeyEntry.Name, KeyScreenSize); + ImGui::PopID(); + } + } + ImGui::PopStyleColor(); + + State->Split_KeybindUI.SetCurrentChannel(draw_list, 0); + + // list + ImVec2 SubwindowMinPos(WindowMinAbs + KeyboardPos + ImVec2(0, KeyboardHeight + KeySize)); + ImVec2 SubwindowSize(KeyboardWidth, WindowSize.y - KeyboardHeight - KeySize*4); + ImGui::SetCursorScreenPos(SubwindowMinPos); + ImGui::BeginChild("Keybinds info", SubwindowSize); + key_mode CurrentKeyMode = (key_mode)9999; + for (int a = 0; a < AmountOf(ShortcutArray); a++) { + shortcut_entry ShortcutEntry = ShortcutArray[a]; + + // header info + if (CurrentKeyMode != ShortcutEntry.Mode) { + ImGui::Dummy(ImVec2(1, KeySize)); + CurrentKeyMode = ShortcutEntry.Mode; + ImVec2 Size = ImGui::CalcTextSize(KeyModeTitles[CurrentKeyMode]); + ImGui::SetCursorPosX(((SubwindowSize.x / 2) - (Size.x / 2))); + ImGui::Text(KeyModeTitles[CurrentKeyMode]); + ImGui::SetCursorPosX((SubwindowSize.x / 2) - (ImGui::CalcTextSize("-----").x / 2)); + ImGui::TextColored(ImColor(UI->LayerColors[CurrentKeyMode]), "-----"); + ImGui::Dummy(ImVec2(1, KeySize/4)); + while (ShortcutEntry.Key == ImGuiKey_None) { + ImVec2 Size = ImGui::CalcTextSize(ShortcutEntry.Name); + ImGui::SetCursorPosX(((SubwindowSize.x / 2) - (Size.x / 2))); + ImGui::Text(ShortcutEntry.Name); + a++; + ShortcutEntry = ShortcutArray[a]; + } + ImGui::Dummy(ImVec2(1, KeySize/2)); + } + + // shortcut text + key + Assert(ShortcutEntry.Key != ImGuiKey_None); + key_entry KeyEntry = KeyEntries[ShortcutEntry.Key - ImGuiKey_Tab]; + real32 Padding = KeySize; + ImGui::Dummy(ImVec2(Padding, 1)); + ImGui::SameLine(); + ImGui::Text(ShortcutEntry.Name); + ImGui::SameLine(); + char buf[64]; + if (ShortcutEntry.Mods == Mod_None) { + sprintf(buf, "%s", KeyEntry.Name); + } else if (ShortcutEntry.Mods == Mod_Shift) { + sprintf(buf, "%s", KeyEntry.ShiftName); + } else { + sprintf(buf, "%s + %s", KeyModText[ShortcutEntry.Mods], KeyEntry.Name); + } + ImVec2 Size = ImGui::CalcTextSize(buf); + ImGui::SetCursorPosX(SubwindowSize.x - Size.x - Padding*1.5); + ImGui::Text(buf); + + // indicator on keyboard + ImVec2 Offset_ScreenPos(0,0); + ImVec2 KeyScreenSize(0,0); + ImGui_Key_GetUIInfo(KeyEntry, KeySize, &Offset_ScreenPos, &KeyScreenSize); + real32 ModeSliverSize = KeySize / key_mode_count; + Offset_ScreenPos.x += (ShortcutEntry.Mode * ModeSliverSize); + KeyScreenSize = ImVec2(ModeSliverSize, KeyScreenSize.y); + ImVec2 MinPos = WindowMinAbs + KeyboardPos + Offset_ScreenPos; + draw_list->AddRectFilled(MinPos, MinPos + KeyScreenSize, UI->LayerColors[CurrentKeyMode]); + } + ImGui::EndChild(); + if (ImGui::IsKeyPressed(ImGuiKey_Escape)) { + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + + State->Split_KeybindUI.Merge(draw_list); +} + +static void ImGui_Popups(project_data *File, project_state *State, ui *UI, memory *Memory, ImGuiIO io) { switch (State->ImGuiPopups) @@ -2530,20 +2463,12 @@ ImGui_Popups(project_data *File, project_state *State, ui *UI, memory *Memory, I case popup_saveas: { ImGui::OpenPopup("Save as"); - ImVec2 Size(300, 300); - ImGuiViewport *Viewport = ImGui::GetMainViewport(); - ImGui::SetNextWindowPos(Viewport->GetCenter(), 0, ImVec2(0.5, 0.5)); - ImGui::SetNextWindowSize(Size); ImGui::SetKeyboardFocusHere(); State->SetFocus = 0; } break; case popup_keybinds: { ImGui::OpenPopup("Keybinds"); - ImVec2 Size(500, 800); - ImGuiViewport *Viewport = ImGui::GetMainViewport(); - ImGui::SetNextWindowPos(Viewport->GetCenter(), 0, ImVec2(0.5, 0.5)); - ImGui::SetNextWindowSize(Size); ImGui::SetKeyboardFocusHere(); State->SetFocus = 0; } break; @@ -2568,34 +2493,7 @@ ImGui_Popups(project_data *File, project_state *State, ui *UI, memory *Memory, I ImGui::EndPopup(); } if (ImGui::BeginPopupModal("Keybinds")) { - real32 KeySize = ImGui::GetFontSize()*2; - ImVec2 WindowSize = ImGui::GetWindowSize(); - ImVec2 WindowMinAbs = ImGui::GetWindowPos(); - ImVec2 WindowMaxAbs = WindowMinAbs + WindowSize; - ImDrawList* draw_list = ImGui::GetWindowDrawList(); - ImVec2 SectorOffset[4] = { ImVec2(0, 1.25), ImVec2(0,0), ImVec2(15.25, 1.25), ImVec2(19.5, 1.25) }; - for (int k = 0; k < AmountOf(KeyEntries); k++) { - key_entry KeyEntry = KeyEntries[k]; - ImVec2 Offset_ScreenPos(0,0); - ImVec2 KeyScreenSize(0,0); - ImGui_Key_GetUIInfo(KeyEntry, KeySize, &Offset_ScreenPos, &KeyScreenSize); - if (KeyEntry.Name[0] != '\0') { - ImGui::PushID(k); - ImGui::SetCursorScreenPos(ImVec2(KeySize*2, KeySize*2) + WindowMinAbs + Offset_ScreenPos); - ImGui::Button(KeyEntry.Name, KeyScreenSize); - // draw_list->AddRectFilled(WindowMinAbs + Offset_ScreenPos, WindowMinAbs + Offset_ScreenPos + KeyScreenSize, IM_COL32(255, 255, 255, 64)); - ImGui::PopID(); - } - } - for (int a = 0; a < AmountOf(ShortcutArray); a++) { - shortcut_entry ShortcutEntry = ShortcutArray[a]; - key_entry KeyEntry = KeyEntries[ShortcutEntry.Key - ImGuiKey_Tab]; - ImGui::Text(ShortcutEntry.Name); - } - if (ImGui::IsKeyPressed(ImGuiKey_Escape)) { - ImGui::CloseCurrentPopup(); - } - ImGui::EndPopup(); + ImGui_KeybindUI(File, State, UI, Memory, io); } } @@ -2761,10 +2659,10 @@ ImGui_ProcessInputs(project_data *File, project_state *State, ui *UI, memory *Me } #if DEBUG - // if (ImGui::IsKeyPressed(ImGuiKey_3)) - // { - // State->ImGuiPopups = popup_keybinds; - // } + if (ImGui::IsKeyPressed(ImGuiKey_3)) + { + State->ImGuiPopups = popup_keybinds; + } if (ImGui::IsKeyPressed(ImGuiKey_F)) { sprintf(State->DummyName, "test2"); @@ -2935,7 +2833,7 @@ ImGui_EffectsPanel(project_data *File, project_state *State, memory *Memory, ui static char ImGuiPrefs[] = "[Window][DockSpaceViewport_11111111]\n" "Pos=0,0\n" -"Size=2133,1333\n" +"Size=3840,2160\n" "Collapsed=0\n" "\n" "[Window][Debug##Default]\n" @@ -2945,37 +2843,37 @@ static char ImGuiPrefs[] = "[Window][DockSpaceViewport_11111111]\n" "\n" "[Window][Viewport]\n" "Pos=443,34\n" -"Size=1165,738\n" +"Size=2872,1565\n" "Collapsed=0\n" "DockId=0x00000010,0\n" "\n" "[Window][###Properties]\n" "Pos=0,34\n" -"Size=441,738\n" +"Size=441,1565\n" "Collapsed=0\n" "DockId=0x0000000B,0\n" "\n" "[Window][Timeline]\n" -"Pos=0,774\n" -"Size=2133,559\n" +"Pos=0,1601\n" +"Size=3840,559\n" "Collapsed=0\n" "DockId=0x0000000A,0\n" "\n" "[Window][Dear ImGui Demo]\n" -"Pos=1610,34\n" -"Size=523,267\n" +"Pos=2677,34\n" +"Size=523,437\n" "Collapsed=0\n" "DockId=0x00000011,1\n" "\n" "[Window][Files]\n" -"Pos=1610,303\n" -"Size=523,469\n" +"Pos=3317,604\n" +"Size=523,743\n" "Collapsed=0\n" "DockId=0x00000007,0\n" "\n" "[Window][Effects list]\n" -"Pos=2677,1047\n" -"Size=523,192\n" +"Pos=3317,1349\n" +"Size=523,250\n" "Collapsed=0\n" "DockId=0x00000008,0\n" "\n" @@ -2986,9 +2884,10 @@ static char ImGuiPrefs[] = "[Window][DockSpaceViewport_11111111]\n" "DockId=0x00000009,0\n" "\n" "[Window][undotree]\n" -"Pos=2114,80\n" -"Size=256,565\n" +"Pos=2677,473\n" +"Size=523,572\n" "Collapsed=0\n" +"DockId=0x00000007,2\n" "\n" "[Window][memoryviewer]\n" "Pos=50,273\n" @@ -3001,8 +2900,8 @@ static char ImGuiPrefs[] = "[Window][DockSpaceViewport_11111111]\n" "Collapsed=0\n" "\n" "[Window][Memory viewer]\n" -"Pos=1610,303\n" -"Size=523,469\n" +"Pos=2677,473\n" +"Size=523,572\n" "Collapsed=0\n" "DockId=0x00000007,1\n" "\n" @@ -3018,14 +2917,14 @@ static char ImGuiPrefs[] = "[Window][DockSpaceViewport_11111111]\n" "DockId=0x0000000F,0\n" "\n" "[Window][Colors]\n" -"Pos=1610,34\n" -"Size=523,267\n" +"Pos=3317,34\n" +"Size=523,568\n" "Collapsed=0\n" "DockId=0x00000011,0\n" "\n" "[Window][Menu]\n" "Pos=0,0\n" -"Size=2133,32\n" +"Size=3840,32\n" "Collapsed=0\n" "DockId=0x0000000D,0\n" "\n" @@ -3052,8 +2951,13 @@ static char ImGuiPrefs[] = "[Window][DockSpaceViewport_11111111]\n" "DockId=0x0000000C,0\n" "\n" "[Window][Save as]\n" -"Pos=300,800\n" -"Size=300,300\n" +"Pos=1782,1058\n" +"Size=300,116\n" +"Collapsed=0\n" +"\n" +"[Window][Keybinds]\n" +"Pos=1573,769\n" +"Size=750,639\n" "Collapsed=0\n" "\n" "[Table][0x861D378E,3]\n" @@ -3079,7 +2983,7 @@ static char ImGuiPrefs[] = "[Window][DockSpaceViewport_11111111]\n" "Column 2 Weight=1.0000\n" "\n" "[Docking][Data]\n" -"DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,0 Size=2133,1333 Split=Y Selected=0x13926F0B\n" +"DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,0 Size=3840,2160 Split=Y Selected=0x13926F0B\n" " DockNode ID=0x0000000D Parent=0x8B93E3BD SizeRef=3200,32 HiddenTabBar=1 Selected=0xA57AB2C6\n" " DockNode ID=0x0000000E Parent=0x8B93E3BD SizeRef=3200,1299 Split=Y\n" " DockNode ID=0x00000001 Parent=0x0000000E SizeRef=3200,1205 Split=X Selected=0x13926F0B\n" @@ -3098,4 +3002,4 @@ static char ImGuiPrefs[] = "[Window][DockSpaceViewport_11111111]\n" " DockNode ID=0x00000002 Parent=0x0000000E SizeRef=3200,559 Split=Y Selected=0x0F18B61B\n" " DockNode ID=0x00000009 Parent=0x00000002 SizeRef=3250,526 Selected=0xA1F22F4D\n" " DockNode ID=0x0000000A Parent=0x00000002 SizeRef=3250,323 HiddenTabBar=1 Selected=0x0F18B61B\n" -"\n"; +"\0"; diff --git a/prenderer.cpp b/prenderer.cpp index 76e76cf..cf5990e 100644 --- a/prenderer.cpp +++ b/prenderer.cpp @@ -51,41 +51,6 @@ Layer_GetDimensions(memory *Memory, block_layer *Layer, int *Width, int *Height) } } -// static v2 -// Layer_SlowTreeTraverse(project_data *File, memory *Memory, block_layer *Layer, v2 Point) -// { -// } - -/* -static v2 -Layer_Transform_ScreenSpaceToLocal_Recurse(project_data *File, memory *Memory, block_layer *Layer, v2 Point) -{ - uint32 Recurse[4]; - real32 Idx = 0; - Recurse[0] = Idx = Layer->Block_Composition_Index; - v2 LayerUV = Point; - int i = 1; - do { - // block_layer *OuterLayer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, Idx); - block_composition *Comp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, Idx); - Recurse[i++] = Idx; - Idx = OuterLayer->Block_Composition_Index; - } while (Idx != File->PrincipalCompIndex); - for (int a = i-2; a >= 0; a--) { - block_layer *OuterLayer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, Recurse[a-1]); - int OuterWidth = 0, OuterHeight = 0; - Layer_GetDimensions(Memory, OuterLayer, &OuterWidth, &OuterHeight); - layer_transforms T = Layer_GetTransforms(OuterLayer); - block_layer *InnerLayer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, Recurse[a]); - int InnerWidth = 0, InnerHeight = 0; - Layer_GetDimensions(Memory, InnerLayer, &InnerWidth, &InnerHeight); - LayerUV = T_CompUVToLayerUV(T, OuterWidth, OuterHeight, InnerWidth, InnerHeight, LayerUV); - } - // return V2(LayerUV.x * SourceWidth, LayerUV.y * SourceHeight); - return V2(LayerUV.x, LayerUV.y); -} -*/ - // Transform given data based on state's Interact data. static void Transform_ApplyInteractive(interact_transform Interact, real32 *OutputX, real32 *OutputY, real32 *OutputRotation, real32 *OutputScale) @@ -284,7 +249,7 @@ Layer_LocalToScreenSpace(project_state *State, memory *Memory, block_layer *Laye layer_transforms T = Layer_GetTransforms(Layer); - if (State->Interact_Active == interact_type_viewport_transform && Layer->IsSelected) { + if (State->Interact_Active == interact_type_viewport_transform && Layer->IsSelected == 1) { Transform_ApplyInteractive(*(interact_transform *)&State->Interact_Offset[0], &T.x, &T.y, &T.rotation, &T.scale); } @@ -385,7 +350,7 @@ Transform_Calculate(project_state *State, memory *Memory, project_data *File, bl real32 s = Layer->scale.CurrentValue; blend_mode BlendMode = Layer->BlendMode; - if (State->Interact_Active == interact_type_viewport_transform && Layer->IsSelected) { + if (State->Interact_Active == interact_type_viewport_transform && Layer->IsSelected == 1) { Transform_ApplyInteractive(*(interact_transform *)&State->Interact_Offset[0], &X, &Y, &Rotation, &s); } |