X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fengineer%2Ftrainpanel.cpp;h=d46bd9d4756ca8c229eb92e7a3df64aadab87ae1;hb=36beacc579d3132642ed4d98ce5a6d99842b5812;hp=d9a8c7752bb8ff58467fc9110c8f1ba9001b7dd7;hpb=6c61179fe09af2f5366d50f10aadbf5f83438087;p=r2c2.git diff --git a/source/engineer/trainpanel.cpp b/source/engineer/trainpanel.cpp index d9a8c77..d46bd9d 100644 --- a/source/engineer/trainpanel.cpp +++ b/source/engineer/trainpanel.cpp @@ -1,4 +1,6 @@ #include +#include +#include "libmarklin/locomotive.h" #include "trainpanel.h" using namespace Msp; @@ -11,9 +13,10 @@ TrainPanel::TrainPanel(Engineer &e, const GLtk::Resources &r, Train &t): { set_size(200, 100); - add(*(lbl_name=new GLtk::Label(res, "Train 1"))); + add(*(lbl_name=new GLtk::Label(res, train.get_name()))); lbl_name->set_style("digital"); lbl_name->set_geometry(GLtk::Geometry(10, geom.h-34, 140, 24)); + train.signal_name_changed.connect(sigc::mem_fun(lbl_name, &GLtk::Label::set_text)); GLtk::Button *btn; @@ -26,11 +29,18 @@ TrainPanel::TrainPanel(Engineer &e, const GLtk::Resources &r, Train &t): sld_speed->set_step(1); sld_speed->signal_value_changed.connect(sigc::mem_fun(this, &TrainPanel::speed_slider_changed)); - add(*(btn=new GLtk::Button(res, "Place"))); - btn->set_geometry(GLtk::Geometry(150, geom.h-75, 40, 24)); + add(*(lbl_speed=new GLtk::Label(res, " 0"))); + lbl_speed->set_style("digital"); + lbl_speed->set_geometry(GLtk::Geometry(10, geom.h-75, 36, 24)); + train.get_locomotive().signal_speed_changed.connect(sigc::mem_fun(this, &TrainPanel::loco_speed_changed)); } void TrainPanel::speed_slider_changed(double v) { train.set_speed(static_cast(v)); } + +void TrainPanel::loco_speed_changed(unsigned speed) +{ + lbl_speed->set_text(format("%2d", speed)); +}