Shaper.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <ewol/debug.hpp>
10 #include <gale/resource/Program.hpp>
13 #include <ewol/resource/Image.hpp>
14 #include <ewol/event/Time.hpp>
15 #include <ewol/Padding.hpp>
16 
17 namespace ewol {
18  namespace compositing {
19  enum renderMode {
22  renderOneBorder,
23  };
24  #define SHAPER_NB_MAX_QUAD (5*5)
25  #define SHAPER_NB_MAX_TRIANGLE (SHAPER_NB_MAX_QUAD*2)
26  #define SHAPER_NB_MAX_VERTEX (SHAPER_NB_MAX_TRIANGLE*3)
27  enum shaperPos {
28  shaperPosLeft,
29  shaperPosRight,
30  shaperPosTop,
31  shaperPosButtom,
32  shaperPosCount,
33  };
37  // TODO : load image
38  // TODO : Abstaraction between states (call by name and the system greate IDs
39  class Shaper : public ewol::Compositing {
40  private:
41  std::string m_name;
42  // External theme config:
44  int32_t m_confIdPaddingOut[shaperPosCount];
45  int32_t m_confIdBorder[shaperPosCount];
46  int32_t m_confIdPaddingIn[shaperPosCount];
47  int32_t m_confIdMode;
48  int32_t m_confIdDisplayOutside;
49  int32_t m_confIdChangeTime;
50  int32_t m_confProgramFile;
51  int32_t m_confColorFile;
52  int32_t m_confImageFile;
53  // openGL shaders programs:
55  int32_t m_GLPosition;
56  int32_t m_GLMatrix;
57  int32_t m_GLPropertyPos;
58  int32_t m_GLStateActivate;
59  int32_t m_GLStateOld;
60  int32_t m_GLStateNew;
61  int32_t m_GLStateTransition;
62  int32_t m_GLtexID;
63  // For the Image :
65  // internal needed data :
66  int32_t m_nextStatusRequested;
67  vec2 m_propertyOrigin;
68  vec2 m_propertySize;
69  vec2 m_propertyInsidePosition;
70  vec2 m_propertyInsideSize;
71  int32_t m_stateActivate;
72  int32_t m_stateOld;
73  int32_t m_stateNew;
74  float m_stateTransition;
75  vec2 m_coord[SHAPER_NB_MAX_VERTEX];
76  vec2 m_pos[SHAPER_NB_MAX_VERTEX];
77  int32_t m_nbVertexToDisplay;
78  // color management theme:
80  std::vector<ivec2> m_listAssiciatedId;
81  private:
85  void loadProgram();
89  void unLoadProgram();
90  public:
95  Shaper(const std::string& _shaperName="");
99  virtual ~Shaper();
100  public:
104  void draw(bool _disableDepthTest=true);
108  void clear();
115  bool setState(int32_t _newState);
122  bool changeStatusIn(int32_t _newStatusId);
128  return m_stateNew;
129  };
135  return m_nextStatusRequested;
136  };
142  return m_stateTransition;
143  };
150  bool periodicCall(const ewol::event::Time& _event);
156  ewol::Padding getPaddingIn();
157  ewol::Padding getPaddingOut();
167  void setSource(const std::string& _newFile);
172  const std::string& getSource() const {
173  return m_name;
174  };
179  bool hasSources();
180  public:
225  void setShape(const vec2& _origin, const vec2& _size, const vec2& _insidePos, const vec2& _insideSize);
226  // @previous
227  void setShape(const vec2& _origin, const vec2& _size) {
228  ewol::Padding tmp = getPadding();
229  setShape(_origin, _size, _origin+vec2(tmp.xLeft(), tmp.yButtom()), _size - vec2(tmp.x(), tmp.y()));
230  }
231  public:
237  int32_t requestColor(const std::string& _name);
243  const etk::Color<float>& getColor(int32_t _id);
244  public:
250  int32_t requestConfig(const std::string& _name);
256  double getConfigNumber(int32_t _id);
257  public:
262  void setActivateState(int32_t _status) {
263  m_stateActivate = _status;
264  }
265  private:
266  void addVertexLine(float _yTop,
267  float _yButtom,
268  float _x1,
269  float _x2,
270  float _x3,
271  float _x4,
272  float _x5,
273  float _x6,
274  float _x7,
275  float _x8,
276  float _yValTop,
277  float _yValButtom,
278  const float* _table,
279  bool _displayOutside);
280  public:
281  /* ****************************************************
282  * == operator
283  *****************************************************/
284  bool operator== (const Shaper& _obj) const {
285  return _obj.m_name == m_name;
286  }
287  bool operator!= (const Shaper& _obj) const {
288  return _obj.m_name != m_name;
289  }
290  };
291  }
292 }
293 
294 
ewol::Padding getBorder()
get the padding declared by the user in the config file
void draw(bool _disableDepthTest=true)
draw All the refistered text in the current element on openGL
virtual ~Shaper()
generic destructor
void setActivateState(int32_t _status)
Set activate state of the element.
Definition: Shaper.hpp:262
Definition: Time.hpp:14
Shaper(const std::string &_shaperName="")
generic constructor
void setShape(const vec2 &_origin, const vec2 &_size, const vec2 &_insidePos, const vec2 &_insideSize)
set the shape property:
const etk::Color< float > & getColor(int32_t _id)
Get The color associated at an ID.
int32_t getCurrentDisplayedStatus()
get the current displayed status of the shaper
Definition: Shaper.hpp:127
Definition: Area.hpp:16
renderMode
Definition: Shaper.hpp:19
void clear()
clear alll tre registered element in the current element
bool hasSources()
Sometimes the user declare an image but not allocate the ressources all the time, this is to know it ...
Definition: Padding.hpp:14
bool setState(int32_t _newState)
Change the current state.
Definition: Compositing.hpp:13
ewol::Padding getPadding()
get the padding declared by the user in the config file
double getConfigNumber(int32_t _id)
Get The number associated at an ID.
bool periodicCall(const ewol::event::Time &_event)
Same as the widfget periodic call (this is for change display)
basic historic render mode
Definition: Shaper.hpp:20
int32_t getNextDisplayedStatus()
get the next displayed status of the shaper
Definition: Shaper.hpp:134
int32_t requestColor(const std::string &_name)
Get an ID on the color instance element.
the Shaper system is a basic theme configuration for every widget, it corespond at a background displ...
Definition: Shaper.hpp:39
int32_t requestConfig(const std::string &_name)
Get an ID on the configuration instance element.
const std::string & getSource() const
get the shaper file Source
Definition: Shaper.hpp:172
void setSource(const std::string &_newFile)
change the shaper Source
bool changeStatusIn(int32_t _newStatusId)
change the current status in an other
Render 4 squares for coiner, and renctangle for border, a big rentangle for background and 8 rectangl...
Definition: Shaper.hpp:21
float getTransitionStatus()
get the current trasion status
Definition: Shaper.hpp:141