summaryrefslogtreecommitdiff
path: root/my_imgui_widgets.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'my_imgui_widgets.cpp')
-rw-r--r--my_imgui_widgets.cpp67
1 files changed, 49 insertions, 18 deletions
diff --git a/my_imgui_widgets.cpp b/my_imgui_widgets.cpp
index 70d4ffc..5bc78bd 100644
--- a/my_imgui_widgets.cpp
+++ b/my_imgui_widgets.cpp
@@ -4,9 +4,9 @@
#include "imgui_helper_widgets.cpp"
static void
-ImGui_InteractSliderProperty(project_state *State, memory *Memory, property_channel *Property)
+ImGui_InteractSliderProperty(project_state *State, memory *Memory, property_channel *Property, char *Name)
{
- ImGui::DragScalar(Property->Name, ImGuiDataType_Float, &Property->CurrentValue,
+ ImGui::DragScalar(Name, ImGuiDataType_Float, &Property->CurrentValue,
Property->ScrubVal, &Property->MinVal, &Property->MaxVal, "%f");
if (ImGui::IsItemActive()) {
State->UpdateFrame = true;
@@ -59,7 +59,8 @@ ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory *
History_Entry_End(Memory);
}
ImGui::SameLine();
- ImGui_InteractSliderProperty(State, Memory, Property);
+ char *Name = DefaultChannel[h];
+ ImGui_InteractSliderProperty(State, Memory, Property, Name);
ImGui::PopID();
}
for (int i = 0; i < Layer->Block_Effect_Count; i++)
@@ -75,7 +76,7 @@ ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory *
property_channel *Property = (property_channel *)Memory_Block_AddressAtIndex(Memory, F_Properties, Effect.Block_Property_Index[c]);
ImGui::PushID(Property);
if (ChannelHeader.DisplayType == property_display_type_standard) {
- ImGui_InteractSliderProperty(State, Memory, Property);
+ ImGui_InteractSliderProperty(State, Memory, Property, ChannelHeader.Name);
} else if (ChannelHeader.DisplayType == property_display_type_color) {
property_channel *Property1 = (property_channel *)Memory_Block_AddressAtIndex(Memory, F_Properties, Effect.Block_Property_Index[c+1]);
property_channel *Property2 = (property_channel *)Memory_Block_AddressAtIndex(Memory, F_Properties, Effect.Block_Property_Index[c+2]);
@@ -326,20 +327,32 @@ ImGui_SD_Thumbnail(project_data *File, project_state *State, ui *UI, memory *Mem
// ImGui::Text("Count: %i", Source->RelativeTimestamp);
real32 Ratio = (real32)Source->Width / Source->Height;
uint32 T_Width = (uint32)(Ratio * T_Height);
- ImVec2 ImgMin = ViewportMin + ImVec2(X * UI_Size, Y * UI_Size);
- ImVec2 ImgMax = ImgMin + ImVec2(UI_Size * Ratio, UI_Size);
if (Source->ThumbnailTex == 0) {
Source_DumpThumbnail(Memory, Source, T_Width, T_Height);
}
// draw_list->AddRect(ImgMin, ImgMax, IM_COL32(255, 255, 255, 64));
+ ImVec2 ImgMin = ViewportMin + ImVec2(X * UI_Size, Y * UI_Size);
ImGui::SetCursorScreenPos(ImgMin);
- ImGui::Button("##thumbnail", ImVec2(UI_Size, UI_Size));
- draw_list->AddImage((void *)(intptr_t)Source->ThumbnailTex, ImgMin, ImgMax);
+ real32 ClosestSpacing = 0.2;
+ bool32 Wide = (Source->Width > Source->Height);
+ // ImVec2 Min = (Wide) ? ImVec2(0,ClosestSpacing) : ImVec2(ClosestSpacing,0);
+ // ImVec2 Max = (Wide) ? ImVec2(1-ClosestSpacing,1) : ImVec2(1,1-ClosestSpacing);
+ ImVec2 Min(0.2, 0.2);
+ ImVec2 Max(0.8, 0.8);
+ ImGui::ImageButton((void *)(intptr_t)Source->ThumbnailTex, ImVec2(UI_Size, UI_Size), Min, Max, 12);
+ // ImGui::ImageButton(user_texture_id, & sizeconst ImVec2& = ImVec2(0, 0), = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding
+ // ImVec2 ImgMax = ImgMin + ImVec2(UI_Size * Ratio, UI_Size);
+ // ImGui::Button("##thumbnail", ImVec2(UI_Size, UI_Size));
+ // draw_list->AddImage((void *)(intptr_t)Source->ThumbnailTex, ImgMin, ImgMax);
if (ImGui::IsItemHovered()) {
State->PreviewSource = SourceArray[i];
State->UpdateFrame = true;
Active = true;
+ block_source *Source1 = (block_source *)Memory_Block_AddressAtIndex(Memory, F_Sources, 1);
+ block_source *Source2 = (block_source *)Memory_Block_AddressAtIndex(Memory, F_Sources, 2);
+ block_source *Source0 = (block_source *)Memory_Block_AddressAtIndex(Memory, F_Sources, 0);
+ real32 a = 0;
}
if (ImGui::IsItemClicked() || ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
@@ -1036,7 +1049,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();
@@ -1171,9 +1184,17 @@ ImGui_Viewport(project_data *File, project_state *State, ui *UI, memory *Memory,
}
}
- if (IsActive && ImGui::IsMouseDragging(ImGuiMouseButton_Left, -1.0f) && ImGui::IsKeyDown(ImGuiKey_Z))
+ real32 Distance = 0;
+ if (IsActive) {
+ if (ImGui::IsMouseDragging(ImGuiMouseButton_Left, -1.0f))
+ Distance = io.MouseDelta.x + io.MouseDelta.y;
+ if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
+ Distance = 200;
+ }
+ if (Distance && ImGui::IsKeyDown(ImGuiKey_Z))
{
- real32 Distance = io.MouseDelta.x + io.MouseDelta.y;
+ if (io.KeyShift)
+ 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;
@@ -2375,6 +2396,10 @@ ImGui_ProcessInputs(project_data *File, project_state *State, ui *UI, memory *Me
}
#if DEBUG
+ if (ImGui::IsKeyPressed(ImGuiKey_0))
+ {
+ Debug.ReloadUI ^= 1;
+ }
if (ImGui::IsKeyPressed(ImGuiKey_1))
{
Debug.ToggleWindow ^= 1;
@@ -2447,20 +2472,23 @@ ImGui_Menu(project_data *File, project_state *State, ui *UI, memory *Memory, ImG
PostMsg(State, "File save failed...");
}
}
- /*
- if (ImGui::MenuItem("New project file", "Ctrl+Shift+N"))
- {
- State->ImGuiPopups = popup_newfile;
- }
if (ImGui::BeginMenu("Open file"))
{
ImGui::InputText("Filename", State->DummyName, 512);
if (ImGui::IsItemDeactivated() && ImGui::IsKeyPressed(ImGuiKey_Enter)) {
- File_Open(State, Memory, State->DummyName);
- State->Context[Index].UpdateFrame = true;
+ if (File_Open(File, State, Memory, State->DummyName)) {
+ State->UpdateFrame = true;
+ } else {
+ PostMsg(State, "File not found.");
+ }
}
ImGui::EndMenu();
}
+ /*
+ if (ImGui::MenuItem("New project file", "Ctrl+Shift+N"))
+ {
+ State->ImGuiPopups = popup_newfile;
+ }
if (ImGui::MenuItem("Save as", "Ctrl+Shift+S"))
{
State->ImGuiPopups = popup_saveas;
@@ -3479,6 +3507,9 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, memory *Memory,
if (UI->Initializing) {
UI->CompZoom = ImVec2(CompBuffer.Width, CompBuffer.Height);
+#if DEBUG
+ UI->CompZoom = UI->CompZoom * ImVec(0.5, 0.5);
+#endif
UI->CompPos = ImVec2(ViewportMin.x + ((ViewportMax.x - ViewportMin.x)/2 - UI->CompZoom.x/2),
ViewportMin.y + ((ViewportMax.y - ViewportMin.y)/2 - UI->CompZoom.y/2));
}