Implementation of "select all" action (CTRL + A)

This commit is contained in:
brunoherbelin
2020-07-10 20:40:38 +02:00
parent b837e7bf8b
commit 41ec7a035b
3 changed files with 33 additions and 3 deletions

View File

@@ -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;
}

View File

@@ -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<Node *, glm::vec2>)
{
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)

3
View.h
View File

@@ -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<Node *, glm::vec2>) override;
void setAlpha (Source *s);
@@ -163,6 +165,7 @@ public:
void update (float dt) override;
void zoom (float factor) override;
std::pair<Node *, glm::vec2> pick(glm::vec2 P) override;
void selectAll() override;
Cursor grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair<Node *, glm::vec2> pick) override;
private: