]> git.tdb.fi Git - r2c2.git/blobdiff - source/designer/zoneproperties.cpp
Support directionality for zones
[r2c2.git] / source / designer / zoneproperties.cpp
index 6ea4f2a330fc1a4b115a597933b01ede9813968d..38d9cc792bc9e7f37da6943dc808b3e8a7ee10bd 100644 (file)
@@ -2,14 +2,25 @@
 #include <msp/gltk/column.h>
 #include <msp/gltk/label.h>
 #include <msp/gltk/row.h>
+#include "libr2c2/block.h"
+#include "libr2c2/track.h"
 #include "zoneproperties.h"
 
 using namespace std;
 using namespace Msp;
 using namespace R2C2;
 
+string track_block_name(Track *const &track)
+{
+       if(track)
+               return track->get_block().get_name();
+       else
+               return "(unspecified)";
+}
+
 ZoneProperties::ZoneProperties(Zone &z):
-       zone(z)
+       zone(z),
+       up_directions(&track_block_name)
 {
        set_layout(new GLtk::Layout);
        GLtk::Column col(*layout);
@@ -50,6 +61,27 @@ ZoneProperties::ZoneProperties(Zone &z):
                ent_number->set_edit_size(4, 1);
        }
 
+       {
+               GLtk::Row row(*layout);
+               add(*(lbl2 = new GLtk::Label("Up towards")));
+               layout->add_constraint(*lbl1, GLtk::Layout::COPY_WIDTH, *lbl2);
+               add(*(drp_up_direction = new GLtk::Dropdown(up_directions)));
+
+               up_directions.append(0);
+
+               Track *up = zone.get_end(TrackChain::UP).next().track();
+               if(!up)
+                       drp_up_direction->set_selected_index(0);
+
+               for(unsigned i=0; i<2; ++i)
+                       if(TrackIter iter = zone.get_end(i).next())
+                       {
+                               up_directions.append(iter.track());
+                               if(iter.track()==up)
+                                       drp_up_direction->set_selected_index(up_directions.size()-1);
+                       }
+       }
+
        GLtk::Button *btn;
 
        {
@@ -73,5 +105,11 @@ void ZoneProperties::on_response(int code)
                        qualifier = drp_qualifier->get_data().get_string(sel);
                unsigned number = lexical_cast<unsigned>(ent_number->get_text());
                zone.set_name(ent_group->get_text(), qualifier, number);
+
+               sel = drp_up_direction->get_selected_index();
+               if(sel==0)
+                       zone.clear_direction();
+               else
+                       zone.set_direction_towards(*up_directions.get(sel), TrackChain::UP);
        }
 }