From 41ec7a035b521cc5152cc4c0995222ddda90e7a0 Mon Sep 17 00:00:00 2001 From: brunoherbelin Date: Fri, 10 Jul 2020 20:40:38 +0200 Subject: [PATCH] Implementation of "select all" action (CTRL + A) --- UserInterfaceManager.cpp | 8 +++++--- View.cpp | 25 +++++++++++++++++++++++++ View.h | 3 +++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index 67f378a..1b1e586 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -284,7 +284,7 @@ void UserInterface::handleKeyboard() } else if (ImGui::IsKeyPressed( GLFW_KEY_A )) { // select all -// Mixer::manager().currentView()->selectall(); + Mixer::manager().view()->selectAll(); } } @@ -1516,7 +1516,8 @@ void Navigator::RenderNewPannel() // show preview new_source_preview_.draw(ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN); // or press Validate button - if ( ImGui::Button("Import", ImVec2(pannel_width_ - padding_width_, 0)) ) { + ImGui::Text(" "); + if ( ImGui::Button(ICON_FA_CHECK " Create", ImVec2(pannel_width_ - padding_width_, 0)) ) { Mixer::manager().addSource(new_source_preview_.getSource()); selected_button[NAV_NEW] = false; } @@ -1552,7 +1553,8 @@ void Navigator::RenderNewPannel() // show preview new_source_preview_.draw(ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN); // ask to import the source in the mixer - if ( ImGui::Button("Import", ImVec2(pannel_width_ - padding_width_, 0)) ) { + ImGui::Text(" "); + if ( ImGui::Button( ICON_FA_CHECK " Create", ImVec2(pannel_width_ - padding_width_, 0)) ) { Mixer::manager().addSource(new_source_preview_.getSource()); selected_button[NAV_NEW] = false; } diff --git a/View.cpp b/View.cpp index 02e038e..1343061 100644 --- a/View.cpp +++ b/View.cpp @@ -117,6 +117,16 @@ void View::initiate() } } +void View::selectAll() +{ + Mixer::selection().clear(); + for(auto sit = Mixer::manager().session()->begin(); + sit != Mixer::manager().session()->end(); sit++) { + if ( (*sit)->active() ) + Mixer::selection().add(*sit); + } +} + void View::select(glm::vec2 A, glm::vec2 B) { // unproject mouse coordinate into scene coordinates @@ -201,6 +211,15 @@ void MixingView::centerSource(Source *s) } + +void MixingView::selectAll() +{ + for(auto sit = Mixer::manager().session()->begin(); + sit != Mixer::manager().session()->end(); sit++) { + Mixer::selection().add(*sit); + } +} + View::Cursor MixingView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair) { if (!s) @@ -884,6 +903,12 @@ void TransitionView::draw() } +void TransitionView::selectAll() +{ + Mixer::selection().clear(); + Mixer::selection().add(transition_source_); +} + void TransitionView::attach(SessionSource *ts) { // store source for later (detatch & interaction) diff --git a/View.h b/View.h index 8e05994..f81aad3 100644 --- a/View.h +++ b/View.h @@ -50,6 +50,7 @@ public: // select sources provided a start and end selection points in screen coordinates virtual void select(glm::vec2, glm::vec2); + virtual void selectAll(); // drag the view provided a start and an end point in screen coordinates virtual Cursor drag (glm::vec2, glm::vec2); @@ -88,6 +89,7 @@ public: void zoom (float factor) override; void centerSource(Source *) override; + void selectAll() override; Cursor grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair) override; void setAlpha (Source *s); @@ -163,6 +165,7 @@ public: void update (float dt) override; void zoom (float factor) override; std::pair pick(glm::vec2 P) override; + void selectAll() override; Cursor grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair pick) override; private: