]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/WaypointList.cxx
toggle fullscreen: also adapt GUI plane when resizing
[flightgear.git] / src / GUI / WaypointList.cxx
index 57b741169d49ff9617ac9460f85829d0b9d68c7c..20183d44ea314894ef63520ccb2ed7317d094734 100644 (file)
@@ -11,7 +11,6 @@
 
 #include <plib/puAux.h>
 
-#include <simgear/route/waypoint.hxx>
 #include <simgear/structure/callback.hxx>
 #include <simgear/sg_inlines.h>
 
@@ -46,13 +45,17 @@ public:
     _fp(fp)
   {    
     SGPropertyNode* routeEdited = fgGetNode("/autopilot/route-manager/signals/edited", true);
+    SGPropertyNode* flightplanChanged = fgGetNode("/autopilot/route-manager/signals/flightplan-changed", true);
     routeEdited->addChangeListener(this);
+    flightplanChanged->addChangeListener(this);
   }
   
   ~FlightPlanWaypointModel()
   {
     SGPropertyNode* routeEdited = fgGetNode("/autopilot/route-manager/signals/edited", true);
+    SGPropertyNode* flightplanChanged = fgGetNode("/autopilot/route-manager/signals/flightplan-changed", true);
     routeEdited->removeChangeListener(this);
+    flightplanChanged->removeChangeListener(this);
   }
   
 // implement WaypointList::Model
@@ -87,14 +90,13 @@ public:
       --destIndex;
     }
     
-    unsigned int currentWpIndex = currentWaypoint();
-    WayptRef w(waypointAt(currentWpIndex));
-    _fp->deleteIndex(currentWpIndex);
+     int currentWpIndex = currentWaypoint();
     
-    SG_LOG(SG_GENERAL, SG_INFO, "wpt:" << w->ident());
+    WayptRef w = _fp->legAtIndex(srcIndex)->waypoint();
+    _fp->deleteIndex(srcIndex);
     _fp->insertWayptAtIndex(w, destIndex);
 
-    if (srcIndex == currentWpIndex) {
+    if ((signed int) srcIndex == currentWpIndex) {
         // current waypoint was moved
         _fp->setCurrentIndex(destIndex);
     }
@@ -108,8 +110,15 @@ public:
 // implement SGPropertyChangeListener
   void valueChanged(SGPropertyNode *prop)
   {
-    if (_cb) {
-      (*_cb)();
+    if (prop->getNameString() == "edited") {
+      if (_cb) {
+        (*_cb)();
+      }
+    }
+    
+    if (prop->getNameString() == "flightplan-changed") {
+      _fp = 
+        static_cast<FGRouteMgr*>(globals->get_subsystem("route-manager"))->flightPlan();
     }
   }
 private:
@@ -402,12 +411,12 @@ void WaypointList::drawRow(int dx, int dy, int rowIndex, int y)
   if (wp->flag(WPT_MISS)) {
     drawBox = true;
     puSetColor(col, 1.0, 0.0, 0.0, 0.3);  // red
-  } else if (wp->flag(WPT_ARRIVAL)) {
+  } else if (wp->flag(WPT_ARRIVAL) || wp->flag(WPT_DEPARTURE)) {
     drawBox = true;
     puSetColor(col, 0.0, 0.0, 0.0, 0.3);
-  } else if (wp->flag(WPT_DEPARTURE)) {
+  } else if (wp->flag(WPT_APPROACH)) {
     drawBox = true;
-    puSetColor(col, 0.0, 0.0, 0.0, 0.3);
+    puSetColor(col, 0.0, 0.0, 0.1, 0.3);
   }
   
   if (isDragSource) {