@@ -22,92 +22,104 @@ FixtureListWindow::FixtureListWindow() {
2222 set_title (" Glight - fixtures" );
2323 set_size_request (200 , 400 );
2424
25- _updateControllablesConnection =
25+ update_controllables_connection_ =
2626 Instance::Events ().SignalUpdateControllables ().connect (
2727 [&]() { FixtureListWindow::update (); });
2828
29- _globalSelectionConnection = Instance::Selection ().SignalChange ().connect (
29+ global_selection_connection_ = Instance::Selection ().SignalChange ().connect (
3030 [&]() { onGlobalSelectionChange (); });
3131
32- _fixturesListModel = Gtk::ListStore::create (_fixturesListColumns );
32+ fixtures_list_model_ = Gtk::ListStore::create (fixtures_list_columns_ );
3333
34- _fixturesListView .get_selection ()->set_mode (Gtk::SELECTION_MULTIPLE);
35- _fixturesListView .get_selection ()->signal_changed ().connect (
34+ fixtures_list_view_ .get_selection ()->set_mode (Gtk::SELECTION_MULTIPLE);
35+ fixtures_list_view_ .get_selection ()->signal_changed ().connect (
3636 [&]() { onSelectionChanged (); });
37- _fixturesListView.set_model (_fixturesListModel);
38- _fixturesListView.append_column (" Fixture" , _fixturesListColumns._title );
39- _fixturesListView.append_column (" Type" , _fixturesListColumns._type );
40- _fixturesListView.append_column (" Universe" , _fixturesListColumns._universe );
41- _fixturesListView.append_column (" Channels" , _fixturesListColumns._channels );
42- _fixturesListView.append_column (" Symbol" , _fixturesListColumns._symbol );
43- _fixturesListView.set_rubber_banding (true );
37+ fixtures_list_view_.set_model (fixtures_list_model_);
38+ fixtures_list_view_.append_column (" Fixture" , fixtures_list_columns_.title_ );
39+ fixtures_list_view_.append_column (" Type" , fixtures_list_columns_.type_ );
40+ fixtures_list_view_.append_column (" Channels" ,
41+ fixtures_list_columns_.channels_ );
42+ fixtures_list_view_.append_column (" Universe" ,
43+ fixtures_list_columns_.universe_ );
44+ fixtures_list_view_.append_column (" Symbol" , fixtures_list_columns_.symbol_ );
45+ fixtures_list_view_.set_rubber_banding (true );
4446 fillFixturesList ();
45- _fixturesScrolledWindow .add (_fixturesListView );
47+ fixtures_scrolled_window_ .add (fixtures_list_view_ );
4648
47- _fixturesScrolledWindow.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
48- _mainBox.pack_start (_fixturesScrolledWindow);
49+ fixtures_scrolled_window_.set_policy (Gtk::POLICY_NEVER,
50+ Gtk::POLICY_AUTOMATIC);
51+ fixtures_scrolled_window_.set_hexpand (true );
52+ fixtures_scrolled_window_.set_vexpand (true );
4953
50- _buttonBox.set_homogeneous (true );
54+ grid_.attach (fixtures_scrolled_window_, 0 , 0 , 1 , 8 );
55+ grid_.set_hexpand (true );
56+ grid_.set_vexpand (true );
5157
52- _newButton .set_image_from_icon_name (" document-new" );
53- _newButton .signal_clicked ().connect (
58+ new_button_ .set_image_from_icon_name (" document-new" );
59+ new_button_ .signal_clicked ().connect (
5460 sigc::mem_fun (*this , &FixtureListWindow::onNewButtonClicked), false );
55- _buttonBox. pack_start (_newButton );
61+ grid_. attach (new_button_, 1 , 0 , 2 , 1 );
5662
57- _removeButton .set_image_from_icon_name (" edit-delete" );
58- _removeButton .signal_clicked ().connect (
63+ remove_button_ .set_image_from_icon_name (" edit-delete" );
64+ remove_button_ .signal_clicked ().connect (
5965 sigc::mem_fun (*this , &FixtureListWindow::onRemoveButtonClicked));
60- _buttonBox. pack_start (_removeButton );
66+ grid_. attach (remove_button_, 1 , 1 , 2 , 1 );
6167
62- _decChannelButton .signal_clicked ().connect (
63- sigc::mem_fun (* this , &FixtureListWindow::onDecChannelButtonClicked) );
64- _buttonBox. pack_start (_decChannelButton );
68+ dec_channel_button_ .signal_clicked ().connect (
69+ [&]() { IncreaseChannelOrUniverse<- 1 , 0 >(); } );
70+ grid_. attach (dec_channel_button_, 1 , 2 , 1 , 1 );
6571
66- _incChannelButton .signal_clicked ().connect (
67- sigc::mem_fun (* this , &FixtureListWindow::onIncChannelButtonClicked) );
68- _buttonBox. pack_start (_incChannelButton );
72+ inc_channel_button_ .signal_clicked ().connect (
73+ [&]() { IncreaseChannelOrUniverse< 1 , 0 >(); } );
74+ grid_. attach (inc_channel_button_, 1 , 3 , 1 , 1 );
6975
70- _setChannelButton.signal_clicked ().connect (
76+ dec_universe_button_.signal_clicked ().connect (
77+ [&]() { IncreaseChannelOrUniverse<0 , -1 >(); });
78+ grid_.attach (dec_universe_button_, 2 , 2 , 1 , 1 );
79+
80+ inc_universe_button_.signal_clicked ().connect (
81+ [&]() { IncreaseChannelOrUniverse<0 , 1 >(); });
82+ grid_.attach (inc_universe_button_, 2 , 3 , 1 , 1 );
83+
84+ set_channel_button_.signal_clicked ().connect (
7185 sigc::mem_fun (*this , &FixtureListWindow::onSetChannelButtonClicked));
72- _buttonBox. pack_start (_setChannelButton );
86+ grid_. attach (set_channel_button_, 1 , 4 , 2 , 1 );
7387
74- _upButton .signal_clicked ().connect (
88+ up_button_ .signal_clicked ().connect (
7589 sigc::mem_fun (*this , &FixtureListWindow::onUpClicked));
76- _upButton .set_image_from_icon_name (" go-up" );
77- _buttonBox. pack_start (_upButton );
90+ up_button_ .set_image_from_icon_name (" go-up" );
91+ grid_. attach (up_button_, 1 , 5 , 2 , 1 );
7892
79- _downButton .signal_clicked ().connect (
93+ down_button_ .signal_clicked ().connect (
8094 sigc::mem_fun (*this , &FixtureListWindow::onDownClicked));
81- _downButton .set_image_from_icon_name (" go-down" );
82- _buttonBox. pack_start (_downButton );
95+ down_button_ .set_image_from_icon_name (" go-down" );
96+ grid_. attach (down_button_, 1 , 6 , 2 , 1 );
8397
84- _reassignButton .signal_clicked ().connect (
98+ reassign_button_ .signal_clicked ().connect (
8599 sigc::mem_fun (*this , &FixtureListWindow::onReassignClicked));
86- _buttonBox. pack_start (_reassignButton );
100+ grid_. attach (reassign_button_, 1 , 7 , 2 , 1 );
87101
88- _mainBox.pack_start (_buttonBox, false , false , 0 );
89-
90- add (_mainBox);
91- _mainBox.show_all ();
102+ add (grid_);
103+ grid_.show_all ();
92104}
93105
94106FixtureListWindow::~FixtureListWindow () = default ;
95107
96108void FixtureListWindow::fillFixturesList () {
97- _fixturesListModel ->clear ();
109+ fixtures_list_model_ ->clear ();
98110
99111 std::lock_guard<std::mutex> lock (Instance::Management ().Mutex ());
100112 const std::vector<system::TrackablePtr<theatre::Fixture>> &fixtures =
101113 Instance::Management ().GetTheatre ().Fixtures ();
102114 for (const system::TrackablePtr<theatre::Fixture> &fixture : fixtures) {
103- Gtk::TreeModel::iterator iter = _fixturesListModel ->append ();
115+ Gtk::TreeModel::iterator iter = fixtures_list_model_ ->append ();
104116 const Gtk::TreeModel::Row &row = *iter;
105- row[_fixturesListColumns. _title ] = fixture->Name ();
106- row[_fixturesListColumns. _type ] = fixture->Type ().Name ();
107- row[_fixturesListColumns. _universe ] = fixture->GetUniverse ();
108- row[_fixturesListColumns. _channels ] = getChannelString (*fixture);
109- row[_fixturesListColumns. _symbol ] = fixture->Symbol ().Name ();
110- row[_fixturesListColumns. _fixture ] = fixture.GetObserver ();
117+ row[fixtures_list_columns_. title_ ] = fixture->Name ();
118+ row[fixtures_list_columns_. type_ ] = fixture->Type ().Name ();
119+ row[fixtures_list_columns_. universe_ ] = fixture->GetUniverse ();
120+ row[fixtures_list_columns_. channels_ ] = getChannelString (*fixture);
121+ row[fixtures_list_columns_. symbol_ ] = fixture->Symbol ().Name ();
122+ row[fixtures_list_columns_. fixture_ ] = fixture.GetObserver ();
111123 }
112124}
113125
@@ -137,14 +149,14 @@ void FixtureListWindow::onNewButtonClicked() {
137149std::vector<system::ObservingPtr<theatre::Fixture>>
138150FixtureListWindow::GetSelection () const {
139151 Glib::RefPtr<const Gtk::TreeSelection> selection =
140- _fixturesListView .get_selection ();
152+ fixtures_list_view_ .get_selection ();
141153 std::vector<Gtk::TreeModel::Path> rows = selection->get_selected_rows ();
142154 std::vector<system::ObservingPtr<theatre::Fixture>> fixtures;
143155 for (const Gtk::TreeModel::Path &path : rows) {
144- const Gtk::TreeModel::iterator iter = _fixturesListModel ->get_iter (path);
156+ const Gtk::TreeModel::iterator iter = fixtures_list_model_ ->get_iter (path);
145157 if (iter) {
146158 const system::ObservingPtr<theatre::Fixture> &fixture =
147- (*iter)[_fixturesListColumns. _fixture ];
159+ (*iter)[fixtures_list_columns_. fixture_ ];
148160 fixtures.emplace_back (fixture);
149161 }
150162 }
@@ -163,30 +175,6 @@ void FixtureListWindow::onRemoveButtonClicked() {
163175 Instance::Events ().EmitUpdate ();
164176}
165177
166- void FixtureListWindow::onIncChannelButtonClicked () {
167- std::unique_lock<std::mutex> lock (Instance::Management ().Mutex ());
168- const std::vector<system::ObservingPtr<theatre::Fixture>> selection =
169- GetSelection ();
170- for (const system::ObservingPtr<theatre::Fixture> &fixture : selection) {
171- fixture->IncChannel ();
172- if (!fixture->IsVisible ())
173- fixture->SetSymbol (theatre::FixtureSymbol::Normal);
174- updateFixture (fixture.Get ());
175- }
176- }
177-
178- void FixtureListWindow::onDecChannelButtonClicked () {
179- std::unique_lock<std::mutex> lock (Instance::Management ().Mutex ());
180- const std::vector<system::ObservingPtr<theatre::Fixture>> selection =
181- GetSelection ();
182- for (const system::ObservingPtr<theatre::Fixture> &fixture : selection) {
183- fixture->DecChannel ();
184- if (!fixture->IsVisible ())
185- fixture->SetSymbol (theatre::FixtureSymbol::Normal);
186- updateFixture (fixture.Get ());
187- }
188- }
189-
190178void FixtureListWindow::onSetChannelButtonClicked () {
191179 const std::vector<system::ObservingPtr<theatre::Fixture>> selection =
192180 GetSelection ();
@@ -218,42 +206,42 @@ void FixtureListWindow::onSetChannelButtonClicked() {
218206}
219207
220208void FixtureListWindow::updateFixture (const theatre::Fixture *fixture) {
221- Gtk::TreeModel::iterator iter = _fixturesListModel ->children ().begin ();
222- while ( iter) {
209+ for ( Gtk::TreeModel::iterator iter = fixtures_list_model_ ->children ().begin ();
210+ iter; ++ iter) {
223211 Gtk::TreeModel::Row row = *iter;
224- if (fixture == (*iter)[_fixturesListColumns._fixture ]) {
225- row[_fixturesListColumns._title ] = fixture->Name ();
226- row[_fixturesListColumns._type ] = fixture->Type ().Name ();
227- row[_fixturesListColumns._channels ] = getChannelString (*fixture);
228- row[_fixturesListColumns._symbol ] = fixture->Symbol ().Name ();
212+ if (fixture == (*iter)[fixtures_list_columns_.fixture_ ]) {
213+ row[fixtures_list_columns_.title_ ] = fixture->Name ();
214+ row[fixtures_list_columns_.type_ ] = fixture->Type ().Name ();
215+ row[fixtures_list_columns_.channels_ ] = getChannelString (*fixture);
216+ row[fixtures_list_columns_.universe_ ] = fixture->GetUniverse ();
217+ row[fixtures_list_columns_.symbol_ ] = fixture->Symbol ().Name ();
229218 return ;
230219 }
231- ++iter;
232220 }
233221 throw std::runtime_error (
234222 " ConfigurationWindow::updateFixture(): Could not find fixture" );
235223}
236224
237225void FixtureListWindow::onSelectionChanged () {
238- if (_recursionLock .IsFirst ()) {
239- RecursionLock::Token token (_recursionLock );
226+ if (recursion_lock_ .IsFirst ()) {
227+ RecursionLock::Token token (recursion_lock_ );
240228 Instance::Selection ().SetSelection (GetSelection ());
241229 }
242230}
243231
244232void FixtureListWindow::onGlobalSelectionChange () {
245- if (_recursionLock .IsFirst ()) {
246- RecursionLock::Token token (_recursionLock );
247- _fixturesListView .get_selection ()->unselect_all ();
233+ if (recursion_lock_ .IsFirst ()) {
234+ RecursionLock::Token token (recursion_lock_ );
235+ fixtures_list_view_ .get_selection ()->unselect_all ();
248236 const std::vector<system::ObservingPtr<theatre::Fixture>> &new_selection =
249237 Instance::Selection ().Selection ();
250- for (const auto &child : _fixturesListModel ->children ()) {
238+ for (const auto &child : fixtures_list_model_ ->children ()) {
251239 const system::ObservingPtr<theatre::Fixture> &fixture =
252- child[_fixturesListColumns. _fixture ];
240+ child[fixtures_list_columns_. fixture_ ];
253241 auto iter =
254242 std::find (new_selection.begin (), new_selection.end (), fixture);
255243 if (iter != new_selection.end ()) {
256- _fixturesListView .get_selection ()->select (child);
244+ fixtures_list_view_ .get_selection ()->select (child);
257245 }
258246 }
259247 }
@@ -319,4 +307,29 @@ void FixtureListWindow::onReassignClicked() {
319307 Instance::Events ().EmitUpdate ();
320308}
321309
310+ template <int ChannelIncrease, int UniverseIncrease>
311+ void FixtureListWindow::IncreaseChannelOrUniverse () {
312+ std::unique_lock<std::mutex> lock (Instance::Management ().Mutex ());
313+ const std::vector<system::ObservingPtr<theatre::Fixture>> selection =
314+ GetSelection ();
315+ for (const system::ObservingPtr<theatre::Fixture> &fixture : selection) {
316+ if constexpr (ChannelIncrease > 0 ) {
317+ for (int i = 0 ; i != ChannelIncrease; ++i) fixture->IncChannel ();
318+ } else if constexpr (ChannelIncrease < 0 ) {
319+ for (int i = 0 ; i != -ChannelIncrease; ++i) fixture->DecChannel ();
320+ }
321+ if constexpr (ChannelIncrease != 0 ) {
322+ if (!fixture->IsVisible ())
323+ fixture->SetSymbol (theatre::FixtureSymbol::Normal);
324+ }
325+ const int universe = fixture->GetUniverse ();
326+ if constexpr (UniverseIncrease != 0 ) {
327+ if (universe + UniverseIncrease >= 0 ) {
328+ fixture->SetUniverse (universe + UniverseIncrease);
329+ }
330+ }
331+ updateFixture (fixture.Get ());
332+ }
333+ }
334+
322335} // namespace glight::gui::windows
0 commit comments