mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-14 04:19:12 +00:00
Rename ui::Widget::type -> m_type and make it private
This commit is contained in:
parent
0517cd1b98
commit
325e9245bf
@ -282,7 +282,7 @@ void AppMenus::applyShortcutToMenuitemsWithCommand(Menu* menu, Command* command,
|
||||
UI_FOREACH_WIDGET(menu->getChildren(), it) {
|
||||
Widget* child = *it;
|
||||
|
||||
if (child->getType() == kMenuItemWidget) {
|
||||
if (child->type() == kMenuItemWidget) {
|
||||
AppMenuItem* menuitem = dynamic_cast<AppMenuItem*>(child);
|
||||
if (!menuitem)
|
||||
continue;
|
||||
|
@ -65,7 +65,7 @@ void EyedropperCommand::onLoadParams(const Params& params)
|
||||
void EyedropperCommand::onExecute(Context* context)
|
||||
{
|
||||
Widget* widget = ui::Manager::getDefault()->getMouse();
|
||||
if (!widget || widget->type != editor_type())
|
||||
if (!widget || widget->type() != editor_type())
|
||||
return;
|
||||
|
||||
Editor* editor = static_cast<Editor*>(widget);
|
||||
|
@ -76,7 +76,7 @@ void ZoomCommand::onExecute(Context* context)
|
||||
|
||||
// Try to use the editor above the mouse.
|
||||
ui::Widget* pick = ui::Manager::getDefault()->pick(mousePos);
|
||||
if (pick && pick->getType() == editor_type())
|
||||
if (pick && pick->type() == editor_type())
|
||||
editor = static_cast<Editor*>(pick);
|
||||
|
||||
render::Zoom zoom = editor->zoom();
|
||||
|
@ -114,11 +114,11 @@ bool ColorButton::onProcessMessage(Message* msg)
|
||||
color = pickedColBut->getColor();
|
||||
}
|
||||
// Pick a color from the color-bar
|
||||
else if (picked->type == palette_view_type()) {
|
||||
else if (picked->type() == palette_view_type()) {
|
||||
color = ((PaletteView*)picked)->getColorByPosition(mousePos);
|
||||
}
|
||||
// Pick a color from a editor
|
||||
else if (picked->type == editor_type()) {
|
||||
else if (picked->type() == editor_type()) {
|
||||
Editor* editor = static_cast<Editor*>(picked);
|
||||
Site site = editor->getSite();
|
||||
if (site.sprite()) {
|
||||
|
@ -672,7 +672,7 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
|
||||
int scale = guiscale();
|
||||
|
||||
switch (widget->type) {
|
||||
switch (widget->type()) {
|
||||
|
||||
case kBoxWidget:
|
||||
BORDER(0);
|
||||
@ -1216,7 +1216,7 @@ void SkinTheme::paintMenuItem(ui::PaintEvent& ev)
|
||||
if (!widget->getParent()->getParent())
|
||||
return;
|
||||
|
||||
bar = (widget->getParent()->getParent()->type == kMenuBarWidget);
|
||||
bar = (widget->getParent()->getParent()->type() == kMenuBarWidget);
|
||||
|
||||
// Colors
|
||||
if (!widget->isEnabled()) {
|
||||
@ -1848,7 +1848,7 @@ gfx::Color SkinTheme::getWidgetBgColor(Widget* widget)
|
||||
gfx::Color c = widget->getBgColor();
|
||||
bool decorative = widget->isDecorative();
|
||||
|
||||
if (!is_transparent(c) || widget->getType() == kWindowWidget)
|
||||
if (!is_transparent(c) || widget->type() == kWindowWidget)
|
||||
return c;
|
||||
else if (decorative)
|
||||
return colors.selected();
|
||||
|
@ -146,7 +146,7 @@ void Workspace::updateTabs()
|
||||
Widget* child = children.back();
|
||||
children.erase(--children.end());
|
||||
|
||||
if (child->getType() == WorkspacePanel::Type())
|
||||
if (child->type() == WorkspacePanel::Type())
|
||||
static_cast<WorkspacePanel*>(child)->tabs()->updateTabs();
|
||||
|
||||
for (auto subchild : child->getChildren())
|
||||
@ -268,7 +268,7 @@ WorkspacePanel* Workspace::getViewPanel(WorkspaceView* view)
|
||||
{
|
||||
Widget* widget = view->getContentWidget();
|
||||
while (widget) {
|
||||
if (widget->getType() == WorkspacePanel::Type())
|
||||
if (widget->type() == WorkspacePanel::Type())
|
||||
return static_cast<WorkspacePanel*>(widget);
|
||||
|
||||
widget = widget->getParent();
|
||||
@ -280,7 +280,7 @@ WorkspacePanel* Workspace::getPanelAt(const gfx::Point& pos)
|
||||
{
|
||||
Widget* widget = getManager()->pick(pos);
|
||||
while (widget) {
|
||||
if (widget->getType() == WorkspacePanel::Type())
|
||||
if (widget->type() == WorkspacePanel::Type())
|
||||
return static_cast<WorkspacePanel*>(widget);
|
||||
|
||||
widget = widget->getParent();
|
||||
@ -292,7 +292,7 @@ WorkspaceTabs* Workspace::getTabsAt(const gfx::Point& pos)
|
||||
{
|
||||
Widget* widget = getManager()->pick(pos);
|
||||
while (widget) {
|
||||
if (widget->getType() == Tabs::Type())
|
||||
if (widget->type() == Tabs::Type())
|
||||
return static_cast<WorkspaceTabs*>(widget);
|
||||
|
||||
widget = widget->getParent();
|
||||
|
@ -108,10 +108,10 @@ void WorkspacePanel::removeView(WorkspaceView* view)
|
||||
// Destroy this panel
|
||||
if (m_views.empty() && m_panelType == SUB_PANEL) {
|
||||
Widget* self = getParent();
|
||||
ASSERT(self->getType() == kBoxWidget);
|
||||
ASSERT(self->type() == kBoxWidget);
|
||||
|
||||
Widget* splitter = self->getParent();
|
||||
ASSERT(splitter->getType() == kSplitterWidget);
|
||||
ASSERT(splitter->type() == kSplitterWidget);
|
||||
|
||||
Widget* parent = splitter->getParent();
|
||||
|
||||
@ -270,13 +270,13 @@ DropViewAtResult WorkspacePanel::dropViewAt(const gfx::Point& pos, WorkspacePane
|
||||
splitter->setExpansive(true);
|
||||
|
||||
Widget* parent = getParent();
|
||||
if (parent->getType() == kBoxWidget) {
|
||||
if (parent->type() == kBoxWidget) {
|
||||
self = parent;
|
||||
parent = self->getParent();
|
||||
ASSERT(parent->getType() == kSplitterWidget);
|
||||
ASSERT(parent->type() == kSplitterWidget);
|
||||
}
|
||||
if (parent->getType() == Workspace::Type() ||
|
||||
parent->getType() == kSplitterWidget) {
|
||||
if (parent->type() == Workspace::Type() ||
|
||||
parent->type() == kSplitterWidget) {
|
||||
parent->replaceChild(self, splitter);
|
||||
}
|
||||
else {
|
||||
@ -353,7 +353,7 @@ Workspace* WorkspacePanel::getWorkspace()
|
||||
{
|
||||
Widget* widget = this;
|
||||
while (widget) {
|
||||
if (widget->getType() == Workspace::Type())
|
||||
if (widget->type() == Workspace::Type())
|
||||
return static_cast<Workspace*>(widget);
|
||||
|
||||
widget = widget->getParent();
|
||||
|
@ -566,12 +566,12 @@ void WidgetLoader::fillWidgetWithXmlElementAttributes(const TiXmlElement* elem,
|
||||
Widget* child = convertXmlElementToWidget(childElem, root, widget, NULL);
|
||||
if (child) {
|
||||
// Attach the child in the view
|
||||
if (widget->type == kViewWidget) {
|
||||
if (widget->type() == kViewWidget) {
|
||||
static_cast<View*>(widget)->attachToView(child);
|
||||
break;
|
||||
}
|
||||
// Add the child in the grid
|
||||
else if (widget->type == kGridWidget) {
|
||||
else if (widget->type() == kGridWidget) {
|
||||
const char* cell_hspan = childElem->Attribute("cell_hspan");
|
||||
const char* cell_vspan = childElem->Attribute("cell_vspan");
|
||||
const char* cell_align = childElem->Attribute("cell_align");
|
||||
@ -584,8 +584,8 @@ void WidgetLoader::fillWidgetWithXmlElementAttributes(const TiXmlElement* elem,
|
||||
grid->addChildInCell(child, hspan, vspan, align);
|
||||
}
|
||||
// Attach the child in the view
|
||||
else if (widget->type == kComboBoxWidget &&
|
||||
child->type == kListItemWidget) {
|
||||
else if (widget->type() == kComboBoxWidget &&
|
||||
child->type() == kListItemWidget) {
|
||||
ComboBox* combo = dynamic_cast<ComboBox*>(widget);
|
||||
ASSERT(combo != NULL);
|
||||
|
||||
@ -598,7 +598,7 @@ void WidgetLoader::fillWidgetWithXmlElementAttributes(const TiXmlElement* elem,
|
||||
childElem = childElem->NextSiblingElement();
|
||||
}
|
||||
|
||||
if (widget->type == kViewWidget) {
|
||||
if (widget->type() == kViewWidget) {
|
||||
bool maxsize = bool_attr_is_true(elem, "maxsize");
|
||||
if (maxsize)
|
||||
static_cast<View*>(widget)->makeVisibleAllScrollableArea();
|
||||
|
@ -37,9 +37,9 @@ ButtonBase::ButtonBase(const std::string& text,
|
||||
setFocusStop(true);
|
||||
|
||||
// Initialize theme
|
||||
this->type = m_drawType; // TODO Fix this nasty trick
|
||||
setType(m_drawType); // TODO Fix this nasty trick
|
||||
initTheme();
|
||||
this->type = type;
|
||||
setType(type);
|
||||
}
|
||||
|
||||
ButtonBase::~ButtonBase()
|
||||
|
@ -58,7 +58,7 @@ void reinitThemeForAllWidgets()
|
||||
|
||||
// Remap the windows
|
||||
for (auto widget : *widgets) {
|
||||
if (widget->type == kWindowWidget)
|
||||
if (widget->type() == kWindowWidget)
|
||||
static_cast<Window*>(widget)->remapWindow();
|
||||
}
|
||||
|
||||
|
@ -1439,7 +1439,7 @@ static Widget* next_widget(Widget* widget)
|
||||
if (!widget->getChildren().empty())
|
||||
return UI_FIRST_WIDGET(widget->getChildren());
|
||||
|
||||
while (widget->getParent()->type != kManagerWidget) {
|
||||
while (widget->getParent()->type() != kManagerWidget) {
|
||||
WidgetsList::const_iterator begin = widget->getParent()->getChildren().begin();
|
||||
WidgetsList::const_iterator end = widget->getParent()->getChildren().end();
|
||||
WidgetsList::const_iterator it = std::find(begin, end, widget);
|
||||
|
@ -317,7 +317,7 @@ void Menu::onResize(ResizeEvent& ev)
|
||||
setBoundsQuietly(ev.getBounds());
|
||||
|
||||
Rect cpos = getChildrenBounds();
|
||||
bool isBar = (getParent()->type == kMenuBarWidget);
|
||||
bool isBar = (getParent()->type() == kMenuBarWidget);
|
||||
|
||||
UI_FOREACH_WIDGET(getChildren(), it) {
|
||||
Widget* child = *it;
|
||||
@ -345,7 +345,7 @@ void Menu::onPreferredSize(PreferredSizeEvent& ev)
|
||||
UI_FOREACH_WIDGET_WITH_END(getChildren(), it, end) {
|
||||
reqSize = (*it)->getPreferredSize();
|
||||
|
||||
if (getParent() && getParent()->type == kMenuBarWidget) {
|
||||
if (getParent() && getParent()->type() == kMenuBarWidget) {
|
||||
size.w += reqSize.w + ((it+1 != end) ? this->child_spacing: 0);
|
||||
size.h = MAX(size.h, reqSize.h);
|
||||
}
|
||||
@ -392,9 +392,9 @@ bool MenuBox::onProcessMessage(Message* msg)
|
||||
if (picked == NULL || // If the button was clicked nowhere
|
||||
picked == this || // If the button was clicked in this menubox
|
||||
// The picked widget isn't menu-related
|
||||
(picked->type != kMenuBoxWidget &&
|
||||
picked->type != kMenuBarWidget &&
|
||||
picked->type != kMenuItemWidget) ||
|
||||
(picked->type() != kMenuBoxWidget &&
|
||||
picked->type() != kMenuBarWidget &&
|
||||
picked->type() != kMenuItemWidget) ||
|
||||
// The picked widget (that is menu-related) isn't from
|
||||
// the same tree of menus
|
||||
(get_base_menubox(picked) != this)) {
|
||||
@ -408,7 +408,7 @@ bool MenuBox::onProcessMessage(Message* msg)
|
||||
// Get the widget below the mouse cursor
|
||||
Widget* picked = menu->pick(mousePos);
|
||||
if (picked) {
|
||||
if ((picked->type == kMenuItemWidget) &&
|
||||
if ((picked->type() == kMenuItemWidget) &&
|
||||
!(picked->flags & DISABLED)) {
|
||||
MenuItem* pickedItem = static_cast<MenuItem*>(picked);
|
||||
|
||||
@ -417,7 +417,7 @@ bool MenuBox::onProcessMessage(Message* msg)
|
||||
// In menu-bar always open the submenu, in other popup-menus
|
||||
// open the submenu only if the user does click
|
||||
bool open_submenu =
|
||||
(this->type == kMenuBarWidget) ||
|
||||
(this->type() == kMenuBarWidget) ||
|
||||
(msg->type() == kMouseDownMessage);
|
||||
|
||||
menu->highlightItem(pickedItem, false, open_submenu, false);
|
||||
@ -485,9 +485,9 @@ bool MenuBox::onProcessMessage(Message* msg)
|
||||
get_base(this)->was_clicked = false;
|
||||
|
||||
// Check for ALT+some underlined letter
|
||||
if (((this->type == kMenuBoxWidget) && (msg->keyModifiers() == kKeyNoneModifier || // <-- Inside menu-boxes we can use letters without Alt modifier pressed
|
||||
msg->keyModifiers() == kKeyAltModifier)) ||
|
||||
((this->type == kMenuBarWidget) && (msg->keyModifiers() == kKeyAltModifier))) {
|
||||
if (((this->type() == kMenuBoxWidget) && (msg->keyModifiers() == kKeyNoneModifier || // <-- Inside menu-boxes we can use letters without Alt modifier pressed
|
||||
msg->keyModifiers() == kKeyAltModifier)) ||
|
||||
((this->type() == kMenuBarWidget) && (msg->keyModifiers() == kKeyAltModifier))) {
|
||||
selected = check_for_letter(menu,
|
||||
static_cast<KeyMessage*>(msg)->unicodeChar());
|
||||
|
||||
@ -506,7 +506,7 @@ bool MenuBox::onProcessMessage(Message* msg)
|
||||
// Search a child with highlight or the submenu opened
|
||||
UI_FOREACH_WIDGET(menu->getChildren(), it) {
|
||||
Widget* child = *it;
|
||||
if (child->type != kMenuItemWidget)
|
||||
if (child->type() != kMenuItemWidget)
|
||||
continue;
|
||||
|
||||
if (static_cast<MenuItem*>(child)->hasSubmenuOpened())
|
||||
@ -520,7 +520,7 @@ bool MenuBox::onProcessMessage(Message* msg)
|
||||
|
||||
case kKeyEsc:
|
||||
// In menu-bar
|
||||
if (this->type == kMenuBarWidget) {
|
||||
if (this->type() == kMenuBarWidget) {
|
||||
if (highlight) {
|
||||
cancelMenuLoop();
|
||||
used = true;
|
||||
@ -543,7 +543,7 @@ bool MenuBox::onProcessMessage(Message* msg)
|
||||
|
||||
case kKeyUp:
|
||||
// In menu-bar
|
||||
if (this->type == kMenuBarWidget) {
|
||||
if (this->type() == kMenuBarWidget) {
|
||||
if (child_with_submenu_opened)
|
||||
child_with_submenu_opened->closeSubmenu(true);
|
||||
}
|
||||
@ -558,7 +558,7 @@ bool MenuBox::onProcessMessage(Message* msg)
|
||||
|
||||
case kKeyDown:
|
||||
// In menu-bar
|
||||
if (this->type == kMenuBarWidget) {
|
||||
if (this->type() == kMenuBarWidget) {
|
||||
// Select the active menu
|
||||
menu->highlightItem(highlight, true, true, true);
|
||||
}
|
||||
@ -573,7 +573,7 @@ bool MenuBox::onProcessMessage(Message* msg)
|
||||
|
||||
case kKeyLeft:
|
||||
// In menu-bar
|
||||
if (this->type == kMenuBarWidget) {
|
||||
if (this->type() == kMenuBarWidget) {
|
||||
// Go to previous
|
||||
highlight = find_previtem(menu, highlight);
|
||||
menu->highlightItem(highlight, false, false, false);
|
||||
@ -587,7 +587,7 @@ bool MenuBox::onProcessMessage(Message* msg)
|
||||
// Go to the previous item in the parent
|
||||
|
||||
// If the parent is the menu-bar
|
||||
if (parent->type == kMenuBarWidget) {
|
||||
if (parent->type() == kMenuBarWidget) {
|
||||
menu = static_cast<MenuBar*>(parent)->getMenu();
|
||||
MenuItem* menuitem = find_previtem(menu, menu->getHighlightedItem());
|
||||
|
||||
@ -606,7 +606,7 @@ bool MenuBox::onProcessMessage(Message* msg)
|
||||
|
||||
case kKeyRight:
|
||||
// In menu-bar
|
||||
if (this->type == kMenuBarWidget) {
|
||||
if (this->type() == kMenuBarWidget) {
|
||||
// Go to next
|
||||
highlight = find_nextitem(menu, highlight);
|
||||
menu->highlightItem(highlight, false, false, false);
|
||||
@ -776,7 +776,7 @@ bool MenuItem::onProcessMessage(Message* msg)
|
||||
UI_FOREACH_WIDGET(m_submenu->getChildren(), it) {
|
||||
Widget* child = *it;
|
||||
|
||||
if (child->type != kMenuItemWidget)
|
||||
if (child->type() != kMenuItemWidget)
|
||||
continue;
|
||||
|
||||
if (child->isEnabled()) {
|
||||
@ -814,7 +814,7 @@ bool MenuItem::onProcessMessage(Message* msg)
|
||||
ASSERT(menubox != NULL);
|
||||
|
||||
window = (Window*)menubox->getParent();
|
||||
ASSERT(window && window->type == kWindowWidget);
|
||||
ASSERT(window && window->type() == kWindowWidget);
|
||||
|
||||
// Fetch the "menu" to avoid destroy it with 'delete'.
|
||||
menubox->setMenu(NULL);
|
||||
@ -905,7 +905,8 @@ static MenuBox* get_base_menubox(Widget* widget)
|
||||
ASSERT_VALID_WIDGET(widget);
|
||||
|
||||
// We are in a menubox
|
||||
if (widget->type == kMenuBoxWidget || widget->type == kMenuBarWidget) {
|
||||
if (widget->type() == kMenuBoxWidget ||
|
||||
widget->type() == kMenuBarWidget) {
|
||||
if (static_cast<MenuBox*>(widget)->getBase()) {
|
||||
return static_cast<MenuBox*>(widget);
|
||||
}
|
||||
@ -920,9 +921,9 @@ static MenuBox* get_base_menubox(Widget* widget)
|
||||
}
|
||||
// We are in a menuitem
|
||||
else {
|
||||
ASSERT(widget->type == kMenuItemWidget);
|
||||
ASSERT(widget->type() == kMenuItemWidget);
|
||||
ASSERT(widget->getParent() != NULL);
|
||||
ASSERT(widget->getParent()->type == kMenuWidget);
|
||||
ASSERT(widget->getParent()->type() == kMenuWidget);
|
||||
|
||||
widget = widget->getParent()->getParent();
|
||||
}
|
||||
@ -942,7 +943,7 @@ MenuItem* Menu::getHighlightedItem()
|
||||
{
|
||||
UI_FOREACH_WIDGET(getChildren(), it) {
|
||||
Widget* child = *it;
|
||||
if (child->type != kMenuItemWidget)
|
||||
if (child->type() != kMenuItemWidget)
|
||||
continue;
|
||||
|
||||
MenuItem* menuitem = static_cast<MenuItem*>(child);
|
||||
@ -957,7 +958,7 @@ void Menu::highlightItem(MenuItem* menuitem, bool click, bool open_submenu, bool
|
||||
// Find the menuitem with the highlight
|
||||
UI_FOREACH_WIDGET(getChildren(), it) {
|
||||
Widget* child = *it;
|
||||
if (child->type != kMenuItemWidget)
|
||||
if (child->type() != kMenuItemWidget)
|
||||
continue;
|
||||
|
||||
if (child != menuitem) {
|
||||
@ -1010,7 +1011,7 @@ bool MenuItem::inBar()
|
||||
return
|
||||
(getParent() &&
|
||||
getParent()->getParent() &&
|
||||
getParent()->getParent()->type == kMenuBarWidget);
|
||||
getParent()->getParent()->type() == kMenuBarWidget);
|
||||
}
|
||||
|
||||
void MenuItem::openSubmenu(bool select_first)
|
||||
@ -1031,7 +1032,7 @@ void MenuItem::openSubmenu(bool select_first)
|
||||
if (menu->getParent()) {
|
||||
UI_FOREACH_WIDGET(menu->getChildren(), it) {
|
||||
Widget* child = *it;
|
||||
if (child->type != kMenuItemWidget)
|
||||
if (child->type() != kMenuItemWidget)
|
||||
continue;
|
||||
|
||||
MenuItem* childMenuItem = static_cast<MenuItem*>(child);
|
||||
@ -1078,7 +1079,7 @@ void MenuItem::closeSubmenu(bool last_of_close_chain)
|
||||
|
||||
UI_FOREACH_WIDGET(menu->getChildren(), it) {
|
||||
Widget* child = *it;
|
||||
if (child->type != kMenuItemWidget)
|
||||
if (child->type() != kMenuItemWidget)
|
||||
continue;
|
||||
|
||||
if (static_cast<MenuItem*>(child)->hasSubmenuOpened())
|
||||
@ -1145,7 +1146,7 @@ void Menu::closeAll()
|
||||
else {
|
||||
UI_FOREACH_WIDGET(menu->getChildren(), it) {
|
||||
Widget* child = *it;
|
||||
if (child->type != kMenuItemWidget)
|
||||
if (child->type() != kMenuItemWidget)
|
||||
continue;
|
||||
|
||||
menuitem = static_cast<MenuItem*>(child);
|
||||
@ -1155,7 +1156,7 @@ void Menu::closeAll()
|
||||
}
|
||||
|
||||
// For popuped menus
|
||||
if (base_menubox->type == kMenuBoxWidget)
|
||||
if (base_menubox->type() == kMenuBoxWidget)
|
||||
base_menubox->closePopup();
|
||||
}
|
||||
|
||||
@ -1194,7 +1195,7 @@ static MenuItem* check_for_letter(Menu* menu, int ascii)
|
||||
{
|
||||
UI_FOREACH_WIDGET(menu->getChildren(), it) {
|
||||
Widget* child = *it;
|
||||
if (child->type != kMenuItemWidget)
|
||||
if (child->type() != kMenuItemWidget)
|
||||
continue;
|
||||
|
||||
MenuItem* menuitem = static_cast<MenuItem*>(child);
|
||||
@ -1222,7 +1223,7 @@ static MenuItem* find_nextitem(Menu* menu, MenuItem* menuitem)
|
||||
|
||||
for (; it != end; ++it) {
|
||||
Widget* nextitem = *it;
|
||||
if ((nextitem->type == kMenuItemWidget) && nextitem->isEnabled())
|
||||
if ((nextitem->type() == kMenuItemWidget) && nextitem->isEnabled())
|
||||
return static_cast<MenuItem*>(nextitem);
|
||||
}
|
||||
|
||||
@ -1247,7 +1248,7 @@ static MenuItem* find_previtem(Menu* menu, MenuItem* menuitem)
|
||||
|
||||
for (; it != end; ++it) {
|
||||
Widget* nextitem = *it;
|
||||
if ((nextitem->type == kMenuItemWidget) && nextitem->isEnabled())
|
||||
if ((nextitem->type() == kMenuItemWidget) && nextitem->isEnabled())
|
||||
return static_cast<MenuItem*>(nextitem);
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ void PopupWindow::onHitTest(HitTestEvent& ev)
|
||||
{
|
||||
Widget* picked = getManager()->pick(ev.getPoint());
|
||||
if (picked) {
|
||||
WidgetType type = picked->getType();
|
||||
WidgetType type = picked->type();
|
||||
if ((type == kWindowWidget && picked == this) ||
|
||||
type == kBoxWidget ||
|
||||
type == kLabelWidget ||
|
||||
|
@ -229,9 +229,9 @@ Rect View::getViewportBounds()
|
||||
View* View::getView(Widget* widget)
|
||||
{
|
||||
if ((widget->getParent()) &&
|
||||
(widget->getParent()->type == kViewViewportWidget) &&
|
||||
(widget->getParent()->type() == kViewViewportWidget) &&
|
||||
(widget->getParent()->getParent()) &&
|
||||
(widget->getParent()->getParent()->type == kViewWidget))
|
||||
(widget->getParent()->getParent()->type() == kViewWidget))
|
||||
return static_cast<View*>(widget->getParent()->getParent());
|
||||
else
|
||||
return 0;
|
||||
|
@ -65,7 +65,7 @@ Widget::Widget(WidgetType type)
|
||||
{
|
||||
addWidget(this);
|
||||
|
||||
this->type = type;
|
||||
this->m_type = type;
|
||||
this->border_width.l = 0;
|
||||
this->border_width.t = 0;
|
||||
this->border_width.r = 0;
|
||||
@ -91,7 +91,7 @@ Widget::Widget(WidgetType type)
|
||||
Widget::~Widget()
|
||||
{
|
||||
// Break relationship with the manager.
|
||||
if (this->type != kManagerWidget) {
|
||||
if (this->type() != kManagerWidget) {
|
||||
Manager* manager = getManager();
|
||||
manager->freeWidget(this);
|
||||
manager->removeMessagesFor(this);
|
||||
@ -300,7 +300,7 @@ bool Widget::isVisible() const
|
||||
} while (widget);
|
||||
|
||||
// The widget is visible if it's inside a visible manager
|
||||
return (lastWidget ? lastWidget->type == kManagerWidget: false);
|
||||
return (lastWidget ? lastWidget->type() == kManagerWidget: false);
|
||||
}
|
||||
|
||||
bool Widget::isEnabled() const
|
||||
@ -351,7 +351,7 @@ Window* Widget::getRoot()
|
||||
Widget* widget = this;
|
||||
|
||||
while (widget) {
|
||||
if (widget->type == kWindowWidget)
|
||||
if (widget->type() == kWindowWidget)
|
||||
return dynamic_cast<Window*>(widget);
|
||||
|
||||
widget = widget->m_parent;
|
||||
@ -365,7 +365,7 @@ Manager* Widget::getManager()
|
||||
Widget* widget = this;
|
||||
|
||||
while (widget) {
|
||||
if (widget->type == kManagerWidget)
|
||||
if (widget->type() == kManagerWidget)
|
||||
return static_cast<Manager*>(widget);
|
||||
|
||||
widget = widget->m_parent;
|
||||
@ -656,7 +656,7 @@ void Widget::noBorderNoChildSpacing()
|
||||
|
||||
void Widget::getRegion(gfx::Region& region)
|
||||
{
|
||||
if (this->type == kWindowWidget)
|
||||
if (type() == kWindowWidget)
|
||||
getTheme()->getWindowMask(this, region);
|
||||
else
|
||||
region = getBounds();
|
||||
@ -1264,7 +1264,7 @@ void Widget::offerCapture(ui::MouseMessage* mouseMsg, int widget_type)
|
||||
{
|
||||
if (hasCapture()) {
|
||||
Widget* pick = getManager()->pick(mouseMsg->position());
|
||||
if (pick && pick != this && pick->getType() == widget_type) {
|
||||
if (pick && pick != this && pick->type() == widget_type) {
|
||||
releaseMouse();
|
||||
|
||||
MouseMessage* mouseMsg2 = new MouseMessage(
|
||||
|
@ -44,17 +44,15 @@ namespace ui {
|
||||
|
||||
class Widget : public Component {
|
||||
public:
|
||||
WidgetType type; // widget's type
|
||||
|
||||
struct {
|
||||
int l, t, r, b;
|
||||
} border_width; /* border separation with the parent */
|
||||
int child_spacing; /* separation between children */
|
||||
} border_width; // Border separation with the parent
|
||||
int child_spacing; // Separation between children
|
||||
|
||||
/* flags */
|
||||
// Flags
|
||||
int flags;
|
||||
|
||||
/* widget size limits */
|
||||
// Widget size limits
|
||||
int min_w, min_h;
|
||||
int max_w, max_h;
|
||||
|
||||
@ -73,7 +71,8 @@ namespace ui {
|
||||
|
||||
// Main properties.
|
||||
|
||||
WidgetType getType() const { return this->type; }
|
||||
WidgetType type() const { return m_type; }
|
||||
void setType(WidgetType type) { m_type = type; } // TODO remove this function
|
||||
|
||||
const std::string& getId() const { return m_id; }
|
||||
void setId(const char* id) { m_id = id; }
|
||||
@ -378,6 +377,7 @@ namespace ui {
|
||||
void paint(Graphics* graphics, const gfx::Region& drawRegion);
|
||||
bool paintEvent(Graphics* graphics);
|
||||
|
||||
WidgetType m_type; // Widget's type
|
||||
std::string m_id; // Widget's id
|
||||
Theme* m_theme; // Widget's theme
|
||||
int m_align; // Widget alignment
|
||||
|
Loading…
x
Reference in New Issue
Block a user