diff --git a/ImGuiToolkit.cpp b/ImGuiToolkit.cpp index 2dd5fd9..92fa12e 100644 --- a/ImGuiToolkit.cpp +++ b/ImGuiToolkit.cpp @@ -801,7 +801,7 @@ void ImGuiToolkit::ShowStats(bool *p_open, int* p_corner) ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background - if (ImGui::Begin("v-mix statistics", NULL, (corner != -1 ? ImGuiWindowFlags_NoMove : 0) | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav)) + if (ImGui::Begin("Metrics", NULL, (corner != -1 ? ImGuiWindowFlags_NoMove : 0) | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav)) { ImGuiToolkit::PushFont(ImGuiToolkit::FONT_MONO); diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index c31ca7b..000c2d4 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -1553,6 +1553,8 @@ Navigator::Navigator() padding_width_ = 100; // clean start + pannel_visible_ = false; + view_pannel_visible = false; clearButtonSelection(); } @@ -1574,7 +1576,6 @@ void Navigator::clearButtonSelection() selected_button[i] = false; // clear new source pannel - sprintf(file_browser_path_, " "); new_source_preview_.setSource(); pattern_type = -1; } @@ -1606,6 +1607,7 @@ void Navigator::hidePannel() { clearButtonSelection(); pannel_visible_ = false; + view_pannel_visible = false; } void Navigator::Render() @@ -1699,22 +1701,29 @@ void Navigator::Render() { bool selected_view[View::INVALID] = { }; selected_view[ Settings::application.current_view ] = true; + int previous_view = Settings::application.current_view; if (ImGui::Selectable( ICON_FA_BULLSEYE, &selected_view[1], 0, iconsize)) { Mixer::manager().setView(View::MIXING); + view_pannel_visible = previous_view == Settings::application.current_view; } if (ImGui::Selectable( ICON_FA_OBJECT_UNGROUP , &selected_view[2], 0, iconsize)) { Mixer::manager().setView(View::GEOMETRY); + view_pannel_visible = previous_view == Settings::application.current_view; } if (ImGui::Selectable( ICON_FA_IMAGES, &selected_view[3], 0, iconsize)) { Mixer::manager().setView(View::LAYER); + view_pannel_visible = previous_view == Settings::application.current_view; } } ImGui::End(); + if ( view_pannel_visible && !pannel_visible_ ) + RenderViewPannel( ImVec2(width_, sourcelist_height_), ImVec2(width_, height_ - sourcelist_height_) ); + ImGui::PopStyleVar(); ImGui::PopFont(); @@ -1739,12 +1748,49 @@ void Navigator::Render() { RenderSourcePannel(Mixer::manager().currentSource()); } + view_pannel_visible = false; } ImGui::PopStyleColor(2); ImGui::PopStyleVar(); } + +void Navigator::RenderViewPannel(ImVec2 draw_pos , ImVec2 draw_size) +{ + ImGui::SetNextWindowPos( draw_pos, ImGuiCond_Always ); + ImGui::SetNextWindowSize( draw_size, ImGuiCond_Always ); + ImGui::SetNextWindowBgAlpha(0.95f); // Transparent background + if (ImGui::Begin("##ViewPannel", NULL, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav)) + { + bool dumm = true; + ImGui::SetCursorPosX(10.f); + ImGui::SetCursorPosY(10.f); + if (ImGuiToolkit::IconToggle(4,7,5,7, &dumm)) { + // reset zoom + Mixer::manager().view((View::Mode)Settings::application.current_view)->recenter(); + } + + draw_size.x *= 0.5; + ImGui::SetCursorPosX( 10.f); + draw_size.y -= ImGui::GetCursorPosY() + 10.f; + int percent_zoom = Mixer::manager().view((View::Mode)Settings::application.current_view)->size(); + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.14, 0.14, 0.14, 0.95)); + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(0.1, 0.1, 0.1, 0.95)); + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(0.1, 0.1, 0.1, 0.95)); + ImGui::PushStyleColor(ImGuiCol_SliderGrab, ImVec4(0.9, 0.9, 0.9, 0.95)); + if (ImGui::VSliderInt("##z", draw_size, &percent_zoom, 0, 100, "") ) + { + Mixer::manager().view((View::Mode)Settings::application.current_view)->resize(percent_zoom); + } + ImGui::PopStyleColor(4); + if (ImGui::IsItemActive() || ImGui::IsItemHovered()) + ImGui::SetTooltip("Zoom %d %%", percent_zoom); + ImGui::End(); + } + +} + // Source pannel : *s was checked before void Navigator::RenderSourcePannel(Source *s) { diff --git a/UserInterfaceManager.h b/UserInterfaceManager.h index e5f7eb9..ad9c7fa 100644 --- a/UserInterfaceManager.h +++ b/UserInterfaceManager.h @@ -41,6 +41,7 @@ class Navigator // behavior pannel bool pannel_visible_; + bool view_pannel_visible; bool selected_button[NAV_COUNT]; int pattern_type; void clearButtonSelection(); @@ -51,7 +52,7 @@ class Navigator void RenderMainPannel(); void RenderTransitionPannel(); void RenderNewPannel(); - char file_browser_path_[2048]; + void RenderViewPannel(ImVec2 draw_pos, ImVec2 draw_size); SourcePreview new_source_preview_; diff --git a/View.cpp b/View.cpp index 0c4387f..ee9bada 100644 --- a/View.cpp +++ b/View.cpp @@ -301,6 +301,21 @@ void MixingView::zoom( float factor ) scene.root()->scale_.y = z; } +void MixingView::resize ( int scale ) +{ + float z = 0.01f * (float) scale; + z *= MIXING_MAX_SCALE - MIXING_MIN_SCALE; + z += MIXING_MIN_SCALE; + scene.root()->scale_.x = z; + scene.root()->scale_.y = z; +} + +int MixingView::size () +{ + float z = (scene.root()->scale_.x - MIXING_MIN_SCALE) / (MIXING_MAX_SCALE - MIXING_MIN_SCALE); + return (int) (z * 100.f); +} + void MixingView::centerSource(Source *s) { // setup view so that the center of the source ends at screen coordinates (650, 150) @@ -728,6 +743,20 @@ void GeometryView::zoom( float factor ) scene.root()->scale_.y = z; } +void GeometryView::resize ( int scale ) +{ + float z = 0.01f * (float) scale; + z *= GEOMETRY_MAX_SCALE - GEOMETRY_MIN_SCALE; + z += GEOMETRY_MIN_SCALE; + scene.root()->scale_.x = z; + scene.root()->scale_.y = z; +} + +int GeometryView::size () +{ + float z = (scene.root()->scale_.x - GEOMETRY_MIN_SCALE) / (GEOMETRY_MAX_SCALE - GEOMETRY_MIN_SCALE); + return (int) (z * 100.f); +} void GeometryView::draw() { @@ -1202,6 +1231,20 @@ void LayerView::zoom (float factor) scene.root()->scale_.y = z; } +void LayerView::resize ( int scale ) +{ + float z = 0.01f * (float) scale; + z *= LAYER_MAX_SCALE - LAYER_MIN_SCALE; + z += LAYER_MIN_SCALE; + scene.root()->scale_.x = z; + scene.root()->scale_.y = z; +} + +int LayerView::size () +{ + float z = (scene.root()->scale_.x - LAYER_MIN_SCALE) / (LAYER_MAX_SCALE - LAYER_MIN_SCALE); + return (int) (z * 100.f); +} float LayerView::setDepth(Source *s, float d) { diff --git a/View.h b/View.h index 6f5e1e8..6fdd522 100644 --- a/View.h +++ b/View.h @@ -24,6 +24,8 @@ public: virtual void draw (); virtual void zoom (float) {} + virtual void resize (int) {} + virtual int size () { return 0; } virtual void recenter(); virtual void centerSource(Source *) {} @@ -91,6 +93,8 @@ public: void draw () override; void update (float dt) override; void zoom (float factor) override; + void resize (int) override; + int size () override; void centerSource(Source *) override; void selectAll() override; @@ -140,6 +144,8 @@ public: void draw () override; void update (float dt) override; void zoom (float factor) override; + void resize (int) override; + int size () override; std::pair pick(glm::vec2 P) override; Cursor grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair pick) override; @@ -166,6 +172,8 @@ public: void update (float dt) override; void zoom (float factor) override; + void resize (int) override; + int size () override; Cursor grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair pick) override; Cursor drag (glm::vec2, glm::vec2) override;