mirror of https://github.com/stella-emu/stella.git
Added ColorWidget, which currently only shows a color. This will
be expanded to pop up a palette when double-clicking on a color, to visually choose a new one. Added ColorWidgets for the 4 TIA color registers to TiaWidget. Since these are tied to a DataGridWidget, a nice side-effect is being able to press '+' and have all the colors cycle. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@648 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
0f4b93acf3
commit
65e166cf9c
|
@ -0,0 +1,68 @@
|
||||||
|
//============================================================================
|
||||||
|
//
|
||||||
|
// SSSS tt lll lll
|
||||||
|
// SS SS tt ll ll
|
||||||
|
// SS tttttt eeee ll ll aaaa
|
||||||
|
// SSSS tt ee ee ll ll aa
|
||||||
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
||||||
|
// SS SS tt ee ll ll aa aa
|
||||||
|
// SSSS ttt eeeee llll llll aaaaa
|
||||||
|
//
|
||||||
|
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
|
||||||
|
//
|
||||||
|
// See the file "license" for information on usage and redistribution of
|
||||||
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
|
//
|
||||||
|
// $Id: ColorWidget.cxx,v 1.1 2005-07-14 23:47:17 stephena Exp $
|
||||||
|
//
|
||||||
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
#include "OSystem.hxx"
|
||||||
|
#include "FrameBuffer.hxx"
|
||||||
|
#include "Command.hxx"
|
||||||
|
#include "GuiObject.hxx"
|
||||||
|
#include "bspf.hxx"
|
||||||
|
#include "GuiUtils.hxx"
|
||||||
|
#include "ColorWidget.hxx"
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
ColorWidget::ColorWidget(GuiObject* boss, int x, int y, int w, int h, int cmd)
|
||||||
|
: Widget(boss, x, y, w, h),
|
||||||
|
CommandSender(boss),
|
||||||
|
_color(0),
|
||||||
|
_cmd(cmd)
|
||||||
|
{
|
||||||
|
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS;
|
||||||
|
_type = kColorWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
ColorWidget::~ColorWidget()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void ColorWidget::handleMouseDown(int x, int y, int button, int clickCount)
|
||||||
|
{
|
||||||
|
// FIXME - add ColorDialog, which will show all 256 colors in the
|
||||||
|
// TIA palette
|
||||||
|
// if(isEnabled())
|
||||||
|
// parent()->addDialog(myColorDialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void ColorWidget::drawWidget(bool hilite)
|
||||||
|
{
|
||||||
|
FrameBuffer& fb = instance()->frameBuffer();
|
||||||
|
|
||||||
|
// Draw a thin frame around us.
|
||||||
|
fb.hLine(_x, _y, _x + _w - 1, kColor);
|
||||||
|
fb.hLine(_x, _y +_h, _x + _w - 1, kShadowColor);
|
||||||
|
fb.vLine(_x, _y, _y+_h, kColor);
|
||||||
|
fb.vLine(_x + _w - 1, _y, _y +_h - 1, kShadowColor);
|
||||||
|
|
||||||
|
// Show the currently selected color
|
||||||
|
fb.fillRect(_x+1, _y+1, _w-2, _h-1, (OverlayColor) _color);
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
//============================================================================
|
||||||
|
//
|
||||||
|
// SSSS tt lll lll
|
||||||
|
// SS SS tt ll ll
|
||||||
|
// SS tttttt eeee ll ll aaaa
|
||||||
|
// SSSS tt ee ee ll ll aa
|
||||||
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
||||||
|
// SS SS tt ee ll ll aa aa
|
||||||
|
// SSSS ttt eeeee llll llll aaaaa
|
||||||
|
//
|
||||||
|
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
|
||||||
|
//
|
||||||
|
// See the file "license" for information on usage and redistribution of
|
||||||
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
|
//
|
||||||
|
// $Id: ColorWidget.hxx,v 1.1 2005-07-14 23:47:17 stephena Exp $
|
||||||
|
//
|
||||||
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
#ifndef COLOR_WIDGET_HXX
|
||||||
|
#define COLOR_WIDGET_HXX
|
||||||
|
|
||||||
|
class ColorDialog;
|
||||||
|
class GuiObject;
|
||||||
|
|
||||||
|
#include "Widget.hxx"
|
||||||
|
#include "Command.hxx"
|
||||||
|
|
||||||
|
#include "bspf.hxx"
|
||||||
|
|
||||||
|
/**
|
||||||
|
Displays a color from the TIA palette. This class will eventually
|
||||||
|
be expanded with a TIA palette table, to set the color visually.
|
||||||
|
|
||||||
|
@author Stephen Anthony
|
||||||
|
@version $Id: ColorWidget.hxx,v 1.1 2005-07-14 23:47:17 stephena Exp $
|
||||||
|
*/
|
||||||
|
class ColorWidget : public Widget, public CommandSender
|
||||||
|
{
|
||||||
|
friend class ColorDialog;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ColorWidget(GuiObject* boss, int x, int y, int w, int h, int cmd = 0);
|
||||||
|
~ColorWidget();
|
||||||
|
|
||||||
|
void setColor(int color) { _color = color; }
|
||||||
|
int getColor() const { return _color; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void drawWidget(bool hilite);
|
||||||
|
void handleMouseDown(int x, int y, int button, int clickCount);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int _color;
|
||||||
|
int _cmd;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: TiaWidget.cxx,v 1.10 2005-07-14 18:28:36 stephena Exp $
|
// $Id: TiaWidget.cxx,v 1.11 2005-07-14 23:47:17 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from ScummVM - Scumm Interpreter
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
#include "Widget.hxx"
|
#include "Widget.hxx"
|
||||||
#include "EditTextWidget.hxx"
|
#include "EditTextWidget.hxx"
|
||||||
#include "DataGridWidget.hxx"
|
#include "DataGridWidget.hxx"
|
||||||
|
#include "ColorWidget.hxx"
|
||||||
#include "TiaWidget.hxx"
|
#include "TiaWidget.hxx"
|
||||||
|
|
||||||
// ID's for the various widgets
|
// ID's for the various widgets
|
||||||
|
@ -55,7 +55,7 @@ TiaWidget::TiaWidget(GuiObject* boss, int x, int y, int w, int h)
|
||||||
int xpos = 10;
|
int xpos = 10;
|
||||||
int ypos = 20;
|
int ypos = 20;
|
||||||
int lwidth = 25;
|
int lwidth = 25;
|
||||||
const int vWidth = _w - kButtonWidth - 20, space = 6, buttonw = 24;
|
// const int vWidth = _w - kButtonWidth - 20, space = 6, buttonw = 24;
|
||||||
const GUI::Font& font = instance()->consoleFont();
|
const GUI::Font& font = instance()->consoleFont();
|
||||||
|
|
||||||
// Create a 16x1 grid holding byte values with labels
|
// Create a 16x1 grid holding byte values with labels
|
||||||
|
@ -137,10 +137,25 @@ TiaWidget::TiaWidget(GuiObject* boss, int x, int y, int w, int h)
|
||||||
kTextAlignLeft);
|
kTextAlignLeft);
|
||||||
}
|
}
|
||||||
xpos += 40;
|
xpos += 40;
|
||||||
myColorRegs = new DataGridWidget(boss, xpos, ypos-1, 1, 4, 2, 8, kBASE_16);
|
myColorRegs = new DataGridWidget(boss, xpos, ypos, 1, 4, 2, 8, kBASE_16);
|
||||||
myColorRegs->setTarget(this);
|
myColorRegs->setTarget(this);
|
||||||
myColorRegs->setID(kColorRegsID);
|
myColorRegs->setID(kColorRegsID);
|
||||||
|
|
||||||
|
xpos += myColorRegs->colWidth() + 5;
|
||||||
|
myCOLUP0Color = new ColorWidget(boss, xpos, ypos+2, 20, kLineHeight - 4);
|
||||||
|
myCOLUP0Color->setTarget(this);
|
||||||
|
|
||||||
|
ypos += kLineHeight;
|
||||||
|
myCOLUP1Color = new ColorWidget(boss, xpos, ypos+2, 20, kLineHeight - 4);
|
||||||
|
myCOLUP1Color->setTarget(this);
|
||||||
|
|
||||||
|
ypos += kLineHeight;
|
||||||
|
myCOLUPFColor = new ColorWidget(boss, xpos, ypos+2, 20, kLineHeight - 4);
|
||||||
|
myCOLUPFColor->setTarget(this);
|
||||||
|
|
||||||
|
ypos += kLineHeight;
|
||||||
|
myCOLUBKColor = new ColorWidget(boss, xpos, ypos+2, 20, kLineHeight - 4);
|
||||||
|
myCOLUBKColor->setTarget(this);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Add some buttons for common actions
|
// Add some buttons for common actions
|
||||||
|
@ -188,7 +203,7 @@ void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
||||||
}
|
}
|
||||||
// FIXME - maybe issue a full reload, since changing one item can affect
|
// FIXME - maybe issue a full reload, since changing one item can affect
|
||||||
// others in this tab??
|
// others in this tab??
|
||||||
loadConfig();
|
// loadConfig();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kDGSelectionChangedCmd:
|
case kDGSelectionChangedCmd:
|
||||||
|
@ -233,7 +248,6 @@ void TiaWidget::loadConfig()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void TiaWidget::fillGrid()
|
void TiaWidget::fillGrid()
|
||||||
{
|
{
|
||||||
// FIXME - have these widget get correct values from TIADebug
|
|
||||||
IntArray alist;
|
IntArray alist;
|
||||||
IntArray vlist;
|
IntArray vlist;
|
||||||
BoolArray changed;
|
BoolArray changed;
|
||||||
|
@ -267,6 +281,11 @@ void TiaWidget::fillGrid()
|
||||||
changed.push_back(state.coluRegs[i] != oldstate.coluRegs[i]);
|
changed.push_back(state.coluRegs[i] != oldstate.coluRegs[i]);
|
||||||
}
|
}
|
||||||
myColorRegs->setList(alist, vlist, changed);
|
myColorRegs->setList(alist, vlist, changed);
|
||||||
|
|
||||||
|
myCOLUP0Color->setColor(state.coluRegs[0]);
|
||||||
|
myCOLUP1Color->setColor(state.coluRegs[1]);
|
||||||
|
myCOLUPFColor->setColor(state.coluRegs[2]);
|
||||||
|
myCOLUBKColor->setColor(state.coluRegs[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -279,18 +298,22 @@ void TiaWidget::changeColorRegs()
|
||||||
{
|
{
|
||||||
case kCOLUP0Addr:
|
case kCOLUP0Addr:
|
||||||
instance()->debugger().tiaDebug().coluP0(value);
|
instance()->debugger().tiaDebug().coluP0(value);
|
||||||
|
myCOLUP0Color->setColor(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kCOLUP1Addr:
|
case kCOLUP1Addr:
|
||||||
instance()->debugger().tiaDebug().coluP1(value);
|
instance()->debugger().tiaDebug().coluP1(value);
|
||||||
|
myCOLUP1Color->setColor(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kCOLUPFAddr:
|
case kCOLUPFAddr:
|
||||||
instance()->debugger().tiaDebug().coluPF(value);
|
instance()->debugger().tiaDebug().coluPF(value);
|
||||||
|
myCOLUPFColor->setColor(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kCOLUBKAddr:
|
case kCOLUBKAddr:
|
||||||
instance()->debugger().tiaDebug().coluBK(value);
|
instance()->debugger().tiaDebug().coluBK(value);
|
||||||
|
myCOLUBKColor->setColor(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: TiaWidget.hxx,v 1.5 2005-07-14 18:28:36 stephena Exp $
|
// $Id: TiaWidget.hxx,v 1.6 2005-07-14 23:47:17 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from ScummVM - Scumm Interpreter
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -24,13 +24,13 @@
|
||||||
|
|
||||||
class GuiObject;
|
class GuiObject;
|
||||||
class ButtonWidget;
|
class ButtonWidget;
|
||||||
|
class DataGridWidget;
|
||||||
class StaticTextWidget;
|
class StaticTextWidget;
|
||||||
class EditTextWidget;
|
class EditTextWidget;
|
||||||
|
class ColorWidget;
|
||||||
|
|
||||||
#include "Array.hxx"
|
|
||||||
#include "Widget.hxx"
|
#include "Widget.hxx"
|
||||||
#include "Command.hxx"
|
#include "Command.hxx"
|
||||||
#include "DataGridWidget.hxx"
|
|
||||||
|
|
||||||
|
|
||||||
class TiaWidget : public Widget, public CommandSender
|
class TiaWidget : public Widget, public CommandSender
|
||||||
|
@ -61,12 +61,11 @@ class TiaWidget : public Widget, public CommandSender
|
||||||
CheckboxWidget* myVBlank;
|
CheckboxWidget* myVBlank;
|
||||||
|
|
||||||
DataGridWidget* myColorRegs;
|
DataGridWidget* myColorRegs;
|
||||||
/* FIXME - add widget for this, with ability to show color wheel or something
|
|
||||||
PaletteWidget* myCOLUP0Color;
|
ColorWidget* myCOLUP0Color;
|
||||||
PaletteWidget* myCOLUP1Color;
|
ColorWidget* myCOLUP1Color;
|
||||||
PaletteWidget* myCOLUPFColor;
|
ColorWidget* myCOLUPFColor;
|
||||||
PaletteWidget* myCOLUBKColor;
|
ColorWidget* myCOLUBKColor;
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: Widget.hxx,v 1.23 2005-07-05 15:25:45 stephena Exp $
|
// $Id: Widget.hxx,v 1.24 2005-07-14 23:47:17 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from ScummVM - Scumm Interpreter
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -56,7 +56,8 @@ enum {
|
||||||
kTabWidget = 'TABW',
|
kTabWidget = 'TABW',
|
||||||
kPromptWidget = 'PROM',
|
kPromptWidget = 'PROM',
|
||||||
kDataGridWidget = 'BGRI',
|
kDataGridWidget = 'BGRI',
|
||||||
kToggleBitWidget = 'TGBT'
|
kToggleBitWidget = 'TGBT',
|
||||||
|
kColorWidget = 'COLR'
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -68,7 +69,7 @@ enum {
|
||||||
This is the base class for all widgets.
|
This is the base class for all widgets.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: Widget.hxx,v 1.23 2005-07-05 15:25:45 stephena Exp $
|
@version $Id: Widget.hxx,v 1.24 2005-07-14 23:47:17 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class Widget : public GuiObject
|
class Widget : public GuiObject
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,7 @@ MODULE_OBJS := \
|
||||||
src/gui/AudioDialog.o \
|
src/gui/AudioDialog.o \
|
||||||
src/gui/BrowserDialog.o \
|
src/gui/BrowserDialog.o \
|
||||||
src/gui/CheatWidget.o \
|
src/gui/CheatWidget.o \
|
||||||
|
src/gui/ColorWidget.o \
|
||||||
src/gui/CpuWidget.o \
|
src/gui/CpuWidget.o \
|
||||||
src/gui/DataGridWidget.o \
|
src/gui/DataGridWidget.o \
|
||||||
src/gui/DebuggerDialog.o \
|
src/gui/DebuggerDialog.o \
|
||||||
|
|
Loading…
Reference in New Issue