Convert "bool" members in ui::Widget to flags

This commit is contained in:
David Capello 2016-08-26 15:24:03 -03:00
parent 97813251e1
commit 03be4aa23d
3 changed files with 8 additions and 10 deletions

View File

@ -47,7 +47,9 @@ namespace ui {
INITIALIZED = 0x00000400, // The widget was already initialized by a theme. INITIALIZED = 0x00000400, // The widget was already initialized by a theme.
DIRTY = 0x00000800, // The widget (or one child) is dirty (update_region != empty). DIRTY = 0x00000800, // The widget (or one child) is dirty (update_region != empty).
HAS_TEXT = 0x00001000, // The widget has text (at least setText() was called one time). HAS_TEXT = 0x00001000, // The widget has text (at least setText() was called one time).
CTRL_RIGHT_CLICK = 0x00002000, // The widget should transform Ctrl+click to right-click on OS X. DOUBLE_BUFFERED = 0x00002000, // The widget is painted in a back-buffer and then flipped to the main display
TRANSPARENT = 0x00004000, // The widget has transparent parts that needs the background painted before
CTRL_RIGHT_CLICK = 0x00008000, // The widget should transform Ctrl+click to right-click on OS X.
PROPERTIES_MASK = 0x0000ffff, PROPERTIES_MASK = 0x0000ffff,
HORIZONTAL = 0x00010000, HORIZONTAL = 0x00010000,

View File

@ -69,8 +69,6 @@ Widget::Widget(WidgetType type)
, m_bounds(0, 0, 0, 0) , m_bounds(0, 0, 0, 0)
, m_parent(nullptr) , m_parent(nullptr)
, m_sizeHint(nullptr) , m_sizeHint(nullptr)
, m_doubleBuffered(false)
, m_transparent(false)
, m_minSize(0, 0) , m_minSize(0, 0)
, m_maxSize(INT_MAX, INT_MAX) , m_maxSize(INT_MAX, INT_MAX)
, m_childSpacing(0) , m_childSpacing(0)
@ -1010,22 +1008,22 @@ bool Widget::paintEvent(Graphics* graphics)
bool Widget::isDoubleBuffered() const bool Widget::isDoubleBuffered() const
{ {
return m_doubleBuffered; return hasFlags(DOUBLE_BUFFERED);
} }
void Widget::setDoubleBuffered(bool doubleBuffered) void Widget::setDoubleBuffered(bool doubleBuffered)
{ {
m_doubleBuffered = doubleBuffered; enableFlags(DOUBLE_BUFFERED);
} }
bool Widget::isTransparent() const bool Widget::isTransparent() const
{ {
return m_transparent; return hasFlags(TRANSPARENT);
} }
void Widget::setTransparent(bool transparent) void Widget::setTransparent(bool transparent)
{ {
m_transparent = transparent; enableFlags(TRANSPARENT);
} }
void Widget::invalidate() void Widget::invalidate()
@ -1084,7 +1082,7 @@ GraphicsPtr Widget::getGraphics(const gfx::Rect& clip)
// In case of double-buffering, we need to create the temporary // In case of double-buffering, we need to create the temporary
// buffer only if the default surface is the screen. // buffer only if the default surface is the screen.
if (m_doubleBuffered && defaultSurface->isDirectToScreen()) { if (isDoubleBuffered() && defaultSurface->isDirectToScreen()) {
surface = she::instance()->createSurface(clip.w, clip.h); surface = she::instance()->createSurface(clip.w, clip.h);
graphics.reset(new Graphics(surface, -clip.x, -clip.y), graphics.reset(new Graphics(surface, -clip.x, -clip.y),
DeleteGraphicsAndSurface(clip, surface)); DeleteGraphicsAndSurface(clip, surface));

View File

@ -392,8 +392,6 @@ namespace ui {
WidgetsList m_children; // Sub-widgets WidgetsList m_children; // Sub-widgets
Widget* m_parent; // Who is the parent? Widget* m_parent; // Who is the parent?
gfx::Size* m_sizeHint; gfx::Size* m_sizeHint;
bool m_doubleBuffered;
bool m_transparent;
// Widget size limits // Widget size limits
gfx::Size m_minSize, m_maxSize; gfx::Size m_minSize, m_maxSize;