From 47246db7e9d71ba694b719001033fba1766a58c4 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 10 Jun 2006 02:43:54 +0000 Subject: More juggling git-svn-id: http://svn.drobilla.net/lad/grauph@16 a436a847-0d15-0410-975c-d299462d15a1 --- src/progs/gtk/NodeControlWindow.cpp | 127 ++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 src/progs/gtk/NodeControlWindow.cpp (limited to 'src/progs/gtk/NodeControlWindow.cpp') diff --git a/src/progs/gtk/NodeControlWindow.cpp b/src/progs/gtk/NodeControlWindow.cpp new file mode 100644 index 00000000..e40af67f --- /dev/null +++ b/src/progs/gtk/NodeControlWindow.cpp @@ -0,0 +1,127 @@ +/* This file is part of Om. Copyright (C) 2006 Dave Robillard. + * + * Om is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Om is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License alongCont + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "NodeControlWindow.h" +#include "GladeFactory.h" +#include "NodeController.h" +#include "ControlGroups.h" +#include "PatchWindow.h" +#include +#include +using std::cerr; using std::cout; using std::endl; + +namespace OmGtk { + + +/** Create a node control window and load a new ControlPanel for it. + */ +NodeControlWindow::NodeControlWindow(NodeController* node, size_t poly) +: m_node(node), + m_position_stored(false), + m_x(0), m_y(0) +{ + assert(m_node != NULL); + + property_resizable() = true; + set_border_width(5); + + set_title(m_node->path() + " Controls"); + + Glib::RefPtr xml = GladeFactory::new_glade_reference("warehouse_win"); + xml->get_widget_derived("control_panel_vbox", m_control_panel); + m_control_panel->reparent(*this); + + m_control_panel->init(m_node, poly); + + show_all_children(); + resize(); + + // FIXME: not working + set_icon_from_file(string(PKGDATADIR) + "/om-icon.png"); + + m_callback_enabled = true; +} + + +/** Create a node control window and with an existing ControlPanel. + */ +NodeControlWindow::NodeControlWindow(NodeController* node, ControlPanel* panel) +: m_node(node), + m_control_panel(panel) +{ + assert(m_node != NULL); + + property_resizable() = true; + set_border_width(5); + + set_title(m_node->path() + " Controls"); + + m_control_panel->reparent(*this); + + show_all_children(); + resize(); + + m_callback_enabled = true; +} + + +NodeControlWindow::~NodeControlWindow() +{ + delete m_control_panel; +} + + +void +NodeControlWindow::resize() +{ + pair controls_size = m_control_panel->ideal_size(); + /*int width = 400; + int height = controls_size.second + + ((m_node->polyphonic()) ? 4 : 40);*/ + int width = controls_size.first; + int height = controls_size.second; + + if (height > property_screen().get_value()->get_height() - 64) + height = property_screen().get_value()->get_height() - 64; + if (width > property_screen().get_value()->get_width() - 64) + width = property_screen().get_value()->get_width() - 64; + + //cerr << "Resizing to: " << width << " x " << height << endl; + + Gtk::Window::resize(width, height); +} + + +void +NodeControlWindow::on_show() +{ + if (m_position_stored) + move(m_x, m_y); + + Gtk::Window::on_show(); +} + + +void +NodeControlWindow::on_hide() +{ + m_position_stored = true; + get_position(m_x, m_y); + Gtk::Window::on_hide(); +} + + +} // namespace OmGtk -- cgit v1.2.1