diff --git a/src/console/piscreentiles.cpp b/src/console/piscreentiles.cpp index 7c1d18a9..6f60c333 100644 --- a/src/console/piscreentiles.cpp +++ b/src/console/piscreentiles.cpp @@ -260,6 +260,7 @@ bool TileButton::keyEvent(PIKbdListener::KeyEvent key) { TileButtons::TileButtons(const PIString & n): PIScreenTile(n) { focus_flags = CanHasFocus | NextByTab; direction = Horizontal; + alignment = PIScreenTypes::Center; cur = 0; } @@ -281,7 +282,16 @@ void TileButtons::sizeHint(int & w, int & h) const { void TileButtons::drawEvent(PIScreenDrawer * d) { - int cx = x, cy = y; + int cx = x, cy = y, shw, shh; + sizeHint(shw, shh); + int dx = 0; + switch (alignment) { + case PIScreenTypes::Center: dx = (width - shw) / 2; break; + case PIScreenTypes::Right: dx = width - shw; break; + default: break; + } + if (direction == PIScreenTypes::Horizontal) + cx += dx; for (int i = 0; i < content.size_s(); ++i) { Color cb = Cyan; Color ct = Black; diff --git a/src/console/piscreentiles.h b/src/console/piscreentiles.h index e338b905..d531bc7d 100644 --- a/src/console/piscreentiles.h +++ b/src/console/piscreentiles.h @@ -93,12 +93,13 @@ public: ButtonSelected }; typedef PIPair Button; + PIScreenTypes::Alignment alignment; PIVector