ardour
visibility_group.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 Paul Davis
3  Author: Carl Hetherington <cth@carlh.net>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 
19 */
20 
21 #ifndef __ardour_visibility_group__
22 #define __ardour_visibility_group__
23 
24 #include <gtkmm/liststore.h>
25 #include "pbd/signals.h"
26 
27 class XMLNode;
28 class XMLProperty;
29 
36 {
37 public:
38  VisibilityGroup (std::string const &);
39 
40  void add (
41  Gtk::Widget *,
42  std::string const &,
43  std::string const &,
44  bool visible = false,
45  boost::function<boost::optional<bool> ()> = 0
46  );
47 
48  Gtk::Menu* menu ();
49  Gtk::Widget* list_view ();
50  bool button_press_event (GdkEventButton *);
51  void update ();
52  void set_state (XMLNode const &);
53  void set_state (std::string);
54  std::string get_state_name () const;
55  std::string get_state_value () const;
56 
57  PBD::Signal0<void> VisibilityChanged;
58 
59 private:
60 
61  struct Member {
62  Gtk::Widget* widget;
63  std::string id;
64  std::string name;
65  bool visible;
66  boost::function<boost::optional<bool> ()> override;
67  };
68 
69  class ModelColumns : public Gtk::TreeModelColumnRecord {
70  public:
72  add (_visible);
73  add (_name);
74  add (_iterator);
75  }
76 
77  Gtk::TreeModelColumn<bool> _visible;
78  Gtk::TreeModelColumn<std::string> _name;
79  Gtk::TreeModelColumn<std::vector<Member>::iterator> _iterator;
80  };
81 
82  void toggle (std::vector<Member>::iterator);
83  void list_view_visible_changed (std::string const &);
84  void update_list_view ();
85  bool should_actually_be_visible (Member const &) const;
86 
87  std::vector<Member> _members;
88  std::string _xml_property_name;
90  Glib::RefPtr<Gtk::ListStore> _model;
92 };
93 
94 #endif
void set_state(XMLNode const &)
Gtk::TreeModelColumn< std::string > _name
std::vector< Member > _members
Gtk::Menu * menu()
bool button_press_event(GdkEventButton *)
std::string _xml_property_name
bool should_actually_be_visible(Member const &) const
PBD::Signal0< void > VisibilityChanged
Gtk::TreeModelColumn< std::vector< Member >::iterator > _iterator
Gtk::Widget * list_view()
std::string get_state_value() const
Definition: xml++.h:95
Gtk::TreeModelColumn< bool > _visible
void add(Gtk::Widget *, std::string const &, std::string const &, bool visible=false, boost::function< boost::optional< bool >()>=0)
Glib::RefPtr< Gtk::ListStore > _model
void list_view_visible_changed(std::string const &)
ModelColumns _model_columns
VisibilityGroup(std::string const &)
void toggle(std::vector< Member >::iterator)
std::string get_state_name() const