This file is indexed.

/usr/include/Nux-4.0/Nux/Painter.h is in libnux-4.0-dev 4.0.8+16.04.20160209-0ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
/*
 * Copyright 2010 Inalogic® Inc.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License, as
 * published by the  Free Software Foundation; either version 2.1 or 3.0
 * of the License.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the applicable version of the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of both the GNU Lesser General Public
 * License along with this program. If not, see <http://www.gnu.org/licenses/>
 *
 * Authored by: Jay Taoko <jaytaoko@inalogic.com>
 *
 */


#ifndef PAINTER_H
#define PAINTER_H

#include <string>
#include <iostream>
#include <list>

#include "Utils.h"
#include "NuxGraphics/GraphicsEngine.h"
#include "PaintLayer.h"

namespace nux
{

  class TextLineRenderer;
  class BaseTexture;

  class GeometryPositioning
  {
  public:
    GeometryPositioning();
    GeometryPositioning(
      HorizontalAlignment horizontal_aligment,
      VerticalAlignment vertical_aligment,
      bool stretch_horizontal = FALSE,
      bool stretch_vertical = FALSE,
      int horizontal_margin = 0,
      int vertical_margin = 0);
    ~GeometryPositioning();

    bool m_stretch_horizontal;  // if TRUE, the content width will be stretched over the width of the container.
    bool m_stretch_vertical;    // if TRUE, the content height will be stretched over the height of the container.

    void SetAlignment(HorizontalAlignment ha, VerticalAlignment va)
    {
      m_vertical_aligment = va;
      m_horizontal_aligment = ha;
    }

    VerticalAlignment m_vertical_aligment;
    HorizontalAlignment m_horizontal_aligment;

    int m_horizontal_margin;    // Add a margin to the horizontal alignment
    int m_vertical_margin;      // Add a margin to the vertical alignment
  };

//! Compute the position of one geometry inside an other.
  /*!
      Compute the position of one geometry inside an other.

      @container_geo The container geometry
      @content_geo   The content geometry
      @GeometryPositioning    The parameter to use to compute the position of the content.
      @return the computed geometry.
  */
  Geometry ComputeGeometryPositioning(const Geometry &container_geo, const Geometry &content_geo, GeometryPositioning gctx);

//! State of UI controls
  /*
      Class storing the states of User interface controls such button, radio, checkbox, combobox.
  */
  class InteractState
  {
  public:

    /*
       Default constructor. All states are set to false.
    */
    InteractState();
    InteractState(bool on, bool focus, bool prelight, bool disable);
    ~InteractState();

    bool is_on;
    bool is_focus;
    bool is_prelight;
    bool is_disable;
  };




// enum PainterBackgroundType
// {
//     eColorBackground = 0,
//     eShapeBackground,
//     eShapeCornerBackground,
//     eTextureBackground,
// };

  class TextureAlignmentStyle
  {
  public:
    TextureAlignmentStyle()
    {
      horz_alignment = eTACenter;
      vert_alignment = eTACenter;
      horizontal_margin = 0;
      vertical_margin = 0;
    };
    TextureAlignmentStyle(TextureAlignment horz_align, TextureAlignment vert_align)
    {
      horz_alignment = horz_align;
      vert_alignment = vert_align;
      horizontal_margin = 0;
      vertical_margin = 0;
    };

    ~TextureAlignmentStyle() {};

    enum TextureAlignment horz_alignment;
    enum TextureAlignment vert_alignment;
    int horizontal_margin;
    int vertical_margin;
  };

  class BasePainter
  {
  public:
    BasePainter(WindowThread *window_thread);
    virtual ~BasePainter();
    int intTest;

    //! Draw unscaled texture at position(x, y). The size of the quad is the size of the texture.
    virtual void Draw2DTexture(GraphicsEngine &graphics_engine, BaseTexture *Texture, int x, int y) const;
    virtual void Draw2DTextureAligned(GraphicsEngine &graphics_engine, BaseTexture *Texture, const Geometry &g, TextureAlignmentStyle tex_align) const;

    ///////////////////

    ////////////////////
    // TEXT PAINTING  //
    ////////////////////
    virtual int PaintColorTextLineEdit(GraphicsEngine &graphics_engine, const Geometry &g,
                                       std::string const& Str,
                                        Color TextColor,
                                        bool WriteAlphaChannel,
                                        Color SelectedTextColor,
                                        Color SelectedTextBackgroundColor,
                                        Color TextBlinkColor,
                                        Color CursorColor,
                                        bool ShowCursor, unsigned int CursorPosition,
                                        int offset = 0,
                                        int selection_start = 0, int selection_end = 0) const;

    virtual int PaintTextLineStatic(GraphicsEngine &graphics_engine,
                                    ObjectPtr<FontTexture> Font,
                                    Geometry const& g,
                                    std::string const& text_line,
                                    Color const& color = Color(0.0f, 0.0f, 0.0f, 1.0f),
                                    bool WriteAlphaChannel = true,
                                    TextAlignment alignment = eAlignTextLeft) const;

    void Paint2DQuadColor(GraphicsEngine &graphics_engine, const Geometry &g, const Color &c0) const;
    void Paint2DQuadColor(GraphicsEngine &graphics_engine, const Geometry &g, const Color &c0_top_left, const Color &c1_bottom_left, const Color &c2_bottom_right, const Color &c3_top_right) const;

    void Paint2DQuadColor(GraphicsEngine &graphics_engine, int x, int y, int width, int height, const Color &c0) const;
    void Paint2DQuadColor(GraphicsEngine &graphics_engine, int x, int y, int width, int height, const Color &c0_top_left, const Color &c1_bottom_left, const Color &c2_bottom_right, const Color &c3_top_right) const;

    //! Paint a 2D quad with a gradient color going from Top to Bottom.
    /*! Paint a 2D quad with a gradient color going from Top to Bottom.
        @param g Geometry of the quad.
        @param TopColor color at the top of the quad.
        @param TopColor color at the bottom of the quad.
    */
    void Paint2DQuadVGradient(GraphicsEngine &graphics_engine, const Geometry &g, Color TopColor, Color BottomColor) const;
    //! Paint a 2D quad with a gradient color going from Left to Right.
    /*! Paint a 2D quad with a gradient color going from Left to Right.
        @param g Geometry of the quad.
        @param LeftColor color at the top of the quad.
        @param RightColor color at the bottom of the quad.
    */
    void Paint2DQuadHGradient(GraphicsEngine &graphics_engine, const Geometry &g, Color LeftColor, Color RightColor) const;

    void Paint2DQuadWireframe(GraphicsEngine &graphics_engine, const Geometry &g, Color c0) const;
    void Paint2DQuadWireframe(GraphicsEngine &graphics_engine, const Geometry &g, Color c_top_left, Color c_bottom_left, Color c_bottom_right, Color c_top_right) const;

    void Paint2DQuadWireframe(GraphicsEngine &graphics_engine, int x, int y, int width, int height, Color c0) const;
    void Paint2DQuadWireframe(GraphicsEngine &graphics_engine, int x, int y, int width, int height, Color c_top_left, Color c_bottom_left, Color c_bottom_right, Color c_top_right) const;

    void Draw2DTriangleColor(GraphicsEngine &graphics_engine, int x0, int y0,
                              int x1, int y1,
                              int x2, int y2,
                              Color c0);
    void Draw2DTriangleColor(GraphicsEngine &graphics_engine, int x0, int y0,
                              int x1, int y1,
                              int x2, int y2,
                              Color c0, Color c1, Color c2);

    //////////////////////
    // DRAW LINES       //
    //////////////////////
    void Draw2DLine(GraphicsEngine &graphics_engine, int x0, int y0,
                     int x1, int y1, Color c0) const;
    void Draw2DLine(GraphicsEngine &graphics_engine, int x0, int y0,
                     int x1, int y1, Color c0, Color c1) const;

    ////////////////////
    // Themes         //
    ////////////////////
    void PaintShape(GraphicsEngine &graphics_engine, const Geometry &geo, const Color &c0, UXStyleImageRef style, bool WriteAlpha = true) const;
    void PaintShapeCorner(GraphicsEngine &graphics_engine, const Geometry &geo, const Color &c0, UXStyleImageRef style, long corners, bool WriteAlpha = true) const;
    void PaintShapeROP(GraphicsEngine &graphics_engine, const Geometry &geo, const Color &c0, UXStyleImageRef style, bool WriteAlpha = true,
                        const ROPConfig &ROP = ROPConfig::Default) const;
    void PaintShapeCornerROP(GraphicsEngine &graphics_engine,
                            const Geometry &geo,
                            const Color &c0,
                            UXStyleImageRef style,
                            long corners,
                            bool WriteAlpha = true,
                            const ROPConfig &ROP = ROPConfig::Default) const;

    void PaintTextureShape(GraphicsEngine &graphics_engine, const Geometry &geo, UXStyleImageRef style) const;
    void PaintTextureShape(GraphicsEngine &graphics_engine, const Geometry &geo, BaseTexture *Texture,
                            int border_left, int border_right, int border_top, int border_bottom, bool draw_borders_only, bool premultiply = true) const;

    //! Draw Check Box.
    /*!
        Draw a Check box.
    */

    void PaintCheckBox(GraphicsEngine &graphics_engine, const Geometry &geo, const InteractState &interaction_state,
                        Color check_mark_color = Color(0x0), Color check_box_color = Color(0x0));

    void PaintRadioButton(GraphicsEngine &graphics_engine, const Geometry &geo, const InteractState &interaction_state,
                           Color check_mark_color = Color(0x0), Color check_box_color = Color(0x0));

    void PaintHorizontalGradientQuad(GraphicsEngine &graphics_engine, const Geometry &geo, int num_color, float *percentage_array, Color *color_array);

  public:
    void PushColorLayer(GraphicsEngine &graphics_engine, const Geometry &geo,
                         Color color,
                         bool WriteAlpha = false,
                         const ROPConfig &ROP = ROPConfig::Default);

    void PushShapeLayer(GraphicsEngine &graphics_engine, Geometry geo,
                         UXStyleImageRef imageStyle,
                         const Color &color,
                         unsigned long Corners = eAllCorners,
                         bool WriteAlpha = false,
                         const ROPConfig &ROP = ROPConfig::Default);

    void PushSliceScaledTextureLayer(GraphicsEngine &graphics_engine, Geometry geo,
                                      UXStyleImageRef imageStyle,
                                      const Color &color,
                                      unsigned long Corners = eAllCorners,
                                      bool WriteAlpha = false,
                                      const ROPConfig &ROP = ROPConfig::Default);

    void PushTextureLayer(GraphicsEngine &graphics_engine, Geometry geo,
                           ObjectPtr<IOpenGLBaseTexture> DeviceTexture,
                           TexCoordXForm texxform,
                           const Color &color,
                           bool WriteAlpha = false,
                           const ROPConfig &ROP = ROPConfig::Default);

    void PushColorizeTextureLayer(GraphicsEngine &graphics_engine, Geometry geo,
				  ObjectPtr<IOpenGLBaseTexture> DeviceTexture,
				  TexCoordXForm texxform,
				  const Color &color,
				  bool WriteAlpha,
				  const ROPConfig &ROP,
				  const Color &blend_color,
				  LayerBlendMode layer_blend_mode);

    void PushDrawColorLayer(GraphicsEngine &graphics_engine, const Geometry &geo,
                             Color color,
                             bool WriteAlpha = false,
                             const ROPConfig &ROP = ROPConfig::Default);

    void PushDrawShapeLayer(GraphicsEngine &graphics_engine, Geometry geo,
                             UXStyleImageRef imageStyle,
                             const Color &color,
                             unsigned long Corners = eAllCorners,
                             bool WriteAlpha = false,
                             const ROPConfig &ROP = ROPConfig::Default);

    void PushDrawSliceScaledTextureLayer(GraphicsEngine &graphics_engine, Geometry geo,
                                          UXStyleImageRef imageStyle,
                                          const Color &color,
                                          unsigned long Corners = eAllCorners,
                                          bool WriteAlpha = false,
                                          const ROPConfig &ROP = ROPConfig::Default);

    void PushDrawTextureLayer(GraphicsEngine &graphics_engine, Geometry geo,
                               ObjectPtr<IOpenGLBaseTexture> DeviceTexture,
                               TexCoordXForm texxform,
                               const Color &color,
                               bool WriteAlpha = false,
                               const ROPConfig &ROP = ROPConfig::Default);

    void PushDrawColorizeTextureLayer(GraphicsEngine& graphics_engine, Geometry geo,
				  ObjectPtr<IOpenGLBaseTexture> DeviceTexture,
				  TexCoordXForm texxform,
				  const Color &color,
				  bool WriteAlpha,
				  const ROPConfig &ROP,
				  const Color &blend_color,
				  LayerBlendMode layer_blend_mode);
    
    void PushCompositionLayer (GraphicsEngine &graphics_engine,
			       Geometry geo,
			       ObjectPtr <IOpenGLBaseTexture> texture0,
			       TexCoordXForm texxform0,
			       const Color &color0,
			       ObjectPtr <IOpenGLBaseTexture> texture1,
			       TexCoordXForm texxform1,
			       const Color &color1, 
			       LayerBlendMode layer_blend_mode,
			       bool WriteAlpha,
			       const ROPConfig &ROP);

    void PushDrawCompositionLayer (GraphicsEngine &graphics_engine,
			       Geometry geo,
			       ObjectPtr <IOpenGLBaseTexture> texture0,
			       TexCoordXForm texxform0,
			       const Color &color0,
			       ObjectPtr <IOpenGLBaseTexture> texture1,
			       TexCoordXForm texxform1,
			       const Color &color1, 
			       LayerBlendMode layer_blend_mode,
			       bool WriteAlpha,
			       const ROPConfig &ROP);

    void PushCompositionLayer (GraphicsEngine &graphics_engine,
			       Geometry geo,
			       ObjectPtr <IOpenGLBaseTexture> texture0,
			       TexCoordXForm texxform0,
			       const Color& color0,
			       const Color& blend_color,
			       LayerBlendMode layer_blend_mode,
			       bool WriteAlpha,
			       const ROPConfig &ROP);
    
    void PushDrawCompositionLayer (GraphicsEngine &graphics_engine,
				   Geometry geo,
				   ObjectPtr <IOpenGLBaseTexture> texture0,
				   TexCoordXForm texxform0,
				   const Color &color0,
				   const Color& blend_color,
				   LayerBlendMode layer_blend_mode,
				   bool WriteAlpha,
				   const ROPConfig &ROP);

    void PushCompositionLayer (GraphicsEngine &graphics_engine,
			       Geometry geo,
			       const Color& base_color,
			       ObjectPtr <IOpenGLBaseTexture> texture0,
			       TexCoordXForm texxform0,
			       const Color& color0,
			       LayerBlendMode layer_blend_mode,
			       bool WriteAlpha,
			       const ROPConfig &ROP);
    
    void PushDrawCompositionLayer (GraphicsEngine &graphics_engine,
				   Geometry geo,
				   const Color& base_color,
				   ObjectPtr <IOpenGLBaseTexture> texture0,
				   TexCoordXForm texxform0,
				   const Color &color0,
				   LayerBlendMode layer_blend_mode,
				   bool WriteAlpha,
				   const ROPConfig &ROP);


    void PushLayer(GraphicsEngine &graphics_engine, const Geometry &geo, AbstractPaintLayer *layer);
    void PushDrawLayer(GraphicsEngine &graphics_engine, const Geometry &geo, AbstractPaintLayer *layer);

    //! Render a paint layer.
    /*!
        When calling this function make sure to assign a correct geometry to the paint layer parameter.
    */
    void RenderSinglePaintLayer(GraphicsEngine &graphics_engine, Geometry geo, AbstractPaintLayer *paint_layer);

    //! Deprecated. Use PopPaintLayer.
    void PopBackground(int level = 1);

    //! Pop the top most paint layers from the active paint layer stack.
    /*!
        Pop the top most paint layers from the active paint layer stack.

        @param level The number of layer to pop off.
    */
    void PopPaintLayer(int level = 1);
    
    //! Deprecated. Use EmptyActivePaintLayerStack.
    void EmptyBackgroundStack();
    
    //! Empty the active paint layer stack.
    /*!
        Empty the active paint layer stack. All paint layers in the active stack are deleted.

    */
    void EmptyActivePaintLayerStack();

    //! Deprecated. Use PaintActivePaintLayerStack.
    void PaintBackground(GraphicsEngine &graphics_engine, const Geometry &geo);

    //! Paint all the layers in the active paint layer stack.
    /*!
        Paint all the layers in the active paint layer stack.

    */
    void PaintActivePaintLayerStack(GraphicsEngine &graphics_engine, const Geometry &geo);

    //! Paint all layers in all stacks
    /*
        Paint all layers in all stacks with the current model-view and projection matrices.
        This is useful for redirected rendering to textures.
    */
    void PaintAllLayerStack(GraphicsEngine& graphics_engine, const Geometry& geo);

    //! Deprecated. Use PushPaintLayerStack.
    void PushBackgroundStack();

    //! Push the current paint layer stack.
    /*!
        Push the current paint layer stack.
    */
    void PushPaintLayerStack();
    
    //! Deprecated. Use PopPaintLayerStack.
    void PopBackgroundStack();

    //! Pop a previously pushed paint layer stack.
    /*!
        Pop a previously pushed paint layer stack.
    */
    void PopPaintLayerStack();

  private:
    
    //! Clear all the pushed paint layers.
    /*!
        Clear all the pushed paint layers.
        Each layer in a paint layer stack is deleted.
    */
    void EmptyPushedPaintLayerStack();
    std::list<AbstractPaintLayer*> active_paint_layer_stack_;
    std::list<std::list<AbstractPaintLayer*> > pushed_paint_layer_stack_;

    WindowThread *window_thread_; //!< The WindowThread to which this object belongs.

  };


  class PushBackgroundScope
  {
  public:
    PushBackgroundScope(BasePainter &painter, GraphicsEngine &graphics_engine, const Geometry &geo, UXStyleImageRef image_style, bool PushAndDraw = false)
      : m_painter(painter)
    {
      if (PushAndDraw)
        m_painter.PushDrawShapeLayer(graphics_engine, geo, image_style, color::White, eAllCorners);
      else
        m_painter.PushShapeLayer(graphics_engine, geo, image_style, color::White, eAllCorners);
    }

    ~PushBackgroundScope()
    {
      //m_painter.PopBackground();
    }

  private:
    BasePainter &m_painter;
  };

  class PushShapeBackgroundScope
  {
  public:
    PushShapeBackgroundScope(BasePainter &painter, GraphicsEngine &graphics_engine, const Geometry &geo, UXStyleImageRef image_style, const Color &color, bool PushAndDraw = false, bool WriteAlpha = false, const ROPConfig &ROP = ROPConfig::Default)
      : m_painter(painter)
    {
      if (PushAndDraw)
        m_painter.PushDrawShapeLayer(graphics_engine, geo, image_style, color, eAllCorners, WriteAlpha, ROP);
      else
        m_painter.PushShapeLayer(graphics_engine, geo, image_style, color, eAllCorners, WriteAlpha, ROP);
    }
    ~PushShapeBackgroundScope()
    {
      m_painter.PopBackground();
    }
  private:
    BasePainter &m_painter;
  };

  class PushShapeCornerBackgroundScope
  {
  public:
    PushShapeCornerBackgroundScope(BasePainter &painter, GraphicsEngine &graphics_engine, const Geometry &geo, UXStyleImageRef image_style, const Color &color, long corners, bool PushAndDraw = false, bool WriteAlpha = false, const ROPConfig &ROP = ROPConfig::Default)
      : m_painter(painter)
    {
      if (PushAndDraw)
        m_painter.PushDrawShapeLayer(graphics_engine, geo, image_style, color, corners, WriteAlpha, ROP);
      else
        m_painter.PushShapeLayer(graphics_engine, geo, image_style, color, corners, WriteAlpha, ROP);
    }
    ~PushShapeCornerBackgroundScope()
    {
      m_painter.PopBackground();
    }
  private:
    BasePainter &m_painter;
  };

  class PushColorBackgroundScope
  {
  public:
    PushColorBackgroundScope(BasePainter &painter, GraphicsEngine &graphics_engine, const Geometry &geo, const Color &color, bool PushAndDraw = false, bool WriteAlpha = false, const ROPConfig &ROP = ROPConfig::Default)
      : m_painter(painter)
    {
      if (PushAndDraw)
        m_painter.PushDrawColorLayer(graphics_engine, geo, color, WriteAlpha, ROP);
      else
        m_painter.PushColorLayer(graphics_engine, geo, color, WriteAlpha, ROP);
    }

    ~PushColorBackgroundScope()
    {
      m_painter.PopBackground();
    }
  private:
    BasePainter &m_painter;
  };


}

#endif // PAINTER_H