summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2021-07-06 02:38:27 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2021-07-06 02:38:27 -0400
commitecf8fb6a5f0cdd674c79fec78698aa66099f5fc7 (patch)
tree64f82e706fa787935ed8174a912bac63aff8ed09 /components
parent9ec52e3473f4e90ba940324a5d058afefc0bd8f1 (diff)
downloadabaddon-portaudio-ecf8fb6a5f0cdd674c79fec78698aa66099f5fc7.tar.gz
abaddon-portaudio-ecf8fb6a5f0cdd674c79fec78698aa66099f5fc7.zip
fix up channel row selection to work how i want it to
Diffstat (limited to 'components')
-rw-r--r--components/channels.cpp16
-rw-r--r--components/channels.hpp3
2 files changed, 19 insertions, 0 deletions
diff --git a/components/channels.cpp b/components/channels.cpp
index 520c8fd..a085d62 100644
--- a/components/channels.cpp
+++ b/components/channels.cpp
@@ -29,6 +29,8 @@ ChannelList::ChannelList()
m_view.signal_row_collapsed().connect(sigc::mem_fun(*this, &ChannelList::OnRowCollapsed), false);
m_view.signal_row_expanded().connect(sigc::mem_fun(*this, &ChannelList::OnRowExpanded), false);
m_view.set_activate_on_single_click(true);
+ m_view.get_selection()->set_mode(Gtk::SELECTION_SINGLE);
+ m_view.get_selection()->set_select_function(sigc::mem_fun(*this, &ChannelList::SelectionFunc));
m_view.set_hexpand(true);
m_view.set_vexpand(true);
@@ -309,6 +311,20 @@ void ChannelList::OnRowExpanded(const Gtk::TreeModel::iterator &iter, const Gtk:
if ((*it)[m_columns.m_expanded])
m_view.expand_row(m_model->get_path(it), false);
}
+
+ // try and restore selection if previous collapsed
+ if (auto selection = m_view.get_selection(); selection && !selection->get_selected()) {
+ selection->select(m_last_selected);
+ }
+}
+
+bool ChannelList::SelectionFunc(const Glib::RefPtr<Gtk::TreeModel> &model, const Gtk::TreeModel::Path &path, bool is_currently_selected) {
+ if (auto selection = m_view.get_selection())
+ if (auto row = selection->get_selected())
+ m_last_selected = m_model->get_path(row);
+
+ auto iter = m_model->get_iter(path);
+ return (*iter)[m_columns.m_type] == RenderType::TextChannel;
}
ChannelList::type_signal_action_channel_item_select ChannelList::signal_action_channel_item_select() {
diff --git a/components/channels.hpp b/components/channels.hpp
index 0bc0b04..c0f0d33 100644
--- a/components/channels.hpp
+++ b/components/channels.hpp
@@ -131,6 +131,9 @@ protected:
void OnRowCollapsed(const Gtk::TreeModel::iterator &iter, const Gtk::TreeModel::Path &path);
void OnRowExpanded(const Gtk::TreeModel::iterator &iter, const Gtk::TreeModel::Path &path);
+ bool SelectionFunc(const Glib::RefPtr<Gtk::TreeModel> &model, const Gtk::TreeModel::Path &path, bool is_currently_selected);
+
+ Gtk::TreeModel::Path m_last_selected;
public:
typedef sigc::signal<void, Snowflake> type_signal_action_channel_item_select;