-/* $Id$
-
-This file is part of R²C²
-Copyright © 2010 Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
+#include <msp/gltk/row.h>
#include "toolbar.h"
using namespace std;
using namespace Msp;
-Toolbar::Toolbar(const string &name, unsigned w):
- content_width(w),
+Toolbar::Toolbar(const string &name):
expanded(true)
{
set_focusable(false);
+ set_layout(new GLtk::Layout);
+ GLtk::Row row(*layout);
+ layout->set_margin(GLtk::Sides(6, 10));
+ layout->set_column_spacing(10);
add(*(lbl_title = new GLtk::Label(name)));
add(*(btn_expand = new GLtk::Button));
- btn_expand->set_size(15, 20);
btn_expand->set_style("arrow_left");
btn_expand->set_tooltip("Collapse toolbar");
btn_expand->signal_clicked.connect(sigc::mem_fun(this, &Toolbar::expand_clicked));
add(*(pnl_content = new GLtk::Panel));
- pnl_content->set_size(content_width, 40);
pnl_content->set_style("group");
+ GLtk::Layout *content_layout = new GLtk::Layout;
+ // XXX This needs to get deleted somehow
+ new GLtk::Row(*content_layout);
+ pnl_content->set_layout(content_layout);
+ content_layout->set_margin(0);
}
void Toolbar::expand(bool e)
btn_expand->set_style(expanded ? "arrow_left" : "arrow_right");
btn_expand->set_tooltip(expanded ? "Collapse toolbar" : "Expand toolbar");
pnl_content->set_visible(expanded);
-
- unsigned w = lbl_title->get_geometry().w+40;
- if(expanded)
- w += content_width+5;
- set_size(w, 40);
+ signal_autosize_changed.emit();
signal_expanded.emit(expanded);
}
{
expand(!expanded);
}
-
-void Toolbar::on_style_change()
-{
- lbl_title->autosize();
- const GLtk::Geometry &lbl_geom = lbl_title->get_geometry();
- unsigned w = lbl_geom.w+40;
- if(expanded)
- w += content_width+5;
- set_size(w, 40);
-
- lbl_title->set_position(10, (geom.h-lbl_geom.h)/2);
- btn_expand->set_position(lbl_geom.w+15, 10);
- pnl_content->set_position(lbl_geom.w+35, 0);
-}