From 5a02a4f42dfc5dc6b4daef5fc02431bdfb2968d8 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 7 Nov 2013 15:13:01 +0200 Subject: [PATCH] Use a GLtk::Layout with FloatingArrangement to manage dialogs --- source/engineer/engineer.cpp | 6 ++++++ source/engineer/engineer.h | 1 + source/engineer/mainwindow.cpp | 1 - source/engineer/traindialog.cpp | 8 +++----- source/engineer/trainlistdialog.cpp | 1 - 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/source/engineer/engineer.cpp b/source/engineer/engineer.cpp index fb21f99..c88bae8 100644 --- a/source/engineer/engineer.cpp +++ b/source/engineer/engineer.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -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; diff --git a/source/engineer/engineer.h b/source/engineer/engineer.h index c4ee605..418c0cd 100644 --- a/source/engineer/engineer.h +++ b/source/engineer/engineer.h @@ -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; diff --git a/source/engineer/mainwindow.cpp b/source/engineer/mainwindow.cpp index f5c8df7..5fdda1d 100644 --- a/source/engineer/mainwindow.cpp +++ b/source/engineer/mainwindow.cpp @@ -59,7 +59,6 @@ void MainWindow::trains_clicked() { TrainListDialog *dlg = new TrainListDialog(engineer); find_ancestor()->add(*dlg); - dlg->autosize(); } void MainWindow::quit_clicked() diff --git a/source/engineer/traindialog.cpp b/source/engineer/traindialog.cpp index 350fbf0..54dac6a 100644 --- a/source/engineer/traindialog.cpp +++ b/source/engineer/traindialog.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #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()->get_layout()->update(); } void TrainDialog::toggle_panel(bool show, GLtk::Panel *panel) diff --git a/source/engineer/trainlistdialog.cpp b/source/engineer/trainlistdialog.cpp index ce1bcb8..dbeb796 100644 --- a/source/engineer/trainlistdialog.cpp +++ b/source/engineer/trainlistdialog.cpp @@ -66,7 +66,6 @@ void TrainListDialog::show_clicked() { TrainDialog *dlg = new TrainDialog(engineer, *trains.get(index)); find_ancestor()->add(*dlg); - dlg->autosize(); } } -- 2.45.2