Remove JI_ prefix from ui/base.h constants

This commit is contained in:
David Capello 2015-06-23 14:00:00 -03:00
parent 66330dc39a
commit f01b816fb5
53 changed files with 384 additions and 380 deletions

View File

@ -209,7 +209,7 @@ Widget* AppMenus::convertXmlelemToMenuitem(TiXmlElement* elem)
{ {
// is it a <separator>? // is it a <separator>?
if (strcmp(elem->Value(), "separator") == 0) if (strcmp(elem->Value(), "separator") == 0)
return new Separator("", JI_HORIZONTAL); return new Separator("", HORIZONTAL);
const char* command_name = elem->Attribute("command"); const char* command_name = elem->Attribute("command");
Command* command = Command* command =
@ -265,7 +265,7 @@ Widget* AppMenus::createInvalidVersionMenuitem()
subMenu->addChild(new AppMenuItem(PACKAGE " is using a customized gui.xml (maybe from your HOME directory).")); subMenu->addChild(new AppMenuItem(PACKAGE " is using a customized gui.xml (maybe from your HOME directory)."));
subMenu->addChild(new AppMenuItem("You should update your customized gui.xml file to the new version to get")); subMenu->addChild(new AppMenuItem("You should update your customized gui.xml file to the new version to get"));
subMenu->addChild(new AppMenuItem("the latest commands available.")); subMenu->addChild(new AppMenuItem("the latest commands available."));
subMenu->addChild(new Separator("", JI_HORIZONTAL)); subMenu->addChild(new Separator("", HORIZONTAL));
subMenu->addChild(new AppMenuItem("You can bypass this validation adding the correct version")); subMenu->addChild(new AppMenuItem("You can bypass this validation adding the correct version"));
subMenu->addChild(new AppMenuItem("number in <gui version=\"" VERSION "\"> element.")); subMenu->addChild(new AppMenuItem("number in <gui version=\"" VERSION "\"> element."));
menuitem->setSubmenu(subMenu); menuitem->setSubmenu(subMenu);

View File

@ -37,20 +37,20 @@ AboutCommand::AboutCommand()
void AboutCommand::onExecute(Context* context) void AboutCommand::onExecute(Context* context)
{ {
base::UniquePtr<Window> window(new Window(Window::WithTitleBar, "About " PACKAGE)); base::UniquePtr<Window> window(new Window(Window::WithTitleBar, "About " PACKAGE));
Box* box1 = new Box(JI_VERTICAL); Box* box1 = new Box(VERTICAL);
Grid* grid = new Grid(2, false); Grid* grid = new Grid(2, false);
Label* title = new Label(PACKAGE " v" VERSION); Label* title = new Label(PACKAGE " v" VERSION);
Label* subtitle = new Label("Animated sprite editor & pixel art tool"); Label* subtitle = new Label("Animated sprite editor & pixel art tool");
Separator* authors_separator1 = new Separator("Authors:", JI_HORIZONTAL | JI_TOP); Separator* authors_separator1 = new Separator("Authors:", HORIZONTAL | TOP);
Separator* authors_separator2 = new Separator("", JI_HORIZONTAL); Separator* authors_separator2 = new Separator("", HORIZONTAL);
Label* author1 = new LinkLabel("http://davidcapello.com/", "David Capello"); Label* author1 = new LinkLabel("http://davidcapello.com/", "David Capello");
Label* author1_desc = new Label("- Lead developer, graphics & maintainer"); Label* author1_desc = new Label("- Lead developer, graphics & maintainer");
Label* author2 = new LinkLabel("http://ilkke.blogspot.com/", "Ilija Melentijevic"); Label* author2 = new LinkLabel("http://ilkke.blogspot.com/", "Ilija Melentijevic");
Label* author2_desc = new Label("- Default skin & graphics introduced in v0.8"); Label* author2_desc = new Label("- Default skin & graphics introduced in v0.8");
Label* author3 = new LinkLabel(WEBSITE_CONTRIBUTORS, "Contributors"); Label* author3 = new LinkLabel(WEBSITE_CONTRIBUTORS, "Contributors");
Box* bottom_box1 = new Box(JI_HORIZONTAL); Box* bottom_box1 = new Box(HORIZONTAL);
Box* bottom_box2 = new Box(JI_HORIZONTAL); Box* bottom_box2 = new Box(HORIZONTAL);
Box* bottom_box3 = new Box(JI_HORIZONTAL); Box* bottom_box3 = new Box(HORIZONTAL);
Label* copyright = new Label(COPYRIGHT); Label* copyright = new Label(COPYRIGHT);
Label* website = new LinkLabel(WEBSITE); Label* website = new LinkLabel(WEBSITE);
Button* close_button = new Button("&Close"); Button* close_button = new Button("&Close");

View File

@ -99,14 +99,14 @@ void CelPropertiesCommand::onExecute(Context* context)
tooltipManager->addTooltipFor(slider_opacity, tooltipManager->addTooltipFor(slider_opacity,
"The `Background' layer is opaque,\n" "The `Background' layer is opaque,\n"
"its opacity can't be changed.", "its opacity can't be changed.",
JI_LEFT); LEFT);
} }
else if (sprite->pixelFormat() == IMAGE_INDEXED) { else if (sprite->pixelFormat() == IMAGE_INDEXED) {
slider_opacity->setEnabled(false); slider_opacity->setEnabled(false);
tooltipManager->addTooltipFor(slider_opacity, tooltipManager->addTooltipFor(slider_opacity,
"Cel opacity of Indexed images\n" "Cel opacity of Indexed images\n"
"cannot be changed.", "cannot be changed.",
JI_LEFT); LEFT);
} }
} }
else { else {

View File

@ -96,10 +96,10 @@ void MaskByColorCommand::onExecute(Context* context)
return; return;
m_window = new Window(Window::WithTitleBar, "Mask by Color"); m_window = new Window(Window::WithTitleBar, "Mask by Color");
box1 = new Box(JI_VERTICAL); box1 = new Box(VERTICAL);
box2 = new Box(JI_HORIZONTAL); box2 = new Box(HORIZONTAL);
box3 = new Box(JI_HORIZONTAL); box3 = new Box(HORIZONTAL);
box4 = new Box(JI_HORIZONTAL | JI_HOMOGENEOUS); box4 = new Box(HORIZONTAL | HOMOGENEOUS);
label_color = new Label("Color:"); label_color = new Label("Color:");
m_buttonColor = new ColorButton m_buttonColor = new ColorButton
(get_config_color("MaskColor", "Color", (get_config_color("MaskColor", "Color",

View File

@ -239,9 +239,9 @@ bool PaletteEditorCommand::onChecked(Context* context)
PaletteEntryEditor::PaletteEntryEditor() PaletteEntryEditor::PaletteEntryEditor()
: Window(WithTitleBar, "Palette Editor (F4)") : Window(WithTitleBar, "Palette Editor (F4)")
, m_type(app::Color::MaskType) , m_type(app::Color::MaskType)
, m_vbox(JI_VERTICAL) , m_vbox(VERTICAL)
, m_topBox(JI_HORIZONTAL) , m_topBox(HORIZONTAL)
, m_bottomBox(JI_HORIZONTAL) , m_bottomBox(HORIZONTAL)
, m_colorType(2) , m_colorType(2)
, m_changeMode(2) , m_changeMode(2)
, m_entryLabel("") , m_entryLabel("")
@ -263,9 +263,9 @@ PaletteEntryEditor::PaletteEntryEditor()
// Top box // Top box
m_topBox.addChild(&m_colorType); m_topBox.addChild(&m_colorType);
m_topBox.addChild(new Separator("", JI_VERTICAL)); m_topBox.addChild(new Separator("", VERTICAL));
m_topBox.addChild(&m_changeMode); m_topBox.addChild(&m_changeMode);
m_topBox.addChild(new Separator("", JI_VERTICAL)); m_topBox.addChild(new Separator("", VERTICAL));
m_topBox.addChild(&m_hexColorEntry); m_topBox.addChild(&m_hexColorEntry);
m_topBox.addChild(&m_entryLabel); m_topBox.addChild(&m_entryLabel);
m_topBox.addChild(new BoxFiller); m_topBox.addChild(new BoxFiller);

View File

@ -30,7 +30,7 @@ using namespace ui;
using namespace app::skin; using namespace app::skin;
FilterTargetButtons::FilterTargetButtons(int imgtype, bool withChannels) FilterTargetButtons::FilterTargetButtons(int imgtype, bool withChannels)
: Box(JI_VERTICAL) : Box(VERTICAL)
, m_target(0) , m_target(0)
{ {
#define ADD(box, widget, hook) \ #define ADD(box, widget, hook) \
@ -49,7 +49,7 @@ FilterTargetButtons::FilterTargetButtons(int imgtype, bool withChannels)
CheckBox* index = NULL; CheckBox* index = NULL;
Button* images = NULL; Button* images = NULL;
hbox = new Box(JI_HORIZONTAL | JI_HOMOGENEOUS); hbox = new Box(HORIZONTAL | HOMOGENEOUS);
this->noBorderNoChildSpacing(); this->noBorderNoChildSpacing();
hbox->noBorderNoChildSpacing(); hbox->noBorderNoChildSpacing();
@ -96,7 +96,7 @@ FilterTargetButtons::FilterTargetButtons(int imgtype, bool withChannels)
set_gfxicon_to_button(images, set_gfxicon_to_button(images,
getTargetNormalIcon(), getTargetNormalIcon(),
getTargetSelectedIcon(), -1, getTargetSelectedIcon(), -1,
JI_CENTER | JI_MIDDLE); CENTER | MIDDLE);
// Make hierarchy // Make hierarchy
ADD(hbox, r, onChannelChange); ADD(hbox, r, onChannelChange);
@ -175,7 +175,7 @@ void FilterTargetButtons::onImagesChange(ButtonBase* button)
set_gfxicon_to_button(button, set_gfxicon_to_button(button,
getTargetNormalIcon(), getTargetNormalIcon(),
getTargetSelectedIcon(), -1, getTargetSelectedIcon(), -1,
JI_CENTER | JI_MIDDLE); CENTER | MIDDLE);
TargetChange(); TargetChange();
} }

View File

@ -30,9 +30,9 @@ FilterWindow::FilterWindow(const char* title, const char* cfgSection,
: Window(WithTitleBar, title) : Window(WithTitleBar, title)
, m_cfgSection(cfgSection) , m_cfgSection(cfgSection)
, m_filterMgr(filterMgr) , m_filterMgr(filterMgr)
, m_hbox(JI_HORIZONTAL) , m_hbox(HORIZONTAL)
, m_vbox(JI_VERTICAL) , m_vbox(VERTICAL)
, m_container(JI_VERTICAL) , m_container(VERTICAL)
, m_okButton("&OK") , m_okButton("&OK")
, m_cancelButton("&Cancel") , m_cancelButton("&Cancel")
, m_preview(filterMgr) , m_preview(filterMgr)

View File

@ -55,7 +55,7 @@ Console::Console(Context* ctx)
Window* window = new Window(Window::WithTitleBar, "Errors Console"); Window* window = new Window(Window::WithTitleBar, "Errors Console");
Grid* grid = new Grid(1, false); Grid* grid = new Grid(1, false);
View* view = new View(); View* view = new View();
TextBox* textbox = new TextBox("", JI_WORDWRAP); TextBox* textbox = new TextBox("", WORDWRAP);
Button* button = new Button("&Cancel"); Button* button = new Button("&Cancel");
if (!grid || !textbox || !button) if (!grid || !textbox || !button)
@ -68,8 +68,8 @@ Console::Console(Context* ctx)
button->setMinSize(gfx::Size(60, 0)); button->setMinSize(gfx::Size(60, 0));
grid->addChildInCell(view, 1, 1, JI_HORIZONTAL | JI_VERTICAL); grid->addChildInCell(view, 1, 1, HORIZONTAL | VERTICAL);
grid->addChildInCell(button, 1, 1, JI_CENTER); grid->addChildInCell(button, 1, 1, CENTER);
window->addChild(grid); window->addChild(grid);
view->setVisible(false); view->setVisible(false);

View File

@ -331,7 +331,7 @@ CheckBox* check_button_new(const char *text, int b1, int b2, int b3, int b4)
{ {
CheckBox* widget = new CheckBox(text, kButtonWidget); CheckBox* widget = new CheckBox(text, kButtonWidget);
widget->setAlign(JI_CENTER | JI_MIDDLE); widget->setAlign(CENTER | MIDDLE);
setup_mini_look(widget); setup_mini_look(widget);
setup_bevels(widget, b1, b2, b3, b4); setup_bevels(widget, b1, b2, b3, b4);

View File

@ -72,7 +72,7 @@ protected:
deleteAllItem.Click.connect(&Item::onDeleteAllBrushes, this); deleteAllItem.Click.connect(&Item::onDeleteAllBrushes, this);
menu.addChild(&lockItem); menu.addChild(&lockItem);
menu.addChild(&deleteItem); menu.addChild(&deleteItem);
menu.addChild(new Separator("", JI_HORIZONTAL)); menu.addChild(new Separator("", HORIZONTAL));
menu.addChild(&deleteAllItem); menu.addChild(&deleteAllItem);
// Here we make the popup window temporaly floating, so it's // Here we make the popup window temporaly floating, so it's
@ -173,7 +173,7 @@ void BrushPopup::regenerate(const gfx::Rect& box, const Brushes& brushes)
std::string tooltip; std::string tooltip;
tooltip += "Shortcut: "; tooltip += "Shortcut: ";
tooltip += key->accels().front().toString(); tooltip += key->accels().front().toString();
m_tooltipManager->addTooltipFor(item, tooltip, JI_TOP); m_tooltipManager->addTooltipFor(item, tooltip, TOP);
} }
slot++; slot++;
} }

View File

@ -201,7 +201,7 @@ void ButtonSet::addItem(she::Surface* icon, int hspan, int vspan)
void ButtonSet::addItem(Item* item, int hspan, int vspan) void ButtonSet::addItem(Item* item, int hspan, int vspan)
{ {
addChildInCell(item, hspan, vspan, JI_CENTER | JI_MIDDLE); addChildInCell(item, hspan, vspan, CENTER | MIDDLE);
} }
ButtonSet::Item* ButtonSet::getItem(int index) ButtonSet::Item* ButtonSet::getItem(int index)

View File

@ -140,7 +140,7 @@ ColorBar::ColorBar(int align)
palViewBox->addChild(&m_remapButton); palViewBox->addChild(&m_remapButton);
ColorSpectrum* spectrum = new ColorSpectrum; ColorSpectrum* spectrum = new ColorSpectrum;
Splitter* splitter = new Splitter(Splitter::ByPercentage, JI_VERTICAL); Splitter* splitter = new Splitter(Splitter::ByPercentage, VERTICAL);
splitter->setPosition(80); splitter->setPosition(80);
splitter->setExpansive(true); splitter->setExpansive(true);
splitter->addChild(palViewBox); splitter->addChild(palViewBox);
@ -184,11 +184,11 @@ ColorBar::ColorBar(int align)
// Tooltips // Tooltips
TooltipManager* tooltipManager = new TooltipManager(); TooltipManager* tooltipManager = new TooltipManager();
addChild(tooltipManager); addChild(tooltipManager);
tooltipManager->addTooltipFor(m_buttons.getItem((int)PalButton::EDIT), "Edit Color", JI_BOTTOM); tooltipManager->addTooltipFor(m_buttons.getItem((int)PalButton::EDIT), "Edit Color", BOTTOM);
tooltipManager->addTooltipFor(m_buttons.getItem((int)PalButton::SORT), "Sort & Gradients", JI_BOTTOM); tooltipManager->addTooltipFor(m_buttons.getItem((int)PalButton::SORT), "Sort & Gradients", BOTTOM);
tooltipManager->addTooltipFor(m_buttons.getItem((int)PalButton::PRESETS), "Presets", JI_BOTTOM); tooltipManager->addTooltipFor(m_buttons.getItem((int)PalButton::PRESETS), "Presets", BOTTOM);
tooltipManager->addTooltipFor(m_buttons.getItem((int)PalButton::OPTIONS), "Options", JI_BOTTOM); tooltipManager->addTooltipFor(m_buttons.getItem((int)PalButton::OPTIONS), "Options", BOTTOM);
tooltipManager->addTooltipFor(&m_remapButton, "Matches old indexes with new indexes", JI_BOTTOM); tooltipManager->addTooltipFor(&m_remapButton, "Matches old indexes with new indexes", BOTTOM);
onColorButtonChange(getFgColor()); onColorButtonChange(getFgColor());
@ -298,12 +298,12 @@ void ColorBar::onPaletteButtonClick()
des("Descending"); des("Descending");
menu.addChild(&rev); menu.addChild(&rev);
menu.addChild(&grd); menu.addChild(&grd);
menu.addChild(new ui::Separator("", JI_HORIZONTAL)); menu.addChild(new ui::Separator("", HORIZONTAL));
menu.addChild(&hue); menu.addChild(&hue);
menu.addChild(&sat); menu.addChild(&sat);
menu.addChild(&bri); menu.addChild(&bri);
menu.addChild(&lum); menu.addChild(&lum);
menu.addChild(new ui::Separator("", JI_HORIZONTAL)); menu.addChild(new ui::Separator("", HORIZONTAL));
menu.addChild(&asc); menu.addChild(&asc);
menu.addChild(&des); menu.addChild(&des);

View File

@ -59,8 +59,8 @@ public:
ColorSelector::ColorSelector() ColorSelector::ColorSelector()
: PopupWindowPin("Color Selector", PopupWindow::kCloseOnClickInOtherWindow) : PopupWindowPin("Color Selector", PopupWindow::kCloseOnClickInOtherWindow)
, m_vbox(JI_VERTICAL) , m_vbox(VERTICAL)
, m_topBox(JI_HORIZONTAL) , m_topBox(HORIZONTAL)
, m_color(app::Color::fromMask()) , m_color(app::Color::fromMask())
, m_colorPalette(false, PaletteView::SelectOneColor, this, 7*guiscale()) , m_colorPalette(false, PaletteView::SelectOneColor, this, 7*guiscale())
, m_colorType(5) , m_colorType(5)
@ -82,11 +82,11 @@ ColorSelector::ColorSelector()
m_colorPaletteContainer.setExpansive(true); m_colorPaletteContainer.setExpansive(true);
m_topBox.addChild(&m_colorType); m_topBox.addChild(&m_colorType);
m_topBox.addChild(new Separator("", JI_VERTICAL)); m_topBox.addChild(new Separator("", VERTICAL));
m_topBox.addChild(&m_hexColorEntry); m_topBox.addChild(&m_hexColorEntry);
m_topBox.addChild(m_warningIcon); m_topBox.addChild(m_warningIcon);
{ {
Box* miniVbox = new Box(JI_VERTICAL); Box* miniVbox = new Box(VERTICAL);
miniVbox->addChild(getPin()); miniVbox->addChild(getPin());
m_topBox.addChild(new BoxFiller); m_topBox.addChild(new BoxFiller);
m_topBox.addChild(miniVbox); m_topBox.addChild(miniVbox);
@ -113,7 +113,7 @@ ColorSelector::ColorSelector()
m_onPaletteChangeConn = m_onPaletteChangeConn =
App::instance()->PaletteChange.connect(&ColorSelector::onPaletteChange, this); App::instance()->PaletteChange.connect(&ColorSelector::onPaletteChange, this);
m_tooltips.addTooltipFor(m_warningIcon, "This color isn't in the palette\nPress here to add it.", JI_BOTTOM); m_tooltips.addTooltipFor(m_warningIcon, "This color isn't in the palette\nPress here to add it.", BOTTOM);
initTheme(); initTheme();
} }

View File

@ -151,9 +151,9 @@ void ColorSliders::addSlider(Channel channel, const char* labelText, int min, in
relSlider->setExpansive(true); relSlider->setExpansive(true);
relSlider->setVisible(false); relSlider->setVisible(false);
m_grid.addChildInCell(label, 1, 1, JI_LEFT | JI_MIDDLE); m_grid.addChildInCell(label, 1, 1, LEFT | MIDDLE);
m_grid.addChildInCell(box, 1, 1, JI_HORIZONTAL | JI_VERTICAL | JI_EXPANSIVE); m_grid.addChildInCell(box, 1, 1, HORIZONTAL | VERTICAL | EXPANSIVE);
m_grid.addChildInCell(entry, 1, 1, JI_LEFT | JI_MIDDLE); m_grid.addChildInCell(entry, 1, 1, LEFT | MIDDLE);
} }
void ColorSliders::setAbsSliderValue(int sliderIndex, int value) void ColorSliders::setAbsSliderValue(int sliderIndex, int value)

View File

@ -30,7 +30,7 @@ using namespace ui;
ColorSpectrum::ColorSpectrum() ColorSpectrum::ColorSpectrum()
: Widget(kGenericWidget) : Widget(kGenericWidget)
{ {
setAlign(JI_HORIZONTAL); setAlign(HORIZONTAL);
} }
ColorSpectrum::~ColorSpectrum() ColorSpectrum::~ColorSpectrum()
@ -43,11 +43,11 @@ app::Color ColorSpectrum::pickColor(const gfx::Point& pos) const
if (rc.isEmpty() || !rc.contains(pos)) if (rc.isEmpty() || !rc.contains(pos))
return app::Color::fromMask(); return app::Color::fromMask();
int vmid = (getAlign() & JI_HORIZONTAL ? rc.h/2 : rc.w/2); int vmid = (getAlign() & HORIZONTAL ? rc.h/2 : rc.w/2);
vmid = MAX(1, vmid); vmid = MAX(1, vmid);
int u, v, umax; int u, v, umax;
if (getAlign() & JI_HORIZONTAL) { if (getAlign() & HORIZONTAL) {
u = pos.x - rc.x; u = pos.x - rc.x;
v = pos.y - rc.y; v = pos.y - rc.y;
umax = MAX(1, rc.w-1); umax = MAX(1, rc.w-1);
@ -90,13 +90,13 @@ void ColorSpectrum::onPaint(ui::PaintEvent& ev)
if (rc.isEmpty()) if (rc.isEmpty())
return; return;
int vmid = (getAlign() & JI_HORIZONTAL ? rc.h/2 : rc.w/2); int vmid = (getAlign() & HORIZONTAL ? rc.h/2 : rc.w/2);
vmid = MAX(1, vmid); vmid = MAX(1, vmid);
for (int y=0; y<rc.h; ++y) { for (int y=0; y<rc.h; ++y) {
for (int x=0; x<rc.w; ++x) { for (int x=0; x<rc.w; ++x) {
int u, v, umax; int u, v, umax;
if (getAlign() & JI_HORIZONTAL) { if (getAlign() & HORIZONTAL) {
u = x; u = x;
v = y; v = y;
umax = MAX(1, rc.w-1); umax = MAX(1, rc.w-1);

View File

@ -564,7 +564,7 @@ public:
} }
int getIconAlign() override { int getIconAlign() override {
return JI_CENTER | JI_MIDDLE; return CENTER | MIDDLE;
} }
protected: protected:
@ -605,9 +605,9 @@ private:
m_freehandAlgoButton->setTransparent(true); m_freehandAlgoButton->setTransparent(true);
m_freehandAlgoButton->setBgColor(gfx::ColorNone); m_freehandAlgoButton->setBgColor(gfx::ColorNone);
m_tooltipManager->addTooltipFor(at(0), "Normal trace", JI_TOP); m_tooltipManager->addTooltipFor(at(0), "Normal trace", TOP);
m_tooltipManager->addTooltipFor(at(1), "Pixel-perfect trace", JI_TOP); m_tooltipManager->addTooltipFor(at(1), "Pixel-perfect trace", TOP);
m_tooltipManager->addTooltipFor(at(2), "Dots", JI_TOP); m_tooltipManager->addTooltipFor(at(2), "Dots", TOP);
m_popupWindow->addChild(m_freehandAlgoButton); m_popupWindow->addChild(m_freehandAlgoButton);
m_popupWindow->openWindow(); m_popupWindow->openWindow();
@ -694,9 +694,9 @@ public:
} }
void setupTooltips(TooltipManager* tooltipManager) { void setupTooltips(TooltipManager* tooltipManager) {
tooltipManager->addTooltipFor(at(0), "Replace selection", JI_BOTTOM); tooltipManager->addTooltipFor(at(0), "Replace selection", BOTTOM);
tooltipManager->addTooltipFor(at(1), "Add to selection\n(Shift)", JI_BOTTOM); tooltipManager->addTooltipFor(at(1), "Add to selection\n(Shift)", BOTTOM);
tooltipManager->addTooltipFor(at(2), "Subtract from selection\n(Shift+Alt)", JI_BOTTOM); tooltipManager->addTooltipFor(at(2), "Subtract from selection\n(Shift+Alt)", BOTTOM);
} }
void setSelectionMode(SelectionMode mode) { void setSelectionMode(SelectionMode mode) {
@ -725,8 +725,8 @@ public:
} }
void setupTooltips(TooltipManager* tooltipManager) { void setupTooltips(TooltipManager* tooltipManager) {
tooltipManager->addTooltipFor(at(0), "Drop pixels here", JI_BOTTOM); tooltipManager->addTooltipFor(at(0), "Drop pixels here", BOTTOM);
tooltipManager->addTooltipFor(at(1), "Cancel drag and drop", JI_BOTTOM); tooltipManager->addTooltipFor(at(1), "Cancel drag and drop", BOTTOM);
} }
Signal1<void, ContextBarObserver::DropAction> DropPixels; Signal1<void, ContextBarObserver::DropAction> DropPixels;
@ -777,7 +777,7 @@ protected:
}; };
ContextBar::ContextBar() ContextBar::ContextBar()
: Box(JI_HORIZONTAL) : Box(HORIZONTAL)
{ {
border_width.b = 2*guiscale(); border_width.b = 2*guiscale();
@ -835,20 +835,20 @@ ContextBar::ContextBar()
TooltipManager* tooltipManager = new TooltipManager(); TooltipManager* tooltipManager = new TooltipManager();
addChild(tooltipManager); addChild(tooltipManager);
tooltipManager->addTooltipFor(m_brushType, "Brush Type", JI_BOTTOM); tooltipManager->addTooltipFor(m_brushType, "Brush Type", BOTTOM);
tooltipManager->addTooltipFor(m_brushSize, "Brush Size (in pixels)", JI_BOTTOM); tooltipManager->addTooltipFor(m_brushSize, "Brush Size (in pixels)", BOTTOM);
tooltipManager->addTooltipFor(m_brushAngle, "Brush Angle (in degrees)", JI_BOTTOM); tooltipManager->addTooltipFor(m_brushAngle, "Brush Angle (in degrees)", BOTTOM);
tooltipManager->addTooltipFor(m_inkOpacity, "Opacity (Alpha value in RGBA)", JI_BOTTOM); tooltipManager->addTooltipFor(m_inkOpacity, "Opacity (Alpha value in RGBA)", BOTTOM);
tooltipManager->addTooltipFor(m_sprayWidth, "Spray Width", JI_BOTTOM); tooltipManager->addTooltipFor(m_sprayWidth, "Spray Width", BOTTOM);
tooltipManager->addTooltipFor(m_spraySpeed, "Spray Speed", JI_BOTTOM); tooltipManager->addTooltipFor(m_spraySpeed, "Spray Speed", BOTTOM);
tooltipManager->addTooltipFor(m_transparentColor, "Transparent Color", JI_BOTTOM); tooltipManager->addTooltipFor(m_transparentColor, "Transparent Color", BOTTOM);
tooltipManager->addTooltipFor(m_rotAlgo, "Rotation Algorithm", JI_BOTTOM); tooltipManager->addTooltipFor(m_rotAlgo, "Rotation Algorithm", BOTTOM);
tooltipManager->addTooltipFor(m_freehandAlgo, "Freehand trace algorithm", JI_BOTTOM); tooltipManager->addTooltipFor(m_freehandAlgo, "Freehand trace algorithm", BOTTOM);
tooltipManager->addTooltipFor(m_grabAlpha, tooltipManager->addTooltipFor(m_grabAlpha,
"When checked the tool picks the color from the active layer, and its alpha\n" "When checked the tool picks the color from the active layer, and its alpha\n"
"component is used to setup the opacity level of all drawing tools.\n\n" "component is used to setup the opacity level of all drawing tools.\n\n"
"When unchecked -the default behavior- the color is picked\n" "When unchecked -the default behavior- the color is picked\n"
"from the composition of all sprite layers.", JI_LEFT | JI_TOP); "from the composition of all sprite layers.", LEFT | TOP);
m_brushType->setupTooltips(tooltipManager); m_brushType->setupTooltips(tooltipManager);
m_selectionMode->setupTooltips(tooltipManager); m_selectionMode->setupTooltips(tooltipManager);

View File

@ -133,7 +133,7 @@ private:
} // anonymous namespace } // anonymous namespace
DataRecoveryView::DataRecoveryView(crash::DataRecovery* dataRecovery) DataRecoveryView::DataRecoveryView(crash::DataRecovery* dataRecovery)
: Box(JI_VERTICAL) : Box(VERTICAL)
, m_dataRecovery(dataRecovery) , m_dataRecovery(dataRecovery)
{ {
SkinTheme* theme = static_cast<SkinTheme*>(getTheme()); SkinTheme* theme = static_cast<SkinTheme*>(getTheme());

View File

@ -60,8 +60,8 @@ protected:
}; };
DevConsoleView::DevConsoleView() DevConsoleView::DevConsoleView()
: Box(JI_VERTICAL) : Box(VERTICAL)
, m_textBox("Welcome to Aseprite JavaScript Console\n(Experimental)", JI_LEFT) , m_textBox("Welcome to Aseprite JavaScript Console\n(Experimental)", LEFT)
, m_label(">") , m_label(">")
, m_entry(new CommmandEntry) , m_entry(new CommmandEntry)
, m_engine(this) , m_engine(this)

View File

@ -202,7 +202,7 @@ private:
}; };
DocumentView::DocumentView(Document* document, Type type) DocumentView::DocumentView(Document* document, Type type)
: Box(JI_VERTICAL) : Box(VERTICAL)
, m_type(type) , m_type(type)
, m_document(document) , m_document(document)
, m_view(new EditorView(type == Normal ? EditorView::CurrentEditorMode: , m_view(new EditorView(type == Normal ? EditorView::CurrentEditorMode:

View File

@ -31,7 +31,7 @@ DropDownButton::DropDownButton(const char* text)
setup_look(m_dropDown, RightButtonLook); setup_look(m_dropDown, RightButtonLook);
m_button->setExpansive(true); m_button->setExpansive(true);
m_button->setAlign(JI_LEFT | JI_MIDDLE); m_button->setAlign(LEFT | MIDDLE);
m_button->Click.connect(&DropDownButton::onButtonClick, this); m_button->Click.connect(&DropDownButton::onButtonClick, this);
m_dropDown->Click.connect(&DropDownButton::onDropDownButtonClick, this); m_dropDown->Click.connect(&DropDownButton::onDropDownButtonClick, this);
@ -45,7 +45,7 @@ DropDownButton::DropDownButton(const char* text)
PART_COMBOBOX_ARROW_DOWN, PART_COMBOBOX_ARROW_DOWN,
PART_COMBOBOX_ARROW_DOWN_SELECTED, PART_COMBOBOX_ARROW_DOWN_SELECTED,
PART_COMBOBOX_ARROW_DOWN_DISABLED, PART_COMBOBOX_ARROW_DOWN_DISABLED,
JI_CENTER | JI_MIDDLE)); CENTER | MIDDLE));
} }
void DropDownButton::onButtonClick(Event& ev) void DropDownButton::onButtonClick(Event& ev)

View File

@ -1612,7 +1612,7 @@ void Editor::showAnimationSpeedMultiplierPopup(bool withStopBehaviorOptions)
} }
if (withStopBehaviorOptions) { if (withStopBehaviorOptions) {
menu.addChild(new Separator("", JI_HORIZONTAL)); menu.addChild(new Separator("", HORIZONTAL));
MenuItem* item = new MenuItem("Rewind on Stop"); MenuItem* item = new MenuItem("Rewind on Stop");
item->Click.connect( item->Click.connect(
[]() { []() {

View File

@ -256,22 +256,22 @@ FileSelector::FileSelector(FileSelectorType type, FileSelectorDelegate* delegate
PART_COMBOBOX_ARROW_LEFT, PART_COMBOBOX_ARROW_LEFT,
PART_COMBOBOX_ARROW_LEFT_SELECTED, PART_COMBOBOX_ARROW_LEFT_SELECTED,
PART_COMBOBOX_ARROW_LEFT_DISABLED, PART_COMBOBOX_ARROW_LEFT_DISABLED,
JI_CENTER | JI_MIDDLE); CENTER | MIDDLE);
set_gfxicon_to_button(goForwardButton(), set_gfxicon_to_button(goForwardButton(),
PART_COMBOBOX_ARROW_RIGHT, PART_COMBOBOX_ARROW_RIGHT,
PART_COMBOBOX_ARROW_RIGHT_SELECTED, PART_COMBOBOX_ARROW_RIGHT_SELECTED,
PART_COMBOBOX_ARROW_RIGHT_DISABLED, PART_COMBOBOX_ARROW_RIGHT_DISABLED,
JI_CENTER | JI_MIDDLE); CENTER | MIDDLE);
set_gfxicon_to_button(goUpButton(), set_gfxicon_to_button(goUpButton(),
PART_COMBOBOX_ARROW_UP, PART_COMBOBOX_ARROW_UP,
PART_COMBOBOX_ARROW_UP_SELECTED, PART_COMBOBOX_ARROW_UP_SELECTED,
PART_COMBOBOX_ARROW_UP_DISABLED, PART_COMBOBOX_ARROW_UP_DISABLED,
JI_CENTER | JI_MIDDLE); CENTER | MIDDLE);
set_gfxicon_to_button(newFolderButton(), set_gfxicon_to_button(newFolderButton(),
PART_NEWFOLDER, PART_NEWFOLDER,
PART_NEWFOLDER_SELECTED, PART_NEWFOLDER_SELECTED,
PART_NEWFOLDER, PART_NEWFOLDER,
JI_CENTER | JI_MIDDLE); CENTER | MIDDLE);
setup_mini_look(goBackButton()); setup_mini_look(goBackButton());
setup_mini_look(goForwardButton()); setup_mini_look(goForwardButton());

View File

@ -28,7 +28,7 @@ static inline bool is_hex_digit(char digit)
} }
HexColorEntry::HexColorEntry() HexColorEntry::HexColorEntry()
: Box(JI_HORIZONTAL) : Box(HORIZONTAL)
, m_label("#") , m_label("#")
, m_entry(16, "") , m_entry(16, "")
{ {

View File

@ -37,7 +37,7 @@ PopupWindowPin::PopupWindowPin(const std::string& text, ClickBehavior clickBehav
m_pin.Click.connect(&PopupWindowPin::onPinClick, this); m_pin.Click.connect(&PopupWindowPin::onPinClick, this);
set_gfxicon_to_button(&m_pin, PART_UNPINNED, PART_PINNED, PART_UNPINNED, JI_CENTER | JI_MIDDLE); set_gfxicon_to_button(&m_pin, PART_UNPINNED, PART_PINNED, PART_UNPINNED, CENTER | MIDDLE);
} }
void PopupWindowPin::onPinClick(Event& ev) void PopupWindowPin::onPinClick(Event& ev)

View File

@ -561,17 +561,17 @@ void SkinTheme::onRegenerate()
const char* valign = xmlRule->Attribute("valign"); const char* valign = xmlRule->Attribute("valign");
const char* wordwrap = xmlRule->Attribute("wordwrap"); const char* wordwrap = xmlRule->Attribute("wordwrap");
if (halign) { if (halign) {
if (strcmp(halign, "left") == 0) align |= JI_LEFT; if (strcmp(halign, "left") == 0) align |= LEFT;
else if (strcmp(halign, "right") == 0) align |= JI_RIGHT; else if (strcmp(halign, "right") == 0) align |= RIGHT;
else if (strcmp(halign, "center") == 0) align |= JI_CENTER; else if (strcmp(halign, "center") == 0) align |= CENTER;
} }
if (valign) { if (valign) {
if (strcmp(valign, "top") == 0) align |= JI_TOP; if (strcmp(valign, "top") == 0) align |= TOP;
else if (strcmp(valign, "bottom") == 0) align |= JI_BOTTOM; else if (strcmp(valign, "bottom") == 0) align |= BOTTOM;
else if (strcmp(valign, "middle") == 0) align |= JI_MIDDLE; else if (strcmp(valign, "middle") == 0) align |= MIDDLE;
} }
if (wordwrap && strcmp(wordwrap, "true") == 0) if (wordwrap && strcmp(wordwrap, "true") == 0)
align |= JI_WORDWRAP; align |= WORDWRAP;
if (ruleName == "background") { if (ruleName == "background") {
const char* repeat_id = xmlRule->Attribute("repeat"); const char* repeat_id = xmlRule->Attribute("repeat");
@ -697,7 +697,7 @@ void SkinTheme::initWidget(Widget* widget)
PART_CHECK_NORMAL, PART_CHECK_NORMAL,
PART_CHECK_SELECTED, PART_CHECK_SELECTED,
PART_CHECK_DISABLED, PART_CHECK_DISABLED,
JI_LEFT | JI_MIDDLE)); LEFT | MIDDLE));
break; break;
case kEntryWidget: case kEntryWidget:
@ -746,7 +746,7 @@ void SkinTheme::initWidget(Widget* widget)
PART_COMBOBOX_ARROW_DOWN, PART_COMBOBOX_ARROW_DOWN,
PART_COMBOBOX_ARROW_DOWN_SELECTED, PART_COMBOBOX_ARROW_DOWN_SELECTED,
PART_COMBOBOX_ARROW_DOWN_DISABLED, PART_COMBOBOX_ARROW_DOWN_DISABLED,
JI_CENTER | JI_MIDDLE)); CENTER | MIDDLE));
} }
break; break;
@ -776,17 +776,17 @@ void SkinTheme::initWidget(Widget* widget)
PART_RADIO_NORMAL, PART_RADIO_NORMAL,
PART_RADIO_SELECTED, PART_RADIO_SELECTED,
PART_RADIO_DISABLED, PART_RADIO_DISABLED,
JI_LEFT | JI_MIDDLE)); LEFT | MIDDLE));
break; break;
case kSeparatorWidget: case kSeparatorWidget:
// Frame // Frame
if ((widget->getAlign() & JI_HORIZONTAL) && if ((widget->getAlign() & HORIZONTAL) &&
(widget->getAlign() & JI_VERTICAL)) { (widget->getAlign() & VERTICAL)) {
BORDER(4 * scale); BORDER(4 * scale);
} }
// Horizontal bar // Horizontal bar
else if (widget->getAlign() & JI_HORIZONTAL) { else if (widget->getAlign() & HORIZONTAL) {
BORDER4(2 * scale, 4 * scale, 2 * scale, 0); BORDER4(2 * scale, 4 * scale, 2 * scale, 0);
} }
// Vertical bar // Vertical bar
@ -795,9 +795,9 @@ void SkinTheme::initWidget(Widget* widget)
} }
if (widget->hasText()) { if (widget->hasText()) {
if (widget->getAlign() & JI_TOP) if (widget->getAlign() & TOP)
widget->border_width.t = widget->getTextHeight(); widget->border_width.t = widget->getTextHeight();
else if (widget->getAlign() & JI_BOTTOM) else if (widget->getAlign() & BOTTOM)
widget->border_width.b = widget->getTextHeight(); widget->border_width.b = widget->getTextHeight();
} }
break; break;
@ -809,7 +809,7 @@ void SkinTheme::initWidget(Widget* widget)
m_part[PART_SLIDER_EMPTY_E]->width()-1*scale, m_part[PART_SLIDER_EMPTY_E]->width()-1*scale,
m_part[PART_SLIDER_EMPTY_S]->height()-1*scale); m_part[PART_SLIDER_EMPTY_S]->height()-1*scale);
widget->child_spacing = widget->getTextHeight(); widget->child_spacing = widget->getTextHeight();
widget->setAlign(JI_CENTER | JI_MIDDLE); widget->setAlign(CENTER | MIDDLE);
break; break;
case kTextBoxWidget: case kTextBoxWidget:
@ -843,7 +843,7 @@ void SkinTheme::initWidget(Widget* widget)
BORDER4(6 * scale, (4+6) * scale, 6 * scale, 6 * scale); BORDER4(6 * scale, (4+6) * scale, 6 * scale, 6 * scale);
widget->border_width.t += widget->getTextHeight(); widget->border_width.t += widget->getTextHeight();
if (!(widget->flags & JI_INITIALIZED)) { if (!(widget->flags & INITIALIZED)) {
Button* button = new WindowCloseButton(); Button* button = new WindowCloseButton();
widget->addChild(button); widget->addChild(button);
} }
@ -1255,9 +1255,9 @@ void SkinTheme::paintMenuItem(ui::PaintEvent& ev)
// Text // Text
if (bar) if (bar)
widget->setAlign(JI_CENTER | JI_MIDDLE); widget->setAlign(CENTER | MIDDLE);
else else
widget->setAlign(JI_LEFT | JI_MIDDLE); widget->setAlign(LEFT | MIDDLE);
Rect pos = bounds; Rect pos = bounds;
if (!bar) if (!bar)
@ -1298,7 +1298,7 @@ void SkinTheme::paintMenuItem(ui::PaintEvent& ev)
std::string buf = appMenuItem->getKey()->accels().front().toString(); std::string buf = appMenuItem->getKey()->accels().front().toString();
widget->setAlign(JI_RIGHT | JI_MIDDLE); widget->setAlign(RIGHT | MIDDLE);
drawTextString(g, buf.c_str(), fg, ColorNone, widget, pos, 0); drawTextString(g, buf.c_str(), fg, ColorNone, widget, pos, 0);
widget->setAlign(old_align); widget->setAlign(old_align);
} }
@ -1359,10 +1359,10 @@ void SkinTheme::paintSeparator(ui::PaintEvent& ev)
// background // background
g->fillRect(BGCOLOR, bounds); g->fillRect(BGCOLOR, bounds);
if (widget->getAlign() & JI_HORIZONTAL) if (widget->getAlign() & HORIZONTAL)
draw_part_as_hline(g, bounds, PART_SEPARATOR_HORZ); draw_part_as_hline(g, bounds, PART_SEPARATOR_HORZ);
if (widget->getAlign() & JI_VERTICAL) if (widget->getAlign() & VERTICAL)
draw_part_as_vline(g, bounds, PART_SEPARATOR_VERT); draw_part_as_vline(g, bounds, PART_SEPARATOR_VERT);
// text // text
@ -1680,7 +1680,7 @@ void SkinTheme::paintViewScrollbar(PaintEvent& ev)
bgStyle->paint(g, rc, NULL, Style::State()); bgStyle->paint(g, rc, NULL, Style::State());
// Horizontal bar // Horizontal bar
if (widget->getAlign() & JI_HORIZONTAL) { if (widget->getAlign() & HORIZONTAL) {
rc.x += pos; rc.x += pos;
rc.w = len; rc.w = len;
} }
@ -1784,10 +1784,10 @@ void SkinTheme::paintTooltip(PaintEvent& ev)
int w = PART_TOOLTIP_W; int w = PART_TOOLTIP_W;
switch (widget->getArrowAlign()) { switch (widget->getArrowAlign()) {
case JI_TOP | JI_LEFT: nw = PART_TOOLTIP_ARROW_NW; break; case TOP | LEFT: nw = PART_TOOLTIP_ARROW_NW; break;
case JI_TOP | JI_RIGHT: ne = PART_TOOLTIP_ARROW_NE; break; case TOP | RIGHT: ne = PART_TOOLTIP_ARROW_NE; break;
case JI_BOTTOM | JI_LEFT: sw = PART_TOOLTIP_ARROW_SW; break; case BOTTOM | LEFT: sw = PART_TOOLTIP_ARROW_SW; break;
case JI_BOTTOM | JI_RIGHT: se = PART_TOOLTIP_ARROW_SE; break; case BOTTOM | RIGHT: se = PART_TOOLTIP_ARROW_SE; break;
} }
draw_bounds_template(g, rc, nw, n, ne, e, se, s, sw, w); draw_bounds_template(g, rc, nw, n, ne, e, se, s, sw, w);
@ -1799,25 +1799,25 @@ void SkinTheme::paintTooltip(PaintEvent& ev)
target.offset(-absRc.getOrigin()); target.offset(-absRc.getOrigin());
switch (widget->getArrowAlign()) { switch (widget->getArrowAlign()) {
case JI_TOP: case TOP:
arrow = m_part[PART_TOOLTIP_ARROW_N]; arrow = m_part[PART_TOOLTIP_ARROW_N];
g->drawRgbaSurface(arrow, g->drawRgbaSurface(arrow,
target.x+target.w/2-arrow->width()/2, target.x+target.w/2-arrow->width()/2,
rc.y); rc.y);
break; break;
case JI_BOTTOM: case BOTTOM:
arrow = m_part[PART_TOOLTIP_ARROW_S]; arrow = m_part[PART_TOOLTIP_ARROW_S];
g->drawRgbaSurface(arrow, g->drawRgbaSurface(arrow,
target.x+target.w/2-arrow->width()/2, target.x+target.w/2-arrow->width()/2,
rc.y+rc.h-arrow->height()); rc.y+rc.h-arrow->height());
break; break;
case JI_LEFT: case LEFT:
arrow = m_part[PART_TOOLTIP_ARROW_W]; arrow = m_part[PART_TOOLTIP_ARROW_W];
g->drawRgbaSurface(arrow, g->drawRgbaSurface(arrow,
rc.x, rc.x,
target.y+target.h/2-arrow->height()/2); target.y+target.h/2-arrow->height()/2);
break; break;
case JI_RIGHT: case RIGHT:
arrow = m_part[PART_TOOLTIP_ARROW_E]; arrow = m_part[PART_TOOLTIP_ARROW_E];
g->drawRgbaSurface(arrow, g->drawRgbaSurface(arrow,
rc.x+rc.w-arrow->width(), rc.x+rc.w-arrow->width(),
@ -1872,18 +1872,18 @@ void SkinTheme::drawTextString(Graphics* g, const char *t, gfx::Color fg_color,
// Horizontally text alignment // Horizontally text alignment
if (widget->getAlign() & JI_RIGHT) if (widget->getAlign() & RIGHT)
textrc.x = rc.x + rc.w - textrc.w - 1; textrc.x = rc.x + rc.w - textrc.w - 1;
else if (widget->getAlign() & JI_CENTER) else if (widget->getAlign() & CENTER)
textrc.x = rc.getCenter().x - textrc.w/2; textrc.x = rc.getCenter().x - textrc.w/2;
else else
textrc.x = rc.x; textrc.x = rc.x;
// Vertically text alignment // Vertically text alignment
if (widget->getAlign() & JI_BOTTOM) if (widget->getAlign() & BOTTOM)
textrc.y = rc.y + rc.h - textrc.h - 1; textrc.y = rc.y + rc.h - textrc.h - 1;
else if (widget->getAlign() & JI_MIDDLE) else if (widget->getAlign() & MIDDLE)
textrc.y = rc.getCenter().y - textrc.h/2; textrc.y = rc.getCenter().y - textrc.h/2;
else else
textrc.y = rc.y; textrc.y = rc.y;

View File

@ -93,16 +93,16 @@ void IconRule::onPaint(ui::Graphics* g, const gfx::Rect& bounds, const char* tex
she::Surface* bmp = m_part->getBitmap(0); she::Surface* bmp = m_part->getBitmap(0);
int x, y; int x, y;
if (m_align & JI_RIGHT) if (m_align & ui::RIGHT)
x = bounds.x2() - bmp->width(); x = bounds.x2() - bmp->width();
else if (m_align & JI_CENTER) else if (m_align & ui::CENTER)
x = bounds.x + bounds.w/2 - bmp->width()/2; x = bounds.x + bounds.w/2 - bmp->width()/2;
else else
x = bounds.x; x = bounds.x;
if (m_align & JI_BOTTOM) if (m_align & ui::BOTTOM)
y = bounds.y2() - bmp->height(); y = bounds.y2() - bmp->height();
else if (m_align & JI_MIDDLE) else if (m_align & ui::MIDDLE)
y = bounds.y + bounds.h/2 - bmp->height()/2; y = bounds.y + bounds.h/2 - bmp->height()/2;
else else
y = bounds.y; y = bounds.y;

View File

@ -160,8 +160,8 @@ StatusBar::StatusBar()
// Construct the commands box // Construct the commands box
{ {
Box* box1 = new Box(JI_HORIZONTAL); Box* box1 = new Box(HORIZONTAL);
Box* box4 = new Box(JI_HORIZONTAL); Box* box4 = new Box(HORIZONTAL);
m_frameLabel = new Label("Frame:"); m_frameLabel = new Label("Frame:");
m_currentFrame = new GotoFrameEntry(); m_currentFrame = new GotoFrameEntry();
@ -192,8 +192,8 @@ StatusBar::StatusBar()
// Tooltips manager // Tooltips manager
TooltipManager* tooltipManager = new TooltipManager(); TooltipManager* tooltipManager = new TooltipManager();
addChild(tooltipManager); addChild(tooltipManager);
tooltipManager->addTooltipFor(m_currentFrame, "Current Frame", JI_BOTTOM); tooltipManager->addTooltipFor(m_currentFrame, "Current Frame", BOTTOM);
tooltipManager->addTooltipFor(m_slider, "Cel Opacity", JI_BOTTOM); tooltipManager->addTooltipFor(m_slider, "Cel Opacity", BOTTOM);
Preferences::instance().toolBox.activeTool.AfterChange.connect( Preferences::instance().toolBox.activeTool.AfterChange.connect(
Bind<void>(&StatusBar::onCurrentToolChange, this)); Bind<void>(&StatusBar::onCurrentToolChange, this));

View File

@ -552,7 +552,7 @@ void ToolBar::openTipWindow(int group_index, Tool* tool)
Point arrow = tool ? getToolPositionInGroup(group_index, tool): Point(0, 0); Point arrow = tool ? getToolPositionInGroup(group_index, tool): Point(0, 0);
m_tipWindow = new TipWindow(tooltip.c_str(), gfx::Rect(arrow, toolrc.getSize())); m_tipWindow = new TipWindow(tooltip.c_str(), gfx::Rect(arrow, toolrc.getSize()));
m_tipWindow->setArrowAlign(JI_TOP | JI_RIGHT); m_tipWindow->setArrowAlign(TOP | RIGHT);
m_tipWindow->remapWindow(); m_tipWindow->remapWindow();
int w = m_tipWindow->getBounds().w; int w = m_tipWindow->getBounds().w;

View File

@ -207,10 +207,10 @@ void WorkspacePanel::onAnimationStop(int animation)
void WorkspacePanel::onAnimationFrame() void WorkspacePanel::onAnimationFrame()
{ {
if (animation() == ANI_DROPAREA) { if (animation() == ANI_DROPAREA) {
adjustTime(m_leftTime, JI_LEFT); adjustTime(m_leftTime, LEFT);
adjustTime(m_topTime, JI_TOP); adjustTime(m_topTime, TOP);
adjustTime(m_rightTime, JI_RIGHT); adjustTime(m_rightTime, RIGHT);
adjustTime(m_bottomTime, JI_BOTTOM); adjustTime(m_bottomTime, BOTTOM);
layout(); layout();
} }
} }
@ -238,8 +238,8 @@ DropViewAtResult WorkspacePanel::dropViewAt(const gfx::Point& pos, WorkspacePane
return DropViewAtResult::NOTHING; return DropViewAtResult::NOTHING;
int splitterAlign = 0; int splitterAlign = 0;
if (dropArea & (JI_LEFT | JI_RIGHT)) splitterAlign = JI_HORIZONTAL; if (dropArea & (LEFT | RIGHT)) splitterAlign = HORIZONTAL;
else if (dropArea & (JI_TOP | JI_BOTTOM)) splitterAlign = JI_VERTICAL; else if (dropArea & (TOP | BOTTOM)) splitterAlign = VERTICAL;
ASSERT(from); ASSERT(from);
DropViewAtResult result; DropViewAtResult result;
@ -290,14 +290,14 @@ DropViewAtResult WorkspacePanel::dropViewAt(const gfx::Point& pos, WorkspacePane
sideSpace = 50; sideSpace = 50;
switch (dropArea) { switch (dropArea) {
case JI_LEFT: case LEFT:
case JI_TOP: case TOP:
splitter->setPosition(sideSpace); splitter->setPosition(sideSpace);
splitter->addChild(side); splitter->addChild(side);
splitter->addChild(self); splitter->addChild(self);
break; break;
case JI_RIGHT: case RIGHT:
case JI_BOTTOM: case BOTTOM:
splitter->setPosition(100-sideSpace); splitter->setPosition(100-sideSpace);
splitter->addChild(self); splitter->addChild(self);
splitter->addChild(side); splitter->addChild(side);
@ -324,16 +324,16 @@ int WorkspacePanel::calculateDropArea(const gfx::Point& pos) const
int threshold = getDropThreshold(); int threshold = getDropThreshold();
if (left < threshold && left < right && left < top && left < bottom) { if (left < threshold && left < right && left < top && left < bottom) {
return JI_LEFT; return LEFT;
} }
else if (top < threshold && top < left && top < right && top < bottom) { else if (top < threshold && top < left && top < right && top < bottom) {
return JI_TOP; return TOP;
} }
else if (right < threshold && right < left && right < top && right < bottom) { else if (right < threshold && right < left && right < top && right < bottom) {
return JI_RIGHT; return RIGHT;
} }
else if (bottom < threshold && bottom < left && bottom < top && bottom < right) { else if (bottom < threshold && bottom < left && bottom < top && bottom < right) {
return JI_BOTTOM; return BOTTOM;
} }
} }

View File

@ -130,7 +130,7 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
else if (elem_name == "box") { else if (elem_name == "box") {
bool horizontal = bool_attr_is_true(elem, "horizontal"); bool horizontal = bool_attr_is_true(elem, "horizontal");
bool vertical = bool_attr_is_true(elem, "vertical"); bool vertical = bool_attr_is_true(elem, "vertical");
int align = (horizontal ? JI_HORIZONTAL: vertical ? JI_VERTICAL: 0); int align = (horizontal ? HORIZONTAL: vertical ? VERTICAL: 0);
if (!widget) if (!widget)
widget = new Box(align); widget = new Box(align);
@ -160,8 +160,8 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
bool closewindow = bool_attr_is_true(elem, "closewindow"); bool closewindow = bool_attr_is_true(elem, "closewindow");
const char *_bevel = elem->Attribute("bevel"); const char *_bevel = elem->Attribute("bevel");
widget->setAlign((left ? JI_LEFT: (right ? JI_RIGHT: JI_CENTER)) | widget->setAlign((left ? LEFT: (right ? RIGHT: CENTER)) |
(top ? JI_TOP: (bottom ? JI_BOTTOM: JI_MIDDLE))); (top ? TOP: (bottom ? BOTTOM: MIDDLE)));
if (_bevel != NULL) { if (_bevel != NULL) {
char* bevel = base_strdup(_bevel); char* bevel = base_strdup(_bevel);
@ -204,10 +204,10 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
bool top = bool_attr_is_true(elem, "top"); bool top = bool_attr_is_true(elem, "top");
bool bottom = bool_attr_is_true(elem, "bottom"); bool bottom = bool_attr_is_true(elem, "bottom");
widget->setAlign((center ? JI_CENTER: widget->setAlign((center ? CENTER:
(right ? JI_RIGHT: JI_LEFT)) | (right ? RIGHT: LEFT)) |
(top ? JI_TOP: (top ? TOP:
(bottom ? JI_BOTTOM: JI_MIDDLE))); (bottom ? BOTTOM: MIDDLE)));
} }
else if (elem_name == "combobox") { else if (elem_name == "combobox") {
if (!widget) if (!widget)
@ -253,10 +253,10 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
bool top = bool_attr_is_true(elem, "top"); bool top = bool_attr_is_true(elem, "top");
bool bottom = bool_attr_is_true(elem, "bottom"); bool bottom = bool_attr_is_true(elem, "bottom");
widget->setAlign((center ? JI_CENTER: widget->setAlign((center ? CENTER:
(right ? JI_RIGHT: JI_LEFT)) | (right ? RIGHT: LEFT)) |
(top ? JI_TOP: (top ? TOP:
(bottom ? JI_BOTTOM: JI_MIDDLE))); (bottom ? BOTTOM: MIDDLE)));
} }
else if (elem_name == "link") { else if (elem_name == "link") {
const char* url = elem->Attribute("url"); const char* url = elem->Attribute("url");
@ -276,8 +276,8 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
bool bottom = bool_attr_is_true(elem, "bottom"); bool bottom = bool_attr_is_true(elem, "bottom");
widget->setAlign( widget->setAlign(
(center ? JI_CENTER: (right ? JI_RIGHT: JI_LEFT)) | (center ? CENTER: (right ? RIGHT: LEFT)) |
(top ? JI_TOP: (bottom ? JI_BOTTOM: JI_MIDDLE))); (top ? TOP: (bottom ? BOTTOM: MIDDLE)));
} }
else if (elem_name == "listbox") { else if (elem_name == "listbox") {
if (!widget) if (!widget)
@ -308,8 +308,8 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
Splitter::ByPercentage); Splitter::ByPercentage);
Splitter* splitter = new Splitter(type, Splitter* splitter = new Splitter(type,
horizontal ? JI_HORIZONTAL: horizontal ? HORIZONTAL:
vertical ? JI_VERTICAL: 0); vertical ? VERTICAL: 0);
if (position) { if (position) {
splitter->setPosition(strtod(position, NULL) splitter->setPosition(strtod(position, NULL)
* (type == Splitter::ByPixel ? guiscale(): 1)); * (type == Splitter::ByPixel ? guiscale(): 1));
@ -343,10 +343,10 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
bool bottom = bool_attr_is_true(elem, "bottom"); bool bottom = bool_attr_is_true(elem, "bottom");
widget->setAlign( widget->setAlign(
(center ? JI_CENTER: (center ? CENTER:
(right ? JI_RIGHT: JI_LEFT)) | (right ? RIGHT: LEFT)) |
(top ? JI_TOP: (top ? TOP:
(bottom ? JI_BOTTOM: JI_MIDDLE))); (bottom ? BOTTOM: MIDDLE)));
} }
else if (elem_name == "separator") { else if (elem_name == "separator") {
bool center = bool_attr_is_true(elem, "center"); bool center = bool_attr_is_true(elem, "center");
@ -356,10 +356,10 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
bool horizontal = bool_attr_is_true(elem, "horizontal"); bool horizontal = bool_attr_is_true(elem, "horizontal");
bool vertical = bool_attr_is_true(elem, "vertical"); bool vertical = bool_attr_is_true(elem, "vertical");
int align = int align =
(horizontal ? JI_HORIZONTAL: 0) | (horizontal ? HORIZONTAL: 0) |
(vertical ? JI_VERTICAL: 0) | (vertical ? VERTICAL: 0) |
(center ? JI_CENTER: (right ? JI_RIGHT: JI_LEFT)) | (center ? CENTER: (right ? RIGHT: LEFT)) |
(middle ? JI_MIDDLE: (bottom ? JI_BOTTOM: JI_TOP)); (middle ? MIDDLE: (bottom ? BOTTOM: TOP));
if (!widget) { if (!widget) {
const char* text = elem->Attribute("text"); const char* text = elem->Attribute("text");
@ -385,7 +385,7 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
widget->setText(elem->GetText()); widget->setText(elem->GetText());
if (wordwrap) if (wordwrap)
widget->setAlign(widget->getAlign() | JI_WORDWRAP); widget->setAlign(widget->getAlign() | WORDWRAP);
} }
else if (elem_name == "view") { else if (elem_name == "view") {
if (!widget) if (!widget)
@ -508,7 +508,7 @@ void WidgetLoader::fillWidgetWithXmlElementAttributes(const TiXmlElement* elem,
m_tooltipManager = new ui::TooltipManager(); m_tooltipManager = new ui::TooltipManager();
root->addChild(m_tooltipManager); root->addChild(m_tooltipManager);
} }
m_tooltipManager->addTooltipFor(widget, tooltip, JI_LEFT); m_tooltipManager->addTooltipFor(widget, tooltip, LEFT);
} }
if (selected) if (selected)
@ -521,7 +521,7 @@ void WidgetLoader::fillWidgetWithXmlElementAttributes(const TiXmlElement* elem,
widget->setExpansive(true); widget->setExpansive(true);
if (homogeneous) if (homogeneous)
widget->setAlign(widget->getAlign() | JI_HOMOGENEOUS); widget->setAlign(widget->getAlign() | HOMOGENEOUS);
if (magnet) if (magnet)
widget->setFocusMagnet(true); widget->setFocusMagnet(true);
@ -614,31 +614,31 @@ static int convert_align_value_to_flags(const char *value)
tok != NULL; tok != NULL;
tok=strtok(NULL, " ")) { tok=strtok(NULL, " ")) {
if (strcmp(tok, "horizontal") == 0) { if (strcmp(tok, "horizontal") == 0) {
flags |= JI_HORIZONTAL; flags |= HORIZONTAL;
} }
else if (strcmp(tok, "vertical") == 0) { else if (strcmp(tok, "vertical") == 0) {
flags |= JI_VERTICAL; flags |= VERTICAL;
} }
else if (strcmp(tok, "left") == 0) { else if (strcmp(tok, "left") == 0) {
flags |= JI_LEFT; flags |= LEFT;
} }
else if (strcmp(tok, "center") == 0) { else if (strcmp(tok, "center") == 0) {
flags |= JI_CENTER; flags |= CENTER;
} }
else if (strcmp(tok, "right") == 0) { else if (strcmp(tok, "right") == 0) {
flags |= JI_RIGHT; flags |= RIGHT;
} }
else if (strcmp(tok, "top") == 0) { else if (strcmp(tok, "top") == 0) {
flags |= JI_TOP; flags |= TOP;
} }
else if (strcmp(tok, "middle") == 0) { else if (strcmp(tok, "middle") == 0) {
flags |= JI_MIDDLE; flags |= MIDDLE;
} }
else if (strcmp(tok, "bottom") == 0) { else if (strcmp(tok, "bottom") == 0) {
flags |= JI_BOTTOM; flags |= BOTTOM;
} }
else if (strcmp(tok, "homogeneous") == 0) { else if (strcmp(tok, "homogeneous") == 0) {
flags |= JI_HOMOGENEOUS; flags |= HOMOGENEOUS;
} }
} }

View File

@ -162,7 +162,7 @@ void Alert::processString(char* buf, std::vector<Widget*>& labels, std::vector<W
labels.push_back(label); labels.push_back(label);
} }
else if (separator) { else if (separator) {
labels.push_back(new Separator("", JI_HORIZONTAL)); labels.push_back(new Separator("", HORIZONTAL));
} }
else if (button) { else if (button) {
char buttonId[256]; char buttonId[256];
@ -188,9 +188,9 @@ void Alert::processString(char* buf, std::vector<Widget*>& labels, std::vector<W
align = 0; align = 0;
switch (buf[c]) { switch (buf[c]) {
case '<': label=true; align=JI_LEFT; break; case '<': label=true; align=LEFT; break;
case '=': label=true; align=JI_CENTER; break; case '=': label=true; align=CENTER; break;
case '>': label=true; align=JI_RIGHT; break; case '>': label=true; align=RIGHT; break;
case '-': separator=true; break; case '-': separator=true; break;
case '|': button=true; break; case '|': button=true; break;
} }
@ -199,10 +199,10 @@ void Alert::processString(char* buf, std::vector<Widget*>& labels, std::vector<W
} }
} }
box1 = new Box(JI_VERTICAL); box1 = new Box(VERTICAL);
box2 = new Box(JI_VERTICAL); box2 = new Box(VERTICAL);
grid = new Grid(1, false); grid = new Grid(1, false);
box3 = new Box(JI_HORIZONTAL | JI_HOMOGENEOUS); box3 = new Box(HORIZONTAL | HOMOGENEOUS);
// To identify by the user // To identify by the user
box2->setId("labels"); box2->setId("labels");
@ -229,7 +229,7 @@ void Alert::processString(char* buf, std::vector<Widget*>& labels, std::vector<W
box1->addChild(box5); // Filler box1->addChild(box5); // Filler
box1->addChild(grid); // Buttons box1->addChild(grid); // Buttons
grid->addChildInCell(box3, 1, 1, JI_CENTER | JI_BOTTOM); grid->addChildInCell(box3, 1, 1, CENTER | BOTTOM);
for (std::vector<Widget*>::iterator it = labels.begin(); it != labels.end(); ++it) for (std::vector<Widget*>::iterator it = labels.begin(); it != labels.end(); ++it)
box2->addChild(*it); box2->addChild(*it);

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2001-2013 David Capello // Copyright (C) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -32,32 +32,36 @@
namespace ui { namespace ui {
// Alignment. // Alignment flags
#define JI_HORIZONTAL 0x0001 enum {
#define JI_VERTICAL 0x0002 HORIZONTAL = 0x0001,
#define JI_LEFT 0x0004 VERTICAL = 0x0002,
#define JI_CENTER 0x0008 LEFT = 0x0004,
#define JI_RIGHT 0x0010 CENTER = 0x0008,
#define JI_TOP 0x0020 RIGHT = 0x0010,
#define JI_MIDDLE 0x0040 TOP = 0x0020,
#define JI_BOTTOM 0x0080 MIDDLE = 0x0040,
#define JI_HOMOGENEOUS 0x0100 BOTTOM = 0x0080,
#define JI_WORDWRAP 0x0200 HOMOGENEOUS = 0x0100,
WORDWRAP = 0x0200,
};
// Widget flags. // Widget flags
#define JI_HIDDEN 0x0001 // Is hidden (not visible, not clickeable). enum {
#define JI_SELECTED 0x0002 // Is selected. HIDDEN = 0x0001, // Is hidden (not visible, not clickeable).
#define JI_DISABLED 0x0004 // Is disabled (not usable). SELECTED = 0x0002, // Is selected.
#define JI_HASFOCUS 0x0008 // Has the input focus. DISABLED = 0x0004, // Is disabled (not usable).
#define JI_HASMOUSE 0x0010 // Has the mouse. HAS_FOCUS = 0x0008, // Has the input focus.
#define JI_HASCAPTURE 0x0020 // Captured the mouse . HAS_MOUSE = 0x0010, // Has the mouse.
#define JI_FOCUSSTOP 0x0040 // The widget support the focus on it. HAS_CAPTURE = 0x0020, // Captured the mouse .
#define JI_FOCUSMAGNET 0x0080 // The widget wants the focus by default (e.g. when the dialog is shown by first time). FOCUS_STOP = 0x0040, // The widget support the focus on it.
#define JI_EXPANSIVE 0x0100 // Is expansive (want more space). FOCUS_MAGNET = 0x0080, // The widget wants the focus by default (e.g. when the dialog is shown by first time).
#define JI_DECORATIVE 0x0200 // To decorate windows. EXPANSIVE = 0x0100, // Is expansive (want more space).
#define JI_INITIALIZED 0x0400 // The widget was already initialized by a theme. DECORATIVE = 0x0200, // To decorate windows.
#define JI_DIRTY 0x0800 // The widget (or one child) is dirty (update_region != empty). INITIALIZED = 0x0400, // The widget was already initialized by a theme.
#define JI_HASTEXT 0x1000 // The widget has text (at least setText() was called one time). DIRTY = 0x0800, // The widget (or one child) is dirty (update_region != empty).
HAS_TEXT = 0x1000, // The widget has text (at least setText() was called one time).
};
class GuiSystem { class GuiSystem {
public: public:

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2001-2013 David Capello // Copyright (C) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -32,7 +32,7 @@ void Box::onPreferredSize(PreferredSizeEvent& ev)
{ {
#define GET_CHILD_SIZE(w, h) \ #define GET_CHILD_SIZE(w, h) \
{ \ { \
if (getAlign() & JI_HOMOGENEOUS) \ if (getAlign() & HOMOGENEOUS) \
w = MAX(w, reqSize.w); \ w = MAX(w, reqSize.w); \
else \ else \
w += reqSize.w; \ w += reqSize.w; \
@ -42,7 +42,7 @@ void Box::onPreferredSize(PreferredSizeEvent& ev)
#define FINAL_SIZE(w) \ #define FINAL_SIZE(w) \
{ \ { \
if (getAlign() & JI_HOMOGENEOUS) \ if (getAlign() & HOMOGENEOUS) \
w *= nvis_children; \ w *= nvis_children; \
\ \
w += child_spacing * (nvis_children-1); \ w += child_spacing * (nvis_children-1); \
@ -53,7 +53,7 @@ void Box::onPreferredSize(PreferredSizeEvent& ev)
nvis_children = 0; nvis_children = 0;
UI_FOREACH_WIDGET(getChildren(), it) { UI_FOREACH_WIDGET(getChildren(), it) {
Widget* child = *it; Widget* child = *it;
if (!(child->flags & JI_HIDDEN)) if (!(child->flags & HIDDEN))
nvis_children++; nvis_children++;
} }
@ -62,12 +62,12 @@ void Box::onPreferredSize(PreferredSizeEvent& ev)
UI_FOREACH_WIDGET(getChildren(), it) { UI_FOREACH_WIDGET(getChildren(), it) {
Widget* child = *it; Widget* child = *it;
if (child->flags & JI_HIDDEN) if (child->flags & HIDDEN)
continue; continue;
Size reqSize = child->getPreferredSize(); Size reqSize = child->getPreferredSize();
if (this->getAlign() & JI_HORIZONTAL) { if (this->getAlign() & HORIZONTAL) {
GET_CHILD_SIZE(w, h); GET_CHILD_SIZE(w, h);
} }
else { else {
@ -76,7 +76,7 @@ void Box::onPreferredSize(PreferredSizeEvent& ev)
} }
if (nvis_children > 0) { if (nvis_children > 0) {
if (this->getAlign() & JI_HORIZONTAL) { if (this->getAlign() & HORIZONTAL) {
FINAL_SIZE(w); FINAL_SIZE(w);
} }
else { else {
@ -95,7 +95,7 @@ void Box::onResize(ResizeEvent& ev)
#define FIXUP(x, y, w, h, l, t, r, b) \ #define FIXUP(x, y, w, h, l, t, r, b) \
{ \ { \
if (nvis_children > 0) { \ if (nvis_children > 0) { \
if (getAlign() & JI_HOMOGENEOUS) { \ if (getAlign() & HOMOGENEOUS) { \
width = (getBounds().w \ width = (getBounds().w \
- this->border_width.l \ - this->border_width.l \
- this->border_width.r \ - this->border_width.r \
@ -120,8 +120,8 @@ void Box::onResize(ResizeEvent& ev)
UI_FOREACH_WIDGET(getChildren(), it) { \ UI_FOREACH_WIDGET(getChildren(), it) { \
child = *it; \ child = *it; \
\ \
if (!(child->flags & JI_HIDDEN)) { \ if (!(child->flags & HIDDEN)) { \
if (this->getAlign() & JI_HOMOGENEOUS) { \ if (this->getAlign() & HOMOGENEOUS) { \
if (nvis_children == 1) \ if (nvis_children == 1) \
child_width = width; \ child_width = width; \
else \ else \
@ -149,7 +149,7 @@ void Box::onResize(ResizeEvent& ev)
w = MAX(1, child_width); \ w = MAX(1, child_width); \
\ \
gfx::Rect cpos; \ gfx::Rect cpos; \
if (getAlign() & JI_HORIZONTAL) \ if (getAlign() & HORIZONTAL) \
cpos = gfx::Rect(x, y, w, h); \ cpos = gfx::Rect(x, y, w, h); \
else \ else \
cpos = gfx::Rect(y, x, h, w); \ cpos = gfx::Rect(y, x, h, w); \
@ -169,13 +169,13 @@ void Box::onResize(ResizeEvent& ev)
int width; int width;
int extra; int extra;
int x, y, w, h; int x, y, w, h;
setBoundsQuietly(ev.getBounds()); setBoundsQuietly(ev.getBounds());
UI_FOREACH_WIDGET(getChildren(), it) { UI_FOREACH_WIDGET(getChildren(), it) {
child = *it; child = *it;
if (!(child->flags & JI_HIDDEN)) { if (!(child->flags & HIDDEN)) {
nvis_children++; nvis_children++;
if (child->isExpansive()) if (child->isExpansive())
nexpand_children++; nexpand_children++;
@ -184,7 +184,7 @@ void Box::onResize(ResizeEvent& ev)
Size reqSize = getPreferredSize(); Size reqSize = getPreferredSize();
if (this->getAlign() & JI_HORIZONTAL) { if (this->getAlign() & HORIZONTAL) {
FIXUP(x, y, w, h, l, t, r, b); FIXUP(x, y, w, h, l, t, r, b);
} }
else { else {

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2001-2013 David Capello // Copyright (C) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -27,19 +27,19 @@ namespace ui {
class VBox : public Box class VBox : public Box
{ {
public: public:
VBox() : Box(JI_VERTICAL) { } VBox() : Box(VERTICAL) { }
}; };
class HBox : public Box class HBox : public Box
{ {
public: public:
HBox() : Box(JI_HORIZONTAL) { } HBox() : Box(HORIZONTAL) { }
}; };
class BoxFiller : public Box class BoxFiller : public Box
{ {
public: public:
BoxFiller() : Box(JI_HORIZONTAL) { BoxFiller() : Box(HORIZONTAL) {
this->setExpansive(true); this->setExpansive(true);
} }
}; };

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2001-2013 David Capello // Copyright (C) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -32,7 +32,7 @@ ButtonBase::ButtonBase(const std::string& text,
, m_iconInterface(NULL) , m_iconInterface(NULL)
, m_handleSelect(true) , m_handleSelect(true)
{ {
setAlign(JI_CENTER | JI_MIDDLE); setAlign(CENTER | MIDDLE);
setText(text); setText(text);
setFocusStop(true); setFocusStop(true);
@ -309,7 +309,7 @@ void ButtonBase::generateButtonSelectSignal()
Button::Button(const std::string& text) Button::Button(const std::string& text)
: ButtonBase(text, kButtonWidget, kButtonWidget, kButtonWidget) : ButtonBase(text, kButtonWidget, kButtonWidget, kButtonWidget)
{ {
setAlign(JI_CENTER | JI_MIDDLE); setAlign(CENTER | MIDDLE);
} }
// ====================================================================== // ======================================================================
@ -319,7 +319,7 @@ Button::Button(const std::string& text)
CheckBox::CheckBox(const std::string& text, WidgetType drawType) CheckBox::CheckBox(const std::string& text, WidgetType drawType)
: ButtonBase(text, kCheckWidget, kCheckWidget, drawType) : ButtonBase(text, kCheckWidget, kCheckWidget, drawType)
{ {
setAlign(JI_LEFT | JI_MIDDLE); setAlign(LEFT | MIDDLE);
} }
// ====================================================================== // ======================================================================
@ -329,7 +329,7 @@ CheckBox::CheckBox(const std::string& text, WidgetType drawType)
RadioButton::RadioButton(const std::string& text, int radioGroup, WidgetType drawType) RadioButton::RadioButton(const std::string& text, int radioGroup, WidgetType drawType)
: ButtonBase(text, kRadioWidget, kRadioWidget, drawType) : ButtonBase(text, kRadioWidget, kRadioWidget, drawType)
{ {
setAlign(JI_LEFT | JI_MIDDLE); setAlign(LEFT | MIDDLE);
setRadioGroup(radioGroup); setRadioGroup(radioGroup);
} }

View File

@ -57,7 +57,7 @@ Entry::Entry(std::size_t maxsize, const char *format, ...)
} }
// TODO support for text alignment and multi-line // TODO support for text alignment and multi-line
// widget->align = JI_LEFT | JI_MIDDLE; // widget->align = LEFT | MIDDLE;
setText(buf); setText(buf);
setFocusStop(true); setFocusStop(true);

View File

@ -258,11 +258,11 @@ gfx::Size Graphics::doUIStringAlgorithm(const std::string& str, gfx::Color fg, g
{ {
gfx::Point pt(0, rc.y); gfx::Point pt(0, rc.y);
if ((align & (JI_MIDDLE | JI_BOTTOM)) != 0) { if ((align & (MIDDLE | BOTTOM)) != 0) {
gfx::Size preSize = doUIStringAlgorithm(str, gfx::ColorNone, gfx::ColorNone, rc, 0, false); gfx::Size preSize = doUIStringAlgorithm(str, gfx::ColorNone, gfx::ColorNone, rc, 0, false);
if (align & JI_MIDDLE) if (align & MIDDLE)
pt.y = rc.y + rc.h/2 - preSize.h/2; pt.y = rc.y + rc.h/2 - preSize.h/2;
else if (align & JI_BOTTOM) else if (align & BOTTOM)
pt.y = rc.y + rc.h - preSize.h; pt.y = rc.y + rc.h - preSize.h;
} }
@ -276,7 +276,7 @@ gfx::Size Graphics::doUIStringAlgorithm(const std::string& str, gfx::Color fg, g
pt.x = rc.x; pt.x = rc.x;
// Without word-wrap // Without word-wrap
if ((align & JI_WORDWRAP) == 0) { if ((align & WORDWRAP) == 0) {
end = str.find('\n', beg); end = str.find('\n', beg);
} }
// With word-wrap // With word-wrap
@ -322,9 +322,9 @@ gfx::Size Graphics::doUIStringAlgorithm(const std::string& str, gfx::Color fg, g
// Render the text // Render the text
if (draw) { if (draw) {
int xout; int xout;
if ((align & JI_CENTER) == JI_CENTER) if ((align & CENTER) == CENTER)
xout = pt.x + rc.w/2 - lineSize.w/2; xout = pt.x + rc.w/2 - lineSize.w/2;
else if ((align & JI_RIGHT) == JI_RIGHT) else if ((align & RIGHT) == RIGHT)
xout = pt.x + rc.w - lineSize.w; xout = pt.x + rc.w - lineSize.w;
else else
xout = pt.x; xout = pt.x;

View File

@ -70,17 +70,17 @@ Grid::~Grid()
* @param align * @param align
* It's a combination of the following values: * It's a combination of the following values:
* *
* - JI_HORIZONTAL: The widget'll get excess horizontal space. * - HORIZONTAL: The widget'll get excess horizontal space.
* - JI_VERTICAL: The widget'll get excess vertical space. * - VERTICAL: The widget'll get excess vertical space.
* *
* - JI_LEFT: Sets horizontal alignment to the beginning of cell. * - LEFT: Sets horizontal alignment to the beginning of cell.
* - JI_CENTER: Sets horizontal alignment to the center of cell. * - CENTER: Sets horizontal alignment to the center of cell.
* - JI_RIGHT: Sets horizontal alignment to the end of cell. * - RIGHT: Sets horizontal alignment to the end of cell.
* - None: Uses the whole horizontal space of the cell. * - None: Uses the whole horizontal space of the cell.
* *
* - JI_TOP: Sets vertical alignment to the beginning of the cell. * - TOP: Sets vertical alignment to the beginning of the cell.
* - JI_MIDDLE: Sets vertical alignment to the center of the cell. * - MIDDLE: Sets vertical alignment to the center of the cell.
* - JI_BOTTOM: Sets vertical alignment to the end of the cell. * - BOTTOM: Sets vertical alignment to the end of the cell.
* - None: Uses the whole vertical space of the cell. * - None: Uses the whole vertical space of the cell.
*/ */
void Grid::addChildInCell(Widget* child, int hspan, int vspan, int align) void Grid::addChildInCell(Widget* child, int hspan, int vspan, int align)
@ -139,7 +139,7 @@ void Grid::onResize(ResizeEvent& ev)
if (cell->child != NULL && if (cell->child != NULL &&
cell->parent == NULL && cell->parent == NULL &&
!(cell->child->flags & JI_HIDDEN)) { !(cell->child->flags & HIDDEN)) {
x = pos_x; x = pos_x;
y = pos_y; y = pos_y;
@ -148,26 +148,26 @@ void Grid::onResize(ResizeEvent& ev)
reqSize = cell->child->getPreferredSize(); reqSize = cell->child->getPreferredSize();
if (cell->align & JI_LEFT) { if (cell->align & LEFT) {
w = reqSize.w; w = reqSize.w;
} }
else if (cell->align & JI_CENTER) { else if (cell->align & CENTER) {
x += w/2 - reqSize.w/2; x += w/2 - reqSize.w/2;
w = reqSize.w; w = reqSize.w;
} }
else if (cell->align & JI_RIGHT) { else if (cell->align & RIGHT) {
x += w - reqSize.w; x += w - reqSize.w;
w = reqSize.w; w = reqSize.w;
} }
if (cell->align & JI_TOP) { if (cell->align & TOP) {
h = reqSize.h; h = reqSize.h;
} }
else if (cell->align & JI_MIDDLE) { else if (cell->align & MIDDLE) {
y += h/2 - reqSize.h/2; y += h/2 - reqSize.h/2;
h = reqSize.h; h = reqSize.h;
} }
else if (cell->align & JI_BOTTOM) { else if (cell->align & BOTTOM) {
y += h - reqSize.h; y += h - reqSize.h;
h = reqSize.h; h = reqSize.h;
} }
@ -247,8 +247,8 @@ void Grid::calculateSize()
if (m_rowstrip.size() == 0) if (m_rowstrip.size() == 0)
return; return;
calculateStripSize(m_colstrip, m_rowstrip, JI_HORIZONTAL); calculateStripSize(m_colstrip, m_rowstrip, HORIZONTAL);
calculateStripSize(m_rowstrip, m_colstrip, JI_VERTICAL); calculateStripSize(m_rowstrip, m_colstrip, VERTICAL);
expandStrip(m_colstrip, m_rowstrip, &Grid::incColSize); expandStrip(m_colstrip, m_rowstrip, &Grid::incColSize);
expandStrip(m_rowstrip, m_colstrip, &Grid::incRowSize); expandStrip(m_rowstrip, m_colstrip, &Grid::incRowSize);
@ -285,7 +285,7 @@ void Grid::calculateStripSize(std::vector<Strip>& colstrip,
if (cell->child != NULL) { if (cell->child != NULL) {
if (cell->parent == NULL) { if (cell->parent == NULL) {
// If the widget isn't hidden then we can request its size // If the widget isn't hidden then we can request its size
if (!(cell->child->flags & JI_HIDDEN)) { if (!(cell->child->flags & HIDDEN)) {
Size reqSize = cell->child->getPreferredSize(); Size reqSize = cell->child->getPreferredSize();
cell->w = reqSize.w - (cell->hspan-1) * this->child_spacing; cell->w = reqSize.w - (cell->hspan-1) * this->child_spacing;
cell->h = reqSize.h - (cell->vspan-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; cell->w = cell->h = 0;
} }
else { else {
if (!(cell->child->flags & JI_HIDDEN)) { if (!(cell->child->flags & HIDDEN)) {
if ((cell->parent->align & align) == align) if ((cell->parent->align & align) == align)
++expand_count; ++expand_count;
} }

View File

@ -62,7 +62,7 @@ TEST(Grid, Expand2ndWidget)
w2->setMinSize(gfx::Size(10, 10)); w2->setMinSize(gfx::Size(10, 10));
grid->addChildInCell(w1, 1, 1, 0); grid->addChildInCell(w1, 1, 1, 0);
grid->addChildInCell(w2, 1, 1, JI_HORIZONTAL | JI_TOP); grid->addChildInCell(w2, 1, 1, HORIZONTAL | TOP);
// Test request size // Test request size
Size reqSize = grid->getPreferredSize(); Size reqSize = grid->getPreferredSize();
@ -128,9 +128,9 @@ TEST(Grid, SameWidth2x1Grid)
// +-------+---+ // +-------+---+
// //
// 1.align = 0 // 1.align = 0
// 2.align = JI_HORIZONTAL // 2.align = HORIZONTAL
// 3.align = JI_HORIZONTAL | JI_VERTICAL // 3.align = HORIZONTAL | VERTICAL
// 4.align = JI_VERTICAL // 4.align = VERTICAL
// //
// //
// When we expand the grid we get the following layout: // When we expand the grid we get the following layout:
@ -161,9 +161,9 @@ TEST(Grid, Intrincate3x3Grid)
w4->setMinSize(gfx::Size(10, 10)); w4->setMinSize(gfx::Size(10, 10));
grid->addChildInCell(w1, 1, 1, 0); grid->addChildInCell(w1, 1, 1, 0);
grid->addChildInCell(w2, 2, 1, JI_HORIZONTAL); grid->addChildInCell(w2, 2, 1, HORIZONTAL);
grid->addChildInCell(w3, 2, 2, JI_HORIZONTAL | JI_VERTICAL); grid->addChildInCell(w3, 2, 2, HORIZONTAL | VERTICAL);
grid->addChildInCell(w4, 1, 2, JI_VERTICAL); grid->addChildInCell(w4, 1, 2, VERTICAL);
// Test request size // Test request size
grid->child_spacing = 2; grid->child_spacing = 2;

View File

@ -19,7 +19,7 @@ namespace ui {
Label::Label(const std::string& text) Label::Label(const std::string& text)
: Widget(kLabelWidget) : Widget(kLabelWidget)
{ {
setAlign(JI_LEFT | JI_MIDDLE); setAlign(LEFT | MIDDLE);
setText(text); setText(text);
initTheme(); initTheme();
} }

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2001-2013 David Capello // Copyright (C) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -24,7 +24,7 @@ ListItem::ListItem(const std::string& text)
: Widget(kListItemWidget) : Widget(kListItemWidget)
{ {
setDoubleBuffered(true); setDoubleBuffered(true);
setAlign(JI_LEFT | JI_MIDDLE); setAlign(LEFT | MIDDLE);
setText(text); setText(text);
initTheme(); initTheme();
} }

View File

@ -39,11 +39,11 @@
namespace ui { namespace ui {
#define ACCEPT_FOCUS(widget) \ #define ACCEPT_FOCUS(widget) \
((((widget)->flags & (JI_FOCUSSTOP | \ ((((widget)->flags & (FOCUS_STOP | \
JI_DISABLED | \ DISABLED | \
JI_HIDDEN | \ HIDDEN | \
JI_DECORATIVE)) == JI_FOCUSSTOP) && \ DECORATIVE)) == FOCUS_STOP) && \
((widget)->isVisible())) ((widget)->isVisible()))
static const int NFILTERS = (int)(kFirstRegisteredMessage+1); static const int NFILTERS = (int)(kFirstRegisteredMessage+1);
@ -540,9 +540,9 @@ void Manager::setFocus(Widget* widget)
{ {
if ((focus_widget != widget) if ((focus_widget != widget)
&& (!(widget) && (!(widget)
|| (!(widget->flags & JI_DISABLED) || (!(widget->flags & DISABLED)
&& !(widget->flags & JI_HIDDEN) && !(widget->flags & HIDDEN)
&& !(widget->flags & JI_DECORATIVE) && !(widget->flags & DECORATIVE)
&& someParentIsFocusStop(widget)))) { && someParentIsFocusStop(widget)))) {
WidgetsList widget_parents; WidgetsList widget_parents;
Widget* common_parent = NULL; Widget* common_parent = NULL;
@ -570,7 +570,7 @@ void Manager::setFocus(Widget* widget)
} }
if ((*it)->hasFocus()) { if ((*it)->hasFocus()) {
(*it)->flags &= ~JI_HASFOCUS; (*it)->flags &= ~HAS_FOCUS;
msg->addRecipient(*it); msg->addRecipient(*it);
} }
} }
@ -598,8 +598,8 @@ void Manager::setFocus(Widget* widget)
for (; it != widget_parents.end(); ++it) { for (; it != widget_parents.end(); ++it) {
Widget* w = *it; Widget* w = *it;
if (w->flags & JI_FOCUSSTOP) { if (w->flags & FOCUS_STOP) {
w->flags |= JI_HASFOCUS; w->flags |= HAS_FOCUS;
msg->addRecipient(w); msg->addRecipient(w);
} }
@ -652,7 +652,7 @@ void Manager::setMouse(Widget* widget)
} }
if ((*it)->hasMouse()) { if ((*it)->hasMouse()) {
(*it)->flags &= ~JI_HASMOUSE; (*it)->flags &= ~HAS_MOUSE;
msg->addRecipient(*it); msg->addRecipient(*it);
} }
} }
@ -679,7 +679,7 @@ void Manager::setMouse(Widget* widget)
get_mouse_position(), _internal_get_mouse_buttons()); get_mouse_position(), _internal_get_mouse_buttons());
for (; it != widget_parents.end(); ++it) { for (; it != widget_parents.end(); ++it) {
(*it)->flags |= JI_HASMOUSE; (*it)->flags |= HAS_MOUSE;
msg->addRecipient(*it); msg->addRecipient(*it);
} }
@ -691,7 +691,7 @@ void Manager::setMouse(Widget* widget)
void Manager::setCapture(Widget* widget) void Manager::setCapture(Widget* widget)
{ {
widget->flags |= JI_HASCAPTURE; widget->flags |= HAS_CAPTURE;
capture_widget = widget; capture_widget = widget;
m_display->captureMouse(); m_display->captureMouse();
@ -731,7 +731,7 @@ void Manager::freeMouse()
void Manager::freeCapture() void Manager::freeCapture()
{ {
if (capture_widget) { if (capture_widget) {
capture_widget->flags &= ~JI_HASCAPTURE; capture_widget->flags &= ~HAS_CAPTURE;
capture_widget = NULL; capture_widget = NULL;
m_display->releaseMouse(); m_display->releaseMouse();
@ -1124,7 +1124,7 @@ void Manager::pumpQueue()
// We need to configure the clip region for paint messages // We need to configure the clip region for paint messages
// before we call Widget::sendMessage(). // before we call Widget::sendMessage().
if (msg->type() == kPaintMessage) { if (msg->type() == kPaintMessage) {
if (widget->flags & JI_HIDDEN) if (widget->flags & HIDDEN)
continue; continue;
PaintMessage* paintMsg = static_cast<PaintMessage*>(msg); PaintMessage* paintMsg = static_cast<PaintMessage*>(msg);

View File

@ -409,7 +409,7 @@ bool MenuBox::onProcessMessage(Message* msg)
Widget* picked = menu->pick(mousePos); Widget* picked = menu->pick(mousePos);
if (picked) { if (picked) {
if ((picked->type == kMenuItemWidget) && if ((picked->type == kMenuItemWidget) &&
!(picked->flags & JI_DISABLED)) { !(picked->flags & DISABLED)) {
MenuItem* pickedItem = static_cast<MenuItem*>(picked); MenuItem* pickedItem = static_cast<MenuItem*>(picked);
// If the picked menu-item is not highlighted... // If the picked menu-item is not highlighted...

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2001-2013 David Capello // Copyright (C) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -27,7 +27,7 @@ PopupWindow::PopupWindow(const std::string& text, ClickBehavior clickBehavior)
setSizeable(false); setSizeable(false);
setMoveable(false); setMoveable(false);
setWantFocus(false); setWantFocus(false);
setAlign(JI_LEFT | JI_TOP); setAlign(LEFT | TOP);
removeDecorativeWidgets(); removeDecorativeWidgets();

View File

@ -73,7 +73,7 @@ bool ScrollBar::onProcessMessage(Message* msg)
getScrollBarThemeInfo(&pos, &len); getScrollBarThemeInfo(&pos, &len);
m_wherepos = pos; m_wherepos = pos;
m_whereclick = getAlign() & JI_HORIZONTAL ? m_whereclick = getAlign() & HORIZONTAL ?
mousePos.x: mousePos.x:
mousePos.y; mousePos.y;
@ -89,7 +89,7 @@ bool ScrollBar::onProcessMessage(Message* msg)
Point scroll = view->getViewScroll(); Point scroll = view->getViewScroll();
if (this->getAlign() & JI_HORIZONTAL) { if (this->getAlign() & HORIZONTAL) {
// in the bar // in the bar
if (MOUSE_IN(u1+pos, v1, u1+pos+len-1, v2)) { if (MOUSE_IN(u1+pos, v1, u1+pos+len-1, v2)) {
// capture mouse // capture mouse
@ -144,7 +144,7 @@ bool ScrollBar::onProcessMessage(Message* msg)
if (bar_size > len) { if (bar_size > len) {
Point scroll = view->getViewScroll(); Point scroll = view->getViewScroll();
if (this->getAlign() & JI_HORIZONTAL) { if (this->getAlign() & HORIZONTAL) {
pos = (m_wherepos + mousePos.x - m_whereclick); pos = (m_wherepos + mousePos.x - m_whereclick);
pos = MID(0, pos, bar_size - len); pos = MID(0, pos, bar_size - len);
@ -189,7 +189,7 @@ void ScrollBar::getScrollBarInfo(int *_pos, int *_len, int *_bar_size, int *_vie
int pos, len; int pos, len;
int border_width; int border_width;
if (this->getAlign() & JI_HORIZONTAL) { if (this->getAlign() & HORIZONTAL) {
bar_size = getBounds().w; bar_size = getBounds().w;
viewport_size = view->getVisibleSize().w; viewport_size = view->getVisibleSize().w;
border_width = this->border_width.t + this->border_width.b; border_width = this->border_width.t + this->border_width.b;

View File

@ -62,7 +62,7 @@ bool Splitter::onProcessMessage(Message* msg)
++bar; ++bar;
if (this->getAlign() & JI_HORIZONTAL) { if (this->getAlign() & HORIZONTAL) {
x1 = c1->getBounds().x2(); x1 = c1->getBounds().x2();
y1 = getBounds().y; y1 = getBounds().y;
x2 = c2->getBounds().x; x2 = c2->getBounds().x;
@ -95,7 +95,7 @@ bool Splitter::onProcessMessage(Message* msg)
if (hasCapture()) { if (hasCapture()) {
gfx::Point mousePos = static_cast<MouseMessage*>(msg)->position(); gfx::Point mousePos = static_cast<MouseMessage*>(msg)->position();
if (getAlign() & JI_HORIZONTAL) { if (getAlign() & HORIZONTAL) {
switch (m_type) { switch (m_type) {
case ByPercentage: case ByPercentage:
m_pos = 100.0 * (mousePos.x - getBounds().x) / getBounds().w; m_pos = 100.0 * (mousePos.x - getBounds().x) / getBounds().w;
@ -141,7 +141,7 @@ bool Splitter::onProcessMessage(Message* msg)
c1 = *it; c1 = *it;
c2 = *(it+1); c2 = *(it+1);
if (this->getAlign() & JI_HORIZONTAL) { if (this->getAlign() & HORIZONTAL) {
x1 = c1->getBounds().x2(); x1 = c1->getBounds().x2();
y1 = getBounds().y; y1 = getBounds().y;
x2 = c2->getBounds().x; x2 = c2->getBounds().x;
@ -163,7 +163,7 @@ bool Splitter::onProcessMessage(Message* msg)
} }
if (change_cursor) { if (change_cursor) {
if (getAlign() & JI_HORIZONTAL) if (getAlign() & HORIZONTAL)
set_mouse_cursor(kSizeWECursor); set_mouse_cursor(kSizeWECursor);
else else
set_mouse_cursor(kSizeNSCursor); set_mouse_cursor(kSizeNSCursor);
@ -220,7 +220,7 @@ void Splitter::onResize(ResizeEvent& ev)
Widget* child2 = panel2(); Widget* child2 = panel2();
if (child1 && child2) { if (child1 && child2) {
if (getAlign() & JI_HORIZONTAL) { if (getAlign() & HORIZONTAL) {
LAYOUT_TWO_CHILDREN(x, y, w, h, l, t, r, b); LAYOUT_TWO_CHILDREN(x, y, w, h, l, t, r, b);
} }
else { else {
@ -270,14 +270,14 @@ void Splitter::onPreferredSize(PreferredSizeEvent& ev)
reqSize = child->getPreferredSize(); reqSize = child->getPreferredSize();
if (this->getAlign() & JI_HORIZONTAL) if (this->getAlign() & HORIZONTAL)
GET_CHILD_SIZE(w, h); GET_CHILD_SIZE(w, h);
else else
GET_CHILD_SIZE(h, w); GET_CHILD_SIZE(h, w);
} }
if (visibleChildren > 0) { if (visibleChildren > 0) {
if (this->getAlign() & JI_HORIZONTAL) if (this->getAlign() & HORIZONTAL)
FINAL_SIZE(w); FINAL_SIZE(w);
else else
FINAL_SIZE(h); FINAL_SIZE(h);
@ -331,7 +331,7 @@ Widget* Splitter::panel2() const
void Splitter::limitPos() void Splitter::limitPos()
{ {
if (getAlign() & JI_HORIZONTAL) { if (getAlign() & HORIZONTAL) {
switch (m_type) { switch (m_type) {
case ByPercentage: case ByPercentage:
m_pos = MID(0, m_pos, 100); m_pos = MID(0, m_pos, 100);

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2001-2013 David Capello // Copyright (C) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -158,7 +158,7 @@ void TextBox::onPreferredSize(PreferredSizeEvent& ev)
drawTextBox(NULL, this, &w, &h, gfx::ColorNone, gfx::ColorNone); drawTextBox(NULL, this, &w, &h, gfx::ColorNone, gfx::ColorNone);
if (this->getAlign() & JI_WORDWRAP) { if (this->getAlign() & WORDWRAP) {
View* view = View::getView(this); View* view = View::getView(this);
int width, min = w; int width, min = w;

View File

@ -114,7 +114,7 @@ void drawTextBox(Graphics* g, Widget* widget,
chr = 0; chr = 0;
// Without word-wrap // Without word-wrap
if (!(widget->getAlign() & JI_WORDWRAP)) { if (!(widget->getAlign() & WORDWRAP)) {
width = widget->getClientBounds().w; width = widget->getClientBounds().w;
} }
// With word-wrap // With word-wrap
@ -147,7 +147,7 @@ void drawTextBox(Graphics* g, Widget* widget,
x = x1 - scroll.x; x = x1 - scroll.x;
// Without word-wrap // Without word-wrap
if (!(widget->getAlign() & JI_WORDWRAP)) { if (!(widget->getAlign() & WORDWRAP)) {
end = std::strchr(beg, '\n'); end = std::strchr(beg, '\n');
if (end) { if (end) {
chr = *end; chr = *end;
@ -197,9 +197,9 @@ void drawTextBox(Graphics* g, Widget* widget,
if (g) { if (g) {
int xout; int xout;
if (widget->getAlign() & JI_CENTER) if (widget->getAlign() & CENTER)
xout = x + width/2 - len/2; xout = x + width/2 - len/2;
else if (widget->getAlign() & JI_RIGHT) else if (widget->getAlign() & RIGHT)
xout = x + width - len; xout = x + width - len;
else // Left align else // Left align
xout = x; xout = x;

View File

@ -110,35 +110,35 @@ void TooltipManager::onTick()
int trycount = 0; int trycount = 0;
for (; trycount < 4; ++trycount) { for (; trycount < 4; ++trycount) {
switch (arrowAlign) { switch (arrowAlign) {
case JI_TOP | JI_LEFT: case TOP | LEFT:
x = bounds.x + bounds.w; x = bounds.x + bounds.w;
y = bounds.y + bounds.h; y = bounds.y + bounds.h;
break; break;
case JI_TOP | JI_RIGHT: case TOP | RIGHT:
x = bounds.x - w; x = bounds.x - w;
y = bounds.y + bounds.h; y = bounds.y + bounds.h;
break; break;
case JI_BOTTOM | JI_LEFT: case BOTTOM | LEFT:
x = bounds.x + bounds.w; x = bounds.x + bounds.w;
y = bounds.y - h; y = bounds.y - h;
break; break;
case JI_BOTTOM | JI_RIGHT: case BOTTOM | RIGHT:
x = bounds.x - w; x = bounds.x - w;
y = bounds.y - h; y = bounds.y - h;
break; break;
case JI_TOP: case TOP:
x = bounds.x + bounds.w/2 - w/2; x = bounds.x + bounds.w/2 - w/2;
y = bounds.y + bounds.h; y = bounds.y + bounds.h;
break; break;
case JI_BOTTOM: case BOTTOM:
x = bounds.x + bounds.w/2 - w/2; x = bounds.x + bounds.w/2 - w/2;
y = bounds.y - h; y = bounds.y - h;
break; break;
case JI_LEFT: case LEFT:
x = bounds.x + bounds.w; x = bounds.x + bounds.w;
y = bounds.y + bounds.h/2 - h/2; y = bounds.y + bounds.h/2 - h/2;
break; break;
case JI_RIGHT: case RIGHT:
x = bounds.x - w; x = bounds.x - w;
y = bounds.y + bounds.h/2 - h/2; y = bounds.y + bounds.h/2 - h/2;
break; break;
@ -152,13 +152,13 @@ void TooltipManager::onTick()
case 0: case 0:
case 2: case 2:
// Switch position // Switch position
if (arrowAlign & (JI_TOP | JI_BOTTOM)) arrowAlign ^= JI_TOP | JI_BOTTOM; if (arrowAlign & (TOP | BOTTOM)) arrowAlign ^= TOP | BOTTOM;
if (arrowAlign & (JI_LEFT | JI_RIGHT)) arrowAlign ^= JI_LEFT | JI_RIGHT; if (arrowAlign & (LEFT | RIGHT)) arrowAlign ^= LEFT | RIGHT;
break; break;
case 1: case 1:
// Rotate positions // Rotate positions
if (arrowAlign & (JI_TOP | JI_LEFT)) arrowAlign ^= JI_TOP | JI_LEFT; if (arrowAlign & (TOP | LEFT)) arrowAlign ^= TOP | LEFT;
if (arrowAlign & (JI_BOTTOM | JI_RIGHT)) arrowAlign ^= JI_BOTTOM | JI_RIGHT; if (arrowAlign & (BOTTOM | RIGHT)) arrowAlign ^= BOTTOM | RIGHT;
break; break;
} }
} }

View File

@ -27,8 +27,8 @@ using namespace gfx;
View::View() View::View()
: Widget(kViewWidget) : Widget(kViewWidget)
, m_scrollbar_h(JI_HORIZONTAL) , m_scrollbar_h(HORIZONTAL)
, m_scrollbar_v(JI_VERTICAL) , m_scrollbar_v(VERTICAL)
{ {
m_hasBars = true; m_hasBars = true;

View File

@ -49,7 +49,7 @@ using namespace gfx;
static inline void mark_dirty_flag(Widget* widget) static inline void mark_dirty_flag(Widget* widget)
{ {
while (widget) { while (widget) {
widget->flags |= JI_DIRTY; widget->flags |= DIRTY;
widget = widget->getParent(); widget = widget->getParent();
} }
} }
@ -162,7 +162,7 @@ void Widget::setTextf(const char *format, ...)
void Widget::setTextQuiet(const std::string& text) void Widget::setTextQuiet(const std::string& text)
{ {
m_text = text; m_text = text;
flags |= JI_HASTEXT; flags |= HAS_TEXT;
} }
she::Font* Widget::getFont() const she::Font* Widget::getFont() const
@ -198,16 +198,16 @@ void Widget::setTheme(Theme* theme)
void Widget::setVisible(bool state) void Widget::setVisible(bool state)
{ {
if (state) { if (state) {
if (this->flags & JI_HIDDEN) { if (this->flags & HIDDEN) {
this->flags &= ~JI_HIDDEN; this->flags &= ~HIDDEN;
invalidate(); invalidate();
} }
} }
else { else {
if (!(this->flags & JI_HIDDEN)) { if (!(this->flags & HIDDEN)) {
getManager()->freeWidget(this); // Free from manager getManager()->freeWidget(this); // Free from manager
this->flags |= JI_HIDDEN; this->flags |= HIDDEN;
} }
} }
} }
@ -215,18 +215,18 @@ void Widget::setVisible(bool state)
void Widget::setEnabled(bool state) void Widget::setEnabled(bool state)
{ {
if (state) { if (state) {
if (this->flags & JI_DISABLED) { if (this->flags & DISABLED) {
this->flags &= ~JI_DISABLED; this->flags &= ~DISABLED;
invalidate(); invalidate();
onEnable(); onEnable();
} }
} }
else { else {
if (!(this->flags & JI_DISABLED)) { if (!(this->flags & DISABLED)) {
getManager()->freeWidget(this); // Free from the manager getManager()->freeWidget(this); // Free from the manager
this->flags |= JI_DISABLED; this->flags |= DISABLED;
invalidate(); invalidate();
onDisable(); onDisable();
@ -237,16 +237,16 @@ void Widget::setEnabled(bool state)
void Widget::setSelected(bool state) void Widget::setSelected(bool state)
{ {
if (state) { if (state) {
if (!(this->flags & JI_SELECTED)) { if (!(this->flags & SELECTED)) {
this->flags |= JI_SELECTED; this->flags |= SELECTED;
invalidate(); invalidate();
onSelect(); onSelect();
} }
} }
else { else {
if (this->flags & JI_SELECTED) { if (this->flags & SELECTED) {
this->flags &= ~JI_SELECTED; this->flags &= ~SELECTED;
invalidate(); invalidate();
onDeselect(); onDeselect();
@ -257,33 +257,33 @@ void Widget::setSelected(bool state)
void Widget::setExpansive(bool state) void Widget::setExpansive(bool state)
{ {
if (state) if (state)
this->flags |= JI_EXPANSIVE; this->flags |= EXPANSIVE;
else else
this->flags &= ~JI_EXPANSIVE; this->flags &= ~EXPANSIVE;
} }
void Widget::setDecorative(bool state) void Widget::setDecorative(bool state)
{ {
if (state) if (state)
this->flags |= JI_DECORATIVE; this->flags |= DECORATIVE;
else else
this->flags &= ~JI_DECORATIVE; this->flags &= ~DECORATIVE;
} }
void Widget::setFocusStop(bool state) void Widget::setFocusStop(bool state)
{ {
if (state) if (state)
this->flags |= JI_FOCUSSTOP; this->flags |= FOCUS_STOP;
else else
this->flags &= ~JI_FOCUSSTOP; this->flags &= ~FOCUS_STOP;
} }
void Widget::setFocusMagnet(bool state) void Widget::setFocusMagnet(bool state)
{ {
if (state) if (state)
this->flags |= JI_FOCUSMAGNET; this->flags |= FOCUS_MAGNET;
else else
this->flags &= ~JI_FOCUSMAGNET; this->flags &= ~FOCUS_MAGNET;
} }
bool Widget::isVisible() const bool Widget::isVisible() const
@ -292,7 +292,7 @@ bool Widget::isVisible() const
const Widget* lastWidget = nullptr; const Widget* lastWidget = nullptr;
do { do {
if (widget->flags & JI_HIDDEN) if (widget->flags & HIDDEN)
return false; return false;
lastWidget = widget; lastWidget = widget;
@ -308,7 +308,7 @@ bool Widget::isEnabled() const
const Widget* widget = this; const Widget* widget = this;
do { do {
if (widget->flags & JI_DISABLED) if (widget->flags & DISABLED)
return false; return false;
widget = widget->m_parent; widget = widget->m_parent;
@ -319,27 +319,27 @@ bool Widget::isEnabled() const
bool Widget::isSelected() const bool Widget::isSelected() const
{ {
return (this->flags & JI_SELECTED) ? true: false; return (this->flags & SELECTED) ? true: false;
} }
bool Widget::isExpansive() const bool Widget::isExpansive() const
{ {
return (this->flags & JI_EXPANSIVE) ? true: false; return (this->flags & EXPANSIVE) ? true: false;
} }
bool Widget::isDecorative() const bool Widget::isDecorative() const
{ {
return (this->flags & JI_DECORATIVE) ? true: false; return (this->flags & DECORATIVE) ? true: false;
} }
bool Widget::isFocusStop() const bool Widget::isFocusStop() const
{ {
return (this->flags & JI_FOCUSSTOP) ? true: false; return (this->flags & FOCUS_STOP) ? true: false;
} }
bool Widget::isFocusMagnet() const bool Widget::isFocusMagnet() const
{ {
return (this->flags & JI_FOCUSMAGNET) ? true: false; return (this->flags & FOCUS_MAGNET) ? true: false;
} }
// =============================================================== // ===============================================================
@ -423,7 +423,7 @@ Widget* Widget::pick(const gfx::Point& pt)
{ {
Widget* inside, *picked = NULL; Widget* inside, *picked = NULL;
if (!(this->flags & JI_HIDDEN) && // Is visible if (!(this->flags & HIDDEN) && // Is visible
getBounds().contains(pt)) { // The point is inside the bounds getBounds().contains(pt)) { // The point is inside the bounds
picked = this; picked = this;
@ -708,7 +708,7 @@ void Widget::getDrawableRegion(gfx::Region& region, DrawableRegionFlags flags)
Region reg3; Region reg3;
child->getRegion(reg3); child->getRegion(reg3);
if (child->flags & JI_DECORATIVE) { if (child->flags & DECORATIVE) {
reg1 = getBounds(); reg1 = getBounds();
reg1.createIntersection(reg1, reg3); reg1.createIntersection(reg1, reg3);
} }
@ -721,7 +721,7 @@ void Widget::getDrawableRegion(gfx::Region& region, DrawableRegionFlags flags)
} }
// Intersect with the parent area // Intersect with the parent area
if (!(this->flags & JI_DECORATIVE)) { if (!(this->flags & DECORATIVE)) {
Widget* parent = getParent(); Widget* parent = getParent();
while (parent) { while (parent) {
@ -799,8 +799,8 @@ void Widget::getTextIconInfo(
} }
/* box size */ /* box size */
if (icon_align & JI_CENTER) { /* with the icon in the center */ if (icon_align & CENTER) { /* with the icon in the center */
if (icon_align & JI_MIDDLE) { /* with the icon inside the text */ if (icon_align & MIDDLE) { /* with the icon inside the text */
box_w = MAX(icon_w, text_w); box_w = MAX(icon_w, text_w);
box_h = MAX(icon_h, text_h); box_h = MAX(icon_h, text_h);
} }
@ -817,16 +817,16 @@ void Widget::getTextIconInfo(
} }
/* box position */ /* box position */
if (getAlign() & JI_RIGHT) if (getAlign() & RIGHT)
box_x = bounds.x2() - box_w - border_width.r; box_x = bounds.x2() - box_w - border_width.r;
else if (getAlign() & JI_CENTER) else if (getAlign() & CENTER)
box_x = (bounds.x+bounds.x2())/2 - box_w/2; box_x = (bounds.x+bounds.x2())/2 - box_w/2;
else else
box_x = bounds.x + border_width.l; box_x = bounds.x + border_width.l;
if (getAlign() & JI_BOTTOM) if (getAlign() & BOTTOM)
box_y = bounds.y2() - box_h - border_width.b; box_y = bounds.y2() - box_h - border_width.b;
else if (getAlign() & JI_MIDDLE) else if (getAlign() & MIDDLE)
box_y = (bounds.y+bounds.y2())/2 - box_h/2; box_y = (bounds.y+bounds.y2())/2 - box_h/2;
else else
box_y = bounds.y + border_width.t; box_y = bounds.y + border_width.t;
@ -834,11 +834,11 @@ void Widget::getTextIconInfo(
// With text // With text
if (hasText()) { if (hasText()) {
// Text/icon X position // Text/icon X position
if (icon_align & JI_RIGHT) { if (icon_align & RIGHT) {
text_x = box_x; text_x = box_x;
icon_x = box_x + box_w - icon_w; icon_x = box_x + box_w - icon_w;
} }
else if (icon_align & JI_CENTER) { else if (icon_align & CENTER) {
text_x = box_x + box_w/2 - text_w/2; text_x = box_x + box_w/2 - text_w/2;
icon_x = box_x + box_w/2 - icon_w/2; icon_x = box_x + box_w/2 - icon_w/2;
} }
@ -848,11 +848,11 @@ void Widget::getTextIconInfo(
} }
// Text Y position // Text Y position
if (icon_align & JI_BOTTOM) { if (icon_align & BOTTOM) {
text_y = box_y; text_y = box_y;
icon_y = box_y + box_h - icon_h; icon_y = box_y + box_h - icon_h;
} }
else if (icon_align & JI_MIDDLE) { else if (icon_align & MIDDLE) {
text_y = box_y + box_h/2 - text_h/2; text_y = box_y + box_h/2 - text_h/2;
icon_y = box_y + box_h/2 - icon_h/2; icon_y = box_y + box_h/2 - icon_h/2;
} }
@ -890,8 +890,8 @@ void Widget::flushRedraw()
std::queue<Widget*> processing; std::queue<Widget*> processing;
Message* msg; Message* msg;
if (this->flags & JI_DIRTY) { if (this->flags & DIRTY) {
this->flags ^= JI_DIRTY; this->flags ^= DIRTY;
processing.push(this); processing.push(this);
} }
@ -907,8 +907,8 @@ void Widget::flushRedraw()
UI_FOREACH_WIDGET(widget->getChildren(), it) { UI_FOREACH_WIDGET(widget->getChildren(), it) {
Widget* child = *it; Widget* child = *it;
if (child->flags & JI_DIRTY) { if (child->flags & DIRTY) {
child->flags ^= JI_DIRTY; child->flags ^= DIRTY;
processing.push(child); processing.push(child);
} }
} }
@ -995,7 +995,7 @@ bool Widget::paintEvent(Graphics* graphics)
graphics->fillRect(gfx::rgba(255, 0, 0), getClientBounds()); graphics->fillRect(gfx::rgba(255, 0, 0), getClientBounds());
#endif #endif
this->flags |= JI_HIDDEN; this->flags |= HIDDEN;
gfx::Region rgn(getParent()->getBounds()); gfx::Region rgn(getParent()->getBounds());
rgn.createIntersection(rgn, rgn.createIntersection(rgn,
@ -1005,7 +1005,7 @@ bool Widget::paintEvent(Graphics* graphics)
graphics->getInternalDeltaY()))); graphics->getInternalDeltaY())));
getParent()->paint(graphics, rgn); getParent()->paint(graphics, rgn);
this->flags &= ~JI_HIDDEN; this->flags &= ~HIDDEN;
} }
PaintEvent ev(this, graphics); PaintEvent ev(this, graphics);
@ -1279,12 +1279,12 @@ void Widget::offerCapture(ui::MouseMessage* mouseMsg, int widget_type)
bool Widget::hasFocus() bool Widget::hasFocus()
{ {
return (this->flags & JI_HASFOCUS) ? true: false; return (this->flags & HAS_FOCUS) ? true: false;
} }
bool Widget::hasMouse() bool Widget::hasMouse()
{ {
return (this->flags & JI_HASMOUSE) ? true: false; return (this->flags & HAS_MOUSE) ? true: false;
} }
bool Widget::hasMouseOver() bool Widget::hasMouseOver()
@ -1294,7 +1294,7 @@ bool Widget::hasMouseOver()
bool Widget::hasCapture() bool Widget::hasCapture()
{ {
return (this->flags & JI_HASCAPTURE) ? true: false; return (this->flags & HAS_CAPTURE) ? true: false;
} }
int Widget::getMnemonicChar() const int Widget::getMnemonicChar() const
@ -1447,8 +1447,8 @@ void Widget::onInitTheme(InitThemeEvent& ev)
if (m_theme) { if (m_theme) {
m_theme->initWidget(this); m_theme->initWidget(this);
if (!(flags & JI_INITIALIZED)) if (!(flags & INITIALIZED))
flags |= JI_INITIALIZED; flags |= INITIALIZED;
} }
} }

View File

@ -83,7 +83,7 @@ namespace ui {
// Text property. // Text property.
bool hasText() const { return (flags & JI_HASTEXT) == JI_HASTEXT; } bool hasText() const { return (flags & HAS_TEXT) == HAS_TEXT; }
const std::string& getText() const { return m_text; } const std::string& getText() const { return m_text; }
int getTextInt() const; int getTextInt() const;

View File

@ -51,7 +51,7 @@ Window::Window(Type type, const std::string& text)
m_isAutoRemap = true; m_isAutoRemap = true;
setVisible(false); setVisible(false);
setAlign(JI_LEFT | JI_MIDDLE); setAlign(LEFT | MIDDLE);
if (type == WithTitleBar) if (type == WithTitleBar)
setText(text); setText(text);
@ -246,7 +246,7 @@ void Window::openWindowInForeground()
openWindow(); openWindow();
MessageLoop loop(getManager()); MessageLoop loop(getManager());
while (!(this->flags & JI_HIDDEN)) while (!(this->flags & HIDDEN))
loop.pumpMessages(); loop.pumpMessages();
m_isForeground = false; m_isForeground = false;