FastUIDraw
fill_rule.hpp
Go to the documentation of this file.
1 /*!
2  * \file fill_rule.hpp
3  * \brief file fill_rule.hpp
4  *
5  * Copyright 2016 by Intel.
6  *
7  * Contact: kevin.rogovin@gmail.com
8  *
9  * This Source Code Form is subject to the
10  * terms of the Mozilla Public License, v. 2.0.
11  * If a copy of the MPL was not distributed with
12  * this file, You can obtain one at
13  * http://mozilla.org/MPL/2.0/.
14  *
15  * \author Kevin Rogovin <kevin.rogovin@gmail.com>
16  *
17  */
18 
19 #ifndef FASTUIDRAW_FILL_RULE_HPP
20 #define FASTUIDRAW_FILL_RULE_HPP
21 
23 
24 namespace fastuidraw
25 {
26 /*!\addtogroup Painter
27  * @{
28  */
29  /*!
30  * \brief
31  * Base class to specify a custom fill rule.
32  */
34  {
35  public:
36  /*!
37  * To be implemented by a derived class to return
38  * true if to draw those regions with the passed
39  * winding number.
40  * \param winding_number winding number value to test.
41  */
42  virtual
43  bool
44  operator()(int winding_number) const = 0;
45  };
46 
47  /*!
48  * \brief
49  * Class to specify a custom fill rule from
50  * a function.
51  */
53  {
54  public:
55  /*!
56  * Typedef to fill rule function pointer type
57  */
58  typedef bool (*fill_rule_fcn)(int);
59 
60  /*!
61  * Ctor.
62  * \param fill_rule function to use to implement
63  * operator(int) const.
64  */
65  explicit
66  CustomFillRuleFunction(fill_rule_fcn fill_rule):
67  m_fill_rule(fill_rule)
68  {}
69 
70  /*!
71  * Ctor from a PainterEnums::fill_rule_t enumeration
72  * \param fill_rule enumeration for fill rule.
73  */
74  explicit
76  m_fill_rule(function_from_enum(fill_rule))
77  {}
78 
79  virtual
80  bool
81  operator()(int winding_number) const
82  {
83  return m_fill_rule && m_fill_rule(winding_number);
84  }
85 
86  /*!
87  * Returns a \ref fill_rule_fcn implementing
88  * a fill rule from a \ref PainterEnums::fill_rule_t.
89  * \param fill_rule enumerated fill rule.
90  */
91  static
92  fill_rule_fcn
93  function_from_enum(enum PainterEnums::fill_rule_t fill_rule);
94 
95  private:
96  fill_rule_fcn m_fill_rule;
97  };
98  /*! @} */
99 }
100 
101 #endif
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
CustomFillRuleFunction(enum PainterEnums::fill_rule_t fill_rule)
Definition: fill_rule.hpp:75
CustomFillRuleFunction(fill_rule_fcn fill_rule)
Definition: fill_rule.hpp:66
virtual bool operator()(int winding_number) const =0
file painter_enums.hpp
fill_rule_t
Enumerations specifying common fill rules.
virtual bool operator()(int winding_number) const
Definition: fill_rule.hpp:81
Class to specify a custom fill rule from a function.
Definition: fill_rule.hpp:52
Base class to specify a custom fill rule.
Definition: fill_rule.hpp:33