CanvasCV: CanvasCV-doxygen/src/canvascv/widgets/compoundwidget.h Source File
CanvasCV  1.0.0
compoundwidget.h
1 #ifndef COMPOUNDWIDGET_H
2 #define COMPOUNDWIDGET_H
3 
4 #include "widget.h"
5 #include "layoutbase.h"
6 
7 #include <list>
8 #include <memory>
9 
10 namespace canvascv
11 {
12 
18 class CompoundWidget : public Widget, public LayoutBase
19 {
20 public:
21 
23  virtual void setOutlineColor(const cv::Scalar &value);
24 
26  virtual void setFillColor(const cv::Scalar &value);
27 
29  virtual void setSelectColor(const cv::Scalar &value);
30 
32  virtual void setThickness(int value);
33 
35  virtual void setLineType(int value);
36 
38  virtual void setVisible(bool value);
39 
41  virtual const std::string &getStatusMsg() const;
42 
44  virtual void translate(const cv::Point &translation);
45 
59  void doForAll(CBWidget cb, int recurseLevel, bool doOnSelf);
60 
61  virtual const cv::Rect &getRect();
62 protected:
63  // force inheritance
64  CompoundWidget(const cv::Point &pos);
65  virtual ~CompoundWidget() {}
66 
67  virtual bool isCompoundWidget() const;
68 
70  virtual void recalc() final;
71  void recalcRect(int padding);
72 
81  virtual void recalcCompound() = 0;
82 
83  virtual void addWidget(const std::shared_ptr<Widget> &widget);
84  virtual std::shared_ptr<Widget> rmvWidget(const std::shared_ptr<Widget> &widget);
85 
86  virtual const cv::Rect getBoundaries() const;
87 
88  virtual void renderOn(cv::Mat &dst);
89  virtual void drawFG(cv::Mat &dst);
90  virtual bool isAtPos(const cv::Point &pos);
91 
92  virtual const cv::Rect &getMinimalRect();
93 
94  virtual void reloadPointers(std::list<Widget*>::const_iterator &)
95  {}
96 
97  virtual std::shared_ptr<Widget> rmvWidget(Widget* widget);
98 
99  /* TODO - write/read widgets to file for a designer app
100  virtual void writeInternals(cv::FileStorage &fs) const;
101  virtual void readInternals(const cv::FileNode &node);
102  */
103 
104  bool fillBG;
105  cv::Rect rect;
106  cv::Rect minimalRect;
107 
108  std::list<std::shared_ptr<Widget>> widgets;
109 private:
110  virtual bool setDirtyLayout();
111 
112  virtual void broadcastChange(State status);
113 
114  void recalcMinimalRect();
115 
116  std::shared_ptr<Widget> active;
117 };
118 
119 }
120 
121 #endif // COMPOUNDWIDGET_H
virtual void setOutlineColor(const cv::Scalar &value)
delegate to internal Widget parts added by derived classes
The LayoutBase class.
Definition: layoutbase.h:14
virtual const std::string & getStatusMsg() const
delegate to active widget or to our derived class if none active
void doForAll(CBWidget cb, int recurseLevel, bool doOnSelf)
doForAll
The CompoundWidget class.
Definition: compoundwidget.h:18
virtual void renderOn(cv::Mat &dst)
render the widget to dst
virtual void drawFG(cv::Mat &dst)
dst is the roi of the widget size and not the full image
virtual void setLineType(int value)
delegate to internal Widget parts added by derived classes
virtual const cv::Rect & getRect()
Actual size the widget is occupying due to Layout manager.
virtual std::shared_ptr< Widget > rmvWidget(const std::shared_ptr< Widget > &widget)
rmvWidget
State
These are the widget states.
Definition: widget.h:33
This namespace holds all the classes of the CanvasCV library.
Definition: canvas.h:20
virtual const cv::Rect & getMinimalRect()
Minimal size the widget coould have occupy.
virtual void setSelectColor(const cv::Scalar &value)
delegate to internal Widget parts added by derived classes
virtual void setVisible(bool value)
delegate to internal Widget parts added by derived classes
virtual void recalc() final
delegate to internal Widget parts added by derived classes
virtual void addWidget(const std::shared_ptr< Widget > &widget)
adds the widget to this Layout after removing it from it&#39;s previous layout
virtual bool isAtPos(const cv::Point &pos)
isAtPos
virtual void recalcCompound()=0
recalcCompound
virtual void translate(const cv::Point &translation)
delegate to internal Widget parts added by derived classes
The Widget class.
Definition: widget.h:28
virtual void setThickness(int value)
delegate to internal Widget parts added by derived classes
std::function< void(Widget *)> CBWidget
signature of a callback which only gets the widget
Definition: widget.h:42
virtual void setFillColor(const cv::Scalar &value)
delegate to internal Widget parts added by derived classes