mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-30 06:32:42 +00:00
Fix ui::Alert buttons center alignment
This bug was introduced in 4a6d6951e3f22964a3c84171f0ca8643b454c5ab
This commit is contained in:
parent
a30b7c5217
commit
5d0d609a3f
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2001-2013, 2015 David Capello
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -129,8 +129,6 @@ int Alert::show(const char* format, ...)
|
||||
|
||||
void Alert::processString(char* buf, std::vector<Widget*>& labels, std::vector<Widget*>& buttons)
|
||||
{
|
||||
Box* box1, *box2, *box3, *box4, *box5;
|
||||
Grid* grid;
|
||||
bool title = true;
|
||||
bool label = false;
|
||||
bool separator = false;
|
||||
@ -200,18 +198,18 @@ void Alert::processString(char* buf, std::vector<Widget*>& labels, std::vector<W
|
||||
}
|
||||
}
|
||||
|
||||
box1 = new Box(VERTICAL);
|
||||
box2 = new Box(VERTICAL);
|
||||
grid = new Grid(1, false);
|
||||
box3 = new Box(HORIZONTAL | HOMOGENEOUS);
|
||||
auto box1 = new Box(VERTICAL);
|
||||
auto box2 = new Box(VERTICAL);
|
||||
auto grid = new Grid(1, false);
|
||||
auto box3 = new Box(HORIZONTAL | HOMOGENEOUS);
|
||||
|
||||
// To identify by the user
|
||||
box2->setId("labels");
|
||||
box3->setId("buttons");
|
||||
|
||||
// Pseudo separators (only to fill blank space)
|
||||
box4 = new Box(0);
|
||||
box5 = new Box(0);
|
||||
auto box4 = new Box(0);
|
||||
auto box5 = new Box(0);
|
||||
m_progressPlaceholder = new Box(0);
|
||||
|
||||
box4->setExpansive(true);
|
||||
@ -230,7 +228,7 @@ void Alert::processString(char* buf, std::vector<Widget*>& labels, std::vector<W
|
||||
box1->addChild(box5); // Filler
|
||||
box1->addChild(grid); // Buttons
|
||||
|
||||
grid->addChildInCell(box3, 1, 1, CENTER | BOTTOM);
|
||||
grid->addChildInCell(box3, 1, 1, CENTER | BOTTOM | HORIZONTAL);
|
||||
|
||||
for (std::vector<Widget*>::iterator it = labels.begin(); it != labels.end(); ++it)
|
||||
box2->addChild(*it);
|
||||
|
@ -306,3 +306,24 @@ TEST(Grid, ReduceThree)
|
||||
EXPECT_EQ(gfx::Rect(0, 4, 10, 4), b.bounds());
|
||||
EXPECT_EQ(gfx::Rect(0, 8, 10, 4), c.bounds());
|
||||
}
|
||||
|
||||
TEST(Grid, Alignment)
|
||||
{
|
||||
Grid grid(1, false);
|
||||
grid.noBorderNoChildSpacing();
|
||||
|
||||
Widget a;
|
||||
a.setMinSize(gfx::Size(10, 10));
|
||||
|
||||
grid.addChildInCell(&a, 1, 1, CENTER | BOTTOM | HORIZONTAL | VERTICAL);
|
||||
|
||||
Size reqSize = grid.sizeHint();
|
||||
EXPECT_EQ(10, reqSize.w);
|
||||
EXPECT_EQ(10, reqSize.h);
|
||||
|
||||
grid.setBounds(gfx::Rect(10, 10, 40, 10));
|
||||
EXPECT_EQ(gfx::Rect(25, 10, 10, 10), a.bounds());
|
||||
|
||||
grid.setBounds(gfx::Rect(10, 10, 60, 20));
|
||||
EXPECT_EQ(gfx::Rect(35, 20, 10, 10), a.bounds());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user