Drawing.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <etk/Color.hpp>
9 
10 #include <ewol/debug.hpp>
12 #include <gale/resource/Program.hpp>
13 
14 
15 namespace ewol {
16  namespace compositing {
17  class Drawing : public ewol::Compositing {
18  private:
19  vec3 m_position;
20  vec3 m_clippingPosStart;
21  vec3 m_clippingPosStop;
22  bool m_clippingEnable;
23  private:
24  etk::Color<> m_color;
25  etk::Color<> m_colorBg;
26  private:
28  int32_t m_GLPosition;
29  int32_t m_GLMatrix;
30  int32_t m_GLMatrixPosition;
31  int32_t m_GLColor;
32  public: // Background Color (display only when needed)
33  std::vector<vec3 > m_coord;
34  std::vector<etk::Color<float> > m_coordColor;
35  public:
39  Drawing();
43  virtual ~Drawing();
44  private:
48  void loadProgram();
52  void unLoadProgram();
53  float m_thickness;
54  int32_t m_triElement;
55  vec3 m_triangle[3];
56  etk::Color<float> m_tricolor[3];
57  // internal API for the generation abstraction of triangles
61  void generateTriangle();
65  void resetCount();
70  void internalSetColor(const etk::Color<>& _color);
75  void setPoint(const vec3& point);
76 
77  public:
81  void draw(bool _disableDepthTest=true);
85  void clear();
90  const vec3& getPos() {
91  return m_position;
92  };
97  void setPos(const vec3& _pos) {
98  m_position = _pos;
99  };
100  inline void setPos(const vec2& _pos) {
101  setPos(vec3(_pos.x(), _pos.y(), 0));
102  };
107  void setRelPos(const vec3& _pos) {
108  m_position += _pos;
109  };
110  inline void setRelPos(const vec2& _pos) {
111  setRelPos(vec3(_pos.x(), _pos.y(), 0));
112  };
117  void setColor(const etk::Color<>& _color) {
118  m_color = _color;
119  };
125  return m_color;
126  };
131  void setColorBg(const etk::Color<>& _color) {
132  m_colorBg = _color;
133  };
139  return m_colorBg;
140  };
146  void setClippingWidth(const vec3& _pos, const vec3& _width) {
147  setClipping(_pos, _pos+_width);
148  };
149  inline void setClippingWidth(const vec2& _pos, const vec2& _width) {
150  setClippingWidth(vec3(_pos.x(),_pos.y(),-1), vec3(_width.x(),_width.y(), 2));
151  };
157  void setClipping(const vec3& _pos, const vec3& _posEnd);
158  inline void setClipping(const vec2& _pos, const vec2& _posEnd) {
159  setClipping(vec3(_pos.x(),_pos.y(),-1), vec3(_posEnd.x(),_posEnd.y(), 1));
160  };
165  void setClippingMode(bool _newMode) {
166  m_clippingEnable = _newMode;
167  };
172  void setThickness(float _thickness);
176  void addVertex();
181  void lineTo(const vec3& _dest);
182  inline void lineTo(const vec2& _dest) {
183  lineTo(vec3(_dest.x(), _dest.y(), 0));
184  };
189  void lineRel(const vec3& _vect) {
190  lineTo(m_position+_vect);
191  };
192  inline void lineRel(const vec2& _vect) {
193  lineRel(vec3(_vect.x(), _vect.y(), 0));
194  };
199  void rectangle(const vec3& _dest);
200  inline void rectangle(const vec2& _dest) {
201  rectangle(vec3(_dest.x(), _dest.y(), 0));
202  };
207  void rectangleWidth(const vec3& _size) {
208  rectangle(m_position+_size);
209  };
210  inline void rectangleWidth(const vec2& _size) {
211  rectangleWidth(vec3(_size.x(), _size.y(), 0));
212  };
217  void cube(const vec3& _dest);
224  void circle(float _radius, float _angleStart = 0, float _angleStop = 2*M_PI);
225  };
226  };
227 };
228 
std::vector< etk::Color< float > > m_coordColor
internal color of the background
Definition: Drawing.hpp:34
const T & x() const
void setColorBg(const etk::Color<> &_color)
set the background color of the font (for selected Text (not the global BG))
Definition: Drawing.hpp:131
void cube(const vec3 &_dest)
draw a 3D rectangle to the position requested.
void clear()
clear alll tre registered element in the current element
void setClippingWidth(const vec3 &_pos, const vec3 &_width)
Request a clipping area for the text (next draw only)
Definition: Drawing.hpp:146
void circle(float _radius, float _angleStart=0, float _angleStop=2 *M_PI)
draw a 2D circle with the specify rafdius parameter.
Definition: Drawing.hpp:17
void rectangle(const vec3 &_dest)
draw a 2D rectangle to the position requested.
const vec3 & getPos()
get the current display position (sometime needed in the gui control)
Definition: Drawing.hpp:90
void setPos(const vec3 &_pos)
set position for the next text writen
Definition: Drawing.hpp:97
void lineRel(const vec3 &_vect)
Relative drawing a line (spacial vector)
Definition: Drawing.hpp:189
Drawing()
Basic constructor.
Definition: Area.hpp:16
void addVertex()
add a point reference at the current position (this is a vertex reference at the current position ...
const T & y() const
virtual ~Drawing()
Basic destructor.
void setColor(const etk::Color<> &_color)
set the Color of the current foreground font
Definition: Drawing.hpp:117
std::vector< vec3 > m_coord
internal position for the text display
Definition: Drawing.hpp:33
void setRelPos(const vec3 &_pos)
set relative position for the next text writen
Definition: Drawing.hpp:107
Definition: Compositing.hpp:13
void draw(bool _disableDepthTest=true)
draw All the refistered text in the current element on openGL
const etk::Color & getColorBg()
Get the background color of the font.
Definition: Drawing.hpp:138
void setClippingMode(bool _newMode)
enable/Disable the clipping (without lose the current clipping position)
Definition: Drawing.hpp:165
void lineTo(const vec3 &_dest)
draw a line to a specific position
void setThickness(float _thickness)
Specify the line thickness for the next elements.
void rectangleWidth(const vec3 &_size)
draw a 2D rectangle to the requested size.
Definition: Drawing.hpp:207
const etk::Color & getColor()
Get the foreground color of the font.
Definition: Drawing.hpp:124
void setClipping(const vec3 &_pos, const vec3 &_posEnd)
Request a clipping area for the text (next draw only)