mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 19:13:43 +00:00
Fix problem resizing splitters with pixel-based position outside its own bounds (fix #663)
This commit is contained in:
parent
cc2a5e8cc5
commit
7b1b667a8a
@ -36,10 +36,8 @@ Splitter::Splitter(Type type, int align)
|
||||
|
||||
void Splitter::setPosition(double pos)
|
||||
{
|
||||
if (m_type == ByPercentage)
|
||||
m_pos = MID(0, pos, 100);
|
||||
else
|
||||
m_pos = pos;
|
||||
m_pos = pos;
|
||||
limitPos();
|
||||
|
||||
invalidate();
|
||||
}
|
||||
@ -101,7 +99,6 @@ bool Splitter::onProcessMessage(Message* msg)
|
||||
switch (m_type) {
|
||||
case ByPercentage:
|
||||
m_pos = 100.0 * (mousePos.x - getBounds().x) / getBounds().w;
|
||||
m_pos = MID(0, m_pos, 100);
|
||||
break;
|
||||
case ByPixel:
|
||||
m_pos = mousePos.x - getBounds().x;
|
||||
@ -111,15 +108,15 @@ bool Splitter::onProcessMessage(Message* msg)
|
||||
else {
|
||||
switch (m_type) {
|
||||
case ByPercentage:
|
||||
m_pos = 100.0 * (mousePos.y-getBounds().y) / getBounds().h;
|
||||
m_pos = MID(0, m_pos, 100);
|
||||
m_pos = 100.0 * (mousePos.y - getBounds().y) / getBounds().h;
|
||||
break;
|
||||
case ByPixel:
|
||||
m_pos = (mousePos.y-getBounds().y);
|
||||
m_pos = mousePos.y - getBounds().y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
limitPos();
|
||||
layout();
|
||||
return true;
|
||||
}
|
||||
@ -217,6 +214,7 @@ void Splitter::onResize(ResizeEvent& ev)
|
||||
int avail;
|
||||
|
||||
setBoundsQuietly(rc);
|
||||
limitPos();
|
||||
|
||||
Widget* child1 = panel1();
|
||||
Widget* child2 = panel2();
|
||||
@ -331,4 +329,28 @@ Widget* Splitter::panel2() const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Splitter::limitPos()
|
||||
{
|
||||
if (getAlign() & JI_HORIZONTAL) {
|
||||
switch (m_type) {
|
||||
case ByPercentage:
|
||||
m_pos = MID(0, m_pos, 100);
|
||||
break;
|
||||
case ByPixel:
|
||||
m_pos = MID(0, m_pos, getBounds().w);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (m_type) {
|
||||
case ByPercentage:
|
||||
m_pos = MID(0, m_pos, 100);
|
||||
break;
|
||||
case ByPixel:
|
||||
m_pos = MID(0, m_pos, getBounds().h);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
|
@ -34,6 +34,7 @@ namespace ui {
|
||||
private:
|
||||
Widget* panel1() const;
|
||||
Widget* panel2() const;
|
||||
void limitPos();
|
||||
|
||||
Type m_type;
|
||||
double m_pos;
|
||||
|
Loading…
x
Reference in New Issue
Block a user