Skip to content

Commit

Permalink
Convert "bool" members in ui::Widget to flags
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed Aug 29, 2016
1 parent 9781325 commit 03be4aa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/ui/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ namespace ui {
INITIALIZED = 0x00000400, // The widget was already initialized by a theme.
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).
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,

HORIZONTAL = 0x00010000,
Expand Down
12 changes: 5 additions & 7 deletions src/ui/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ Widget::Widget(WidgetType type)
, m_bounds(0, 0, 0, 0)
, m_parent(nullptr)
, m_sizeHint(nullptr)
, m_doubleBuffered(false)
, m_transparent(false)
, m_minSize(0, 0)
, m_maxSize(INT_MAX, INT_MAX)
, m_childSpacing(0)
Expand Down Expand Up @@ -1010,22 +1008,22 @@ bool Widget::paintEvent(Graphics* graphics)

bool Widget::isDoubleBuffered() const
{
return m_doubleBuffered;
return hasFlags(DOUBLE_BUFFERED);
}

void Widget::setDoubleBuffered(bool doubleBuffered)
{
m_doubleBuffered = doubleBuffered;
enableFlags(DOUBLE_BUFFERED);
}

bool Widget::isTransparent() const
{
return m_transparent;
return hasFlags(TRANSPARENT);
}

void Widget::setTransparent(bool transparent)
{
m_transparent = transparent;
enableFlags(TRANSPARENT);
}

void Widget::invalidate()
Expand Down Expand Up @@ -1084,7 +1082,7 @@ GraphicsPtr Widget::getGraphics(const gfx::Rect& clip)

// In case of double-buffering, we need to create the temporary
// 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);
graphics.reset(new Graphics(surface, -clip.x, -clip.y),
DeleteGraphicsAndSurface(clip, surface));
Expand Down
2 changes: 0 additions & 2 deletions src/ui/widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,6 @@ namespace ui {
WidgetsList m_children; // Sub-widgets
Widget* m_parent; // Who is the parent?
gfx::Size* m_sizeHint;
bool m_doubleBuffered;
bool m_transparent;

// Widget size limits
gfx::Size m_minSize, m_maxSize;
Expand Down

3 comments on commit 03be4aa

@jakiki6
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the last free commit :(

@crabdancing
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😭

@JOELwindows7

This comment was marked as off-topic.

Please sign in to comment.