Manager.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <etk/types.hpp>
9 #include <ewol/debug.hpp>
10 #include <vector>
11 #include <unordered_map>
12 #include <ewol/widget/Widget.hpp>
13 
14 namespace ewol {
15  namespace widget {
16  class Manager {
17  public:
18  Manager();
19  virtual ~Manager();
20  // ---------------------------------------------
21  // -- Focus area
22  // ---------------------------------------------
23  private:
24  ewol::WidgetWeak m_focusWidgetDefault;
25  ewol::WidgetWeak m_focusWidgetCurrent;
26  public:
31  void focusKeep(ewol::WidgetShared _newWidget);
36  void focusSetDefault(ewol::WidgetShared _newWidget);
40  void focusRelease();
46  // ---------------------------------------------
47  // -- Factory area
48  // ---------------------------------------------
49  public:
50  using widgetCreatorFunction = std::function<ewol::WidgetShared()>;
51  private:
52  std::unordered_map<std::string, widgetCreatorFunction> m_creatorList;
53  public:
59  void addWidgetCreator(const std::string& _name, widgetCreatorFunction _factory);
65  ewol::WidgetShared create(const std::string& _name);
72  bool exist(const std::string& _name);
77  std::string list();
78  // ---------------------------------------------
79  // -- Something change area (TODO: maybe set it in the windows)
80  // ---------------------------------------------
81  private:
82  bool m_haveRedraw;
83  private:
84  std::function<void()> m_funcRedrawNeeded;
85  public:
89  void markDrawingIsNeeded();
94  bool isDrawingNeeded();
95  private:
96 
101  void setCallbackonRedrawNeeded(const std::function<void()>& _func);
102 
103  };
104  };
105 };
106 
void addWidgetCreator(const std::string &_name, widgetCreatorFunction _factory)
add a factory of a specific widget.
Definition: Manager.hpp:16
bool exist(const std::string &_name)
Check if an Widget exist.
std::string list()
Get the list of all Widget that can be created.
void focusRelease()
Release the current focus (back on default if possible).
Definition: Area.hpp:16
ewol::WidgetShared create(const std::string &_name)
Create a widget with his name.
bool isDrawingNeeded()
Check if a redraw has been requested (set the local value back at false)
ewol::WidgetShared focusGet()
Get the current Focused widget.
void focusKeep(ewol::WidgetShared _newWidget)
Request a focus on a specify widget.
void focusSetDefault(ewol::WidgetShared _newWidget)
Set the default focus when none selected.
std::function< ewol::WidgetShared()> widgetCreatorFunction
funtion factory basic definition
Definition: Manager.hpp:50
void markDrawingIsNeeded()
Mark the display to redraw.