X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdesigner%2Ftoolbar.cpp;h=f970607fc054b97879950dda94179c5db6c1e818;hb=9e96d36a21c24befc88c7bf9c1014c22169e3a6a;hp=a4046f545a978495e8852b5eb939617fb3cabd7d;hpb=c6b9a38300cc2ecfc0df66af162620b9ea5a1e3e;p=r2c2.git diff --git a/source/designer/toolbar.cpp b/source/designer/toolbar.cpp index a4046f5..f970607 100644 --- a/source/designer/toolbar.cpp +++ b/source/designer/toolbar.cpp @@ -1,32 +1,32 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2010 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - +#include #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) @@ -35,11 +35,7 @@ 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); } @@ -48,17 +44,3 @@ void Toolbar::expand_clicked() { 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); -}