Made scrollbars a little wider, and provided new arrows.

Cleaned up the Widget API a little, eliminating some redundant code.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1596 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2009-01-04 02:28:12 +00:00
parent 6a4945528f
commit e6e5dd1caf
14 changed files with 65 additions and 91 deletions

View File

@ -22,7 +22,7 @@ X * New UI subsystem where drawing is done into separate buffers, not
X * Make UI 'font-sensitive' and remove all hardcoded dimensions for
widget/font sizes
* Add option to automatically save snapshots in 1X mode (useful for
X * Add option to automatically save snapshots in 1X mode (useful for
RomInfoWidget)
X * A way to override (possibly temporarily) all properties for a ROM, and

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CheatCodeDialog.cxx,v 1.23 2009-01-01 18:13:34 stephena Exp $
// $Id: CheatCodeDialog.cxx,v 1.24 2009-01-04 02:28:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -56,7 +56,7 @@ CheatCodeDialog::CheatCodeDialog(OSystem* osystem, DialogContainer* parent,
myCheatList->setEditable(false);
wid.push_back(myCheatList);
xpos += myCheatList->getWidth() + 15; ypos = 15;
xpos += myCheatList->getWidth() + 5; ypos = 15;
b = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
"Add", kAddCheatCmd);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: mainSDL.cxx,v 1.84 2009-01-03 22:57:12 stephena Exp $
// $Id: mainSDL.cxx,v 1.85 2009-01-04 02:28:12 stephena Exp $
//============================================================================
#include <SDL.h>
@ -165,7 +165,7 @@ int main(int argc, char* argv[])
{
if(theOSystem->settings().getBool("takesnapshot"))
{
for(int i = 0; i < 60; ++i) theOSystem->frameBuffer().update();
for(int i = 0; i < 30; ++i) theOSystem->frameBuffer().update();
theOSystem->eventHandler().takeSnapshot();
Cleanup();
return 0;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: PromptWidget.cxx,v 1.28 2009-01-03 22:57:12 stephena Exp $
// $Id: PromptWidget.cxx,v 1.29 2009-01-04 02:28:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -495,17 +495,6 @@ void PromptWidget::handleCommand(CommandSender* sender, int cmd,
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GUI::Rect PromptWidget::getRect() const
{
// Account for attached scrollbar when calculating width
int x = getAbsX() - 1, y = getAbsY() - 1,
w = getWidth() + kScrollBarWidth + 2, h = getHeight() + 2;
GUI::Rect r(x, y, x+w, y+h);
return r;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PromptWidget::loadConfig()
{

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: PromptWidget.hxx,v 1.15 2009-01-03 22:57:12 stephena Exp $
// $Id: PromptWidget.hxx,v 1.16 2009-01-04 02:28:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -22,13 +22,12 @@
#ifndef PROMPT_WIDGET_HXX
#define PROMPT_WIDGET_HXX
class ScrollBarWidget;
#include <stdarg.h>
#include "GuiObject.hxx"
#include "Widget.hxx"
#include "Command.hxx"
#include "ScrollBarWidget.hxx"
#include "bspf.hxx"
class PromptWidget : public Widget, public CommandSender
@ -73,7 +72,9 @@ class PromptWidget : public Widget, public CommandSender
bool handleKeyDown(int ascii, int keycode, int modifiers);
void handleCommand(CommandSender* sender, int cmd, int data, int id);
virtual GUI::Rect getRect() const;
// Account for the extra width of embedded scrollbar
virtual int getWidth() const { return _w + kScrollBarWidth; }
virtual bool wantsFocus() { return true; }
void loadConfig();

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: EventMappingWidget.cxx,v 1.25 2009-01-01 18:13:38 stephena Exp $
// $Id: EventMappingWidget.cxx,v 1.26 2009-01-04 02:28:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -57,7 +57,7 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
addFocusWidget(myActionsList);
// Add remap, erase, cancel and default buttons
xpos += myActionsList->getWidth() + 15; ypos += 5;
xpos += myActionsList->getWidth() + 5; ypos += 5;
myMapButton = new ButtonWidget(boss, font, xpos, ypos,
buttonWidth, buttonHeight,
"Map", kStartMapCmd);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: GuiObject.hxx,v 1.27 2009-01-01 18:13:38 stephena Exp $
// $Id: GuiObject.hxx,v 1.28 2009-01-04 02:28:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -46,15 +46,11 @@ enum {
kRefreshAllCmd = 'REFA'
};
enum {
kScrollBarWidth = 9
};
/**
This is the base class for all GUI objects/widgets.
@author Stephen Anthony
@version $Id: GuiObject.hxx,v 1.27 2009-01-01 18:13:38 stephena Exp $
@version $Id: GuiObject.hxx,v 1.28 2009-01-04 02:28:12 stephena Exp $
*/
class GuiObject : public CommandReceiver
{
@ -87,8 +83,8 @@ class GuiObject : public CommandReceiver
virtual int getWidth() const { return _w; }
virtual int getHeight() const { return _h; }
virtual void setWidth(int w) { _w = w; }
virtual void setHeight(int h) { _h = h; }
virtual void setWidth(int w) { _w = w; }
virtual void setHeight(int h) { _h = h; }
virtual void setDirty() { _dirty = true; }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: LauncherDialog.cxx,v 1.95 2009-01-03 15:44:13 stephena Exp $
// $Id: LauncherDialog.cxx,v 1.96 2009-01-04 02:28:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -89,7 +89,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
else if(romSize > 0 && w >= 640 && h >= 480)
romWidth = 365;
int listWidth = _w - (romWidth > 0 ? romWidth+25 : 20);
int listWidth = _w - (romWidth > 0 ? romWidth+5 : 0) - 20;
myList = new StringListWidget(this, font, xpos, ypos,
listWidth, _h - 28 - bheight - 2*fontHeight);
myList->setNumberingMode(kListNumberingOff);
@ -99,7 +99,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
// Add ROM info area (if enabled)
if(romWidth > 0)
{
xpos += myList->getWidth() + 15;
xpos += myList->getWidth() + 5;
myRomInfoWidget = new RomInfoWidget(this, instance().consoleFont(), xpos, ypos,
romWidth, myList->getHeight());
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: ListWidget.cxx,v 1.52 2009-01-01 18:13:38 stephena Exp $
// $Id: ListWidget.cxx,v 1.53 2009-01-04 02:28:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -396,17 +396,6 @@ void ListWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GUI::Rect ListWidget::getRect() const
{
// Account for attached scrollbar when calculating width
int x = getAbsX() - 1, y = getAbsY() - 1,
w = getWidth() + kScrollBarWidth + 2, h = getHeight() + 2;
GUI::Rect r(x, y, x+w, y+h);
return r;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ListWidget::scrollToCurrent(int item)
{

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: ListWidget.hxx,v 1.23 2009-01-02 01:50:03 stephena Exp $
// $Id: ListWidget.hxx,v 1.24 2009-01-04 02:28:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -71,7 +71,8 @@ class ListWidget : public EditableWidget
virtual bool handleEvent(Event::Type e);
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
virtual GUI::Rect getRect() const;
// Account for the extra width of embedded scrollbar
virtual int getWidth() const { return _w + kScrollBarWidth; }
void startEditMode();
void endEditMode();

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: ScrollBarWidget.cxx,v 1.24 2009-01-01 18:13:39 stephena Exp $
// $Id: ScrollBarWidget.cxx,v 1.25 2009-01-04 02:28:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -32,30 +32,30 @@
* and we thus should not highlight the arrows/slider.
*/
#define UP_DOWN_BOX_HEIGHT 10
#define UP_DOWN_BOX_HEIGHT 12
// Up arrow
static unsigned int up_arrow[8] = {
0x00011000,
0x00111100,
0x01111110,
0x11111111,
0x00000000,
0x00000000,
0x00001000,
0x00001000,
0x00011100,
0x00011100,
0x00110110,
0x00100010,
0x00000000,
0x00000000
};
// Down arrow
static unsigned int down_arrow[8] = {
0x11111111,
0x01111110,
0x00111100,
0x00011000,
0x00000000,
0x00000000,
0x00100010,
0x00110110,
0x00011100,
0x00011100,
0x00001000,
0x00001000,
0x00000000,
0x00000000
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -258,12 +258,12 @@ void ScrollBarWidget::drawWidget(bool hilite)
// Up arrow
s.frameRect(_x, _y, _w, UP_DOWN_BOX_HEIGHT, kColor);
s.drawBitmap(up_arrow, _x, _y, isSinglePage ? kColor :
(hilite && _part == kUpArrowPart) ? kScrollColorHi : kScrollColor);
s.drawBitmap(up_arrow, _x+2, _y+4, isSinglePage ? kColor :
(hilite && _part == kUpArrowPart) ? kScrollColorHi : kScrollColor, 4);
// Down arrow
s.frameRect(_x, bottomY - UP_DOWN_BOX_HEIGHT, _w, UP_DOWN_BOX_HEIGHT, kColor);
s.drawBitmap(down_arrow, _x, bottomY - UP_DOWN_BOX_HEIGHT, isSinglePage ? kColor :
s.drawBitmap(down_arrow, _x+2, bottomY - UP_DOWN_BOX_HEIGHT + 4, isSinglePage ? kColor :
(hilite && _part == kDownArrowPart) ? kScrollColorHi : kScrollColor);
// Slider

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: ScrollBarWidget.hxx,v 1.11 2009-01-01 18:13:39 stephena Exp $
// $Id: ScrollBarWidget.hxx,v 1.12 2009-01-04 02:28:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -27,6 +27,9 @@
#include "Command.hxx"
#include "bspf.hxx"
enum {
kScrollBarWidth = 12
};
class ScrollBarWidget : public Widget, public CommandSender
{

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Widget.cxx,v 1.61 2009-01-03 22:57:12 stephena Exp $
// $Id: Widget.cxx,v 1.62 2009-01-04 02:28:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -150,16 +150,6 @@ void Widget::lostFocus()
lostFocusWidget();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GUI::Rect Widget::getRect() const
{
int x = getAbsX() - 1, y = getAbsY() - 1,
w = getWidth() + 2, h = getHeight() + 2;
GUI::Rect r(x, y, x+w, y+h);
return r;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Widget::setEnabled(bool e)
{
@ -239,9 +229,12 @@ Widget* Widget::setFocusForChain(GuiObject* boss, WidgetArray& arr,
if(wid == tmp)
pos = i;
GUI::Rect rect = tmp->getRect();
int x = rect.left, y = rect.top,
w = rect.width(), h = rect.height();
// Get area around widget
// Note: we must use getXXX() methods and not access the variables
// directly, since in some cases (notably those widgets with embedded
// ScrollBars) the two quantities may be different
int x = tmp->getAbsX() - 1, y = tmp->getAbsY() - 1,
w = tmp->getWidth() + 2, h = tmp->getHeight() + 2;
// First clear area surrounding all widgets
if(tmp->_hasFocus)
@ -281,9 +274,13 @@ Widget* Widget::setFocusForChain(GuiObject* boss, WidgetArray& arr,
// Now highlight the active widget
tmp = arr[pos];
GUI::Rect rect = tmp->getRect();
int x = rect.left, y = rect.top,
w = rect.width(), h = rect.height();
// Get area around widget
// Note: we must use getXXX() methods and not access the variables
// directly, since in some cases (notably those widgets with embedded
// ScrollBars) the two quantities may be different
int x = tmp->getAbsX() - 1, y = tmp->getAbsY() - 1,
w = tmp->getWidth() + 2, h = tmp->getHeight() + 2;
tmp->receivedFocus();
s.frameRect(x, y, w, h, kWidFrameColor, kDashLine);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Widget.hxx,v 1.66 2009-01-03 22:57:12 stephena Exp $
// $Id: Widget.hxx,v 1.67 2009-01-04 02:28:12 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -83,7 +83,7 @@ enum {
This is the base class for all widgets.
@author Stephen Anthony
@version $Id: Widget.hxx,v 1.66 2009-01-03 22:57:12 stephena Exp $
@version $Id: Widget.hxx,v 1.67 2009-01-04 02:28:12 stephena Exp $
*/
class Widget : public GuiObject
{
@ -115,8 +115,6 @@ class Widget : public GuiObject
void lostFocus();
void addFocusWidget(Widget* w) { _focusList.push_back(w); }
virtual GUI::Rect getRect() const;
/** Set/clear WIDGET_ENABLED flag and immediately redraw */
void setEnabled(bool e);
@ -166,10 +164,10 @@ class Widget : public GuiObject
bool _hasFocus;
int _fontWidth;
int _fontHeight;
uInt32 _bgcolor;
uInt32 _bgcolorhi;
uInt32 _textcolor;
uInt32 _textcolorhi;
uInt32 _bgcolor;
uInt32 _bgcolorhi;
uInt32 _textcolor;
uInt32 _textcolorhi;
public:
static Widget* findWidgetInChain(Widget* start, int x, int y);