Parcourir la source

Added gotoEnd(). We position the cursor at end of menu.

Side effect is cursor changes colors (in my menus),
when going up vs. going down.
Steve Thielemann il y a 4 ans
Parent
commit
02a8f4703f
2 fichiers modifiés avec 19 ajouts et 3 suppressions
  1. 2 1
      door.h
  2. 17 2
      panel.cpp

+ 2 - 1
door.h

@@ -386,7 +386,7 @@ public:
   /**
   /**
    * Default Goto constructor copier
    * Default Goto constructor copier
    */
    */
-  Goto(Goto &) = default;
+  Goto(const Goto &) = default;
   void set(int xpos, int ypos);
   void set(int xpos, int ypos);
   friend std::ostream &operator<<(std::ostream &os, const Goto &g);
   friend std::ostream &operator<<(std::ostream &os, const Goto &g);
 };
 };
@@ -592,6 +592,7 @@ public:
    */
    */
   bool update(Door &d);
   bool update(Door &d);
   void update(Door &d, int line);
   void update(Door &d, int line);
+  door::Goto gotoEnd(void);
 
 
   friend std::ostream &operator<<(std::ostream &os, const Panel &p);
   friend std::ostream &operator<<(std::ostream &os, const Panel &p);
 };
 };

+ 17 - 2
panel.cpp

@@ -242,6 +242,19 @@ void Panel::update(Door &d, int line) {
   d << *l;
   d << *l;
 }
 }
 
 
+door::Goto Panel::gotoEnd(void) {
+  int row = y;
+  int style = (int)border_style;
+  if (style > 0)
+    ++row;
+  row += lines.size();
+  int col = x;
+  if (style > 0)
+    col += 2;
+  col += width;
+  return door::Goto(col, row);
+}
+
 // operator<< Panel is called to output the Menu.
 // operator<< Panel is called to output the Menu.
 // Menu has been massively changed to use Render instead of Colorizer.
 // Menu has been massively changed to use Render instead of Colorizer.
 
 
@@ -590,8 +603,10 @@ int Menu::choose(Door &door) {
           // *this->update(door, si);
           // *this->update(door, si);
           update(door, si);
           update(door, si);
         }
         }
-        // Currently, the cursor is beside the last line updated.  Where should
-        // the cursor go?  Should I place it back at the end of the panel?
+        // Cursor is positioned at the end of the panel/menu.
+        // The cursor changes colors as you arrow up or down.
+        // Interesting!
+        door << gotoEnd();
       }
       }
       // door << flush;
       // door << flush;
       // door.update();
       // door.update();