Ardour  9.0-pre0-350-gf17a656217
axis_view.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2017 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
4  * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
5  * Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
6  * Copyright (C) 2014-2017 Robin Gareus <robin@gareus.org>
7  * Copyright (C) 2016 Tim Mayberry <mojofunk@gmail.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 
24 #pragma once
25 
26 #include <list>
27 #include <unordered_map>
28 
29 #include <gtkmm/label.h>
30 #include <gtkmm/table.h>
31 #include <gdkmm/color.h>
32 
33 #include "pbd/xml++.h"
34 #include "pbd/signals.h"
35 
37 #include "ardour/session_handle.h"
38 
39 #include "gui_object.h"
40 #include "selectable.h"
41 
42 namespace PBD {
43  class Controllable;
44 }
45 
46 namespace ARDOUR {
47  class Session;
48  class Stripable;
49  class PresentationInfo;
50 }
51 
57 class AxisView : public virtual PBD::ScopedConnectionList, public virtual ARDOUR::SessionHandlePtr, public virtual Selectable
58 {
59 public:
60  virtual std::string name() const = 0;
61  virtual Gdk::Color color() const = 0;
62 
63  sigc::signal<void> Hiding;
64 
65  virtual std::shared_ptr<ARDOUR::Stripable> stripable() const = 0;
66  virtual std::shared_ptr<ARDOUR::AutomationControl> control() const { return std::shared_ptr<ARDOUR::AutomationControl>(); }
67 
68  virtual std::string state_id() const = 0;
69  /* for now, we always return properties in string form.
70  */
71  std::string gui_property (const std::string& property_name) const;
72 
73  bool get_gui_property (const std::string& property_name, std::string& value) const;
74 
75  template <typename T>
76  bool get_gui_property (const std::string& property_name, T& value) const
77  {
78  std::string str = gui_property (property_name);
79 
80  if (!str.empty ()) {
81  return PBD::string_to<T>(str, value);
82  }
83  return false;
84  }
85 
86  template <typename T>
87  bool get_gui_property (const std::string& state_id, const std::string& property_name, T& value) const
88  {
89  std::string str = gui_object_state().get_string (state_id, property_name);
90 
91  if (!str.empty ()) {
92  return PBD::string_to<T>(str, value);
93  }
94  return false;
95  }
96 
97 
98  void set_gui_property (const std::string& property_name, const std::string& value);
99  void remove_gui_property (const std::string& property_name);
100 
101  void set_gui_property (const std::string& property_name, const char* value) {
102  set_gui_property (property_name, std::string(value));
103  }
104 
105  template <typename T>
106  void set_gui_property (const std::string& property_name, const T& value)
107  {
108  set_gui_property (property_name, PBD::to_string(value));
109  }
110 
112  /* remove related property node from the GUI state */
114  property_hashtable.clear ();
115  }
116 
117  void set_selected (bool yn);
118 
119  virtual bool marked_for_display () const;
120  virtual bool set_marked_for_display (bool);
121 
124 
126 
127 protected:
129  virtual ~AxisView();
130 
133 
136 
137  mutable std::unordered_map<std::string, std::string> property_hashtable;
138 }; /* class AxisView */
139 
bool get_gui_property(const std::string &property_name, T &value) const
Definition: axis_view.h:76
virtual std::shared_ptr< ARDOUR::AutomationControl > control() const
Definition: axis_view.h:66
static Gdk::Color round_robin_palette_color()
void set_gui_property(const std::string &property_name, const char *value)
Definition: axis_view.h:101
void clear_property_cache()
Definition: axis_view.h:123
sigc::signal< void > Hiding
Definition: axis_view.h:63
bool get_gui_property(const std::string &property_name, std::string &value) const
std::unordered_map< std::string, std::string > property_hashtable
Definition: axis_view.h:137
virtual std::string state_id() const =0
Gtk::Label name_label
Definition: axis_view.h:131
std::string gui_property(const std::string &property_name) const
Gtk::Table inactive_table
Definition: axis_view.h:135
static GUIObjectState & gui_object_state()
void remove_gui_property(const std::string &property_name)
virtual ~AxisView()
virtual std::shared_ptr< ARDOUR::Stripable > stripable() const =0
void set_name_ellipsize_mode()
bool get_gui_property(const std::string &state_id, const std::string &property_name, T &value) const
Definition: axis_view.h:87
virtual Gdk::Color color() const =0
virtual bool marked_for_display() const
Gtk::Label inactive_label
Definition: axis_view.h:134
virtual bool set_marked_for_display(bool)
void set_gui_property(const std::string &property_name, const std::string &value)
void set_gui_property(const std::string &property_name, const T &value)
Definition: axis_view.h:106
void set_selected(bool yn)
void cleanup_gui_properties()
Definition: axis_view.h:111
virtual std::string name() const =0
void remove_node(const std::string &id)
std::string get_string(const std::string &id, const std::string &prop_name, bool *empty=0)
Definition: axis_view.h:42
bool to_string(ARDOUR::AnyTime const &at, std::string &str)