Browse Source

Moved door::Screen out of experimental.

Steve Thielemann 3 năm trước cách đây
mục cha
commit
69f1a620a6
2 tập tin đã thay đổi với 38 bổ sung19 xóa
  1. 14 8
      door.h
  2. 24 11
      panel.cpp

+ 14 - 8
door.h

@@ -582,6 +582,11 @@ public:
   Panel(Panel &&ref);
 
   void set(int x, int y);
+  /*
+  void get(int &x, int &y) {
+    x = this->x;
+    y = this->y;
+  }; */
   void setTitle(std::unique_ptr<Line> T, int off = 1);
   void setStyle(BorderStyle bs);
   void setColor(ANSIColor c);
@@ -672,26 +677,27 @@ public:
 
 renderFunction renderStatusValue(ANSIColor state, ANSIColor value);
 
-#ifdef EXPERIMENTAL
-
 class Screen {
 private:
-  bool hidden;
+  // bool hidden;
   std::vector<std::shared_ptr<Panel>> parts;
 
 public:
   Screen(void);
   Screen(Screen &) = default;
   void addPanel(std::shared_ptr<Panel> p);
-  bool delPanel(std::shared_ptr<Panel> p); // HMM.  Or ptr?
-  void hide(void);
-  void show(void);
+  /*
+bool delPanel(std::shared_ptr<Panel> p);
+
+void hide(void);
+void show(void);
+*/
+  bool update(Door &d);
+  void update(void);
 
   friend std::ostream &operator<<(std::ostream &os, const Screen &s);
 };
 
-#endif
-
 /*
 screen - contains panels.
   - default to 1,1 X 80,24

+ 24 - 11
panel.cpp

@@ -721,9 +721,7 @@ int Menu::choose(Door &door) {
   return 0;
 }
 
-#ifdef EXPERIMENTAL
-
-Screen::Screen() { hidden = false; }
+Screen::Screen(){}; // hidden = false; }
 
 /*
 Screen::Screen(Screen &s) {
@@ -734,19 +732,34 @@ Screen::Screen(Screen &s) {
 
 void Screen::addPanel(std::shared_ptr<Panel> p) { parts.push_back(p); }
 
+/*
 void Screen::hide(void) { hidden = true; }
 void Screen::show(void) { hidden = false; }
+*/
 
-std::ostream &operator<<(std::ostream &os, const Screen &s) {
-  if (!s.hidden) {
-    for (auto part : s.parts) {
-      os << part;
-    };
-    // os << flush;
+bool Screen::update(Door &d) {
+  bool updated = false;
+  for (auto panel : parts) {
+    if (panel->update(d))
+      updated = true;
   }
-  return os;
+  return updated;
 }
 
-#endif
+void Screen::update(void) {
+  for (auto panel : parts) {
+    panel->update();
+  }
+}
+
+std::ostream &operator<<(std::ostream &os, const Screen &s) {
+  // if (!s.hidden) {
+  for (auto part : s.parts) {
+    os << *part;
+  };
+  // os << flush;
+  // }
+  return os;
+}
 
 } // namespace door