diff --git a/src/Navigator.cpp b/src/Navigator.cpp index a567550..d13624b 100644 --- a/src/Navigator.cpp +++ b/src/Navigator.cpp @@ -308,7 +308,6 @@ void Navigator::Render() // the "+" icon for action of creating new source if (ImGui::Selectable( source_to_replace != nullptr ? ICON_FA_PLUS_SQUARE : ICON_FA_PLUS, &selected_button[NAV_NEW], 0, iconsize)) { - Mixer::manager().unsetCurrentSource(); applyButtonSelection(NAV_NEW); } if (ImGui::IsItemHovered()) @@ -909,11 +908,30 @@ void Navigator::RenderNewPannel(const ImVec2 &iconsize) clearNewPannel(); } ImGui::NextColumn(); + static int _previous_new_type = Settings::application.source.new_type; + if (source_to_replace == nullptr) { + if (ImGuiToolkit::SelectableIcon( ICON_SOURCE_GROUP, "##SOURCE_BUNDLE", selected_type[SOURCE_BUNDLE], + iconsize, ImGuiDir_Right)) { + _previous_new_type = Settings::application.source.new_type; + Settings::application.source.new_type = SOURCE_BUNDLE; + ImGui::OpenPopup("SOURCE_BUNDLE_MENU"); + clearNewPannel(); + } + } ImGui::Columns(1); ImGui::PopStyleVar(); ImGui::PopFont(); + // Menu popup for SOURCE_BUNDLE + if (ImGui::BeginPopup("SOURCE_BUNDLE_MENU")) { + UserInterface::manager().showMenuBundle(); + ImGui::EndPopup(); + } + // restore previous type after closing popup + if (Settings::application.source.new_type == SOURCE_BUNDLE && !ImGui::IsPopupOpen("SOURCE_BUNDLE_MENU")) + Settings::application.source.new_type = _previous_new_type; + // Edit menu ImGui::SetCursorPosY(2.f * width_ - style.WindowPadding.x); static bool request_open_shader_editor = false; @@ -1974,15 +1992,17 @@ void Navigator::RenderMainPannelSession() // Preview session // Session *se = Mixer::manager().session(); - float width = preview_width; - float height = se->frame()->projectionSize().y * width / ( se->frame()->projectionSize().x * se->frame()->aspectRatio()); - if (height > preview_height - space) { - height = preview_height - space; - width = height * se->frame()->aspectRatio() * ( se->frame()->projectionSize().x / se->frame()->projectionSize().y); + if (se->frame()) { + float width = preview_width; + float height = se->frame()->projectionSize().y * width / ( se->frame()->projectionSize().x * se->frame()->aspectRatio()); + if (height > preview_height - space) { + height = preview_height - space; + width = height * se->frame()->aspectRatio() * ( se->frame()->projectionSize().x / se->frame()->projectionSize().y); + } + // centered image + ImGui::SetCursorPos( ImVec2(pos.x + 0.5f * (preview_width-width), pos.y) ); + ImGui::Image((void*)(uintptr_t) se->frame()->texture(), ImVec2(width, height)); } - // centered image - ImGui::SetCursorPos( ImVec2(pos.x + 0.5f * (preview_width-width), pos.y) ); - ImGui::Image((void*)(uintptr_t) se->frame()->texture(), ImVec2(width, height)); // right side options for session if (!Mixer::manager().session()->filename().empty()) { @@ -3423,11 +3443,11 @@ void Navigator::RenderMainPannel(const ImVec2 &iconsize) UserInterface::manager().showMenuWindows(); ImGui::EndMenu(); } - ImGui::SetCursorPos( ImVec2( pannel_width_ IMGUI_RIGHT_ALIGN, IMGUI_TOP_ALIGN + 3.f * ImGui::GetTextLineHeightWithSpacing()) ); - if (ImGui::BeginMenu("Bundle")) { - UserInterface::manager().showMenuBundle(); - ImGui::EndMenu(); - } + // ImGui::SetCursorPos( ImVec2( pannel_width_ IMGUI_RIGHT_ALIGN, IMGUI_TOP_ALIGN + 3.f * ImGui::GetTextLineHeightWithSpacing()) ); + // if (ImGui::BeginMenu("Bundle")) { + // UserInterface::manager().showMenuBundle(); + // ImGui::EndMenu(); + // } // // Panel content diff --git a/src/Navigator.h b/src/Navigator.h index 96c214f..bc04fea 100644 --- a/src/Navigator.h +++ b/src/Navigator.h @@ -82,7 +82,8 @@ public: SOURCE_FILE = 0, SOURCE_SEQUENCE, SOURCE_CONNECTED, - SOURCE_GENERATED + SOURCE_GENERATED, + SOURCE_BUNDLE } NewSourceType; Navigator(); diff --git a/src/Toolkit/ImGuiToolkit.cpp b/src/Toolkit/ImGuiToolkit.cpp index 8f59062..aece3f3 100644 --- a/src/Toolkit/ImGuiToolkit.cpp +++ b/src/Toolkit/ImGuiToolkit.cpp @@ -617,7 +617,7 @@ bool ImGuiToolkit::ComboIcon (const char* label, int* current_item, return ret; } -bool ImGuiToolkit::SelectableIcon(int i, int j, const char* label, bool selected, const ImVec2 &size_arg) +bool ImGuiToolkit::SelectableIcon(int i, int j, const char* label, bool selected, const ImVec2 &size_arg, ImGuiDir dir) { ImGuiContext& g = *GImGui; ImVec2 draw_pos = ImGui::GetCursorScreenPos() - g.Style.FramePadding * 0.5; @@ -640,6 +640,13 @@ bool ImGuiToolkit::SelectableIcon(int i, int j, const char* label, bool selected // overlay of icon on top of first item _drawIcon(draw_pos, i, j); + // draw arrow + if (dir != ImGuiDir_None) { + draw_pos += size_arg - ImVec2( g.FontSize - g.Style.ItemInnerSpacing.x, g.FontSize - g.Style.ItemInnerSpacing.y); + ImGui::RenderArrow(ImGui::GetCurrentWindow()->DrawList, draw_pos, + ImGui::GetColorU32(ImGuiCol_Text), dir, 0.6f); + } + ImGui::PopID(); return ret; diff --git a/src/Toolkit/ImGuiToolkit.h b/src/Toolkit/ImGuiToolkit.h index 5494e92..9e0058d 100644 --- a/src/Toolkit/ImGuiToolkit.h +++ b/src/Toolkit/ImGuiToolkit.h @@ -32,7 +32,7 @@ namespace ImGuiToolkit bool ButtonIconMultistate (std::vector > icons, int* state, std::vector tooltips); bool BeginMenuIcon(int i, int j, const char *label, bool enabled = true); bool MenuItemIcon (int i, int j, const char* label, const char* shortcut = nullptr, bool selected = false, bool enabled = true); - bool SelectableIcon(int i, int j, const char* label, bool selected, const ImVec2& size_arg = ImVec2(0,0)); + bool SelectableIcon(int i, int j, const char* label, bool selected, const ImVec2& size_arg = ImVec2(0,0), ImGuiDir dir = ImGuiDir_None); bool ComboIcon (const char* label, int* current_item, std::vector > items, std::vector tooltips = {}); // buttons diff --git a/src/UserInterfaceManager.cpp b/src/UserInterfaceManager.cpp index 482bddb..a417f8c 100644 --- a/src/UserInterfaceManager.cpp +++ b/src/UserInterfaceManager.cpp @@ -1085,28 +1085,33 @@ void UserInterface::showMenuEdit() } void UserInterface::showMenuBundle() -{ +{ + ImGui::MenuItem("Create bundle with:", NULL, false, false); + bool is_bundle = false; - if (Mixer::manager().currentSource() != nullptr) + bool is_clone = false; + if (Mixer::manager().currentSource() != nullptr){ is_bundle = Mixer::manager().currentSource()->icon() == glm::ivec2(ICON_SOURCE_GROUP); + is_clone = Mixer::manager().currentSource()->cloned() || Mixer::manager().currentSource()->icon() == glm::ivec2(ICON_SOURCE_CLONE); + } if (ImGuiToolkit::MenuItemIcon(11, 2, " Current source", NULL, false, - Mixer::manager().currentSource() != nullptr && !is_bundle)) { + Mixer::manager().currentSource() != nullptr && !is_bundle && !is_clone)) { Mixer::manager().groupCurrent(); // switch pannel to show first source (created) - navigator.showPannelSource(0); + navigator.showPannelSource(Mixer::manager().indexCurrentSource()); } - if (ImGuiToolkit::MenuItemIcon(11, 2, " Selection", NULL, false, + if (ImGuiToolkit::MenuItemIcon(11, 2, " Selected sources", NULL, false, Mixer::manager().selectionCanBeGroupped())) { Mixer::manager().groupSelection(); // switch pannel to show first source (created) - navigator.showPannelSource(0); + navigator.showPannelSource(Mixer::manager().indexCurrentSource()); } if (ImGuiToolkit::MenuItemIcon(11, 2, " All active sources", NULL, false, Mixer::manager().numSource() > 0)) { // create a new group session with only active sources Mixer::manager().groupAll( true ); // switch pannel to show first source (created) - navigator.showPannelSource(0); + navigator.showPannelSource(Mixer::manager().indexCurrentSource()); } if (ImGuiToolkit::MenuItemIcon(11, 2, " Everything", NULL, false, Mixer::manager().numSource() > 0)) { @@ -1116,16 +1121,16 @@ void UserInterface::showMenuBundle() navigator.showPannelSource(0); } ImGui::Separator(); - if (ImGuiToolkit::MenuItemIcon(7, 2, " Uncover bundle", NULL, false, + if (ImGuiToolkit::MenuItemIcon(7, 2, " Uncover selected bundle", NULL, false, is_bundle)) { // import sourses of bundle Mixer::manager().import( dynamic_cast(Mixer::manager().currentSource()) ); } - // if (ImGuiToolkit::MenuItemIcon(7, 2, " Uncover all", NULL, false, - // Mixer::manager().numSource() > 0)) { - // // ungroup all bundle sources - // Mixer::manager().ungroupAll(); - // } + if (ImGuiToolkit::MenuItemIcon(7, 2, " Uncover every bundles", NULL, false, + Mixer::manager().numSource() > 0)) { + // ungroup all bundle sources + Mixer::manager().ungroupAll(); + } } void UserInterface::showMenuWindows()