From: Mikko Rasa Date: Fri, 22 Nov 2013 09:39:23 +0000 (+0200) Subject: Add property editing for terrain X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=3553ca7e70942fe3f5a534a4e27a6ae2dc82e0fe;p=r2c2.git Add property editing for terrain --- diff --git a/source/designer/objectproperties.cpp b/source/designer/objectproperties.cpp index af09033..70ddb60 100644 --- a/source/designer/objectproperties.cpp +++ b/source/designer/objectproperties.cpp @@ -63,6 +63,11 @@ ObjectProperties::ObjectProperties(const Selection &selection): lbl_title->set_text("Beam gate properties"); properties = new BeamGateProperties(*this, *gate); } + else if(Terrain *terrain = dynamic_cast(object)) + { + lbl_title->set_text("Terrain properties"); + properties = new TerrainProperties(*this, *terrain); + } } if(!properties) @@ -169,3 +174,17 @@ void ObjectProperties::BeamGateProperties::apply() { gate.set_address(lexical_cast(ent_address->get_text())); } + + +ObjectProperties::TerrainProperties::TerrainProperties(ObjectProperties &p, Terrain &t): + terrain(t), + ent_width(p.add_property("Width", lexical_cast(terrain.get_width()), 4)), + ent_height(p.add_property("Height", lexical_cast(terrain.get_height()), 4)) +{ } + +void ObjectProperties::TerrainProperties::apply() +{ + unsigned width = lexical_cast(ent_width->get_text()); + unsigned height = lexical_cast(ent_height->get_text()); + terrain.set_size(width, height); +} diff --git a/source/designer/objectproperties.h b/source/designer/objectproperties.h index 9180206..8433b68 100644 --- a/source/designer/objectproperties.h +++ b/source/designer/objectproperties.h @@ -5,6 +5,7 @@ #include #include "libr2c2/beamgate.h" #include "libr2c2/signal.h" +#include "libr2c2/terrain.h" #include "libr2c2/track.h" class Selection; @@ -70,6 +71,19 @@ private: virtual void apply(); }; + class TerrainProperties: public Properties + { + private: + R2C2::Terrain &terrain; + Msp::GLtk::Entry *ent_width; + Msp::GLtk::Entry *ent_height; + + public: + TerrainProperties(ObjectProperties &, R2C2::Terrain &); + + virtual void apply(); + }; + Properties *properties; Msp::GLtk::Widget *prev_widget;