From d32eab21ebacb78500dc46af5b5a6354a9a37fe2 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 9 Jun 2013 23:03:17 +0300 Subject: [PATCH] Arrange widgets in Designer with GLtk::Layout --- r2c2.res | 51 +++++++++++++++++++---------- source/designer/designer.cpp | 40 ++++++++++++---------- source/designer/designer.h | 5 ++- source/designer/input.cpp | 17 +++++----- source/designer/layoutbar.cpp | 6 +--- source/designer/routebar.cpp | 6 +--- source/designer/toolbar.cpp | 32 +++++------------- source/designer/toolbar.h | 4 +-- source/designer/trackbar.cpp | 8 +---- source/designer/trackproperties.cpp | 30 +++++++++-------- source/designer/zonebar.cpp | 7 +--- source/designer/zoneproperties.cpp | 38 +++++++++++---------- 12 files changed, 117 insertions(+), 127 deletions(-) diff --git a/r2c2.res b/r2c2.res index 2fbdb78..d16f555 100644 --- a/r2c2.res +++ b/r2c2.res @@ -15,6 +15,17 @@ style "label" }; }; +style "label-title" +{ + font_color 0 0 0; + part "text" + { + align 0.5 1.0; + fill 0.0 0.0; + margin { bottom 5; }; + }; +}; + style "image" { part "image" @@ -27,7 +38,7 @@ graphic "tooltip" { texture "gui.png"; slice 50 93 20 10; - border { top 2; right 2; bottom 2; left 2; }; + border { horizontal 2; vertical 2; }; }; style "label-tooltip" @@ -43,7 +54,7 @@ style "label-tooltip" { align 0.0 0.5; fill 0.0 0.0; - margin { top 2; right 2; bottom 2; left 2; }; + margin { horizontal 2; vertical 2; }; }; }; @@ -161,12 +172,14 @@ style "button" graphic ACTIVE "grey_button_pressed"; align 0.5 0.0; fill 0.0 0.0; + margin { horizontal 5; }; }; part "text" { align 0.5 1.0; fill 0.0 0.0; + margin { bottom 10; }; }; }; @@ -180,12 +193,14 @@ style "button-green" graphic ACTIVE "green_button_pressed"; align 0.5 0.0; fill 0.0 0.0; + margin { horizontal 5; }; }; part "text" { align 0.5 1.0; fill 0.0 0.0; + margin { bottom 10; }; }; }; @@ -199,12 +214,14 @@ style "button-red" graphic ACTIVE "red_button_pressed"; align 0.5 0.0; fill 0.0 0.0; + margin { horizontal 5; }; }; part "text" { align 0.5 1.0; fill 0.0 0.0; + margin { bottom 10; }; }; }; @@ -325,7 +342,7 @@ graphic "raised_grey_bg" { texture "gui.png"; slice 2 74 24 16; - border { top 4; right 4; bottom 4; left 4; }; + border { horizontal 4; vertical 4; }; }; style "panel" @@ -346,7 +363,7 @@ graphic "sunken_black_bg" { texture "gui.png"; slice 2 110 24 16; - border { top 4; right 4; bottom 4; left 4; }; + border { horizontal 4; vertical 4; }; }; style "label-digital" @@ -371,7 +388,7 @@ graphic "sunken_white_bg" { texture "gui.png"; slice 2 92 24 16; - border { top 4; right 4; bottom 4; left 4; }; + border { horizontal 4; vertical 4; }; }; graphic "cursor" @@ -393,7 +410,7 @@ style "entry" { align 0.0 0.5; fill 0.0 0.0; - margin { left 3; right 3; }; + margin { horizontal 3; vertical 2; }; }; part "cursor" @@ -419,7 +436,7 @@ style "entry-multiline" { align 0.0 1.0; fill 0.0 0.0; - margin { top 2; right 13; left 3; bottom 2; }; + margin { vertical 2; right 13; left 3; }; }; part "cursor" @@ -433,7 +450,7 @@ style "entry-multiline" align 1.0 0.0; fill 0.0 1.0; size 10 0; - margin { top 3; right 2; bottom 3; }; + margin { vertical 3; right 2; }; }; }; @@ -441,7 +458,7 @@ graphic "selection" { texture "gui.png"; slice 44 81 20 10; - border { top 4; right 4; bottom 4; left 4; }; + border { horizontal 4; vertical 4; }; }; style "list" @@ -457,12 +474,12 @@ style "list" { graphic NORMAL "selection"; fill 1.0 1.0; - margin { top 2; right 13; bottom 2; left 2; }; + margin { vertical 2; right 13; left 2; }; }; part "items" { - margin { top 2; right 13; bottom 2; left 2; }; + margin { vertical 2; right 13; left 2; }; }; part "slider" @@ -470,7 +487,7 @@ style "list" align 1.0 0.0; fill 0.0 1.0; size 10 0; - margin { top 3; right 2; bottom 3; }; + margin { vertical 3; right 2; }; }; }; @@ -496,7 +513,7 @@ style "dropdown" { align 0.0 0.5; fill 0.0 0.0; - margin { left 2; }; + margin { vertical 2; left 3; right 17; }; }; part "list"; @@ -539,7 +556,7 @@ graphic "horizontal_slot" { texture "gui.png"; slice 32 97 12 2; - border { left 1; right 1; }; + border { horizontal 1; }; }; graphic "horizontal_knob" @@ -556,7 +573,7 @@ style "hslider" graphic NORMAL "horizontal_slot"; align 0.5 0.5; fill 1.0 0.0; - margin { left 4; right 4; }; + margin { horizontal 4; }; }; part "slider" @@ -570,7 +587,7 @@ graphic "vertical_slot" { texture "gui.png"; slice 32 75 2 12; - border { top 1; bottom 1; }; + border { vertical 1; }; }; graphic "vertical_knob" @@ -587,7 +604,7 @@ style "vslider" graphic NORMAL "vertical_slot"; align 0.5 0.5; fill 0.0 1.0; - margin { top 4; bottom 4; }; + margin { vertical 4; }; }; part "slider" diff --git a/source/designer/designer.cpp b/source/designer/designer.cpp index d640073..04e15d3 100644 --- a/source/designer/designer.cpp +++ b/source/designer/designer.cpp @@ -111,24 +111,34 @@ Designer::Designer(int argc, char **argv): mouse.signal_button_press.connect(sigc::bind_return(sigc::mem_fun(this, &Designer::button_press), false)); mouse.signal_axis_motion.connect(sigc::bind_return(sigc::mem_fun(this, &Designer::axis_motion), false)); root.signal_tooltip.connect(sigc::mem_fun(this, &Designer::tooltip)); + root_layout = new GLtk::Layout; + root_layout->set_margin(0); + root.set_layout(root_layout); toolbars.push_back(new Layoutbar(*this)); toolbars.push_back(new Trackbar(*this)); toolbars.push_back(new Routebar(*this)); toolbars.push_back(new Zonebar(*this)); + Toolbar *prev = 0; for(vector::iterator i=toolbars.begin(); i!=toolbars.end(); ++i) { root.add(**i); if(i!=toolbars.begin()) (*i)->expand(false); - (*i)->signal_expanded.connect(sigc::hide(sigc::mem_fun(this, &Designer::arrange_toolbars))); + (*i)->signal_expanded.connect(sigc::hide(sigc::mem_fun(root_layout, &GLtk::Layout::update))); + if(prev) + { + root_layout->add_constraint(**i, GLtk::Layout::RIGHT_OF, *prev, 0); + root_layout->add_constraint(**i, GLtk::Layout::COPY_HEIGHT, *prev); + } + prev = *i; } - arrange_toolbars(); GLtk::Panel *statusbar = new GLtk::Panel; root.add(*statusbar); - statusbar->set_size(window.get_width(), 20); statusbar->set_focusable(false); + root_layout->set_gravity(*statusbar, -1, -1); + root_layout->set_expand(*statusbar, true, false); lbl_status = new GLtk::Label; statusbar->add(*lbl_status); @@ -176,6 +186,8 @@ void Designer::save() { InputDialog *input = new InputDialog(*this, "Save layout", filename); input->signal_accept.connect(sigc::mem_fun(layout, &Layout::save)); + root.add(*input); + root_layout->set_gravity(*input, 0, 0); } void Designer::quit() @@ -213,9 +225,7 @@ void Designer::track_properties() TrackProperties *track_prop = new TrackProperties(selection); root.add(*track_prop); - const GLtk::Geometry &root_geom = root.get_geometry(); - const GLtk::Geometry &dlg_geom = track_prop->get_geometry(); - track_prop->set_position((root_geom.w-dlg_geom.w)/2, (root_geom.h-dlg_geom.h)/2); + root_layout->set_gravity(*track_prop, 0, 0); track_prop->signal_response.connect(sigc::mem_fun(this, &Designer::track_properties_response)); } @@ -249,6 +259,8 @@ void Designer::svg_export() { InputDialog *input = new InputDialog(*this, "SVG export", FS::basepart(filename)+".svg"); input->signal_accept.connect(sigc::mem_fun(this, &Designer::svg_export_accept)); + root.add(*input); + root_layout->set_gravity(*input, 0, 0); } void Designer::edit_route(Route *r) @@ -268,6 +280,8 @@ void Designer::rename_route() InputDialog *input = new InputDialog(*this, "Route name", cur_route->get_name()); input->signal_accept.connect(sigc::mem_fun(this, &Designer::route_name_accept)); + root.add(*input); + root_layout->set_gravity(*input, 0, 0); } void Designer::add_selection_to_route() @@ -601,17 +615,6 @@ void Designer::measure_done() selection_changed(); } -void Designer::arrange_toolbars() -{ - unsigned x = 0; - for(vector::iterator i=toolbars.begin(); i!=toolbars.end(); ++i) - { - const GLtk::Geometry &geom = (*i)->get_geometry(); - (*i)->set_position(x, window.get_height()-geom.h); - x += geom.w; - } -} - void Designer::track_properties_response(int) { const set &tracks = selection.get_objects(); @@ -633,7 +636,8 @@ void Designer::svg_export_accept(const string &text) string Designer::tooltip(int x, int y) { - if(Object *obj = pick_object(Vector(x*2.0f/window.get_width()-1.0f, y*2.0f/window.get_height()-1.0f, 0))) + const GLtk::Geometry &rgeom = root.get_geometry(); + if(Object *obj = pick_object(Vector(x*2.0f/rgeom.w-1.0f, y*2.0f/rgeom.h-1.0f, 0))) { const ObjectType &otype = obj->get_type(); string info = format("%d %s", otype.get_article_number(), otype.get_description()); diff --git a/source/designer/designer.h b/source/designer/designer.h index fd70358..b78ad81 100644 --- a/source/designer/designer.h +++ b/source/designer/designer.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,7 @@ private: Msp::Input::Mouse mouse; Msp::GLtk::Resources ui_res; Msp::GLtk::Root root; + Msp::GLtk::Layout *root_layout; std::vector toolbars; Msp::GLtk::Label *lbl_status; @@ -84,8 +86,6 @@ public: R2C2::Layout &get_layout() { return *layout; } R2C2::Layout3D &get_layout_3d() { return *layout_3d; } const CameraController &get_camera_controller() const { return *camera_ctl; } - const Msp::GLtk::Resources &get_ui_resources() const { return ui_res; } - Msp::GLtk::Root &get_root() { return root; } void new_track(); void erase_tracks(); @@ -122,7 +122,6 @@ private: void manipulation_done(bool); void measure_changed(); void measure_done(); - void arrange_toolbars(); void track_properties_response(int); void route_name_accept(const std::string &); void svg_export_accept(const std::string &); diff --git a/source/designer/input.cpp b/source/designer/input.cpp index ea4129a..18b14a5 100644 --- a/source/designer/input.cpp +++ b/source/designer/input.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include "designer.h" #include "input.h" @@ -11,28 +12,28 @@ using namespace Msp; InputDialog::InputDialog(Designer &d, const string &title, const string &text): designer(d) { - set_size(300, 100); + GLtk::MixedRows *rows = new GLtk::MixedRows; + set_layout(rows); GLtk::Label *lbl; add(*(lbl=new GLtk::Label(title))); - lbl->set_geometry(GLtk::Geometry(10, geom.h-30, geom.w-20, 20)); + layout->set_expand(*lbl, true, false); + lbl->set_style("title"); + rows->start_row(); add(*(entry=new GLtk::Entry(text))); - entry->set_geometry(GLtk::Geometry(10, geom.h-60, geom.w-20, 20)); + entry->set_edit_size(60, 1); GLtk::Button *btn; + rows->start_row(); + rows->split_columns(); add_button(*(btn=new GLtk::Button("Cncl")), 0); - btn->set_geometry(GLtk::Geometry(geom.w-90, 10, 40, 24)); btn->set_style("red"); add_button(*(btn=new GLtk::Button("OK")), 1); - btn->set_geometry(GLtk::Geometry(geom.w-50, 10, 40, 24)); btn->set_style("green"); - designer.get_root().add(*this); - const GLtk::Geometry &rgeom=designer.get_root().get_geometry(); - set_position((rgeom.w-geom.w)/2, (rgeom.h-geom.h)/2); entry->set_focus(); } diff --git a/source/designer/layoutbar.cpp b/source/designer/layoutbar.cpp index 7e27b02..db24030 100644 --- a/source/designer/layoutbar.cpp +++ b/source/designer/layoutbar.cpp @@ -4,26 +4,22 @@ using namespace Msp; Layoutbar::Layoutbar(Designer &designer): - Toolbar("Layout", 160) + Toolbar("Layout") { GLtk::Button *btn; pnl_content->add(*(btn = new GLtk::Button("Load"))); - btn->set_geometry(GLtk::Geometry(0, 10, 40, 24)); btn->set_tooltip("Load layout (not implemented)"); pnl_content->add(*(btn = new GLtk::Button("Save"))); - btn->set_geometry(GLtk::Geometry(40, 10, 40, 24)); btn->set_tooltip("Save current layout (W)"); btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::save)); pnl_content->add(*(btn = new GLtk::Button("SVG"))); - btn->set_geometry(GLtk::Geometry(80, 10, 40, 24)); btn->set_tooltip("Export layout as SVG (V)"); btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::svg_export)); pnl_content->add(*(btn = new GLtk::Button("Quit"))); - btn->set_geometry(GLtk::Geometry(120, 10, 40, 24)); btn->set_style("red"); btn->set_tooltip("Exit Designer"); btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::quit)); diff --git a/source/designer/routebar.cpp b/source/designer/routebar.cpp index cebd1d7..9726b2e 100644 --- a/source/designer/routebar.cpp +++ b/source/designer/routebar.cpp @@ -8,11 +8,10 @@ using namespace Msp; using namespace R2C2; Routebar::Routebar(Designer &d): - Toolbar("Route", 370), + Toolbar("Route"), designer(d) { pnl_content->add(*(drp_routes = new GLtk::Dropdown)); - drp_routes->set_geometry(GLtk::Geometry(0, 10, 250, 20)); drp_routes->set_tooltip("Select route to edit"); drp_routes->append("(new route)"); drp_routes->signal_item_selected.connect(sigc::mem_fun(this, &Routebar::route_selected)); @@ -20,18 +19,15 @@ Routebar::Routebar(Designer &d): GLtk::Button *btn; pnl_content->add(*(btn = new GLtk::Button("Del"))); - btn->set_geometry(GLtk::Geometry(250, 10, 40, 24)); btn->set_style("red"); btn->set_tooltip("Delete the current route"); btn->signal_clicked.connect(sigc::mem_fun(this, &Routebar::delete_route_clicked)); pnl_content->add(*(btn = new GLtk::Button("Name"))); - btn->set_geometry(GLtk::Geometry(290, 10, 40, 24)); btn->set_tooltip("Rename the current route"); btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::rename_route)); pnl_content->add(*(btn = new GLtk::Button("Add"))); - btn->set_geometry(GLtk::Geometry(330, 10, 40, 24)); btn->set_tooltip("Add selected tracks to current route (A)"); btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::add_selection_to_route)); diff --git a/source/designer/toolbar.cpp b/source/designer/toolbar.cpp index 950cfc5..559d8c3 100644 --- a/source/designer/toolbar.cpp +++ b/source/designer/toolbar.cpp @@ -1,25 +1,29 @@ +#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::Row); + 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::Row; + pnl_content->set_layout(content_layout); + content_layout->set_margin(0); } void Toolbar::expand(bool e) @@ -28,11 +32,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); } @@ -41,17 +41,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); -} diff --git a/source/designer/toolbar.h b/source/designer/toolbar.h index 25eab21..49412b6 100644 --- a/source/designer/toolbar.h +++ b/source/designer/toolbar.h @@ -11,21 +11,19 @@ public: sigc::signal signal_expanded; private: - unsigned content_width; Msp::GLtk::Label *lbl_title; Msp::GLtk::Button *btn_expand; bool expanded; protected: Msp::GLtk::Panel *pnl_content; - Toolbar(const std::string &, unsigned); + Toolbar(const std::string &); public: void expand(bool); private: void expand_clicked(); - virtual void on_style_change(); }; #endif diff --git a/source/designer/trackbar.cpp b/source/designer/trackbar.cpp index 71e77a9..72ac49a 100644 --- a/source/designer/trackbar.cpp +++ b/source/designer/trackbar.cpp @@ -4,39 +4,33 @@ using namespace Msp; Trackbar::Trackbar(Designer &designer): - Toolbar("Track", 240) + Toolbar("Track") { GLtk::Button *btn; pnl_content->add(*(btn = new GLtk::Button("New"))); - btn->set_geometry(GLtk::Geometry(0, 10, 40, 24)); btn->set_style("green"); btn->set_tooltip("Add a track piece (N)"); btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::new_track)); pnl_content->add(*(btn = new GLtk::Button("Del"))); - btn->set_geometry(GLtk::Geometry(40, 10, 40, 24)); btn->set_style("red"); btn->set_tooltip("Delete selected tracks (X)"); btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::erase_tracks)); pnl_content->add(*(btn = new GLtk::Button("Prop"))); - btn->set_geometry(GLtk::Geometry(80, 10, 40, 24)); btn->set_tooltip("Change properties of selected tracks (P)"); btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::track_properties)); pnl_content->add(*(btn = new GLtk::Button("Xtnd"))); - btn->set_geometry(GLtk::Geometry(120, 10, 40, 24)); btn->set_tooltip("Extend straight track out of free endpoint (Shift+N)"); btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::extend_track)); pnl_content->add(*(btn = new GLtk::Button("Conn"))); - btn->set_geometry(GLtk::Geometry(160, 10, 40, 24)); btn->set_tooltip("Connect free endpoints of selected tracks (C)"); btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::connect_tracks)); pnl_content->add(*(btn = new GLtk::Button("Flat"))); - btn->set_geometry(GLtk::Geometry(200, 10, 40, 24)); btn->set_tooltip("Make selected tracks flat (F)"); btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::flatten_tracks)); } diff --git a/source/designer/trackproperties.cpp b/source/designer/trackproperties.cpp index 9753849..b85a99a 100644 --- a/source/designer/trackproperties.cpp +++ b/source/designer/trackproperties.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "libr2c2/track.h" #include "libr2c2/tracktype.h" #include "selection.h" @@ -12,33 +13,34 @@ using namespace R2C2; TrackProperties::TrackProperties(const Selection &s): selection(s) { - set_size(300, 110); + GLtk::MixedRows *rows = new GLtk::MixedRows; + set_layout(rows); - GLtk::Label *lbl; + GLtk::Label *lbl1, *lbl2; - add(*(lbl = new GLtk::Label("Track properties"))); - lbl->set_geometry(GLtk::Geometry(10, geom.h-30, geom.w-20, 20)); - - add(*(lbl = new GLtk::Label("Turnout ID"))); - lbl->set_geometry(GLtk::Geometry(10, geom.h-65, 70, 20)); + add(*(lbl1 = new GLtk::Label("Track properties"))); + layout->set_expand(*lbl1, true, false); + lbl1->set_style("title"); + rows->start_row(); + add(*(lbl1 = new GLtk::Label("Turnout ID"))); add(*(ent_turnout_id = new GLtk::Entry)); - ent_turnout_id->set_geometry(GLtk::Geometry(80, geom.h-65, 50, 20)); - - add(*(lbl = new GLtk::Label("Sensor ID"))); - lbl->set_geometry(GLtk::Geometry(150, geom.h-65, 70, 20)); + ent_turnout_id->set_edit_size(5, 1); + rows->start_row(); + add(*(lbl2 = new GLtk::Label("Sensor ID"))); + rows->add_constraint(*lbl1, GLtk::Layout::COPY_WIDTH, *lbl2); add(*(ent_sensor_id = new GLtk::Entry)); - ent_sensor_id->set_geometry(GLtk::Geometry(220, geom.h-65, 50, 20)); + ent_sensor_id->set_edit_size(5, 1); GLtk::Button *btn; + rows->start_row(); + rows->split_columns(); add_button(*(btn = new GLtk::Button("Cncl")), 0); - btn->set_geometry(GLtk::Geometry(geom.w-90, 10, 40, 24)); btn->set_style("red"); add_button(*(btn = new GLtk::Button("OK")), 1); - btn->set_geometry(GLtk::Geometry(geom.w-50, 10, 40, 24)); btn->set_style("green"); if(selection.size()==1) diff --git a/source/designer/zonebar.cpp b/source/designer/zonebar.cpp index 09f8f0c..058b2d1 100644 --- a/source/designer/zonebar.cpp +++ b/source/designer/zonebar.cpp @@ -8,34 +8,29 @@ using namespace Msp; using namespace R2C2; Zonebar::Zonebar(Designer &d): - Toolbar("Zone", 420), + Toolbar("Zone"), designer(d) { pnl_content->add(*(drp_groups = new GLtk::Dropdown)); - drp_groups->set_geometry(GLtk::Geometry(0, 10, 195, 20)); drp_groups->set_tooltip("Select zone group to edit"); drp_groups->signal_item_selected.connect(sigc::mem_fun(this, &Zonebar::group_selected)); pnl_content->add(*(drp_numbers = new GLtk::Dropdown)); - drp_numbers->set_geometry(GLtk::Geometry(200, 10, 100, 20)); drp_groups->set_tooltip("Select zone to edit"); drp_numbers->signal_item_selected.connect(sigc::mem_fun(this, &Zonebar::number_selected)); GLtk::Button *btn; pnl_content->add(*(btn = new GLtk::Button("Del"))); - btn->set_geometry(GLtk::Geometry(300, 10, 40, 24)); btn->set_style("red"); btn->set_tooltip("Delete selected zone"); btn->signal_clicked.connect(sigc::mem_fun(this, &Zonebar::delete_zone_clicked)); pnl_content->add(*(btn = new GLtk::Button("Prop"))); - btn->set_geometry(GLtk::Geometry(340, 10, 40, 24)); btn->set_tooltip("Change properties of the selected zone"); btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::zone_properties)); pnl_content->add(*(btn = new GLtk::Button("AddT"))); - btn->set_geometry(GLtk::Geometry(380, 10, 40, 24)); btn->set_tooltip("Add selected tracks to zone"); btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::add_selection_to_zone)); diff --git a/source/designer/zoneproperties.cpp b/source/designer/zoneproperties.cpp index 63cda25..406ebee 100644 --- a/source/designer/zoneproperties.cpp +++ b/source/designer/zoneproperties.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "zoneproperties.h" using namespace std; @@ -9,24 +10,25 @@ using namespace R2C2; ZoneProperties::ZoneProperties(Zone &z): zone(z) { - set_size(300, 140); + GLtk::MixedRows *rows = new GLtk::MixedRows; + set_layout(rows); - GLtk::Label *lbl; + GLtk::Label *lbl1, *lbl2; - add(*(lbl = new GLtk::Label("Zone properties"))); - lbl->set_geometry(GLtk::Geometry(10, geom.h-30, geom.w-20, 20)); - - add(*(lbl = new GLtk::Label("Group"))); - lbl->set_geometry(GLtk::Geometry(10, geom.h-65, 70, 20)); + add(*(lbl1 = new GLtk::Label("Zone properties"))); + layout->set_expand(*lbl1, true, false); + lbl1->set_style("title"); + rows->start_row(); + add(*(lbl1 = new GLtk::Label("Group"))); add(*(ent_group = new GLtk::Entry(zone.get_group()))); - ent_group->set_geometry(GLtk::Geometry(80, geom.h-65, geom.w-90, 20)); - - add(*(lbl = new GLtk::Label("Qualifier"))); - lbl->set_geometry(GLtk::Geometry(10, geom.h-95, 70, 20)); + ent_group->set_edit_size(30, 1); + + rows->start_row(); + add(*(lbl2 = new GLtk::Label("Qualifier"))); + rows->add_constraint(*lbl1, GLtk::Layout::COPY_WIDTH, *lbl2); add(*(drp_qualifier = new GLtk::Dropdown)); - drp_qualifier->set_geometry(GLtk::Geometry(80, geom.h-95, 80, 20)); const char *qualifiers[] = { "track", "platform", "siding", 0 }; for(unsigned i=0; qualifiers[i]; ++i) { @@ -35,20 +37,20 @@ ZoneProperties::ZoneProperties(Zone &z): drp_qualifier->set_selected_index(i); } - add(*(lbl = new GLtk::Label("Number"))); - lbl->set_geometry(GLtk::Geometry(170, geom.h-95, 70, 20)); - + rows->start_row(); + add(*(lbl1 = new GLtk::Label("Number"))); + rows->add_constraint(*lbl1, GLtk::Layout::COPY_WIDTH, *lbl2); add(*(ent_number = new GLtk::Entry(lexical_cast(zone.get_number())))); - ent_number->set_geometry(GLtk::Geometry(240, geom.h-95, 50, 20)); + ent_number->set_edit_size(4, 1); GLtk::Button *btn; + rows->start_row(); + rows->split_columns(); add_button(*(btn = new GLtk::Button("Cncl")), 0); - btn->set_geometry(GLtk::Geometry(geom.w-90, 10, 40, 24)); btn->set_style("red"); add_button(*(btn = new GLtk::Button("OK")), 1); - btn->set_geometry(GLtk::Geometry(geom.w-50, 10, 40, 24)); btn->set_style("green"); } -- 2.43.0