From e431e86fe24027a877d6154912f615fd230ec2a7 Mon Sep 17 00:00:00 2001 From: Pandagrapher Date: Thu, 25 Apr 2019 15:54:58 +0200 Subject: [PATCH] Allow show/hide all spots, fixes #5270 --- rtdata/languages/default | 3 ++ rtgui/controlspotpanel.cc | 62 ++++++++++++++++++++++++++++++--------- rtgui/controlspotpanel.h | 2 +- 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/rtdata/languages/default b/rtdata/languages/default index a9e8ee8d2..41933093b 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -2131,10 +2131,13 @@ TP_LOCALLAB_ROW_VIS;Visible TP_LOCALLAB_ROW_NVIS;Not visible TP_LOCALLAB_EV_VIS;Show TP_LOCALLAB_EV_NVIS;Hide +TP_LOCALLAB_EV_VIS_ALL;Show all +TP_LOCALLAB_EV_NVIS_ALL;Hide all TP_LOCALLAB_REN_DIALOG_NAME;Renaming Control Spot TP_LOCALLAB_REN_DIALOG_LAB;Enter the new Control Spot name TP_LOCALLAB_EV_DUPL;Copy of TP_LOCALLAB_DUPLSPOTNAME;Copy +TP_LOCALLAB_VIS_TOOLTIP;Click to show/hide selected Control Spot.\nCtrl+click to show/hide all Control Spot. TP_LOCAL_HEIGHT;Bottom TP_LOCAL_HEIGHT_T;Top TP_LOCAL_WIDTH;Right diff --git a/rtgui/controlspotpanel.cc b/rtgui/controlspotpanel.cc index f7e87287d..2b2a3b034 100644 --- a/rtgui/controlspotpanel.cc +++ b/rtgui/controlspotpanel.cc @@ -95,8 +95,9 @@ ControlSpotPanel::ControlSpotPanel(): Gtk::HBox* const hbox2_ = Gtk::manage(new Gtk::HBox(true, 4)); buttonrenameconn_ = button_rename_->signal_clicked().connect( sigc::mem_fun(*this, &ControlSpotPanel::on_button_rename)); - buttonvisibilityconn_ = button_visibility_->signal_clicked().connect( + buttonvisibilityconn_ = button_visibility_->signal_button_release_event().connect( sigc::mem_fun(*this, &ControlSpotPanel::on_button_visibility)); + if(showtooltip) button_visibility_->set_tooltip_markup(M("TP_LOCALLAB_VIS_TOOLTIP")); hbox2_->pack_start(*button_rename_); hbox2_->pack_start(*button_visibility_); pack_start(*hbox2_); @@ -446,37 +447,70 @@ void ControlSpotPanel::on_button_rename() } } -void ControlSpotPanel::on_button_visibility() +bool ControlSpotPanel::on_button_visibility(GdkEventButton* event) { // printf("on_button_visibility\n"); if (!listener) { - return; + return true; } // Get selected control spot const auto s = treeview_->get_selection(); if (!s->count_selected_rows()) { - return; + return true; } const auto iter = s->get_selected(); const Gtk::TreeModel::Row row = *iter; - // Update visibility - row[spots_.isvisible] = !(bool)row[spots_.isvisible]; - updateControlSpotCurve(row); + const int ctrl = event->state & GDK_CONTROL_MASK; - // Raise event - visibilityChanged_ = true; - const int id = getSelectedSpot(); + if (event->button == 1) { // Left click on button + if (ctrl) { // Ctrl+click case: all spots are shown/hidden + // Get visibility of selected spot + const bool selVisibility = row[spots_.isvisible]; - if ((bool)row[spots_.isvisible]) { - listener->panelChanged(EvLocallabSpotVisibility, M("TP_LOCALLAB_EV_VIS") + " ID#" + std::to_string(id)); - } else { - listener->panelChanged(EvLocallabSpotVisibility, M("TP_LOCALLAB_EV_NVIS") + " ID#" + std::to_string(id)); + // Update visibility of all spot + const Gtk::TreeModel::Children children = treemodel_->children(); + + for (auto i = children.begin(); i != children.end(); i++) { + Gtk::TreeModel::Row r = *i; + r[spots_.isvisible] = !selVisibility; + updateControlSpotCurve(r); + } + + // Raise event + visibilityChanged_ = true; + + if (!selVisibility) { + listener->panelChanged(EvLocallabSpotVisibility, M("TP_LOCALLAB_EV_VIS_ALL")); + } else { + listener->panelChanged(EvLocallabSpotVisibility, M("TP_LOCALLAB_EV_NVIS_ALL")); + } + + return true; + } else { // Click case: only selected spot is shown/hidden + // Update visibility for selected spot only + row[spots_.isvisible] = !row[spots_.isvisible]; + updateControlSpotCurve(row); + + // Raise event + visibilityChanged_ = true; + const int id = getSelectedSpot(); + + if (row[spots_.isvisible]) { + listener->panelChanged(EvLocallabSpotVisibility, M("TP_LOCALLAB_EV_VIS") + " ID#" + std::to_string(id)); + } else { + listener->panelChanged(EvLocallabSpotVisibility, M("TP_LOCALLAB_EV_NVIS") + " ID#" + std::to_string(id)); + } + + return true; + } } + + return false; } bool ControlSpotPanel::blockTreeviewSearch(GdkEventKey* event) diff --git a/rtgui/controlspotpanel.h b/rtgui/controlspotpanel.h index e1f665833..289a97410 100644 --- a/rtgui/controlspotpanel.h +++ b/rtgui/controlspotpanel.h @@ -239,7 +239,7 @@ private: void on_button_delete(); void on_button_duplicate(); void on_button_rename(); - void on_button_visibility(); + bool on_button_visibility(GdkEventButton* event); bool blockTreeviewSearch(GdkEventKey* event);