mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-01 09:04:02 +00:00
Fix alignment of several controls when UI scaling is 200% and Screen scaling is 100% to make them look the same as when US scaling is 100% and Screen scaling is 200%
This commit is contained in:
parent
af043a0c9f
commit
7a338250a3
@ -668,7 +668,7 @@
|
||||
<icon part="pal_options" />
|
||||
</style>
|
||||
<style id="new_frame_button" extends="mini_button" />
|
||||
<style id="color_button" extends="mini_button" border="5" font="mini" />
|
||||
<style id="color_button" extends="mini_button" font="mini" padding-bottom="1" />
|
||||
<style id="splitter">
|
||||
<background color="face" />
|
||||
</style>
|
||||
|
@ -323,8 +323,8 @@ void ToolBar::onPaint(ui::PaintEvent& ev)
|
||||
os::Surface* icon = theme->getToolIcon(tool->getId().c_str());
|
||||
if (icon) {
|
||||
g->drawRgbaSurface(icon,
|
||||
toolrc.x+toolrc.w/2-icon->width()/2,
|
||||
toolrc.y+toolrc.h/2-icon->height()/2);
|
||||
CALC_FOR_CENTER(toolrc.x, toolrc.w, icon->width()),
|
||||
CALC_FOR_CENTER(toolrc.y, toolrc.h, icon->height()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -342,8 +342,8 @@ void ToolBar::onPaint(ui::PaintEvent& ev)
|
||||
os::Surface* icon = theme->getToolIcon("minieditor");
|
||||
if (icon) {
|
||||
g->drawRgbaSurface(icon,
|
||||
toolrc.x+toolrc.w/2-icon->width()/2,
|
||||
toolrc.y+toolrc.h/2-icon->height()/2);
|
||||
CALC_FOR_CENTER(toolrc.x, toolrc.w, icon->width()),
|
||||
CALC_FOR_CENTER(toolrc.y, toolrc.h, icon->height()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -415,7 +415,7 @@ void ToolBar::openPopupWindow(int group_index, ToolGroup* tool_group)
|
||||
|
||||
for (Tool* tool : *toolbox) {
|
||||
if (tool->getGroup() == tool_group)
|
||||
w += bounds().w-border().width()-1;
|
||||
w += bounds().w-border().width()-1*guiscale();
|
||||
}
|
||||
|
||||
rc.x -= w;
|
||||
@ -722,8 +722,8 @@ void ToolBar::ToolStrip::onPaint(PaintEvent& ev)
|
||||
if (icon) {
|
||||
g->drawRgbaSurface(
|
||||
icon,
|
||||
toolrc.x+toolrc.w/2-icon->width()/2,
|
||||
toolrc.y+toolrc.h/2-icon->height()/2);
|
||||
CALC_FOR_CENTER(toolrc.x, toolrc.w, icon->width()),
|
||||
CALC_FOR_CENTER(toolrc.y, toolrc.h, icon->height()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -734,7 +734,7 @@ Rect ToolBar::ToolStrip::getToolBounds(int index)
|
||||
const Rect& bounds(this->bounds());
|
||||
Size iconsize = getToolIconSize(this);
|
||||
|
||||
return Rect(bounds.x+index*(iconsize.w-1), bounds.y,
|
||||
return Rect(bounds.x+index*(iconsize.w-1*guiscale()), bounds.y,
|
||||
iconsize.w, bounds.h);
|
||||
}
|
||||
|
||||
|
@ -545,7 +545,7 @@ gfx::Rect Entry::onGetEntryTextBounds() const
|
||||
{
|
||||
gfx::Rect bounds = clientBounds();
|
||||
bounds.x += border().left();
|
||||
bounds.y += bounds.h/2 - textHeight()/2;
|
||||
bounds.y += CALC_FOR_CENTER(0, bounds.h, textHeight());
|
||||
bounds.w -= border().width();
|
||||
bounds.h = textHeight();
|
||||
return bounds;
|
||||
|
@ -462,8 +462,7 @@ void Theme::paintLayer(Graphics* g,
|
||||
else if (layer.align() & RIGHT)
|
||||
pt.x = rc.x+rc.w-textSize.w-padding.right();
|
||||
else {
|
||||
pt.x = rc.x+padding.left()+(rc.w-padding.width())/2-textSize.w/2;
|
||||
ADJUST_TO_GUISCALE(pt.x);
|
||||
pt.x = CALC_FOR_CENTER(rc.x+padding.left(), rc.w-padding.width(), textSize.w);
|
||||
}
|
||||
|
||||
if (layer.align() & TOP)
|
||||
@ -471,8 +470,7 @@ void Theme::paintLayer(Graphics* g,
|
||||
else if (layer.align() & BOTTOM)
|
||||
pt.y = rc.y+rc.h-textSize.h-padding.bottom();
|
||||
else {
|
||||
pt.y = rc.y+padding.top()+(rc.h-padding.height())/2-textSize.h/2;
|
||||
ADJUST_TO_GUISCALE(pt.y);
|
||||
pt.y = CALC_FOR_CENTER(rc.y+padding.top(), rc.h-padding.height(), textSize.h);
|
||||
}
|
||||
|
||||
pt += layer.offset();
|
||||
@ -505,8 +503,7 @@ void Theme::paintLayer(Graphics* g,
|
||||
else if (layer.align() & RIGHT)
|
||||
pt.x = rc.x+rc.w-iconSize.w-padding.right();
|
||||
else {
|
||||
pt.x = rc.x+padding.left()+(rc.w-padding.width())/2-iconSize.w/2;
|
||||
ADJUST_TO_GUISCALE(pt.x);
|
||||
pt.x = CALC_FOR_CENTER(rc.x+padding.left(), rc.w-padding.width(), iconSize.w);
|
||||
}
|
||||
|
||||
if (layer.align() & TOP)
|
||||
@ -514,8 +511,7 @@ void Theme::paintLayer(Graphics* g,
|
||||
else if (layer.align() & BOTTOM)
|
||||
pt.y = rc.y+rc.h-iconSize.h-padding.bottom();
|
||||
else {
|
||||
pt.y = rc.y+padding.top()+(rc.h-padding.height())/2-iconSize.h/2;
|
||||
ADJUST_TO_GUISCALE(pt.y);
|
||||
pt.y = CALC_FOR_CENTER(rc.y+padding.top(), rc.h-padding.height(), iconSize.h);
|
||||
}
|
||||
|
||||
pt += layer.offset();
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "ui/style.h"
|
||||
#include "ui/scale.h"
|
||||
|
||||
#define ADJUST_TO_GUISCALE(v) v -= (v % guiscale());
|
||||
#define CALC_FOR_CENTER(p, s1, s2) ((p)/guiscale() + ((s1)/guiscale())/2 - ((s2)/guiscale())/2)*guiscale()
|
||||
|
||||
namespace gfx {
|
||||
class Region;
|
||||
|
@ -973,10 +973,7 @@ void Widget::getTextIconInfo(
|
||||
if (align() & RIGHT)
|
||||
box_x = bounds.x2() - box_w - border().right();
|
||||
else if (align() & CENTER) {
|
||||
box_x = (bounds.x + bounds.x2() - box_w) / 2;
|
||||
// Adjust position when it is not a multiple of guiscale. Without these adjustements
|
||||
// it could happen that an icon or text is displayed a in a fraction of a scaled pixel.
|
||||
ADJUST_TO_GUISCALE(box_x);
|
||||
box_x = CALC_FOR_CENTER(bounds.x + border().top(), bounds.w - border().width(), box_w);
|
||||
}
|
||||
else
|
||||
box_x = bounds.x + border().left();
|
||||
@ -984,9 +981,7 @@ void Widget::getTextIconInfo(
|
||||
if (align() & BOTTOM)
|
||||
box_y = bounds.y2() - box_h - border().bottom();
|
||||
else if (align() & MIDDLE) {
|
||||
box_y = (bounds.y + bounds.y2() - box_h) / 2;
|
||||
// Adjust position when it is not a multiple of guiscale
|
||||
ADJUST_TO_GUISCALE(box_y);
|
||||
box_y = CALC_FOR_CENTER(bounds.y + border().left(), bounds.h - border().height(), box_h);
|
||||
}
|
||||
else
|
||||
box_y = bounds.y + border().top();
|
||||
@ -999,11 +994,8 @@ void Widget::getTextIconInfo(
|
||||
icon_x = box_x + box_w - icon_w;
|
||||
}
|
||||
else if (icon_align & CENTER) {
|
||||
text_x = box_x + (box_w - text_w)/2;
|
||||
icon_x = box_x + (box_w - icon_w)/2;
|
||||
// Adjust position when it is not a multiple of guiscale
|
||||
ADJUST_TO_GUISCALE(text_x);
|
||||
ADJUST_TO_GUISCALE(icon_x);
|
||||
text_x = CALC_FOR_CENTER(box_x, box_w, text_w);
|
||||
icon_x = CALC_FOR_CENTER(box_x, box_w, icon_w);
|
||||
}
|
||||
else {
|
||||
text_x = box_x + box_w - text_w;
|
||||
@ -1016,11 +1008,8 @@ void Widget::getTextIconInfo(
|
||||
icon_y = box_y + box_h - icon_h;
|
||||
}
|
||||
else if (icon_align & MIDDLE) {
|
||||
text_y = box_y + (box_h - text_h)/2;
|
||||
icon_y = box_y + (box_h - icon_h)/2;
|
||||
// Adjust position when it is not a multiple of guiscale
|
||||
ADJUST_TO_GUISCALE(text_y);
|
||||
ADJUST_TO_GUISCALE(icon_y);
|
||||
text_y = CALC_FOR_CENTER(box_y, box_h, text_h);
|
||||
icon_y = CALC_FOR_CENTER(box_y, box_h, icon_h);
|
||||
}
|
||||
else {
|
||||
text_y = box_y + box_h - text_h;
|
||||
|
Loading…
Reference in New Issue
Block a user