Updated ScrollBarWidget

Refined LauncherDialog
Added missing Ellipsis to StellaFont.hxx
This commit is contained in:
thrust26 2018-01-24 20:53:00 +01:00
parent 97553b9d93
commit d179b8ebe8
10 changed files with 179 additions and 92 deletions

View File

@ -993,6 +993,7 @@ void FrameBuffer::VideoModeList::setZoom(uInt32 zoom)
*** UI elements (dialog and widgets) ***
kDlgColor Dialog background
kWidColor Widget background
kWidColorHi Widget highlight color
kWidFrameColor Border for currently selected widget
*** Button colors ***
kBtnColor Normal button background
@ -1021,7 +1022,7 @@ uInt32 FrameBuffer::ourGUIColors[3][kNumColors-256] = {
// Standard
{ 0x686868, 0x000000, 0xa38c61, 0xdccfa5, 0x404040, // base
0x000000, 0x62a108, 0x9f0000, 0x000000, // text
0xc9af7c, 0xf0f0cf, 0xc80000, // elements
0xc9af7c, 0xf0f0cf, 0xd55941, 0xc80000, // UI elements
0xac3410, 0xd55941, 0xffffff, 0xffd652, // buttons
0xac3410, // checkbox
0xac3410, 0xd55941, // scrollbar
@ -1032,7 +1033,7 @@ uInt32 FrameBuffer::ourGUIColors[3][kNumColors-256] = {
// Classic
{ 0x686868, 0x000000, 0x404040, 0x404040, 0x404040, // base
0x20a020, 0x00ff00, 0xc80000, 0x20a020, // text
0x000000, 0x000000, 0xc80000, // elements
0x000000, 0x000000, 0x00ff00, 0xc80000, // UI elements
0x000000, 0x000000, 0x20a020, 0x00ff00, // buttons
0x20a020, // checkbox
0x20a020, 0x00ff00, // scrollbar
@ -1044,10 +1045,10 @@ uInt32 FrameBuffer::ourGUIColors[3][kNumColors-256] = {
{
0x808080, 0x000000, 0xc0c0c0, 0xe1e1e1, 0x333333, // base
0x000000, 0x0078d7, 0x0078d7, 0xffffff, // text
0xf0f0f0, 0xffffff, 0x0f0f0f, // elements
0xf0f0f0, 0xffffff, 0x0078d7, 0x0f0f0f, // UI elements
0xe1e1e1, 0xe5f1fb, 0x000000, 0x000000, // buttons
0x333333, // checkbox
0x808080, 0x0078d7, // scrollbar
0xc0c0c0, 0x808080, // scrollbar
0x333333, 0x0078d7, // slider
0xffc0c0, 0x000000, 0xe00000, 0xc00000, // debugger
0xffffff, 0x808080, 0xffffff // other

View File

@ -53,6 +53,7 @@ enum {
kTextColorInv,
kDlgColor,
kWidColor,
kWidColorHi,
kWidFrameColor,
kBtnColor,
kBtnColorHi,

View File

@ -54,21 +54,22 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
myRomInfoWidget(nullptr),
mySelectedItem(0)
{
const string ELLIPSIS = "\x1d";
const GUI::Font& font = instance().frameBuffer().launcherFont();
const int fontWidth = font.getMaxCharWidth(),
fontHeight = font.getFontHeight(),
lineHeight = font.getLineHeight(),
bwidth = (_w - 2 * 10 - 8 * (4 - 1)) / 4,
bheight = font.getLineHeight() + 4;
bheight = lineHeight + 4;
int xpos = 0, ypos = 0, lwidth = 0, lwidth2 = 0;
WidgetArray wid;
// Show game name
lwidth = font.getStringWidth("Select an item from the list ...");
lwidth = font.getStringWidth("Select a ROM from the list" + ELLIPSIS);
xpos += 10; ypos += 8;
new StaticTextWidget(this, font, xpos, ypos, lwidth, fontHeight,
"Select an item from the list ...", TextAlign::Left);
"Select a ROM from the list" + ELLIPSIS);
lwidth2 = font.getStringWidth("XXXX items found");
xpos = _w - lwidth2 - 10;
@ -81,14 +82,17 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
if(w >= 640)
{
int fwidth = std::min(15 * fontWidth, xpos - 20 - lwidth);
new StaticTextWidget(this, font, xpos - fwidth - 5 - font.getStringWidth("Filter "),
ypos, "Filter ");
xpos -= fwidth + 5;
myPattern = new EditTextWidget(this, font, xpos, ypos,
fwidth, fontHeight, "");
myPattern = new EditTextWidget(this, font, xpos, ypos - 2,
fwidth, lineHeight, "");
}
// Add list with game titles
// Before we add the list, we need to know the size of the RomInfoWidget
xpos = 10; ypos += fontHeight + 5;
xpos = 10; ypos += lineHeight + 4;
int romWidth = 0;
int romSize = instance().settings().getInt("romviewer");
if(romSize > 1 && w >= 1000 && h >= 760)
@ -96,9 +100,9 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
else if(romSize > 0 && w >= 640 && h >= 480)
romWidth = 365;
int listWidth = _w - (romWidth > 0 ? romWidth+5 : 0) - 20;
int listWidth = _w - (romWidth > 0 ? romWidth+8 : 0) - 20;
myList = new StringListWidget(this, font, xpos, ypos,
listWidth, _h - 35 - bheight - 2*fontHeight);
listWidth, _h - 43 - bheight - fontHeight - lineHeight);
myList->setEditable(false);
wid.push_back(myList);
if(myPattern) wid.push_back(myPattern); // Add after the list for tab order
@ -106,7 +110,7 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
// Add ROM info area (if enabled)
if(romWidth > 0)
{
xpos += myList->getWidth() + 5;
xpos += myList->getWidth() + 8;
myRomInfoWidget = new RomInfoWidget(this,
romWidth < 660 ? instance().frameBuffer().smallFont() :
instance().frameBuffer().infoFont(),
@ -115,7 +119,7 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
// Add textfield to show current directory
xpos = 10;
ypos += myList->getHeight() + 4;
ypos += myList->getHeight() + 8;
lwidth = font.getStringWidth("Path ");
myDirLabel = new StaticTextWidget(this, font, xpos, ypos+2, lwidth, fontHeight,
"Path", TextAlign::Left);
@ -125,7 +129,7 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
myDir->clearFlags(WIDGET_RETAIN_FOCUS);
// Add four buttons at the bottom
xpos = 10; ypos += myDir->getHeight() + 4;
xpos = 10; ypos += myDir->getHeight() + 8;
#ifndef BSPF_MAC_OSX
myStartButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight,
"Select", kLoadROMCmd);

View File

@ -160,7 +160,7 @@ void RadioButtonWidget::drawWidget(bool hilite)
FBSurface& s = _boss->dialog().surface();
// Draw the outer bounding circle
s.drawBitmap(radio_img_outercircle, _x, _y + _boxY, hilite ? kScrollColorHi : kShadowColor, 14, 14);
s.drawBitmap(radio_img_outercircle, _x, _y + _boxY, hilite ? kWidColorHi : kShadowColor, 14, 14);
// Draw the inner bounding circle with enabled color
s.drawBitmap(radio_img_innercircle, _x + 1, _y + _boxY + 1, isEnabled()
@ -169,7 +169,7 @@ void RadioButtonWidget::drawWidget(bool hilite)
// draw state
if(_state)
s.drawBitmap(_img, _x + 2, _y + _boxY + 2, isEnabled()
? hilite ? kScrollColorHi : kCheckColor
? hilite ? kWidColorHi : kCheckColor
: kShadowColor, 10);
// Finally draw the label

View File

@ -142,9 +142,9 @@ void RomInfoWidget::drawWidget(bool hilite)
const int yoff = myAvail.h + 10;
s.fillRect(_x+2, _y+2, _w-4, _h-4, kWidColor);
s.box(_x, _y, _w, _h, kColor, kShadowColor);
s.box(_x, _y+yoff, _w, _h-yoff, kColor, kShadowColor);
s.fillRect(_x+2, _y+2, _w-4, _h-4, kDlgColor);
s.frameRect(_x, _y, _w, _h, kColor);
s.frameRect(_x, _y+yoff, _w, _h-yoff, kColor);
if(!myHaveProperties) return;
@ -167,10 +167,10 @@ void RomInfoWidget::drawWidget(bool hilite)
s.drawString(font, mySurfaceErrorMsg, x, y, _w - 10, _textcolor);
}
int xpos = _x + 5, ypos = _y + yoff + 10;
int xpos = _x + 8, ypos = _y + yoff + 10;
for(const auto& info: myRomInfo)
{
s.drawString(_font, info, xpos, ypos, _w - 10, _textcolor);
s.drawString(_font, info, xpos, ypos, _w - 16, _textcolor);
ypos += _font.getLineHeight();
}
}

View File

@ -32,26 +32,26 @@
// Up arrow
static uInt32 up_arrow[8] = {
0b00011000,
0b00011000,
0b00111100,
0b00111100,
0b01111110,
0b01111110,
0b11111111,
0b11111111
0b00000000,
0b00010000,
0b00111000,
0b01111100,
0b11101110,
0b11000110,
0b10000010,
0b00000000
};
// Down arrow
static uInt32 down_arrow[8] = {
0b11111111,
0b11111111,
0b01111110,
0b01111110,
0b00111100,
0b00111100,
0b00011000,
0b00011000
0b00000000,
0b10000010,
0b11000110,
0b11101110,
0b01111100,
0b00111000,
0b00010000,
0b00000000
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -101,11 +101,11 @@ void ScrollBarWidget::handleMouseDown(int x, int y, MouseButton b,
}
else if(y < _sliderPos)
{
_currentPos -= _entriesPerPage;
_currentPos -= _entriesPerPage - 1;
}
else if(y >= _sliderPos + _sliderHeight)
{
_currentPos += _entriesPerPage;
_currentPos += _entriesPerPage - 1;
}
else
{
@ -256,25 +256,22 @@ void ScrollBarWidget::drawWidget(bool hilite)
_part = _draggingPart;
// Up arrow
s.frameRect(_x, _y, _w, UP_DOWN_BOX_HEIGHT, kColor);
s.drawBitmap(up_arrow, _x+3, _y+5, isSinglePage ? kColor :
(hilite && _part == kUpArrowPart) ? kScrollColorHi : kScrollColor, 8);
if(hilite && _part == kUpArrowPart)
s.fillRect(_x + 1, _y + 1, _w - 2, UP_DOWN_BOX_HEIGHT - 2, kScrollColor);
s.drawBitmap(up_arrow, _x+4, _y+5, isSinglePage ? kColor :
(hilite && _part == kUpArrowPart) ? kWidColor : kTextColor, 8);
// Down arrow
s.frameRect(_x, bottomY - UP_DOWN_BOX_HEIGHT, _w, UP_DOWN_BOX_HEIGHT, kColor);
s.drawBitmap(down_arrow, _x+3, bottomY - UP_DOWN_BOX_HEIGHT + 5, isSinglePage ? kColor :
(hilite && _part == kDownArrowPart) ? kScrollColorHi : kScrollColor, 8);
if(hilite && _part == kDownArrowPart)
s.fillRect(_x + 1, bottomY - UP_DOWN_BOX_HEIGHT + 1, _w - 2, UP_DOWN_BOX_HEIGHT - 2, kScrollColor);
s.drawBitmap(down_arrow, _x+4, bottomY - UP_DOWN_BOX_HEIGHT + 5, isSinglePage ? kColor :
(hilite && _part == kDownArrowPart) ? kWidColor : kTextColor, 8);
// Slider
if(!isSinglePage)
{
s.fillRect(_x, _y + _sliderPos, _w, _sliderHeight,
s.fillRect(_x + 1, _y + _sliderPos - 1, _w - 2, _sliderHeight + 2,
(hilite && _part == kSliderPart) ? kScrollColorHi : kScrollColor);
s.frameRect(_x, _y + _sliderPos, _w, _sliderHeight, kColor);
int y = _y + _sliderPos + _sliderHeight / 2;
s.hLine(_x + 2, y - 2, _x + _w - 3, kWidColor);
s.hLine(_x + 2, y, _x + _w - 3, kWidColor);
s.hLine(_x + 2, y + 2, _x + _w - 3, kWidColor);
}
}

View File

@ -25,7 +25,7 @@ class GuiObject;
#include "bspf.hxx"
enum {
kScrollBarWidth = 14
kScrollBarWidth = 15
};
class ScrollBarWidget : public Widget, public CommandSender

View File

@ -30,7 +30,7 @@
size: 95
ascent: 8
descent: 2
first char: 32 (0x20)
first char: 29 (0x1d)
last char: 126 (0x7e)
default char: 32 (0x20)
proportional: no
@ -42,6 +42,90 @@ namespace GUI {
// Font character bitmap data.
static const uInt16 stella_font_bits[] = {
/* Character 29 (0x1d):
width 6
bbx ( 6, 10, 0, -2 )
+------+
| |
| |
| |
| |
| |
| |
| |
|* * * |
| |
| |
+------+
*/
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
0b1010100000000000,
0x0000,
0x0000,
/* Character 30 (0x1e):
width 6
bbx ( 6, 10, 0, -2 )
+------+
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
+------+
*/
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
/* Character 31 (0x1f):
width 6
bbx ( 6, 10, 0, -2 )
+------+
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
+------+
*/
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
/* Character 32 (0x20):
width 6
bbx ( 6, 10, 0, -2 )
@ -445,9 +529,9 @@ static const uInt16 stella_font_bits[] = {
| |
| |
| |
| * |
| *** |
| * |
| |
| ** |
| |
| |
+------+
*/
@ -457,9 +541,9 @@ static const uInt16 stella_font_bits[] = {
0x0000,
0x0000,
0x0000,
0x2000,
0x7000,
0x2000,
0x0000,
0x6000,
0x0000,
0x0000,
/* Character 47 (0x2f):
@ -777,25 +861,25 @@ static const uInt16 stella_font_bits[] = {
+------+
| |
| |
| * |
| *** |
| * |
| |
| * |
| *** |
| * |
| ** |
| |
| |
| |
| ** |
| |
| |
+------+
*/
0x0000,
0x0000,
0x2000,
0x7000,
0x2000,
0x0000,
0x2000,
0x7000,
0x2000,
0x6000,
0x0000,
0x0000,
0x0000,
0x6000,
0x0000,
0x0000,
/* Character 59 (0x3b):
@ -805,9 +889,9 @@ static const uInt16 stella_font_bits[] = {
+------+
| |
| |
| * |
| *** |
| * |
| |
| ** |
| |
| |
| ** |
| * |
@ -817,9 +901,9 @@ static const uInt16 stella_font_bits[] = {
*/
0x0000,
0x0000,
0x2000,
0x7000,
0x2000,
0x0000,
0x3000,
0x0000,
0x0000,
0x3000,
0x2000,
@ -2710,8 +2794,8 @@ static const FontDesc stellaDesc = {
10,
6, 10, 0, -2,
8,
32,
95,
29,
98,
stella_font_bits,
nullptr, /* no encode table*/
nullptr, /* fixed width*/

View File

@ -30,9 +30,9 @@
size: 95
ascent: 14
descent: 4
first char: 30 (0x1e)
first char: 29 (0x1d)
last char: 126 (0x7e)
default char: 30 (0x1e)
default char: 32 (0x20)
proportional: no
Public domain font. Share and enjoy.
*/

View File

@ -90,7 +90,7 @@ void Widget::draw()
// Draw border
if(hasBorder)
{
s.frameRect(_x, _y, _w, _h, (_flags & WIDGET_HILITED) && isEnabled() ? kScrollColorHi : kColor);
s.frameRect(_x, _y, _w, _h, (_flags & WIDGET_HILITED) && isEnabled() ? kWidColorHi : kColor);
_x += 4;
_y += 4;
_w -= 8;
@ -607,12 +607,12 @@ void CheckboxWidget::drawWidget(bool hilite)
FBSurface& s = _boss->dialog().surface();
if(_drawBox)
s.frameRect(_x, _y + _boxY, 14, 14, hilite ? kScrollColorHi : kShadowColor);
s.frameRect(_x, _y + _boxY, 14, 14, hilite ? kWidColorHi : kShadowColor);
// Do we draw a square or cross?
s.fillRect(_x + 1, _y + _boxY + 1, 12, 12, _changed ? kDbgChangedColor
: isEnabled() ? _bgcolor : kColor);
if(_state)
s.drawBitmap(_img, _x + 2, _y + _boxY + 2, isEnabled() ? hilite ? kScrollColorHi : kCheckColor
s.drawBitmap(_img, _x + 2, _y + _boxY + 2, isEnabled() ? hilite ? kWidColorHi : kCheckColor
: kShadowColor, 10);
// Finally draw the label