]> git.tdb.fi Git - r2c2.git/commitdiff
Use a GLtk::Layout with FloatingArrangement to manage dialogs
authorMikko Rasa <tdb@tdb.fi>
Thu, 7 Nov 2013 13:13:01 +0000 (15:13 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 7 Nov 2013 13:13:01 +0000 (15:13 +0200)
source/engineer/engineer.cpp
source/engineer/engineer.h
source/engineer/mainwindow.cpp
source/engineer/traindialog.cpp
source/engineer/trainlistdialog.cpp

index fb21f9917b0e718b4031e0e8a42937aea3375d67..c88bae8e24648cd09f8566d09c1dbf3ddbcb2607 100644 (file)
@@ -12,6 +12,7 @@
 #include <msp/gl/matrix.h>
 #include <msp/gl/misc.h>
 #include <msp/gl/tests.h>
+#include <msp/gltk/floatingarrangement.h>
 #include <msp/io/print.h>
 #include <msp/strings/format.h>
 #include <msp/time/units.h>
@@ -49,6 +50,10 @@ Engineer::Engineer(int argc, char **argv):
        window.signal_close.connect(sigc::bind(sigc::mem_fun(this, &Engineer::exit), 0));
 
        root = new GLtk::Root(ui_res, &window, &keyboard, &mouse);
+       GLtk::Layout *root_layout = new GLtk::Layout;
+       root->set_layout(root_layout);
+       root_layout->set_margin(GLtk::Sides());
+       root_arrangement = new GLtk::FloatingArrangement(*root_layout);
        mouse.signal_button_press.connect(sigc::bind_return(sigc::mem_fun(this, &Engineer::button_press), false));
        mouse.signal_axis_motion.connect(sigc::bind_return(sigc::mem_fun(this, &Engineer::axis_motion), false));
        root->set_visible(true);
@@ -123,6 +128,7 @@ Engineer::~Engineer()
        }
 
        delete overlay;
+       delete root_arrangement;
        delete root;
 
        delete server;
index c4ee605a07a54aa89118eed68a82f8587de91497..418c0cdf730d9f4cfcee5e1bbd48320f69d581b1 100644 (file)
@@ -31,6 +31,7 @@ private:
        Msp::Input::Mouse mouse;
        Msp::GLtk::Resources ui_res;
        Msp::GLtk::Root *root;
+       Msp::GLtk::Arrangement *root_arrangement;
 
        R2C2::Catalogue catalogue;
        R2C2::Layout layout;
index f5c8df73bd15b57d375819bef8b29fbf358cff23..5fdda1d2a4d1c875a0281b44057bf07120be9451 100644 (file)
@@ -59,7 +59,6 @@ void MainWindow::trains_clicked()
 {
        TrainListDialog *dlg = new TrainListDialog(engineer);
        find_ancestor<GLtk::Root>()->add(*dlg);
-       dlg->autosize();
 }
 
 void MainWindow::quit_clicked()
index 350fbf063f81f6fcf76761001eb35f7fc63b7afc..54dac6a84af53c2e69b9ab5896351d32d73eafe0 100644 (file)
@@ -1,6 +1,7 @@
 #include <msp/core/maputils.h>
 #include <msp/core/raii.h>
 #include <msp/gltk/part.h>
+#include <msp/gltk/root.h>
 #include <msp/gltk/stack.h>
 #include <msp/strings/format.h>
 #include "libr2c2/aicontrol.h"
@@ -126,11 +127,8 @@ void TrainDialog::expand_clicked()
 {
        pnl_expander->set_visible(!pnl_expander->is_visible());
        btn_expand->set_style(pnl_expander->is_visible() ? "arrow_up" : "arrow_down");
-       GLtk::Geometry ageom = geom;
-       ageom.h = 0;
-       layout->autosize(ageom);
-       ageom.y = geom.y+geom.h-ageom.h;
-       set_geometry(ageom);
+       signal_autosize_changed.emit();
+       find_ancestor<GLtk::Root>()->get_layout()->update();
 }
 
 void TrainDialog::toggle_panel(bool show, GLtk::Panel *panel)
index ce1bcb8902f27ca0ed6688755f7abb651c601059..dbeb79670d812007a9a67e900a0f1b40204c0576 100644 (file)
@@ -66,7 +66,6 @@ void TrainListDialog::show_clicked()
        {
                TrainDialog *dlg = new TrainDialog(engineer, *trains.get(index));
                find_ancestor<GLtk::Root>()->add(*dlg);
-               dlg->autosize();
        }
 }