diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-22 16:13:43 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-22 16:13:43 (GMT) |
| commit | e38fd405af5f07667203c6f584a5cdb00ed20ca2 (patch) | |
| tree | f5630c0e43cb848bb36a29c0d20599dcc324161c /src/interface | |
| parent | 553cf6552070aae93e1db031b57afdc8c9ba19e0 (diff) | |
| download | powder-e38fd405af5f07667203c6f584a5cdb00ed20ca2.zip powder-e38fd405af5f07667203c6f584a5cdb00ed20ca2.tar.gz | |
Correct quirks with drawrect and fillrect, change UI components accordingly, shorten save name in save button
Diffstat (limited to 'src/interface')
| -rw-r--r-- | src/interface/Button.cpp | 10 | ||||
| -rw-r--r-- | src/interface/Checkbox.cpp | 4 | ||||
| -rw-r--r-- | src/interface/SaveButton.cpp | 21 | ||||
| -rw-r--r-- | src/interface/SaveButton.h | 1 |
4 files changed, 25 insertions, 11 deletions
diff --git a/src/interface/Button.cpp b/src/interface/Button.cpp index 5444cdc..3bf302b 100644 --- a/src/interface/Button.cpp +++ b/src/interface/Button.cpp @@ -45,6 +45,8 @@ void Button::TextPosition() buttonDisplayText += "..."; } } + + // Values 3 and 10 are for vertical padding of 3 pixels, middle uses 7 as that's the height of a capital switch(textVAlign) { case AlignTop: @@ -54,7 +56,7 @@ void Button::TextPosition() textPosition.Y = (Size.Y-10)/2; break; case AlignBottom: - textPosition.Y = Size.Y-12; + textPosition.Y = Size.Y-10; break; } @@ -131,20 +133,20 @@ void Button::Draw(const Point& screenPos) { if(isButtonDown || (isTogglable && toggle)) { - g->fillrect(Position.X-1, Position.Y-1, Size.X+2, Size.Y+2, activeBackground.Red, activeBackground.Green, activeBackground.Blue, 255); + g->fillrect(Position.X+1, Position.Y+1, Size.X-2, Size.Y-2, activeBackground.Red, activeBackground.Green, activeBackground.Blue, 255); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, activeBorder.Red, activeBorder.Green, activeBorder.Blue, 255); g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y+1, buttonDisplayText, activeText.Red, activeText.Green, activeText.Blue, 255); } else { - g->fillrect(Position.X, Position.Y, Size.X, Size.Y, background.Red, background.Green, background.Blue, 255); + g->fillrect(Position.X+1, Position.Y+1, Size.X-2, Size.Y-2, background.Red, background.Green, background.Blue, 255); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, border.Red, border.Green, border.Blue, 255); g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y+1, buttonDisplayText, text.Red, text.Green, text.Blue, 255); } } else { - g->fillrect(Position.X, Position.Y, Size.X, Size.Y, background.Red, background.Green, background.Blue, 180); + g->fillrect(Position.X+1, Position.Y+1, Size.X-2, Size.Y-2, background.Red, background.Green, background.Blue, 180); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 180, 180, 180, 255); g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y+1, buttonDisplayText, 180, 180, 180, 255); } diff --git a/src/interface/Checkbox.cpp b/src/interface/Checkbox.cpp index 3244552..2481b23 100644 --- a/src/interface/Checkbox.cpp +++ b/src/interface/Checkbox.cpp @@ -60,12 +60,12 @@ void Checkbox::Draw(const Point& screenPos) Graphics * g = Engine::Ref().g; if(checked) { - g->fillrect(screenPos.X+4, screenPos.Y+4, 8, 8, 255, 255, 255, 255); + g->fillrect(screenPos.X+5, screenPos.Y+5, 6, 6, 255, 255, 255, 255); } if(isMouseOver) { g->drawrect(screenPos.X+2, screenPos.Y+2, 12, 12, 255, 255, 255, 255); - g->fillrect(screenPos.X+4, screenPos.Y+4, 8, 8, 255, 255, 255, 170); + g->fillrect(screenPos.X+5, screenPos.Y+5, 6, 6, 255, 255, 255, 170); g->drawtext(screenPos.X+18, screenPos.Y+4, text, 255, 255, 255, 255); } else diff --git a/src/interface/SaveButton.cpp b/src/interface/SaveButton.cpp index 6e08e95..0848ff5 100644 --- a/src/interface/SaveButton.cpp +++ b/src/interface/SaveButton.cpp @@ -37,6 +37,17 @@ SaveButton::SaveButton(Point position, Point size, Save * save): voteColour.Red = (1.0f-voteRatio)*255; voteColour.Green = voteRatio*255; } + + if(save) + { + name = save->name; + if(Graphics::textwidth((char *)name.c_str()) > Size.X) + { + int position = Graphics::textwidthx((char *)name.c_str(), Size.X - 22); + name = name.erase(position, name.length()-position); + name += "..."; + } + } } SaveButton::~SaveButton() @@ -122,10 +133,10 @@ void SaveButton::Draw(const Point& screenPos) g->drawrect(screenPos.X-3+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, thumbBoxSize.X, thumbBoxSize.Y, 210, 230, 255, 255); else g->drawrect(screenPos.X-3+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, thumbBoxSize.X, thumbBoxSize.Y, 180, 180, 180, 255); - g->drawrect(screenPos.X-3+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, 6, thumbBoxSize.Y, 180, 180, 180, 255); + g->drawrect(screenPos.X-4+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, 7, thumbBoxSize.Y, 180, 180, 180, 255); - int voteBar = max(10.0f, ((float)(thumbBoxSize.Y-2))*voteRatio); - g->fillrect(1+screenPos.X-3+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, 1+(screenPos.Y-2)+(thumbBoxSize.Y-voteBar)+(Size.Y-21-thumbBoxSize.Y)/2, 4, voteBar, voteColour.Red, voteColour.Green, voteColour.Blue, 255); + int voteBar = max(10.0f, ((float)(thumbBoxSize.Y-4))*voteRatio); + g->fillrect(1+screenPos.X-3+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, (screenPos.Y-2)+(thumbBoxSize.Y-voteBar)+(Size.Y-21-thumbBoxSize.Y)/2, 3, voteBar, voteColour.Red, voteColour.Green, voteColour.Blue, 255); } else { @@ -138,12 +149,12 @@ void SaveButton::Draw(const Point& screenPos) if(isMouseInside) { //g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 255, 255, 255, 255); - g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)save->name.c_str()))/2, screenPos.Y+Size.Y - 21, save->name, 255, 255, 255, 255); + g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)name.c_str()))/2, screenPos.Y+Size.Y - 21, name, 255, 255, 255, 255); g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)save->userName.c_str()))/2, screenPos.Y+Size.Y - 10, save->userName, 200, 230, 255, 255); } else { - g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)save->name.c_str()))/2, screenPos.Y+Size.Y - 21, save->name, 180, 180, 180, 255); + g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)name.c_str()))/2, screenPos.Y+Size.Y - 21, name, 180, 180, 180, 255); g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)save->userName.c_str()))/2, screenPos.Y+Size.Y - 10, save->userName, 100, 130, 160, 255); } } diff --git a/src/interface/SaveButton.h b/src/interface/SaveButton.h index de1b6ed..f456639 100644 --- a/src/interface/SaveButton.h +++ b/src/interface/SaveButton.h @@ -24,6 +24,7 @@ class SaveButton : public Component { Save * save; Thumbnail * thumbnail; + std::string name; public: SaveButton(Point position, Point size, Save * save); virtual ~SaveButton(); |
