mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-14 04:19:12 +00:00
Make ui::Widget::flags field private
This commit is contained in:
parent
7f2cd3b6a9
commit
1922a27b38
@ -843,7 +843,7 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
BORDER4(6 * scale, (4+6) * scale, 6 * scale, 6 * scale);
|
||||
widget->border_width.t += widget->getTextHeight();
|
||||
|
||||
if (!(widget->flags & INITIALIZED)) {
|
||||
if (!widget->hasFlags(INITIALIZED)) {
|
||||
Button* button = new WindowCloseButton();
|
||||
widget->addChild(button);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ void Box::onPreferredSize(PreferredSizeEvent& ev)
|
||||
nvis_children = 0;
|
||||
UI_FOREACH_WIDGET(getChildren(), it) {
|
||||
Widget* child = *it;
|
||||
if (!(child->flags & HIDDEN))
|
||||
if (!child->hasFlags(HIDDEN))
|
||||
nvis_children++;
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ void Box::onPreferredSize(PreferredSizeEvent& ev)
|
||||
UI_FOREACH_WIDGET(getChildren(), it) {
|
||||
Widget* child = *it;
|
||||
|
||||
if (child->flags & HIDDEN)
|
||||
if (child->hasFlags(HIDDEN))
|
||||
continue;
|
||||
|
||||
Size reqSize = child->getPreferredSize();
|
||||
@ -120,7 +120,7 @@ void Box::onResize(ResizeEvent& ev)
|
||||
UI_FOREACH_WIDGET(getChildren(), it) { \
|
||||
child = *it; \
|
||||
\
|
||||
if (!(child->flags & HIDDEN)) { \
|
||||
if (!child->hasFlags(HIDDEN)) { \
|
||||
if (this->getAlign() & HOMOGENEOUS) { \
|
||||
if (nvis_children == 1) \
|
||||
child_width = width; \
|
||||
@ -175,7 +175,7 @@ void Box::onResize(ResizeEvent& ev)
|
||||
UI_FOREACH_WIDGET(getChildren(), it) {
|
||||
child = *it;
|
||||
|
||||
if (!(child->flags & HIDDEN)) {
|
||||
if (!child->hasFlags(HIDDEN)) {
|
||||
nvis_children++;
|
||||
if (child->isExpansive())
|
||||
nexpand_children++;
|
||||
|
@ -139,7 +139,7 @@ void Grid::onResize(ResizeEvent& ev)
|
||||
|
||||
if (cell->child != NULL &&
|
||||
cell->parent == NULL &&
|
||||
!(cell->child->flags & HIDDEN)) {
|
||||
!(cell->child->hasFlags(HIDDEN))) {
|
||||
x = pos_x;
|
||||
y = pos_y;
|
||||
|
||||
@ -285,7 +285,7 @@ void Grid::calculateStripSize(std::vector<Strip>& colstrip,
|
||||
if (cell->child != NULL) {
|
||||
if (cell->parent == NULL) {
|
||||
// If the widget isn't hidden then we can request its size
|
||||
if (!(cell->child->flags & HIDDEN)) {
|
||||
if (!(cell->child->hasFlags(HIDDEN))) {
|
||||
Size reqSize = cell->child->getPreferredSize();
|
||||
cell->w = reqSize.w - (cell->hspan-1) * this->child_spacing;
|
||||
cell->h = reqSize.h - (cell->vspan-1) * this->child_spacing;
|
||||
@ -297,7 +297,7 @@ void Grid::calculateStripSize(std::vector<Strip>& colstrip,
|
||||
cell->w = cell->h = 0;
|
||||
}
|
||||
else {
|
||||
if (!(cell->child->flags & HIDDEN)) {
|
||||
if (!(cell->child->hasFlags(HIDDEN))) {
|
||||
if ((cell->parent->align & align) == align)
|
||||
++expand_count;
|
||||
}
|
||||
|
@ -38,11 +38,11 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
#define ACCEPT_FOCUS(widget) \
|
||||
((((widget)->flags & (FOCUS_STOP | \
|
||||
DISABLED | \
|
||||
HIDDEN | \
|
||||
DECORATIVE)) == FOCUS_STOP) && \
|
||||
#define ACCEPT_FOCUS(widget) \
|
||||
((((widget)->flags() & (FOCUS_STOP | \
|
||||
DISABLED | \
|
||||
HIDDEN | \
|
||||
DECORATIVE)) == FOCUS_STOP) && \
|
||||
((widget)->isVisible()))
|
||||
|
||||
static const int NFILTERS = (int)(kFirstRegisteredMessage+1);
|
||||
@ -540,9 +540,9 @@ void Manager::setFocus(Widget* widget)
|
||||
{
|
||||
if ((focus_widget != widget)
|
||||
&& (!(widget)
|
||||
|| (!(widget->flags & DISABLED)
|
||||
&& !(widget->flags & HIDDEN)
|
||||
&& !(widget->flags & DECORATIVE)
|
||||
|| (!(widget->hasFlags(DISABLED))
|
||||
&& !(widget->hasFlags(HIDDEN))
|
||||
&& !(widget->hasFlags(DECORATIVE))
|
||||
&& someParentIsFocusStop(widget)))) {
|
||||
WidgetsList widget_parents;
|
||||
Widget* common_parent = NULL;
|
||||
@ -570,7 +570,7 @@ void Manager::setFocus(Widget* widget)
|
||||
}
|
||||
|
||||
if ((*it)->hasFocus()) {
|
||||
(*it)->flags &= ~HAS_FOCUS;
|
||||
(*it)->disableFlags(HAS_FOCUS);
|
||||
msg->addRecipient(*it);
|
||||
}
|
||||
}
|
||||
@ -598,9 +598,8 @@ void Manager::setFocus(Widget* widget)
|
||||
for (; it != widget_parents.end(); ++it) {
|
||||
Widget* w = *it;
|
||||
|
||||
if (w->flags & FOCUS_STOP) {
|
||||
w->flags |= HAS_FOCUS;
|
||||
|
||||
if (w->hasFlags(FOCUS_STOP)) {
|
||||
w->enableFlags(HAS_FOCUS);
|
||||
msg->addRecipient(w);
|
||||
}
|
||||
}
|
||||
@ -652,7 +651,7 @@ void Manager::setMouse(Widget* widget)
|
||||
}
|
||||
|
||||
if ((*it)->hasMouse()) {
|
||||
(*it)->flags &= ~HAS_MOUSE;
|
||||
(*it)->disableFlags(HAS_MOUSE);
|
||||
msg->addRecipient(*it);
|
||||
}
|
||||
}
|
||||
@ -679,7 +678,7 @@ void Manager::setMouse(Widget* widget)
|
||||
get_mouse_position(), _internal_get_mouse_buttons());
|
||||
|
||||
for (; it != widget_parents.end(); ++it) {
|
||||
(*it)->flags |= HAS_MOUSE;
|
||||
(*it)->enableFlags(HAS_MOUSE);
|
||||
msg->addRecipient(*it);
|
||||
}
|
||||
|
||||
@ -691,7 +690,7 @@ void Manager::setMouse(Widget* widget)
|
||||
|
||||
void Manager::setCapture(Widget* widget)
|
||||
{
|
||||
widget->flags |= HAS_CAPTURE;
|
||||
widget->enableFlags(HAS_CAPTURE);
|
||||
capture_widget = widget;
|
||||
|
||||
m_display->captureMouse();
|
||||
@ -731,7 +730,7 @@ void Manager::freeMouse()
|
||||
void Manager::freeCapture()
|
||||
{
|
||||
if (capture_widget) {
|
||||
capture_widget->flags &= ~HAS_CAPTURE;
|
||||
capture_widget->disableFlags(HAS_CAPTURE);
|
||||
capture_widget = NULL;
|
||||
|
||||
m_display->releaseMouse();
|
||||
@ -1124,7 +1123,7 @@ void Manager::pumpQueue()
|
||||
// We need to configure the clip region for paint messages
|
||||
// before we call Widget::sendMessage().
|
||||
if (msg->type() == kPaintMessage) {
|
||||
if (widget->flags & HIDDEN)
|
||||
if (widget->hasFlags(HIDDEN))
|
||||
continue;
|
||||
|
||||
PaintMessage* paintMsg = static_cast<PaintMessage*>(msg);
|
||||
|
@ -409,7 +409,7 @@ bool MenuBox::onProcessMessage(Message* msg)
|
||||
Widget* picked = menu->pick(mousePos);
|
||||
if (picked) {
|
||||
if ((picked->type() == kMenuItemWidget) &&
|
||||
!(picked->flags & DISABLED)) {
|
||||
!(picked->hasFlags(DISABLED))) {
|
||||
MenuItem* pickedItem = static_cast<MenuItem*>(picked);
|
||||
|
||||
// If the picked menu-item is not highlighted...
|
||||
|
@ -49,7 +49,7 @@ using namespace gfx;
|
||||
static inline void mark_dirty_flag(Widget* widget)
|
||||
{
|
||||
while (widget) {
|
||||
widget->flags |= DIRTY;
|
||||
widget->enableFlags(DIRTY);
|
||||
widget = widget->getParent();
|
||||
}
|
||||
}
|
||||
@ -61,19 +61,19 @@ WidgetType register_widget_type()
|
||||
}
|
||||
|
||||
Widget::Widget(WidgetType type)
|
||||
: m_bounds(0, 0, 0, 0)
|
||||
: m_type(type)
|
||||
, m_flags(0)
|
||||
, m_bounds(0, 0, 0, 0)
|
||||
, m_minSize(0, 0)
|
||||
, m_maxSize(INT_MAX, INT_MAX)
|
||||
{
|
||||
addWidget(this);
|
||||
|
||||
this->m_type = type;
|
||||
this->border_width.l = 0;
|
||||
this->border_width.t = 0;
|
||||
this->border_width.r = 0;
|
||||
this->border_width.b = 0;
|
||||
this->child_spacing = 0;
|
||||
this->flags = 0;
|
||||
this->m_parent = NULL;
|
||||
this->m_theme = CurrentTheme::get();
|
||||
|
||||
@ -160,7 +160,7 @@ void Widget::setTextf(const char *format, ...)
|
||||
void Widget::setTextQuiet(const std::string& text)
|
||||
{
|
||||
m_text = text;
|
||||
flags |= HAS_TEXT;
|
||||
enableFlags(HAS_TEXT);
|
||||
}
|
||||
|
||||
she::Font* Widget::getFont() const
|
||||
@ -196,16 +196,15 @@ void Widget::setTheme(Theme* theme)
|
||||
void Widget::setVisible(bool state)
|
||||
{
|
||||
if (state) {
|
||||
if (this->flags & HIDDEN) {
|
||||
this->flags &= ~HIDDEN;
|
||||
if (hasFlags(HIDDEN)) {
|
||||
disableFlags(HIDDEN);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!(this->flags & HIDDEN)) {
|
||||
if (!hasFlags(HIDDEN)) {
|
||||
getManager()->freeWidget(this); // Free from manager
|
||||
|
||||
this->flags |= HIDDEN;
|
||||
enableFlags(HIDDEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -213,18 +212,18 @@ void Widget::setVisible(bool state)
|
||||
void Widget::setEnabled(bool state)
|
||||
{
|
||||
if (state) {
|
||||
if (this->flags & DISABLED) {
|
||||
this->flags &= ~DISABLED;
|
||||
if (hasFlags(DISABLED)) {
|
||||
disableFlags(DISABLED);
|
||||
invalidate();
|
||||
|
||||
onEnable();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!(this->flags & DISABLED)) {
|
||||
if (!hasFlags(DISABLED)) {
|
||||
getManager()->freeWidget(this); // Free from the manager
|
||||
|
||||
this->flags |= DISABLED;
|
||||
enableFlags(DISABLED);
|
||||
invalidate();
|
||||
|
||||
onDisable();
|
||||
@ -235,16 +234,16 @@ void Widget::setEnabled(bool state)
|
||||
void Widget::setSelected(bool state)
|
||||
{
|
||||
if (state) {
|
||||
if (!(this->flags & SELECTED)) {
|
||||
this->flags |= SELECTED;
|
||||
if (!hasFlags(SELECTED)) {
|
||||
enableFlags(SELECTED);
|
||||
invalidate();
|
||||
|
||||
onSelect();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this->flags & SELECTED) {
|
||||
this->flags &= ~SELECTED;
|
||||
if (hasFlags(SELECTED)) {
|
||||
disableFlags(SELECTED);
|
||||
invalidate();
|
||||
|
||||
onDeselect();
|
||||
@ -255,33 +254,33 @@ void Widget::setSelected(bool state)
|
||||
void Widget::setExpansive(bool state)
|
||||
{
|
||||
if (state)
|
||||
this->flags |= EXPANSIVE;
|
||||
enableFlags(EXPANSIVE);
|
||||
else
|
||||
this->flags &= ~EXPANSIVE;
|
||||
disableFlags(EXPANSIVE);
|
||||
}
|
||||
|
||||
void Widget::setDecorative(bool state)
|
||||
{
|
||||
if (state)
|
||||
this->flags |= DECORATIVE;
|
||||
enableFlags(DECORATIVE);
|
||||
else
|
||||
this->flags &= ~DECORATIVE;
|
||||
disableFlags(DECORATIVE);
|
||||
}
|
||||
|
||||
void Widget::setFocusStop(bool state)
|
||||
{
|
||||
if (state)
|
||||
this->flags |= FOCUS_STOP;
|
||||
enableFlags(FOCUS_STOP);
|
||||
else
|
||||
this->flags &= ~FOCUS_STOP;
|
||||
disableFlags(FOCUS_STOP);
|
||||
}
|
||||
|
||||
void Widget::setFocusMagnet(bool state)
|
||||
{
|
||||
if (state)
|
||||
this->flags |= FOCUS_MAGNET;
|
||||
enableFlags(FOCUS_MAGNET);
|
||||
else
|
||||
this->flags &= ~FOCUS_MAGNET;
|
||||
disableFlags(FOCUS_MAGNET);
|
||||
}
|
||||
|
||||
bool Widget::isVisible() const
|
||||
@ -290,7 +289,7 @@ bool Widget::isVisible() const
|
||||
const Widget* lastWidget = nullptr;
|
||||
|
||||
do {
|
||||
if (widget->flags & HIDDEN)
|
||||
if (widget->hasFlags(HIDDEN))
|
||||
return false;
|
||||
|
||||
lastWidget = widget;
|
||||
@ -306,7 +305,7 @@ bool Widget::isEnabled() const
|
||||
const Widget* widget = this;
|
||||
|
||||
do {
|
||||
if (widget->flags & DISABLED)
|
||||
if (widget->hasFlags(DISABLED))
|
||||
return false;
|
||||
|
||||
widget = widget->m_parent;
|
||||
@ -317,27 +316,27 @@ bool Widget::isEnabled() const
|
||||
|
||||
bool Widget::isSelected() const
|
||||
{
|
||||
return (this->flags & SELECTED) ? true: false;
|
||||
return hasFlags(SELECTED);
|
||||
}
|
||||
|
||||
bool Widget::isExpansive() const
|
||||
{
|
||||
return (this->flags & EXPANSIVE) ? true: false;
|
||||
return hasFlags(EXPANSIVE);
|
||||
}
|
||||
|
||||
bool Widget::isDecorative() const
|
||||
{
|
||||
return (this->flags & DECORATIVE) ? true: false;
|
||||
return hasFlags(DECORATIVE);
|
||||
}
|
||||
|
||||
bool Widget::isFocusStop() const
|
||||
{
|
||||
return (this->flags & FOCUS_STOP) ? true: false;
|
||||
return hasFlags(FOCUS_STOP);
|
||||
}
|
||||
|
||||
bool Widget::isFocusMagnet() const
|
||||
{
|
||||
return (this->flags & FOCUS_MAGNET) ? true: false;
|
||||
return hasFlags(FOCUS_MAGNET);
|
||||
}
|
||||
|
||||
// ===============================================================
|
||||
@ -421,7 +420,7 @@ Widget* Widget::pick(const gfx::Point& pt)
|
||||
{
|
||||
Widget* inside, *picked = NULL;
|
||||
|
||||
if (!(this->flags & HIDDEN) && // Is visible
|
||||
if (!hasFlags(HIDDEN) && // Is visible
|
||||
getBounds().contains(pt)) { // The point is inside the bounds
|
||||
picked = this;
|
||||
|
||||
@ -706,7 +705,7 @@ void Widget::getDrawableRegion(gfx::Region& region, DrawableRegionFlags flags)
|
||||
Region reg3;
|
||||
child->getRegion(reg3);
|
||||
|
||||
if (child->flags & DECORATIVE) {
|
||||
if (child->hasFlags(DECORATIVE)) {
|
||||
reg1 = getBounds();
|
||||
reg1.createIntersection(reg1, reg3);
|
||||
}
|
||||
@ -719,7 +718,7 @@ void Widget::getDrawableRegion(gfx::Region& region, DrawableRegionFlags flags)
|
||||
}
|
||||
|
||||
// Intersect with the parent area
|
||||
if (!(this->flags & DECORATIVE)) {
|
||||
if (!hasFlags(DECORATIVE)) {
|
||||
Widget* parent = getParent();
|
||||
|
||||
while (parent) {
|
||||
@ -886,8 +885,8 @@ void Widget::flushRedraw()
|
||||
std::queue<Widget*> processing;
|
||||
Message* msg;
|
||||
|
||||
if (this->flags & DIRTY) {
|
||||
this->flags ^= DIRTY;
|
||||
if (hasFlags(DIRTY)) {
|
||||
disableFlags(DIRTY);
|
||||
processing.push(this);
|
||||
}
|
||||
|
||||
@ -903,8 +902,8 @@ void Widget::flushRedraw()
|
||||
|
||||
UI_FOREACH_WIDGET(widget->getChildren(), it) {
|
||||
Widget* child = *it;
|
||||
if (child->flags & DIRTY) {
|
||||
child->flags ^= DIRTY;
|
||||
if (child->hasFlags(DIRTY)) {
|
||||
child->disableFlags(DIRTY);
|
||||
processing.push(child);
|
||||
}
|
||||
}
|
||||
@ -991,7 +990,7 @@ bool Widget::paintEvent(Graphics* graphics)
|
||||
graphics->fillRect(gfx::rgba(255, 0, 0), getClientBounds());
|
||||
#endif
|
||||
|
||||
this->flags |= HIDDEN;
|
||||
enableFlags(HIDDEN);
|
||||
|
||||
gfx::Region rgn(getParent()->getBounds());
|
||||
rgn.createIntersection(rgn,
|
||||
@ -1001,7 +1000,7 @@ bool Widget::paintEvent(Graphics* graphics)
|
||||
graphics->getInternalDeltaY())));
|
||||
getParent()->paint(graphics, rgn);
|
||||
|
||||
this->flags &= ~HIDDEN;
|
||||
disableFlags(HIDDEN);
|
||||
}
|
||||
|
||||
PaintEvent ev(this, graphics);
|
||||
@ -1275,12 +1274,12 @@ void Widget::offerCapture(ui::MouseMessage* mouseMsg, int widget_type)
|
||||
|
||||
bool Widget::hasFocus()
|
||||
{
|
||||
return (this->flags & HAS_FOCUS) ? true: false;
|
||||
return hasFlags(HAS_FOCUS);
|
||||
}
|
||||
|
||||
bool Widget::hasMouse()
|
||||
{
|
||||
return (this->flags & HAS_MOUSE) ? true: false;
|
||||
return hasFlags(HAS_MOUSE);
|
||||
}
|
||||
|
||||
bool Widget::hasMouseOver()
|
||||
@ -1290,7 +1289,7 @@ bool Widget::hasMouseOver()
|
||||
|
||||
bool Widget::hasCapture()
|
||||
{
|
||||
return (this->flags & HAS_CAPTURE) ? true: false;
|
||||
return hasFlags(HAS_CAPTURE);
|
||||
}
|
||||
|
||||
int Widget::getMnemonicChar() const
|
||||
@ -1443,8 +1442,8 @@ void Widget::onInitTheme(InitThemeEvent& ev)
|
||||
if (m_theme) {
|
||||
m_theme->initWidget(this);
|
||||
|
||||
if (!(flags & INITIALIZED))
|
||||
flags |= INITIALIZED;
|
||||
if (!hasFlags(INITIALIZED))
|
||||
enableFlags(INITIALIZED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,6 @@ namespace ui {
|
||||
} border_width; // Border separation with the parent
|
||||
int child_spacing; // Separation between children
|
||||
|
||||
// Flags
|
||||
int flags;
|
||||
|
||||
public:
|
||||
|
||||
// ===============================================================
|
||||
@ -73,12 +70,18 @@ namespace ui {
|
||||
const std::string& getId() const { return m_id; }
|
||||
void setId(const char* id) { m_id = id; }
|
||||
|
||||
int flags() const { return m_flags; }
|
||||
void setFlags(int flags) { m_flags = flags; }
|
||||
bool hasFlags(int flags) const { return ((m_flags & flags) == flags); }
|
||||
void enableFlags(int flags) { m_flags |= flags; }
|
||||
void disableFlags(int flags) { m_flags &= ~flags; }
|
||||
|
||||
int getAlign() const { return m_align; }
|
||||
void setAlign(int align) { m_align = align; }
|
||||
|
||||
// Text property.
|
||||
|
||||
bool hasText() const { return (flags & HAS_TEXT) == HAS_TEXT; }
|
||||
bool hasText() const { return hasFlags(HAS_TEXT); }
|
||||
|
||||
const std::string& getText() const { return m_text; }
|
||||
int getTextInt() const;
|
||||
@ -377,6 +380,7 @@ namespace ui {
|
||||
|
||||
WidgetType m_type; // Widget's type
|
||||
std::string m_id; // Widget's id
|
||||
int m_flags; // Special boolean properties (see flags in ui/base.h)
|
||||
Theme* m_theme; // Widget's theme
|
||||
int m_align; // Widget alignment
|
||||
std::string m_text; // Widget text
|
||||
|
@ -246,7 +246,7 @@ void Window::openWindowInForeground()
|
||||
openWindow();
|
||||
|
||||
MessageLoop loop(getManager());
|
||||
while (!(this->flags & HIDDEN))
|
||||
while (!hasFlags(HIDDEN))
|
||||
loop.pumpMessages();
|
||||
|
||||
m_isForeground = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user