]> git.tdb.fi Git - r2c2.git/commitdiff
Arrange widgets in Designer with GLtk::Layout
authorMikko Rasa <tdb@tdb.fi>
Sun, 9 Jun 2013 20:03:17 +0000 (23:03 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 9 Jun 2013 20:03:17 +0000 (23:03 +0300)
12 files changed:
r2c2.res
source/designer/designer.cpp
source/designer/designer.h
source/designer/input.cpp
source/designer/layoutbar.cpp
source/designer/routebar.cpp
source/designer/toolbar.cpp
source/designer/toolbar.h
source/designer/trackbar.cpp
source/designer/trackproperties.cpp
source/designer/zonebar.cpp
source/designer/zoneproperties.cpp

index 2fbdb7826602d12108a30ed36d003d06feecad7a..d16f555e6bd452cca7a74620d62946705f39f4d6 100644 (file)
--- 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"
index d640073427c5c936ce2ceb53ced27d9a0472775f..04e15d34c5e5a023d0b3cc514c70f8faff95f800 100644 (file)
@@ -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<Toolbar *>::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<Toolbar *>::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<Track *> &tracks = selection.get_objects<Track>();
@@ -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());
index fd70358c56698b0ee923a478d1902becdce06e35..b78ad81becf8db1650f4b9d8a691269148743c4d 100644 (file)
@@ -11,6 +11,7 @@
 #include <msp/gl/object.h>
 #include <msp/gl/pipeline.h>
 #include <msp/gltk/label.h>
+#include <msp/gltk/layout.h>
 #include <msp/gltk/resources.h>
 #include <msp/gltk/root.h>
 #include <msp/time/timestamp.h>
@@ -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<Toolbar *> 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 &);
index ea4129a9cab1948a9383857ad277aefdcb5bd7fa..18b14a573bcad9754407c00525abc482b468c37e 100644 (file)
@@ -1,6 +1,7 @@
 #include <GL/gl.h>
 #include <msp/gl/texture.h>
 #include <msp/gltk/button.h>
+#include <msp/gltk/mixedrows.h>
 #include <msp/input/keys.h>
 #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();
 }
 
index 7e27b02a391dd1b0adf520dc360386cf144f5cf1..db2403010f6ff2f94df7448f9a454973b4304229 100644 (file)
@@ -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));
index cebd1d76edabeb06d85dc85ce066306f278a9a02..9726b2e88f8c853a05f995483e68eafefe67cc4f 100644 (file)
@@ -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));
 
index 950cfc5aaa8edf0706a1e8f6bc89d78a776c8118..559d8c3e9e13636c07d0dcbfcf34f266e813d8d0 100644 (file)
@@ -1,25 +1,29 @@
+#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::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);
-}
index 25eab21e717b841eb701b8fadd94d44b995ea277..49412b6f1ae2a8c22af0c21080c863705aceb62d 100644 (file)
@@ -11,21 +11,19 @@ public:
        sigc::signal<void, bool> 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
index 71e77a9cfb5a58c5be64db4d4771cb4fd2ec05b5..72ac49a6d1f8a4787b3c1b85668af99438a742ed 100644 (file)
@@ -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));
 }
index 9753849eccf3aadae3b4d937e7dbb51e2baecc64..b85a99ae76e6459247f2f2719a0c17e287c0802d 100644 (file)
@@ -1,5 +1,6 @@
 #include <msp/gltk/button.h>
 #include <msp/gltk/label.h>
+#include <msp/gltk/mixedrows.h>
 #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)
index 09f8f0ceab9f19919b7dfc0b53b8165fe5c0cbfe..058b2d1d580111f524a880e794f7b58d08ce6db2 100644 (file)
@@ -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));
 
index 63cda25a1c6261663135bb2b3a348bfb8471e0bc..406ebee1cbdc46bfa6f306e94e7dd150b8476d1e 100644 (file)
@@ -1,5 +1,6 @@
 #include <msp/gltk/button.h>
 #include <msp/gltk/label.h>
+#include <msp/gltk/mixedrows.h>
 #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<string>(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");
 }