summaryrefslogtreecommitdiff
path: root/gtk2_ardour/window_manager.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-07-07 22:12:21 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2016-02-22 15:31:21 -0500
commit9010262bed21611f2db652d16f63e4af4380259d (patch)
treeb112724d2b26eb3b66b5e1c5571dbf6c5509cc24 /gtk2_ardour/window_manager.cc
parent85eee3b09dd53f6f5d1803f2b585270ab535e16f (diff)
first compilable version of tabbable design.
I would have loved to split this apart, but there are just so many interrelated changes, it makes little sense and would be a huge effort that would break future git bisect use because so many intermediate commits would not compile
Diffstat (limited to 'gtk2_ardour/window_manager.cc')
-rw-r--r--gtk2_ardour/window_manager.cc258
1 files changed, 6 insertions, 252 deletions
diff --git a/gtk2_ardour/window_manager.cc b/gtk2_ardour/window_manager.cc
index b476787926..3ab742199d 100644
--- a/gtk2_ardour/window_manager.cc
+++ b/gtk2_ardour/window_manager.cc
@@ -170,269 +170,23 @@ Manager::set_transient_for (Gtk::Window* parent)
/*-------------------------*/
-ProxyBase::ProxyBase (const string& name, const std::string& menu_name)
- : _name (name)
- , _menu_name (menu_name)
- , _window (0)
- , _visible (false)
- , _x_off (-1)
- , _y_off (-1)
- , _width (-1)
- , _height (-1)
- , vistracker (0)
+ProxyBase::ProxyBase (const std::string& name, const std::string& menu_name)
+ : WindowProxy (name, menu_name)
{
}
-ProxyBase::ProxyBase (const string& name, const std::string& menu_name, const XMLNode& node)
- : _name (name)
- , _menu_name (menu_name)
- , _window (0)
- , _visible (false)
- , _x_off (-1)
- , _y_off (-1)
- , _width (-1)
- , _height (-1)
- , vistracker (0)
+ProxyBase::ProxyBase (const std::string& name, const std::string& menu_name, const XMLNode& node)
+ : WindowProxy (name, menu_name, node)
{
- set_state (node);
-}
-
-ProxyBase::~ProxyBase ()
-{
- delete vistracker;
- delete _window;
-}
-
-void
-ProxyBase::set_state (const XMLNode& node)
-{
- XMLNodeList children = node.children ();
-
- XMLNodeList::const_iterator i = children.begin ();
-
- while (i != children.end()) {
- XMLProperty* prop = (*i)->property (X_("name"));
- if ((*i)->name() == X_("Window") && prop && prop->value() == _name) {
- break;
- }
-
- ++i;
- }
-
- if (i != children.end()) {
-
- XMLProperty* prop;
-
- if ((prop = (*i)->property (X_("visible"))) != 0) {
- _visible = PBD::string_is_affirmative (prop->value ());
- }
-
- if ((prop = (*i)->property (X_("x-off"))) != 0) {
- _x_off = atoi (prop->value());
- }
- if ((prop = (*i)->property (X_("y-off"))) != 0) {
- _y_off = atoi (prop->value());
- }
- if ((prop = (*i)->property (X_("x-size"))) != 0) {
- _width = atoi (prop->value());
- }
- if ((prop = (*i)->property (X_("y-size"))) != 0) {
- _height = atoi (prop->value());
- }
- }
-
- /* if we have a window already, reset its properties */
-
- if (_window) {
- setup ();
- }
-}
-
-void
-ProxyBase::set_action (Glib::RefPtr<Gtk::Action> act)
-{
- _action = act;
-}
-
-std::string
-ProxyBase::action_name() const
-{
- return string_compose (X_("toggle-%1"), _name);
-}
-
-void
-ProxyBase::toggle()
-{
- if (!_window) {
- (void) get (true);
- assert (_window);
- /* XXX this is a hack - the window object should really
- ensure its components are all visible. sigh.
- */
- _window->show_all();
- /* we'd like to just call this and nothing else */
- _window->present ();
-
- if (_width != -1 && _height != -1) {
- _window->set_default_size (_width, _height);
- }
- if (_x_off != -1 && _y_off != -1) {
- _window->move (_x_off, _y_off);
- }
-
- } else {
- if (_window->is_mapped()) {
- save_pos_and_size();
- }
- vistracker->cycle_visibility ();
- if (_window->is_mapped()) {
- if (_width != -1 && _height != -1) {
- _window->set_default_size (_width, _height);
- }
- if (_x_off != -1 && _y_off != -1) {
- _window->move (_x_off, _y_off);
- }
- }
- }
-}
-
-XMLNode&
-ProxyBase::get_state () const
-{
- XMLNode* node = new XMLNode (X_("Window"));
- char buf[32];
-
- node->add_property (X_("name"), _name);
-
- if (_window && vistracker) {
-
- /* we have a window, so use current state */
-
- _visible = vistracker->partially_visible ();
- if (_visible) {
- _window->get_position (_x_off, _y_off);
- _window->get_size (_width, _height);
- }
- }
-
- node->add_property (X_("visible"), _visible? X_("yes") : X_("no"));
-
- snprintf (buf, sizeof (buf), "%d", _x_off);
- node->add_property (X_("x-off"), buf);
- snprintf (buf, sizeof (buf), "%d", _y_off);
- node->add_property (X_("y-off"), buf);
- snprintf (buf, sizeof (buf), "%d", _width);
- node->add_property (X_("x-size"), buf);
- snprintf (buf, sizeof (buf), "%d", _height);
- node->add_property (X_("y-size"), buf);
-
- return *node;
-}
-
-void
-ProxyBase::drop_window ()
-{
- if (_window) {
- _window->hide ();
- delete _window;
- _window = 0;
- delete vistracker;
- vistracker = 0;
- }
-}
-
-void
-ProxyBase::use_window (Gtk::Window& win)
-{
- drop_window ();
- _window = &win;
- setup ();
}
void
ProxyBase::setup ()
{
- assert (_window);
-
- vistracker = new Gtkmm2ext::VisibilityTracker (*_window);
- _window->signal_delete_event().connect (sigc::mem_fun (*this, &ProxyBase::delete_event_handler));
-
- if (_width != -1 || _height != -1 || _x_off != -1 || _y_off != -1) {
- /* cancel any mouse-based positioning */
- _window->set_position (Gtk::WIN_POS_NONE);
- }
-
- if (_width != -1 && _height != -1) {
- _window->set_default_size (_width, _height);
- }
-
- if (_x_off != -1 && _y_off != -1) {
- _window->move (_x_off, _y_off);
- }
+ WindowProxy::setup ();
set_session(_session);
-}
-
-void
-ProxyBase::show ()
-{
- get (true);
- assert (_window);
- _window->show ();
-}
-
-void
-ProxyBase::maybe_show ()
-{
- if (_visible) {
- show ();
- }
-}
-
-void
-ProxyBase::show_all ()
-{
- get (true);
- assert (_window);
- _window->show_all ();
-}
-
-void
-ProxyBase::present ()
-{
- get (true);
- assert (_window);
-
- _window->show_all ();
- _window->present ();
-
- /* turn off any mouse-based positioning */
- _window->set_position (Gtk::WIN_POS_NONE);
-}
+}
-void
-ProxyBase::hide ()
-{
- if (_window) {
- save_pos_and_size();
- _window->hide ();
- }
-}
-
-bool
-ProxyBase::delete_event_handler (GdkEventAny* /*ev*/)
-{
- hide();
- return true;
-}
-
-void
-ProxyBase::save_pos_and_size ()
-{
- if (_window) {
- _window->get_position (_x_off, _y_off);
- _window->get_size (_width, _height);
- }
-}
/*-----------------------*/
ProxyTemporary::ProxyTemporary (const string& name, Gtk::Window* win)