mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-14 04:19:12 +00:00
Convert ui::Widget::border_width/child_spacing to private fields
This commit is contained in:
parent
1922a27b38
commit
a2538628c7
@ -80,11 +80,12 @@ void AboutCommand::onExecute(Context* context)
|
||||
box1->addChild(grid);
|
||||
window->addChild(box1);
|
||||
|
||||
close_button->setBorder(gfx::Border(
|
||||
close_button->border_width.l + 16*guiscale(),
|
||||
close_button->border_width.t,
|
||||
close_button->border_width.r + 16*guiscale(),
|
||||
close_button->border_width.b));
|
||||
close_button->setBorder(
|
||||
gfx::Border(
|
||||
close_button->border().left() + 16*guiscale(),
|
||||
close_button->border().top(),
|
||||
close_button->border().right() + 16*guiscale(),
|
||||
close_button->border().bottom()));
|
||||
|
||||
close_button->Click.connect(Bind<void>(&Window::closeWindow, window.get(), close_button));
|
||||
|
||||
|
@ -49,7 +49,10 @@ public:
|
||||
, m_menuitem(menuitem)
|
||||
, m_level(level)
|
||||
, m_hotAccel(-1) {
|
||||
this->border_width.t = this->border_width.b = 0;
|
||||
gfx::Border border = this->border();
|
||||
border.top(0);
|
||||
border.bottom(0);
|
||||
setBorder(border);
|
||||
}
|
||||
|
||||
void restoreKeys() {
|
||||
@ -113,9 +116,8 @@ private:
|
||||
|
||||
void onPreferredSize(PreferredSizeEvent& ev) override {
|
||||
gfx::Size size = getTextSize();
|
||||
size.w = this->border_width.l + size.w + this->border_width.r;
|
||||
size.h = this->border_width.t + size.h + this->border_width.b
|
||||
+ 4*guiscale();
|
||||
size.w = size.w + border().width();
|
||||
size.h = size.h + border().height() + 4*guiscale();
|
||||
|
||||
if (m_key && !m_key->accels().empty()) {
|
||||
size_t combos = m_key->accels().size();
|
||||
@ -143,7 +145,7 @@ private:
|
||||
|
||||
g->fillRect(bg, bounds);
|
||||
|
||||
bounds.shrink(getBorder());
|
||||
bounds.shrink(border());
|
||||
g->drawUIString(getText(), fg, bg,
|
||||
gfx::Point(
|
||||
bounds.x + m_level*16 * guiscale(),
|
||||
|
@ -258,7 +258,7 @@ PaletteEntryEditor::PaletteEntryEditor()
|
||||
m_changeMode.addItem("Rel");
|
||||
|
||||
m_topBox.setBorder(gfx::Border(0));
|
||||
m_topBox.child_spacing = 0;
|
||||
m_topBox.setChildSpacing(0);
|
||||
m_bottomBox.setBorder(gfx::Border(0));
|
||||
|
||||
// Top box
|
||||
|
@ -50,9 +50,8 @@ ColorCurveEditor::ColorCurveEditor(ColorCurve* curve, const gfx::Rect& viewBound
|
||||
setFocusStop(true);
|
||||
setDoubleBuffered(true);
|
||||
|
||||
border_width.l = border_width.r = 1;
|
||||
border_width.t = border_width.b = 1;
|
||||
child_spacing = 0;
|
||||
setBorder(gfx::Border(1));
|
||||
setChildSpacing(0);
|
||||
|
||||
m_status = STATUS_STANDBY;
|
||||
|
||||
@ -174,8 +173,8 @@ bool ColorCurveEditor::onProcessMessage(Message* msg)
|
||||
|
||||
void ColorCurveEditor::onPreferredSize(PreferredSizeEvent& ev)
|
||||
{
|
||||
ev.setPreferredSize(gfx::Size(border_width.l + 1 + border_width.r,
|
||||
border_width.t + 1 + border_width.b));
|
||||
ev.setPreferredSize(gfx::Size(1 + border().width(),
|
||||
1 + border().height()));
|
||||
}
|
||||
|
||||
void ColorCurveEditor::onPaint(ui::PaintEvent& ev)
|
||||
|
@ -91,15 +91,13 @@ void AppMenuItem::onPreferredSize(PreferredSizeEvent& ev)
|
||||
|
||||
if (hasText()) {
|
||||
size.w =
|
||||
+ this->border_width.l
|
||||
+ getTextWidth()
|
||||
+ (inBar() ? this->child_spacing/4: this->child_spacing)
|
||||
+ this->border_width.r;
|
||||
+ (inBar() ? this->childSpacing()/4: this->childSpacing())
|
||||
+ border().width();
|
||||
|
||||
size.h =
|
||||
+ this->border_width.t
|
||||
+ getTextHeight()
|
||||
+ this->border_width.b;
|
||||
+ border().height();
|
||||
|
||||
if (m_key && !m_key->accels().empty()) {
|
||||
size.w += Graphics::measureUIStringLength(
|
||||
|
@ -118,7 +118,7 @@ BrushPopup::BrushPopup(BrushPopupDelegate* delegate)
|
||||
{
|
||||
setAutoRemap(false);
|
||||
setBorder(gfx::Border(0));
|
||||
child_spacing = 0;
|
||||
setChildSpacing(0);
|
||||
}
|
||||
|
||||
void BrushPopup::setBrush(Brush* brush)
|
||||
|
@ -117,7 +117,7 @@ ColorBar::ColorBar(int align)
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
|
||||
|
||||
setBorder(gfx::Border(2*guiscale(), 0, 0, 0));
|
||||
child_spacing = 2*guiscale();
|
||||
setChildSpacing(2*guiscale());
|
||||
|
||||
m_paletteView.setColumns(8);
|
||||
m_fgColor.setPreferredSize(0, m_fgColor.getPreferredSize().h);
|
||||
|
@ -156,8 +156,8 @@ void ColorButton::onPreferredSize(PreferredSizeEvent& ev)
|
||||
getTextIconInfo(&box);
|
||||
box.w = 64*guiscale();
|
||||
|
||||
ev.setPreferredSize(box.w + border_width.l + border_width.r,
|
||||
box.h + border_width.t + border_width.b);
|
||||
ev.setPreferredSize(box.w + border().width(),
|
||||
box.h + border().height());
|
||||
}
|
||||
|
||||
void ColorButton::onPaint(PaintEvent& ev)
|
||||
|
@ -75,7 +75,7 @@ ColorSelector::ColorSelector()
|
||||
m_colorType.addItem("Mask");
|
||||
|
||||
m_topBox.setBorder(gfx::Border(0));
|
||||
m_topBox.child_spacing = 0;
|
||||
m_topBox.setChildSpacing(0);
|
||||
|
||||
m_colorPaletteContainer.attachToView(&m_colorPalette);
|
||||
|
||||
|
@ -779,7 +779,9 @@ protected:
|
||||
ContextBar::ContextBar()
|
||||
: Box(HORIZONTAL)
|
||||
{
|
||||
border_width.b = 2*guiscale();
|
||||
gfx::Border border = this->border();
|
||||
border.bottom(2*guiscale());
|
||||
setBorder(border);
|
||||
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
|
||||
setBgColor(theme->colors.workspace());
|
||||
|
@ -38,7 +38,7 @@ DropDownButton::DropDownButton(const char* text)
|
||||
addChild(m_button);
|
||||
addChild(m_dropDown);
|
||||
|
||||
child_spacing = 0;
|
||||
setChildSpacing(0);
|
||||
|
||||
m_dropDown->setIconInterface
|
||||
(new ButtonIconImpl(static_cast<SkinTheme*>(m_dropDown->getTheme()),
|
||||
|
@ -40,7 +40,7 @@ HexColorEntry::HexColorEntry()
|
||||
initTheme();
|
||||
|
||||
setBorder(gfx::Border(2*guiscale(), 0, 0, 0));
|
||||
child_spacing = 0;
|
||||
setChildSpacing(0);
|
||||
}
|
||||
|
||||
void HexColorEntry::setColor(const app::Color& color)
|
||||
|
@ -46,8 +46,7 @@ HomeView::HomeView()
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
|
||||
setBgColor(theme->colors.workspace());
|
||||
|
||||
child_spacing = 8 * guiscale();
|
||||
setChildSpacing(8 * guiscale());
|
||||
|
||||
newFile()->Click.connect(Bind(&HomeView::onNewFile, this));
|
||||
openFile()->Click.connect(Bind(&HomeView::onOpenFile, this));
|
||||
|
@ -71,9 +71,8 @@ PaletteView::PaletteView(bool editable, PaletteViewStyle style, PaletteViewDeleg
|
||||
setFocusStop(true);
|
||||
setDoubleBuffered(true);
|
||||
|
||||
this->border_width.l = this->border_width.r = 1 * guiscale();
|
||||
this->border_width.t = this->border_width.b = 1 * guiscale();
|
||||
this->child_spacing = 1 * guiscale();
|
||||
setBorder(gfx::Border(1 * guiscale()));
|
||||
setChildSpacing(1 * guiscale());
|
||||
|
||||
m_conn = App::instance()->PaletteChange.connect(&PaletteView::onAppPaletteChange, this);
|
||||
}
|
||||
@ -528,8 +527,8 @@ void PaletteView::onResize(ui::ResizeEvent& ev)
|
||||
View* view = View::getView(this);
|
||||
if (view) {
|
||||
int columns =
|
||||
(view->getViewportBounds().w-this->child_spacing*2)
|
||||
/ (m_boxsize+this->child_spacing);
|
||||
(view->getViewportBounds().w-this->childSpacing()*2)
|
||||
/ (m_boxsize+this->childSpacing());
|
||||
setColumns(MID(1, columns, currentPalette()->size()));
|
||||
}
|
||||
m_isUpdatingColumns = false;
|
||||
@ -556,11 +555,8 @@ void PaletteView::request_size(int* w, int* h)
|
||||
int cols = m_columns;
|
||||
int rows = d.quot + ((d.rem)? 1: 0);
|
||||
|
||||
*w = this->border_width.l + this->border_width.r +
|
||||
+ cols*m_boxsize + (cols-1)*this->child_spacing;
|
||||
|
||||
*h = this->border_width.t + this->border_width.b +
|
||||
+ rows*m_boxsize + (rows-1)*this->child_spacing;
|
||||
*w = border().width() + cols*m_boxsize + (cols-1)*childSpacing();
|
||||
*h = border().height() + rows*m_boxsize + (rows-1)*childSpacing();
|
||||
}
|
||||
|
||||
void PaletteView::update_scroll(int color)
|
||||
@ -579,8 +575,8 @@ void PaletteView::update_scroll(int color)
|
||||
d = div(currentPalette()->size(), m_columns);
|
||||
cols = m_columns;
|
||||
|
||||
y = (m_boxsize+this->child_spacing) * (color / cols);
|
||||
x = (m_boxsize+this->child_spacing) * (color % cols);
|
||||
y = (m_boxsize+childSpacing()) * (color / cols);
|
||||
x = (m_boxsize+childSpacing()) * (color % cols);
|
||||
|
||||
if (scroll.x > x)
|
||||
scroll.x = x;
|
||||
@ -612,8 +608,8 @@ gfx::Rect PaletteView::getPaletteEntryBounds(int index) const
|
||||
int row = index / cols;
|
||||
|
||||
return gfx::Rect(
|
||||
bounds.x + this->border_width.l + col*(m_boxsize+this->child_spacing),
|
||||
bounds.y + this->border_width.t + row*(m_boxsize+this->child_spacing),
|
||||
bounds.x + border().left() + col*(m_boxsize+childSpacing()),
|
||||
bounds.y + border().top() + row*(m_boxsize+childSpacing()),
|
||||
m_boxsize, m_boxsize);
|
||||
}
|
||||
|
||||
@ -654,8 +650,8 @@ PaletteView::Hit PaletteView::hitTest(const gfx::Point& pos)
|
||||
if (i >= palette->size() && box.y2() > vp.h)
|
||||
break;
|
||||
|
||||
box.w += child_spacing;
|
||||
box.h += child_spacing;
|
||||
box.w += childSpacing();
|
||||
box.h += childSpacing();
|
||||
if (box.contains(pos)) {
|
||||
Hit hit(Hit::COLOR, i);
|
||||
hit.after = (pos.x > box.x+box.w/2);
|
||||
|
@ -32,7 +32,7 @@ PopupWindowPin::PopupWindowPin(const std::string& text, ClickBehavior clickBehav
|
||||
{
|
||||
// Configure the micro check-box look without borders, only the "pin" icon is shown.
|
||||
setup_look(&m_pin, WithoutBordersLook);
|
||||
m_pin.child_spacing = 0;
|
||||
m_pin.setChildSpacing(0);
|
||||
m_pin.setBorder(gfx::Border(0));
|
||||
|
||||
m_pin.Click.connect(&PopupWindowPin::onPinClick, this);
|
||||
|
@ -177,7 +177,7 @@ PreviewEditorWindow::PreviewEditorWindow()
|
||||
, m_aniSpeed(1.0)
|
||||
, m_relatedEditor(nullptr)
|
||||
{
|
||||
child_spacing = 0;
|
||||
setChildSpacing(0);
|
||||
setAutoRemap(false);
|
||||
setWantFocus(false);
|
||||
|
||||
|
@ -658,17 +658,11 @@ Cursor* SkinTheme::getCursor(CursorType type)
|
||||
|
||||
void SkinTheme::initWidget(Widget* widget)
|
||||
{
|
||||
#define BORDER(n) \
|
||||
widget->border_width.l = (n); \
|
||||
widget->border_width.t = (n); \
|
||||
widget->border_width.r = (n); \
|
||||
widget->border_width.b = (n);
|
||||
#define BORDER(n) \
|
||||
widget->setBorder(gfx::Border(n))
|
||||
|
||||
#define BORDER4(L,T,R,B) \
|
||||
widget->border_width.l = (L); \
|
||||
widget->border_width.t = (T); \
|
||||
widget->border_width.r = (R); \
|
||||
widget->border_width.b = (B);
|
||||
#define BORDER4(L,T,R,B) \
|
||||
widget->setBorder(gfx::Border((L), (T), (R), (B)))
|
||||
|
||||
int scale = guiscale();
|
||||
|
||||
@ -676,7 +670,7 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
|
||||
case kBoxWidget:
|
||||
BORDER(0);
|
||||
widget->child_spacing = 4 * scale;
|
||||
widget->setChildSpacing(4 * scale);
|
||||
break;
|
||||
|
||||
case kButtonWidget:
|
||||
@ -685,12 +679,12 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
m_part[PART_BUTTON_NORMAL_N]->height(),
|
||||
m_part[PART_BUTTON_NORMAL_E]->width(),
|
||||
m_part[PART_BUTTON_NORMAL_S]->height());
|
||||
widget->child_spacing = 0;
|
||||
widget->setChildSpacing(0);
|
||||
break;
|
||||
|
||||
case kCheckWidget:
|
||||
BORDER(2 * scale);
|
||||
widget->child_spacing = 4 * scale;
|
||||
widget->setChildSpacing(4 * scale);
|
||||
|
||||
static_cast<ButtonBase*>(widget)->setIconInterface
|
||||
(new ButtonIconImpl(static_cast<SkinTheme*>(widget->getTheme()),
|
||||
@ -710,7 +704,7 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
|
||||
case kGridWidget:
|
||||
BORDER(0);
|
||||
widget->child_spacing = 4 * scale;
|
||||
widget->setChildSpacing(4 * scale);
|
||||
break;
|
||||
|
||||
case kLabelWidget:
|
||||
@ -719,7 +713,7 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
|
||||
case kListBoxWidget:
|
||||
BORDER(0);
|
||||
widget->child_spacing = 0;
|
||||
widget->setChildSpacing(0);
|
||||
break;
|
||||
|
||||
case kListItemWidget:
|
||||
@ -733,11 +727,8 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
|
||||
Button* button = combobox->getButtonWidget();
|
||||
|
||||
button->border_width.l = 0;
|
||||
button->border_width.t = 0;
|
||||
button->border_width.r = 0;
|
||||
button->border_width.b = 0;
|
||||
button->child_spacing = 0;
|
||||
button->setBorder(gfx::Border(0));
|
||||
button->setChildSpacing(0);
|
||||
button->setMinSize(gfx::Size(15 * guiscale(),
|
||||
16 * guiscale()));
|
||||
|
||||
@ -754,22 +745,22 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
case kMenuBarWidget:
|
||||
case kMenuBoxWidget:
|
||||
BORDER(0);
|
||||
widget->child_spacing = 0;
|
||||
widget->setChildSpacing(0);
|
||||
break;
|
||||
|
||||
case kMenuItemWidget:
|
||||
BORDER(2 * scale);
|
||||
widget->child_spacing = 18 * scale;
|
||||
widget->setChildSpacing(18 * scale);
|
||||
break;
|
||||
|
||||
case kSplitterWidget:
|
||||
BORDER(0);
|
||||
widget->child_spacing = 3 * scale;
|
||||
widget->setChildSpacing(3 * scale);
|
||||
break;
|
||||
|
||||
case kRadioWidget:
|
||||
BORDER(2 * scale);
|
||||
widget->child_spacing = 4 * scale;
|
||||
widget->setChildSpacing(4 * scale);
|
||||
|
||||
static_cast<ButtonBase*>(widget)->setIconInterface
|
||||
(new ButtonIconImpl(static_cast<SkinTheme*>(widget->getTheme()),
|
||||
@ -795,10 +786,14 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
}
|
||||
|
||||
if (widget->hasText()) {
|
||||
gfx::Border border = widget->border();
|
||||
|
||||
if (widget->getAlign() & TOP)
|
||||
widget->border_width.t = widget->getTextHeight();
|
||||
border.top(widget->getTextHeight());
|
||||
else if (widget->getAlign() & BOTTOM)
|
||||
widget->border_width.b = widget->getTextHeight();
|
||||
border.bottom(widget->getTextHeight());
|
||||
|
||||
widget->setBorder(border);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -808,13 +803,13 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
m_part[PART_SLIDER_EMPTY_N]->height(),
|
||||
m_part[PART_SLIDER_EMPTY_E]->width()-1*scale,
|
||||
m_part[PART_SLIDER_EMPTY_S]->height()-1*scale);
|
||||
widget->child_spacing = widget->getTextHeight();
|
||||
widget->setChildSpacing(widget->getTextHeight());
|
||||
widget->setAlign(CENTER | MIDDLE);
|
||||
break;
|
||||
|
||||
case kTextBoxWidget:
|
||||
BORDER(0);
|
||||
widget->child_spacing = 0;
|
||||
widget->setChildSpacing(0);
|
||||
break;
|
||||
|
||||
case kViewWidget:
|
||||
@ -823,25 +818,27 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
m_part[PART_SUNKEN_NORMAL_N]->height(),
|
||||
m_part[PART_SUNKEN_NORMAL_E]->width()-1*scale,
|
||||
m_part[PART_SUNKEN_NORMAL_S]->height()-1*scale);
|
||||
widget->child_spacing = 0;
|
||||
widget->setChildSpacing(0);
|
||||
widget->setBgColor(colors.windowFace());
|
||||
break;
|
||||
|
||||
case kViewScrollbarWidget:
|
||||
BORDER(1 * scale);
|
||||
widget->child_spacing = 0;
|
||||
widget->setChildSpacing(0);
|
||||
break;
|
||||
|
||||
case kViewViewportWidget:
|
||||
BORDER(0);
|
||||
widget->child_spacing = 0;
|
||||
widget->setChildSpacing(0);
|
||||
break;
|
||||
|
||||
case kWindowWidget:
|
||||
if (!static_cast<Window*>(widget)->isDesktop()) {
|
||||
if (widget->hasText()) {
|
||||
BORDER4(6 * scale, (4+6) * scale, 6 * scale, 6 * scale);
|
||||
widget->border_width.t += widget->getTextHeight();
|
||||
BORDER4(6 * scale,
|
||||
(4+6) * scale + widget->getTextHeight(),
|
||||
6 * scale,
|
||||
6 * scale);
|
||||
|
||||
if (!widget->hasFlags(INITIALIZED)) {
|
||||
Button* button = new WindowCloseButton();
|
||||
@ -855,7 +852,7 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
else {
|
||||
BORDER(0);
|
||||
}
|
||||
widget->child_spacing = 4 * scale; // TODO this hard-coded 4 should be configurable in skin.xml
|
||||
widget->setChildSpacing(4 * scale); // TODO this hard-coded 4 should be configurable in skin.xml
|
||||
widget->setBgColor(colors.windowFace());
|
||||
break;
|
||||
|
||||
@ -1058,7 +1055,7 @@ void SkinTheme::paintEntry(PaintEvent& ev)
|
||||
bg);
|
||||
|
||||
// Draw the text
|
||||
x = bounds.x + widget->border_width.l;
|
||||
x = bounds.x + widget->border().left();
|
||||
y = bounds.y + bounds.h/2 - widget->getTextHeight()/2;
|
||||
|
||||
base::utf8_const_iterator utf8_it = base::utf8_const_iterator(textString.begin());
|
||||
@ -1134,7 +1131,7 @@ void SkinTheme::paintLabel(PaintEvent& ev)
|
||||
if (!is_transparent(bg))
|
||||
g->fillRect(bg, rc);
|
||||
|
||||
rc.shrink(widget->getBorder());
|
||||
rc.shrink(widget->border());
|
||||
|
||||
widget->getTextIconInfo(NULL, &text);
|
||||
style->paint(g, text, widget->getText().c_str(), Style::State());
|
||||
@ -1190,7 +1187,7 @@ void SkinTheme::paintListItem(ui::PaintEvent& ev)
|
||||
g->fillRect(bg, bounds);
|
||||
|
||||
if (widget->hasText()) {
|
||||
bounds.shrink(widget->getBorder());
|
||||
bounds.shrink(widget->border());
|
||||
drawTextString(g, NULL, fg, bg, widget, bounds, 0);
|
||||
}
|
||||
}
|
||||
@ -1261,7 +1258,7 @@ void SkinTheme::paintMenuItem(ui::PaintEvent& ev)
|
||||
|
||||
Rect pos = bounds;
|
||||
if (!bar)
|
||||
pos.offset(widget->child_spacing/2, 0);
|
||||
pos.offset(widget->childSpacing()/2, 0);
|
||||
drawTextString(g, NULL, fg, ColorNone, widget, pos, 0);
|
||||
|
||||
// For menu-box
|
||||
@ -1294,7 +1291,7 @@ void SkinTheme::paintMenuItem(ui::PaintEvent& ev)
|
||||
int old_align = appMenuItem->getAlign();
|
||||
|
||||
pos = bounds;
|
||||
pos.w -= widget->child_spacing/4;
|
||||
pos.w -= widget->childSpacing()/4;
|
||||
|
||||
std::string buf = appMenuItem->getKey()->accels().front().toString();
|
||||
|
||||
@ -1370,11 +1367,11 @@ void SkinTheme::paintSeparator(ui::PaintEvent& ev)
|
||||
int h = widget->getTextHeight();
|
||||
Rect r(
|
||||
Point(
|
||||
bounds.x + widget->border_width.l/2 + h/2,
|
||||
bounds.y + widget->border_width.t/2 - h/2),
|
||||
bounds.x + widget->border().left()/2 + h/2,
|
||||
bounds.y + widget->border().top()/2 - h/2),
|
||||
Point(
|
||||
bounds.x2() - widget->border_width.r/2 - h,
|
||||
bounds.y2() - widget->border_width.b/2 + h));
|
||||
bounds.x2() - widget->border().right()/2 - h,
|
||||
bounds.y2() - widget->border().bottom()/2 + h));
|
||||
|
||||
drawTextString(g, NULL,
|
||||
colors.separatorLabel(), BGCOLOR,
|
||||
@ -1396,7 +1393,7 @@ void SkinTheme::paintSlider(PaintEvent& ev)
|
||||
|
||||
widget->getSliderThemeInfo(&min, &max, &value);
|
||||
|
||||
Rect rc(Rect(bounds).shrink(widget->getBorder()));
|
||||
Rect rc(Rect(bounds).shrink(widget->border()));
|
||||
int x;
|
||||
if (min != max)
|
||||
x = rc.x + rc.w * (value-min) / (max-min);
|
||||
@ -1530,7 +1527,7 @@ void SkinTheme::paintComboBoxEntry(ui::PaintEvent& ev)
|
||||
PART_SUNKEN2_NORMAL_NW, bg);
|
||||
|
||||
// Draw the text
|
||||
x = bounds.x + widget->border_width.l;
|
||||
x = bounds.x + widget->border().left();
|
||||
y = bounds.y + bounds.h/2 - widget->getTextHeight()/2;
|
||||
|
||||
base::utf8_const_iterator utf8_it = base::utf8_const_iterator(textString.begin());
|
||||
@ -1740,7 +1737,7 @@ void SkinTheme::paintPopupWindow(PaintEvent& ev)
|
||||
if (!is_transparent(BGCOLOR))
|
||||
styles.menubox()->paint(g, pos, NULL, Style::State());
|
||||
|
||||
pos.shrink(window->getBorder());
|
||||
pos.shrink(window->border());
|
||||
|
||||
g->drawAlignedUIString(window->getText(),
|
||||
colors.text(),
|
||||
@ -1833,7 +1830,7 @@ void SkinTheme::paintTooltip(PaintEvent& ev)
|
||||
m_part[e]->width(),
|
||||
m_part[s]->height())));
|
||||
|
||||
rc.shrink(widget->getBorder());
|
||||
rc.shrink(widget->border());
|
||||
|
||||
g->drawAlignedUIString(widget->getText(), fg, bg, rc, widget->getAlign());
|
||||
}
|
||||
@ -1904,7 +1901,7 @@ void SkinTheme::drawTextString(Graphics* g, const char *t, gfx::Color fg_color,
|
||||
// Text
|
||||
Rect textWrap = textrc.createIntersection(
|
||||
// TODO add ui::Widget::getPadding() property
|
||||
// Rect(widget->getClientBounds()).shrink(widget->getBorder()));
|
||||
// Rect(widget->getClientBounds()).shrink(widget->border()));
|
||||
widget->getClientBounds()).inflate(0, 1*guiscale());
|
||||
|
||||
IntersectClip clip(g, textWrap);
|
||||
|
@ -326,7 +326,7 @@ void StatusBar::onResize(ResizeEvent& ev)
|
||||
|
||||
setBoundsQuietly(ev.getBounds());
|
||||
|
||||
Border border = getBorder();
|
||||
Border border = this->border();
|
||||
Rect rc = ev.getBounds();
|
||||
bool frameControls = (rc.w > 300*ui::guiscale());
|
||||
|
||||
|
@ -85,10 +85,7 @@ ToolBar::ToolBar()
|
||||
{
|
||||
m_instance = this;
|
||||
|
||||
this->border_width.l = 1*guiscale();
|
||||
this->border_width.t = 0;
|
||||
this->border_width.r = 1*guiscale();
|
||||
this->border_width.b = 0;
|
||||
setBorder(gfx::Border(1*guiscale(), 0, 1*guiscale(), 0));
|
||||
|
||||
m_hotTool = NULL;
|
||||
m_hotIndex = NoneIndex;
|
||||
@ -296,8 +293,8 @@ bool ToolBar::onProcessMessage(Message* msg)
|
||||
void ToolBar::onPreferredSize(PreferredSizeEvent& ev)
|
||||
{
|
||||
Size iconsize = getToolIconSize(this);
|
||||
iconsize.w += this->border_width.l + this->border_width.r;
|
||||
iconsize.h += this->border_width.t + this->border_width.b;
|
||||
iconsize.w += border().width();
|
||||
iconsize.h += border().height();
|
||||
ev.setPreferredSize(iconsize);
|
||||
}
|
||||
|
||||
@ -442,7 +439,7 @@ void ToolBar::openPopupWindow(int group_index, ToolGroup* tool_group)
|
||||
for (ToolIterator it = toolbox->begin(); it != toolbox->end(); ++it) {
|
||||
Tool* tool = *it;
|
||||
if (tool->getGroup() == tool_group)
|
||||
w += getBounds().w-this->border_width.l-this->border_width.r-1;
|
||||
w += getBounds().w-border().width()-1;
|
||||
}
|
||||
|
||||
rc.x -= w;
|
||||
@ -469,7 +466,7 @@ Rect ToolBar::getToolGroupBounds(int group_index)
|
||||
int groups = toolbox->getGroupsCount();
|
||||
Size iconsize = getToolIconSize(this);
|
||||
Rect rc(getBounds());
|
||||
rc.shrink(getBorder());
|
||||
rc.shrink(border());
|
||||
|
||||
switch (group_index) {
|
||||
|
||||
|
@ -533,7 +533,7 @@ void WidgetLoader::fillWidgetWithXmlElementAttributes(const TiXmlElement* elem,
|
||||
widget->setBorder(gfx::Border(strtol(border, NULL, 10)*guiscale()));
|
||||
|
||||
if (childspacing)
|
||||
widget->child_spacing = strtol(childspacing, NULL, 10)*guiscale();
|
||||
widget->setChildSpacing(strtol(childspacing, NULL, 10)*guiscale());
|
||||
|
||||
gfx::Size reqSize = widget->getPreferredSize();
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Gfx 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.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -43,6 +43,9 @@ public:
|
||||
T right() const { return m_right; };
|
||||
T bottom() const { return m_bottom; };
|
||||
|
||||
T width() const { return m_left + m_right; };
|
||||
T height() const { return m_top + m_bottom; };
|
||||
|
||||
void left(const T& left) { m_left = left; }
|
||||
void top(const T& top) { m_top = top; }
|
||||
void right(const T& right) { m_right = right; }
|
||||
|
@ -45,7 +45,7 @@ void Box::onPreferredSize(PreferredSizeEvent& ev)
|
||||
if (getAlign() & HOMOGENEOUS) \
|
||||
w *= nvis_children; \
|
||||
\
|
||||
w += child_spacing * (nvis_children-1); \
|
||||
w += childSpacing() * (nvis_children-1); \
|
||||
}
|
||||
|
||||
int w, h, nvis_children;
|
||||
@ -84,22 +84,22 @@ void Box::onPreferredSize(PreferredSizeEvent& ev)
|
||||
}
|
||||
}
|
||||
|
||||
w += border_width.l + border_width.r;
|
||||
h += border_width.t + border_width.b;
|
||||
w += border().width();
|
||||
h += border().height();
|
||||
|
||||
ev.setPreferredSize(Size(w, h));
|
||||
}
|
||||
|
||||
void Box::onResize(ResizeEvent& ev)
|
||||
{
|
||||
#define FIXUP(x, y, w, h, l, t, r, b) \
|
||||
#define FIXUP(x, y, w, h, left, top, width, height) \
|
||||
{ \
|
||||
int width; \
|
||||
if (nvis_children > 0) { \
|
||||
if (getAlign() & HOMOGENEOUS) { \
|
||||
width = (getBounds().w \
|
||||
- this->border_width.l \
|
||||
- this->border_width.r \
|
||||
- this->child_spacing * (nvis_children - 1)); \
|
||||
- this->border().width() \
|
||||
- this->childSpacing() * (nvis_children - 1)); \
|
||||
extra = width / nvis_children; \
|
||||
} \
|
||||
else if (nexpand_children > 0) { \
|
||||
@ -111,11 +111,9 @@ void Box::onResize(ResizeEvent& ev)
|
||||
extra = 0; \
|
||||
} \
|
||||
\
|
||||
x = getBounds().x + this->border_width.l; \
|
||||
y = getBounds().y + this->border_width.t; \
|
||||
h = MAX(1, getBounds().h \
|
||||
- this->border_width.t \
|
||||
- this->border_width.b); \
|
||||
x = getBounds().x + border().left(); \
|
||||
y = getBounds().y + border().top(); \
|
||||
h = MAX(1, getBounds().h - border().height()); \
|
||||
\
|
||||
UI_FOREACH_WIDGET(getChildren(), it) { \
|
||||
child = *it; \
|
||||
@ -156,7 +154,7 @@ void Box::onResize(ResizeEvent& ev)
|
||||
\
|
||||
child->setBounds(cpos); \
|
||||
\
|
||||
x += child_width + this->child_spacing; \
|
||||
x += child_width + this->childSpacing(); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
@ -166,7 +164,6 @@ void Box::onResize(ResizeEvent& ev)
|
||||
int nvis_children = 0;
|
||||
int nexpand_children = 0;
|
||||
int child_width;
|
||||
int width;
|
||||
int extra;
|
||||
int x, y, w, h;
|
||||
|
||||
@ -185,10 +182,10 @@ void Box::onResize(ResizeEvent& ev)
|
||||
Size reqSize = getPreferredSize();
|
||||
|
||||
if (this->getAlign() & HORIZONTAL) {
|
||||
FIXUP(x, y, w, h, l, t, r, b);
|
||||
FIXUP(x, y, w, h, left, top, width, height);
|
||||
}
|
||||
else {
|
||||
FIXUP(y, x, h, w, t, l, b, r);
|
||||
FIXUP(y, x, h, w, top, left, height, width);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,8 +279,8 @@ void ButtonBase::onPreferredSize(PreferredSizeEvent& ev)
|
||||
m_iconInterface ? m_iconInterface->getWidth(): 0,
|
||||
m_iconInterface ? m_iconInterface->getHeight(): 0);
|
||||
|
||||
ev.setPreferredSize(border_width.l + box.w + border_width.r,
|
||||
border_width.t + box.h + border_width.b);
|
||||
ev.setPreferredSize(box.w + border().width(),
|
||||
box.h + border().height());
|
||||
}
|
||||
|
||||
void ButtonBase::onPaint(PaintEvent& ev)
|
||||
|
@ -85,7 +85,7 @@ ComboBox::ComboBox()
|
||||
, m_casesensitive(true)
|
||||
{
|
||||
// TODO this separation should be from the Theme*
|
||||
this->child_spacing = 0;
|
||||
this->setChildSpacing(0);
|
||||
|
||||
m_entry->setExpansive(true);
|
||||
|
||||
@ -576,10 +576,9 @@ void ComboBox::openListBox()
|
||||
int size = getItemCount();
|
||||
viewport->setMinSize
|
||||
(gfx::Size(
|
||||
m_button->getBounds().x2() - m_entry->getBounds().x - view->border_width.l - view->border_width.r,
|
||||
+viewport->border_width.t
|
||||
m_button->getBounds().x2() - m_entry->getBounds().x - view->border().width(),
|
||||
+(2*guiscale()+m_listbox->getTextHeight())*MID(1, size, 16)+
|
||||
+viewport->border_width.b));
|
||||
+viewport->border().height()));
|
||||
|
||||
m_window->addChild(view);
|
||||
view->attachToView(m_listbox);
|
||||
|
@ -115,13 +115,13 @@ void Entry::setCaretPos(int pos)
|
||||
// Forward scroll
|
||||
m_scroll--;
|
||||
do {
|
||||
x = getBounds().x + this->border_width.l;
|
||||
x = getBounds().x + border().left();
|
||||
for (c=++m_scroll; ; c++) {
|
||||
int ch = (c < textlen ? *(utf8_begin+c) : ' ');
|
||||
|
||||
x += getFont()->charWidth(ch);
|
||||
|
||||
if (x >= getBounds().x2()-this->border_width.r)
|
||||
if (x >= getBounds().x2()-border().right())
|
||||
break;
|
||||
}
|
||||
} while (m_caret >= c);
|
||||
@ -333,12 +333,12 @@ bool Entry::onProcessMessage(Message* msg)
|
||||
else if (mousePos.x >= getBounds().x2()) {
|
||||
if (m_scroll < textlen - getAvailableTextLength()) {
|
||||
m_scroll++;
|
||||
x = getBounds().x + this->border_width.l;
|
||||
x = getBounds().x + border().left();
|
||||
for (c=m_scroll; utf8_begin != utf8_end; ++c) {
|
||||
int ch = (c < textlen ? *(utf8_begin+c) : ' ');
|
||||
|
||||
x += getFont()->charWidth(ch);
|
||||
if (x > getBounds().x2()-this->border_width.r) {
|
||||
if (x > getBounds().x2()-border().right()) {
|
||||
c--;
|
||||
break;
|
||||
}
|
||||
@ -418,17 +418,15 @@ bool Entry::onProcessMessage(Message* msg)
|
||||
void Entry::onPreferredSize(PreferredSizeEvent& ev)
|
||||
{
|
||||
int w =
|
||||
+ border_width.l
|
||||
+ getFont()->charWidth('w') * MIN(m_maxsize, 6)
|
||||
+ 2*guiscale()
|
||||
+ border_width.r;
|
||||
+ border().width();
|
||||
|
||||
w = MIN(w, ui::display_w()/2);
|
||||
|
||||
int h =
|
||||
+ border_width.t
|
||||
+ getFont()->height()
|
||||
+ border_width.b;
|
||||
+ border().height();
|
||||
|
||||
ev.setPreferredSize(w, h);
|
||||
}
|
||||
@ -459,11 +457,11 @@ int Entry::getCaretFromMouse(MouseMessage* mousemsg)
|
||||
int textlen = base::utf8_length(getText());
|
||||
|
||||
mx = mousemsg->position().x;
|
||||
mx = MID(getBounds().x+this->border_width.l,
|
||||
mx = MID(getBounds().x+border().left(),
|
||||
mx,
|
||||
getBounds().x2()-this->border_width.r-1);
|
||||
getBounds().x2()-border().right()-1);
|
||||
|
||||
x = getBounds().x + this->border_width.l;
|
||||
x = getBounds().x + border().left();
|
||||
|
||||
base::utf8_const_iterator utf8_it =
|
||||
(m_scroll < textlen ?
|
||||
@ -472,7 +470,7 @@ int Entry::getCaretFromMouse(MouseMessage* mousemsg)
|
||||
|
||||
for (c=m_scroll; utf8_it != utf8_end; ++c, ++utf8_it) {
|
||||
w = getFont()->charWidth(*utf8_it);
|
||||
if (x+w >= getBounds().x2()-this->border_width.r)
|
||||
if (x+w >= getBounds().x2()-border().right())
|
||||
break;
|
||||
if ((mx >= x) && (mx < x+w)) {
|
||||
caret = c;
|
||||
@ -483,7 +481,7 @@ int Entry::getCaretFromMouse(MouseMessage* mousemsg)
|
||||
|
||||
if (utf8_it == utf8_end) {
|
||||
if ((mx >= x) &&
|
||||
(mx <= getBounds().x2()-this->border_width.r-1)) {
|
||||
(mx <= getBounds().x2()-border().right()-1)) {
|
||||
caret = c;
|
||||
}
|
||||
}
|
||||
|
@ -130,9 +130,9 @@ void Grid::onResize(ResizeEvent& ev)
|
||||
calculateSize();
|
||||
distributeSize(rect);
|
||||
|
||||
pos_y = rect.y + this->border_width.t;
|
||||
pos_y = rect.y + border().top();
|
||||
for (row=0; row<(int)m_rowstrip.size(); ++row) {
|
||||
pos_x = rect.x + this->border_width.l;
|
||||
pos_x = rect.x + border().left();
|
||||
|
||||
for (col=0; col<(int)m_colstrip.size(); ++col) {
|
||||
Cell* cell = m_cells[row][col];
|
||||
@ -172,20 +172,20 @@ void Grid::onResize(ResizeEvent& ev)
|
||||
h = reqSize.h;
|
||||
}
|
||||
|
||||
if (x+w > rect.x+rect.w-this->border_width.r)
|
||||
w = rect.x+rect.w-this->border_width.r-x;
|
||||
if (y+h > rect.y+rect.h-this->border_width.b)
|
||||
h = rect.y+rect.h-this->border_width.b-y;
|
||||
if (x+w > rect.x+rect.w-border().right())
|
||||
w = rect.x+rect.w-border().right()-x;
|
||||
if (y+h > rect.y+rect.h-border().bottom())
|
||||
h = rect.y+rect.h-border().bottom()-y;
|
||||
|
||||
cell->child->setBounds(Rect(x, y, w, h));
|
||||
}
|
||||
|
||||
if (m_colstrip[col].size > 0)
|
||||
pos_x += m_colstrip[col].size + this->child_spacing;
|
||||
pos_x += m_colstrip[col].size + childSpacing();
|
||||
}
|
||||
|
||||
if (m_rowstrip[row].size > 0)
|
||||
pos_y += m_rowstrip[row].size + this->child_spacing;
|
||||
pos_y += m_rowstrip[row].size + childSpacing();
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,8 +201,8 @@ void Grid::onPreferredSize(PreferredSizeEvent& ev)
|
||||
sumStripSize(m_colstrip, w);
|
||||
sumStripSize(m_rowstrip, h);
|
||||
|
||||
w += this->border_width.l + this->border_width.r;
|
||||
h += this->border_width.t + this->border_width.b;
|
||||
w += border().width();
|
||||
h += border().height();
|
||||
|
||||
ev.setPreferredSize(Size(w, h));
|
||||
}
|
||||
@ -221,7 +221,7 @@ void Grid::sumStripSize(const std::vector<Strip>& strip, int& size)
|
||||
if (strip[i].size > 0) {
|
||||
size += strip[i].size;
|
||||
if (++j > 1)
|
||||
size += this->child_spacing;
|
||||
size += this->childSpacing();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -236,7 +236,7 @@ void Grid::calculateCellSize(int start, int span, const std::vector<Strip>& stri
|
||||
if (strip[i].size > 0) {
|
||||
size += strip[i].size;
|
||||
if (++j > 1)
|
||||
size += this->child_spacing;
|
||||
size += this->childSpacing();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -287,8 +287,8 @@ void Grid::calculateStripSize(std::vector<Strip>& colstrip,
|
||||
// If the widget isn't hidden then we can request its size
|
||||
if (!(cell->child->hasFlags(HIDDEN))) {
|
||||
Size reqSize = cell->child->getPreferredSize();
|
||||
cell->w = reqSize.w - (cell->hspan-1) * this->child_spacing;
|
||||
cell->h = reqSize.h - (cell->vspan-1) * this->child_spacing;
|
||||
cell->w = reqSize.w - (cell->hspan-1) * this->childSpacing();
|
||||
cell->h = reqSize.h - (cell->vspan-1) * this->childSpacing();
|
||||
|
||||
if ((cell->align & align) == align)
|
||||
++expand_count;
|
||||
@ -394,8 +394,8 @@ void Grid::distributeSize(const gfx::Rect& rect)
|
||||
if (m_rowstrip.size() == 0)
|
||||
return;
|
||||
|
||||
distributeStripSize(m_colstrip, rect.w, this->border_width.l + this->border_width.r, m_same_width_columns);
|
||||
distributeStripSize(m_rowstrip, rect.h, this->border_width.t + this->border_width.b, false);
|
||||
distributeStripSize(m_colstrip, rect.w, border().width(), m_same_width_columns);
|
||||
distributeStripSize(m_rowstrip, rect.h, border().height(), false);
|
||||
}
|
||||
|
||||
void Grid::distributeStripSize(std::vector<Strip>& colstrip,
|
||||
@ -414,7 +414,7 @@ void Grid::distributeStripSize(std::vector<Strip>& colstrip,
|
||||
if (colstrip[i].size > 0) {
|
||||
total_req += colstrip[i].size;
|
||||
if (++j > 1)
|
||||
total_req += this->child_spacing;
|
||||
total_req += this->childSpacing();
|
||||
}
|
||||
|
||||
if (colstrip[i].expand_count == max_expand_count || same_width) {
|
||||
@ -432,7 +432,7 @@ void Grid::distributeStripSize(std::vector<Strip>& colstrip,
|
||||
for (i=0; i<(int)colstrip.size(); ++i) {
|
||||
if ((colstrip[i].size == 0) &&
|
||||
(colstrip[i].expand_count == max_expand_count || same_width)) {
|
||||
extra_total -= this->child_spacing;
|
||||
extra_total -= this->childSpacing();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,20 +31,18 @@ TEST(Grid, Simple2x1Grid)
|
||||
EXPECT_EQ(10, reqSize.h);
|
||||
|
||||
// Test child-spacing
|
||||
grid->child_spacing = 2;
|
||||
grid->setChildSpacing(2);
|
||||
reqSize = grid->getPreferredSize();
|
||||
EXPECT_EQ(22, reqSize.w);
|
||||
EXPECT_EQ(10, reqSize.h);
|
||||
|
||||
// Test borders
|
||||
grid->border_width.l = 3;
|
||||
grid->border_width.b = 3;
|
||||
grid->setBorder(gfx::Border(3, 0, 0, 3));
|
||||
reqSize = grid->getPreferredSize();
|
||||
EXPECT_EQ(25, reqSize.w);
|
||||
EXPECT_EQ(13, reqSize.h);
|
||||
|
||||
grid->border_width.r = 5;
|
||||
grid->border_width.t = 2;
|
||||
grid->setBorder(gfx::Border(3, 2, 5, 3));
|
||||
reqSize = grid->getPreferredSize();
|
||||
EXPECT_EQ(30, reqSize.w);
|
||||
EXPECT_EQ(15, reqSize.h);
|
||||
@ -166,7 +164,7 @@ TEST(Grid, Intrincate3x3Grid)
|
||||
grid->addChildInCell(w4, 1, 2, VERTICAL);
|
||||
|
||||
// Test request size
|
||||
grid->child_spacing = 2;
|
||||
grid->setChildSpacing(2);
|
||||
Size reqSize = grid->getPreferredSize();
|
||||
EXPECT_EQ(22, reqSize.w);
|
||||
EXPECT_EQ(22, reqSize.h);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// 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.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -35,8 +35,8 @@ void ImageView::onPreferredSize(PreferredSizeEvent& ev)
|
||||
|
||||
ev.setPreferredSize(
|
||||
gfx::Size(
|
||||
border_width.l + box.w + border_width.r,
|
||||
border_width.t + box.h + border_width.b));
|
||||
box.w + border().width(),
|
||||
box.h + border().height()));
|
||||
}
|
||||
|
||||
void ImageView::onPaint(PaintEvent& ev)
|
||||
|
@ -34,8 +34,8 @@ void Label::onPreferredSize(PreferredSizeEvent& ev)
|
||||
sz.h = getTextHeight();
|
||||
}
|
||||
|
||||
sz.w += this->border_width.l + this->border_width.r;
|
||||
sz.h += this->border_width.t + this->border_width.b;
|
||||
sz.w += border().width();
|
||||
sz.h += border().height();
|
||||
|
||||
ev.setPreferredSize(sz);
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ void ListBox::onResize(ResizeEvent& ev)
|
||||
cpos.h = child->getPreferredSize().h;
|
||||
child->setBounds(cpos);
|
||||
|
||||
cpos.y += child->getBounds().h + this->child_spacing;
|
||||
cpos.y += child->getBounds().h + this->childSpacing();
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,11 +301,11 @@ void ListBox::onPreferredSize(PreferredSizeEvent& ev)
|
||||
Size reqSize = static_cast<ListItem*>(*it)->getPreferredSize();
|
||||
|
||||
w = MAX(w, reqSize.w);
|
||||
h += reqSize.h + (it+1 != end ? this->child_spacing: 0);
|
||||
h += reqSize.h + (it+1 != end ? this->childSpacing(): 0);
|
||||
}
|
||||
|
||||
w += this->border_width.l + this->border_width.r;
|
||||
h += this->border_width.t + this->border_width.b;
|
||||
w += border().width();
|
||||
h += border().height();
|
||||
|
||||
ev.setPreferredSize(Size(w, h));
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ void ListItem::onPreferredSize(PreferredSizeEvent& ev)
|
||||
maxSize.h = MAX(maxSize.h, reqSize.h);
|
||||
}
|
||||
|
||||
w = this->border_width.l + maxSize.w + this->border_width.r;
|
||||
h = this->border_width.t + maxSize.h + this->border_width.b;
|
||||
w = maxSize.w + border().width();
|
||||
h = maxSize.h + border().height();
|
||||
|
||||
ev.setPreferredSize(Size(w, h));
|
||||
}
|
||||
|
@ -346,17 +346,17 @@ void Menu::onPreferredSize(PreferredSizeEvent& ev)
|
||||
reqSize = (*it)->getPreferredSize();
|
||||
|
||||
if (getParent() && getParent()->type() == kMenuBarWidget) {
|
||||
size.w += reqSize.w + ((it+1 != end) ? this->child_spacing: 0);
|
||||
size.w += reqSize.w + ((it+1 != end) ? childSpacing(): 0);
|
||||
size.h = MAX(size.h, reqSize.h);
|
||||
}
|
||||
else {
|
||||
size.w = MAX(size.w, reqSize.w);
|
||||
size.h += reqSize.h + ((it+1 != end) ? this->child_spacing: 0);
|
||||
size.h += reqSize.h + ((it+1 != end) ? childSpacing(): 0);
|
||||
}
|
||||
}
|
||||
|
||||
size.w += this->border_width.l + this->border_width.r;
|
||||
size.h += this->border_width.t + this->border_width.b;
|
||||
size.w += border().width();
|
||||
size.h += border().height();
|
||||
|
||||
ev.setPreferredSize(size);
|
||||
}
|
||||
@ -679,8 +679,8 @@ void MenuBox::onPreferredSize(PreferredSizeEvent& ev)
|
||||
if (Menu* menu = getMenu())
|
||||
size = menu->getPreferredSize();
|
||||
|
||||
size.w += this->border_width.l + this->border_width.r;
|
||||
size.h += this->border_width.t + this->border_width.b;
|
||||
size.w += border().width();
|
||||
size.h += border().height();
|
||||
|
||||
ev.setPreferredSize(size);
|
||||
}
|
||||
@ -884,15 +884,13 @@ void MenuItem::onPreferredSize(PreferredSizeEvent& ev)
|
||||
|
||||
if (hasText()) {
|
||||
size.w =
|
||||
+ this->border_width.l
|
||||
+ getTextWidth()
|
||||
+ (inBar() ? this->child_spacing/4: this->child_spacing)
|
||||
+ this->border_width.r;
|
||||
+ (inBar() ? childSpacing()/4: childSpacing())
|
||||
+ border().width();
|
||||
|
||||
size.h =
|
||||
+ this->border_width.t
|
||||
+ getTextHeight()
|
||||
+ this->border_width.b;
|
||||
+ border().height();
|
||||
}
|
||||
|
||||
ev.setPreferredSize(size);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// 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.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -64,8 +64,8 @@ void Panel::onPreferredSize(PreferredSizeEvent& ev)
|
||||
maxSize.w = MAX(maxSize.w, getTextWidth());
|
||||
|
||||
ev.setPreferredSize(
|
||||
this->border_width.l + maxSize.w + this->border_width.r,
|
||||
this->border_width.t + maxSize.h + this->border_width.b);
|
||||
maxSize.w + border().width(),
|
||||
maxSize.h + border().height());
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
|
@ -156,11 +156,11 @@ void PopupWindow::onPreferredSize(PreferredSizeEvent& ev)
|
||||
|
||||
if (hasText())
|
||||
resultSize = g.fitString(getText(),
|
||||
(getClientBounds() - getBorder()).w,
|
||||
(getClientBounds() - border()).w,
|
||||
getAlign());
|
||||
|
||||
resultSize.w += border_width.l + border_width.r;
|
||||
resultSize.h += border_width.t + border_width.b;
|
||||
resultSize.w += border().width();
|
||||
resultSize.h += border().height();
|
||||
|
||||
if (!getChildren().empty()) {
|
||||
Size maxSize(0, 0);
|
||||
@ -175,7 +175,7 @@ void PopupWindow::onPreferredSize(PreferredSizeEvent& ev)
|
||||
maxSize.h = MAX(maxSize.h, reqSize.h);
|
||||
}
|
||||
|
||||
resultSize.w = MAX(resultSize.w, border_width.l + maxSize.w + border_width.r);
|
||||
resultSize.w = MAX(resultSize.w, maxSize.w + border().width());
|
||||
resultSize.h += maxSize.h;
|
||||
}
|
||||
|
||||
@ -191,10 +191,7 @@ void PopupWindow::onInitTheme(InitThemeEvent& ev)
|
||||
{
|
||||
Widget::onInitTheme(ev);
|
||||
|
||||
this->border_width.l = 3 * guiscale();
|
||||
this->border_width.t = 3 * guiscale();
|
||||
this->border_width.r = 3 * guiscale();
|
||||
this->border_width.b = 3 * guiscale();
|
||||
setBorder(gfx::Border(3 * guiscale()));
|
||||
}
|
||||
|
||||
void PopupWindow::onHitTest(HitTestEvent& ev)
|
||||
|
@ -82,10 +82,10 @@ bool ScrollBar::onProcessMessage(Message* msg)
|
||||
x2 = getBounds().x2()-1;
|
||||
y2 = getBounds().y2()-1;
|
||||
|
||||
u1 = x1 + this->border_width.l;
|
||||
v1 = y1 + this->border_width.t;
|
||||
u2 = x2 - this->border_width.r;
|
||||
v2 = y2 - this->border_width.b;
|
||||
u1 = x1 + border().left();
|
||||
v1 = y1 + border().top();
|
||||
u2 = x2 - border().right();
|
||||
v2 = y2 - border().bottom();
|
||||
|
||||
Point scroll = view->getViewScroll();
|
||||
|
||||
@ -189,15 +189,15 @@ void ScrollBar::getScrollBarInfo(int *_pos, int *_len, int *_bar_size, int *_vie
|
||||
int pos, len;
|
||||
int border_width;
|
||||
|
||||
if (this->getAlign() & HORIZONTAL) {
|
||||
if (getAlign() & HORIZONTAL) {
|
||||
bar_size = getBounds().w;
|
||||
viewport_size = view->getVisibleSize().w;
|
||||
border_width = this->border_width.t + this->border_width.b;
|
||||
border_width = border().height();
|
||||
}
|
||||
else {
|
||||
bar_size = getBounds().h;
|
||||
viewport_size = view->getVisibleSize().h;
|
||||
border_width = this->border_width.l + this->border_width.r;
|
||||
border_width = border().width();
|
||||
}
|
||||
|
||||
if (m_size <= viewport_size) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// 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.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -48,8 +48,8 @@ void Separator::onPreferredSize(PreferredSizeEvent& ev)
|
||||
if (hasText())
|
||||
maxSize.w = MAX(maxSize.w, getTextWidth());
|
||||
|
||||
int w = this->border_width.l + maxSize.w + this->border_width.r;
|
||||
int h = this->border_width.t + maxSize.h + this->border_width.b;
|
||||
int w = maxSize.w + border().width();
|
||||
int h = maxSize.h + border().height();
|
||||
|
||||
ev.setPreferredSize(Size(w, h));
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// 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.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -204,8 +204,8 @@ void Slider::onPreferredSize(PreferredSizeEvent& ev)
|
||||
int w = MAX(min_w, max_w);
|
||||
int h = getTextHeight();
|
||||
|
||||
w += this->border_width.l + this->border_width.r;
|
||||
h += this->border_width.t + this->border_width.b;
|
||||
w += border().width();
|
||||
h += border().height();
|
||||
|
||||
ev.setPreferredSize(w, h);
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ void Splitter::onResize(ResizeEvent& ev)
|
||||
{
|
||||
#define LAYOUT_TWO_CHILDREN(x, y, w, h, l, t, r, b) \
|
||||
{ \
|
||||
avail = rc.w - this->child_spacing; \
|
||||
avail = rc.w - this->childSpacing(); \
|
||||
\
|
||||
pos.x = rc.x; \
|
||||
pos.y = rc.y; \
|
||||
@ -201,7 +201,7 @@ void Splitter::onResize(ResizeEvent& ev)
|
||||
child1->setBounds(pos); \
|
||||
gfx::Rect child1Pos = child1->getBounds(); \
|
||||
\
|
||||
pos.x = child1Pos.x + child1Pos.w + this->child_spacing; \
|
||||
pos.x = child1Pos.x + child1Pos.w + this->childSpacing(); \
|
||||
pos.y = rc.y; \
|
||||
pos.w = avail - child1Pos.w; \
|
||||
pos.h = rc.h; \
|
||||
@ -249,7 +249,7 @@ void Splitter::onPreferredSize(PreferredSizeEvent& ev)
|
||||
#define FINAL_SIZE(w) \
|
||||
do { \
|
||||
w *= visibleChildren; \
|
||||
w += this->child_spacing * (visibleChildren-1); \
|
||||
w += this->childSpacing() * (visibleChildren-1); \
|
||||
} while(0)
|
||||
|
||||
int visibleChildren;
|
||||
@ -283,8 +283,8 @@ void Splitter::onPreferredSize(PreferredSizeEvent& ev)
|
||||
FINAL_SIZE(h);
|
||||
}
|
||||
|
||||
w += this->border_width.l + this->border_width.r;
|
||||
h += this->border_width.t + this->border_width.b;
|
||||
w += border().width();
|
||||
h += border().height();
|
||||
|
||||
ev.setPreferredSize(Size(w, h));
|
||||
}
|
||||
|
@ -102,10 +102,10 @@ void drawTextBox(Graphics* g, Widget* widget,
|
||||
scroll = view->getViewScroll();
|
||||
}
|
||||
else {
|
||||
x1 = widget->getClientBounds().x + widget->border_width.l;
|
||||
y1 = widget->getClientBounds().y + widget->border_width.t;
|
||||
viewport_w = widget->getClientBounds().w - widget->border_width.l - widget->border_width.r;
|
||||
viewport_h = widget->getClientBounds().h - widget->border_width.t - widget->border_width.b;
|
||||
x1 = widget->getClientBounds().x + widget->border().left();
|
||||
y1 = widget->getClientBounds().y + widget->border().top();
|
||||
viewport_w = widget->getClientBounds().w - widget->border().width();
|
||||
viewport_h = widget->getClientBounds().h - widget->border().height();
|
||||
scroll.x = scroll.y = 0;
|
||||
}
|
||||
x2 = x1 + viewport_w;
|
||||
@ -224,8 +224,8 @@ void drawTextBox(Graphics* g, Widget* widget,
|
||||
if (h)
|
||||
*h = (y - y1 + scroll.y);
|
||||
|
||||
if (w) *w += widget->border_width.l + widget->border_width.r;
|
||||
if (h) *h += widget->border_width.t + widget->border_width.b;
|
||||
if (w) *w += widget->border().width();
|
||||
if (h) *h += widget->border().height();
|
||||
|
||||
// Fill bottom area
|
||||
if (g && y < y2)
|
||||
|
@ -225,11 +225,11 @@ void TipWindow::onPreferredSize(PreferredSizeEvent& ev)
|
||||
ScreenGraphics g;
|
||||
g.setFont(getFont());
|
||||
Size resultSize = g.fitString(getText(),
|
||||
(getClientBounds() - getBorder()).w,
|
||||
(getClientBounds() - border()).w,
|
||||
getAlign());
|
||||
|
||||
resultSize.w += this->border_width.l + this->border_width.r;
|
||||
resultSize.h += this->border_width.t + this->border_width.b;
|
||||
resultSize.w += border().width();
|
||||
resultSize.h += border().height();
|
||||
|
||||
if (!getChildren().empty()) {
|
||||
Size maxSize(0, 0);
|
||||
@ -244,7 +244,7 @@ void TipWindow::onPreferredSize(PreferredSizeEvent& ev)
|
||||
maxSize.h = MAX(maxSize.h, reqSize.h);
|
||||
}
|
||||
|
||||
resultSize.w = MAX(resultSize.w, border_width.l + maxSize.w + border_width.r);
|
||||
resultSize.w = MAX(resultSize.w, maxSize.w + border().width());
|
||||
resultSize.h += maxSize.h;
|
||||
}
|
||||
|
||||
@ -255,10 +255,11 @@ void TipWindow::onInitTheme(InitThemeEvent& ev)
|
||||
{
|
||||
Window::onInitTheme(ev);
|
||||
|
||||
this->border_width.l = 6 * guiscale();
|
||||
this->border_width.t = 6 * guiscale();
|
||||
this->border_width.r = 6 * guiscale();
|
||||
this->border_width.b = 7 * guiscale();
|
||||
setBorder(
|
||||
gfx::Border(6 * guiscale(),
|
||||
6 * guiscale(),
|
||||
6 * guiscale(),
|
||||
7 * guiscale()));
|
||||
|
||||
// Setup the background color.
|
||||
setBgColor(gfx::rgba(255, 255, 200));
|
||||
|
@ -60,17 +60,13 @@ void View::makeVisibleAllScrollableArea()
|
||||
|
||||
setMinSize(
|
||||
gfx::Size(
|
||||
+ this->border_width.l
|
||||
+ m_viewport.border_width.l
|
||||
+ reqSize.w
|
||||
+ m_viewport.border_width.r
|
||||
+ this->border_width.r,
|
||||
+ m_viewport.border().width()
|
||||
+ border().width(),
|
||||
|
||||
+ this->border_width.t
|
||||
+ m_viewport.border_width.t
|
||||
+ reqSize.h
|
||||
+ m_viewport.border_width.b
|
||||
+ this->border_width.b));
|
||||
+ m_viewport.border().height()
|
||||
+ border().height()));
|
||||
}
|
||||
|
||||
void View::hideScrollBars()
|
||||
@ -93,11 +89,11 @@ Size View::getScrollableSize()
|
||||
|
||||
void View::setScrollableSize(const Size& sz)
|
||||
{
|
||||
#define CHECK(w, h, l, t, r, b) \
|
||||
#define CHECK(w, h, width) \
|
||||
((sz.w > (m_viewport.getBounds().w \
|
||||
- m_viewport.border_width.l \
|
||||
- m_viewport.border_width.r)) && \
|
||||
(VBAR_SIZE < pos.w) && (HBAR_SIZE < pos.h))
|
||||
- m_viewport.border().width())) && \
|
||||
(VBAR_SIZE < pos.w) && \
|
||||
(HBAR_SIZE < pos.h))
|
||||
|
||||
m_scrollbar_h.setSize(sz.w);
|
||||
m_scrollbar_v.setSize(sz.h);
|
||||
@ -109,13 +105,13 @@ void View::setScrollableSize(const Size& sz)
|
||||
if (m_scrollbar_v.getParent()) removeChild(&m_scrollbar_v);
|
||||
|
||||
if (m_hasBars) {
|
||||
if (CHECK(w, h, l, t, r, b)) {
|
||||
if (CHECK(w, h, width)) {
|
||||
pos.h -= HBAR_SIZE;
|
||||
addChild(&m_scrollbar_h);
|
||||
|
||||
if (CHECK(h, w, t, l, b, r)) {
|
||||
if (CHECK(h, w, height)) {
|
||||
pos.w -= VBAR_SIZE;
|
||||
if (CHECK(w, h, l, t, r, b))
|
||||
if (CHECK(w, h, width))
|
||||
addChild(&m_scrollbar_v);
|
||||
else {
|
||||
pos.w += VBAR_SIZE;
|
||||
@ -124,13 +120,13 @@ void View::setScrollableSize(const Size& sz)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (CHECK(h, w, t, l, b, r)) {
|
||||
else if (CHECK(h, w, height)) {
|
||||
pos.w -= VBAR_SIZE;
|
||||
addChild(&m_scrollbar_v);
|
||||
|
||||
if (CHECK(w, h, l, t, r, b)) {
|
||||
if (CHECK(w, h, width)) {
|
||||
pos.h -= HBAR_SIZE;
|
||||
if (CHECK(h, w, t, l, b, r))
|
||||
if (CHECK(h, w, height))
|
||||
addChild(&m_scrollbar_h);
|
||||
else {
|
||||
pos.w += VBAR_SIZE;
|
||||
@ -163,8 +159,8 @@ void View::setScrollableSize(const Size& sz)
|
||||
|
||||
Size View::getVisibleSize()
|
||||
{
|
||||
return Size(m_viewport.getBounds().w - m_viewport.border_width.l - m_viewport.border_width.r,
|
||||
m_viewport.getBounds().h - m_viewport.border_width.t - m_viewport.border_width.b);
|
||||
return Size(m_viewport.getBounds().w - m_viewport.border().width(),
|
||||
m_viewport.getBounds().h - m_viewport.border().height());
|
||||
}
|
||||
|
||||
Point View::getViewScroll()
|
||||
@ -222,7 +218,7 @@ Viewport* View::getViewport()
|
||||
|
||||
Rect View::getViewportBounds()
|
||||
{
|
||||
return m_viewport.getBounds() - m_viewport.getBorder();
|
||||
return m_viewport.getBounds() - m_viewport.border();
|
||||
}
|
||||
|
||||
// static
|
||||
@ -265,8 +261,8 @@ void View::onResize(ResizeEvent& ev)
|
||||
void View::onPreferredSize(PreferredSizeEvent& ev)
|
||||
{
|
||||
Size viewSize = m_viewport.getPreferredSize();
|
||||
viewSize.w += this->border_width.l + this->border_width.r;
|
||||
viewSize.h += this->border_width.t + this->border_width.b;
|
||||
viewSize.w += border().width();
|
||||
viewSize.h += border().height();
|
||||
ev.setPreferredSize(viewSize);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// 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.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -35,20 +35,15 @@ void Viewport::onResize(ResizeEvent& ev)
|
||||
Point scroll = static_cast<View*>(this->getParent())->getViewScroll();
|
||||
|
||||
Rect cpos(0, 0, 0, 0);
|
||||
cpos.x = rect.x + this->border_width.l - scroll.x;
|
||||
cpos.y = rect.y + this->border_width.t - scroll.y;
|
||||
cpos.x = rect.x + border().left() - scroll.x;
|
||||
cpos.y = rect.y + border().top() - scroll.y;
|
||||
|
||||
UI_FOREACH_WIDGET(getChildren(), it) {
|
||||
Widget* child = *it;
|
||||
Size reqSize = child->getPreferredSize();
|
||||
|
||||
cpos.w = MAX(reqSize.w, rect.w
|
||||
- this->border_width.l
|
||||
- this->border_width.r);
|
||||
|
||||
cpos.h = MAX(reqSize.h, rect.h
|
||||
- this->border_width.t
|
||||
- this->border_width.b);
|
||||
cpos.w = MAX(reqSize.w, rect.w - border().width());
|
||||
cpos.h = MAX(reqSize.h, rect.h - border().height());
|
||||
|
||||
child->setBounds(cpos);
|
||||
}
|
||||
@ -56,8 +51,8 @@ void Viewport::onResize(ResizeEvent& ev)
|
||||
|
||||
void Viewport::onPreferredSize(PreferredSizeEvent& ev)
|
||||
{
|
||||
ev.setPreferredSize(gfx::Size(this->border_width.l + 1 + this->border_width.r,
|
||||
this->border_width.t + 1 + this->border_width.b));
|
||||
ev.setPreferredSize(gfx::Size(1 + border().width(),
|
||||
1 + border().height()));
|
||||
}
|
||||
|
||||
void Viewport::onPaint(PaintEvent& ev)
|
||||
|
@ -63,27 +63,20 @@ WidgetType register_widget_type()
|
||||
Widget::Widget(WidgetType type)
|
||||
: m_type(type)
|
||||
, m_flags(0)
|
||||
, m_theme(CurrentTheme::get())
|
||||
, m_align(0)
|
||||
, m_font(nullptr)
|
||||
, m_bgColor(gfx::ColorNone)
|
||||
, m_bounds(0, 0, 0, 0)
|
||||
, m_parent(nullptr)
|
||||
, m_preferredSize(nullptr)
|
||||
, m_doubleBuffered(false)
|
||||
, m_transparent(false)
|
||||
, m_minSize(0, 0)
|
||||
, m_maxSize(INT_MAX, INT_MAX)
|
||||
, m_childSpacing(0)
|
||||
{
|
||||
addWidget(this);
|
||||
|
||||
this->border_width.l = 0;
|
||||
this->border_width.t = 0;
|
||||
this->border_width.r = 0;
|
||||
this->border_width.b = 0;
|
||||
this->child_spacing = 0;
|
||||
this->m_parent = NULL;
|
||||
this->m_theme = CurrentTheme::get();
|
||||
|
||||
this->m_align = 0;
|
||||
this->m_font = nullptr;
|
||||
this->m_bgColor = gfx::ColorNone;
|
||||
|
||||
m_preferredSize = NULL;
|
||||
m_doubleBuffered = false;
|
||||
m_transparent = false;
|
||||
}
|
||||
|
||||
Widget::~Widget()
|
||||
@ -603,18 +596,18 @@ void Widget::setDecorativeWidgetBounds()
|
||||
|
||||
Rect Widget::getChildrenBounds() const
|
||||
{
|
||||
return Rect(m_bounds.x+border_width.l,
|
||||
m_bounds.y+border_width.t,
|
||||
m_bounds.w - border_width.l - border_width.r,
|
||||
m_bounds.h - border_width.t - border_width.b);
|
||||
return Rect(m_bounds.x + border().left(),
|
||||
m_bounds.y + border().top(),
|
||||
m_bounds.w - border().width(),
|
||||
m_bounds.h - border().height());
|
||||
}
|
||||
|
||||
Rect Widget::getClientChildrenBounds() const
|
||||
{
|
||||
return Rect(border_width.l,
|
||||
border_width.t,
|
||||
m_bounds.w - border_width.l - border_width.r,
|
||||
m_bounds.h - border_width.t - border_width.b);
|
||||
return Rect(border().left(),
|
||||
border().top(),
|
||||
m_bounds.w - border().width(),
|
||||
m_bounds.h - border().height());
|
||||
}
|
||||
|
||||
void Widget::setBounds(const Rect& rc)
|
||||
@ -629,26 +622,20 @@ void Widget::setBoundsQuietly(const gfx::Rect& rc)
|
||||
m_bounds = rc;
|
||||
}
|
||||
|
||||
Border Widget::getBorder() const
|
||||
{
|
||||
return Border(border_width.l, border_width.t, border_width.r, border_width.b);
|
||||
}
|
||||
|
||||
void Widget::setBorder(const Border& br)
|
||||
{
|
||||
border_width.l = br.left();
|
||||
border_width.t = br.top();
|
||||
border_width.r = br.right();
|
||||
border_width.b = br.bottom();
|
||||
m_border = br;
|
||||
}
|
||||
|
||||
void Widget::setChildSpacing(int childSpacing)
|
||||
{
|
||||
m_childSpacing = childSpacing;
|
||||
}
|
||||
|
||||
void Widget::noBorderNoChildSpacing()
|
||||
{
|
||||
border_width.l = 0;
|
||||
border_width.t = 0;
|
||||
border_width.r = 0;
|
||||
border_width.b = 0;
|
||||
child_spacing = 0;
|
||||
m_border = gfx::Border(0, 0, 0, 0);
|
||||
m_childSpacing = 0;
|
||||
}
|
||||
|
||||
void Widget::getRegion(gfx::Region& region)
|
||||
@ -804,29 +791,29 @@ void Widget::getTextIconInfo(
|
||||
/* with the icon in the top or bottom */
|
||||
else {
|
||||
box_w = MAX(icon_w, text_w);
|
||||
box_h = icon_h + (hasText() ? child_spacing: 0) + text_h;
|
||||
box_h = icon_h + (hasText() ? childSpacing(): 0) + text_h;
|
||||
}
|
||||
}
|
||||
/* with the icon in left or right that doesn't care by now */
|
||||
else {
|
||||
box_w = icon_w + (hasText() ? child_spacing: 0) + text_w;
|
||||
box_w = icon_w + (hasText() ? childSpacing(): 0) + text_w;
|
||||
box_h = MAX(icon_h, text_h);
|
||||
}
|
||||
|
||||
/* box position */
|
||||
if (getAlign() & RIGHT)
|
||||
box_x = bounds.x2() - box_w - border_width.r;
|
||||
box_x = bounds.x2() - box_w - border().right();
|
||||
else if (getAlign() & CENTER)
|
||||
box_x = (bounds.x+bounds.x2())/2 - box_w/2;
|
||||
else
|
||||
box_x = bounds.x + border_width.l;
|
||||
box_x = bounds.x + border().left();
|
||||
|
||||
if (getAlign() & BOTTOM)
|
||||
box_y = bounds.y2() - box_h - border_width.b;
|
||||
box_y = bounds.y2() - box_h - border().bottom();
|
||||
else if (getAlign() & MIDDLE)
|
||||
box_y = (bounds.y+bounds.y2())/2 - box_h/2;
|
||||
else
|
||||
box_y = bounds.y + border_width.t;
|
||||
box_y = bounds.y + border().top();
|
||||
|
||||
// With text
|
||||
if (hasText()) {
|
||||
|
@ -43,12 +43,6 @@ namespace ui {
|
||||
class Window;
|
||||
|
||||
class Widget : public Component {
|
||||
public:
|
||||
struct {
|
||||
int l, t, r, b;
|
||||
} border_width; // Border separation with the parent
|
||||
int child_spacing; // Separation between children
|
||||
|
||||
public:
|
||||
|
||||
// ===============================================================
|
||||
@ -258,9 +252,12 @@ namespace ui {
|
||||
void setMinSize(const gfx::Size& sz);
|
||||
void setMaxSize(const gfx::Size& sz);
|
||||
|
||||
gfx::Border getBorder() const;
|
||||
const gfx::Border& border() const { return m_border; }
|
||||
void setBorder(const gfx::Border& border);
|
||||
|
||||
int childSpacing() const { return m_childSpacing; }
|
||||
void setChildSpacing(int childSpacing);
|
||||
|
||||
void noBorderNoChildSpacing();
|
||||
|
||||
// Flags for getDrawableRegion()
|
||||
@ -396,6 +393,9 @@ namespace ui {
|
||||
|
||||
// Widget size limits
|
||||
gfx::Size m_minSize, m_maxSize;
|
||||
|
||||
gfx::Border m_border; // Border separation with the parent
|
||||
int m_childSpacing; // Separation between children
|
||||
};
|
||||
|
||||
WidgetType register_widget_type();
|
||||
|
@ -135,7 +135,7 @@ void Window::onHitTest(HitTestEvent& ev)
|
||||
if ((hasText())
|
||||
&& (((x >= cpos.x) &&
|
||||
(x < cpos.x2()) &&
|
||||
(y >= pos.y+this->border_width.b) &&
|
||||
(y >= pos.y+border().bottom()) &&
|
||||
(y < cpos.y)))) {
|
||||
ht = HitTestCaption;
|
||||
}
|
||||
@ -449,8 +449,8 @@ void Window::onPreferredSize(PreferredSizeEvent& ev)
|
||||
if (hasText())
|
||||
maxSize.w = MAX(maxSize.w, getTextWidth());
|
||||
|
||||
ev.setPreferredSize(this->border_width.l + maxSize.w + this->border_width.r,
|
||||
this->border_width.t + maxSize.h + this->border_width.b);
|
||||
ev.setPreferredSize(maxSize.w + border().width(),
|
||||
maxSize.h + border().height());
|
||||
}
|
||||
}
|
||||
|
||||
@ -498,10 +498,10 @@ void Window::windowSetPosition(const gfx::Rect& rect)
|
||||
onWindowResize();
|
||||
}
|
||||
|
||||
void Window::limitSize(int *w, int *h)
|
||||
void Window::limitSize(int* w, int* h)
|
||||
{
|
||||
*w = MAX(*w, this->border_width.l+this->border_width.r);
|
||||
*h = MAX(*h, this->border_width.t+this->border_width.b);
|
||||
*w = MAX(*w, border().width());
|
||||
*h = MAX(*h, border().height());
|
||||
}
|
||||
|
||||
void Window::moveWindow(const gfx::Rect& rect, bool use_blit)
|
||||
|
Loading…
x
Reference in New Issue
Block a user