mirror of https://github.com/stella-emu/stella.git
Fixed issue with 'floating focus' rectangle in TabWidget, which
sometimes caused the focus rect to be drawn in the wrong place. Activated some more items in GameInfoDialog, and have it actually load properties for viewing/editing. Fixed EventHandler/GUI unicode<->keycode conversion yet again. Mark, if you're reading this, can you test it on OSX again? git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@800 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
bf108706ac
commit
9ba65abb12
|
@ -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: EventHandler.cxx,v 1.100 2005-09-28 22:49:06 stephena Exp $
|
||||
// $Id: EventHandler.cxx,v 1.101 2005-09-29 18:50:51 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -706,6 +706,7 @@ void EventHandler::handleKeyEvent(int unicode, SDLKey key, SDLMod mod, uInt8 sta
|
|||
else // Determine which dialog to send events to
|
||||
{
|
||||
// Make sure the unicode field is valid
|
||||
/*
|
||||
if (key >= SDLK_F1 && key <= SDLK_F9)
|
||||
unicode = key - SDLK_F1 + 315;
|
||||
else if (key >= SDLK_KP0 && key <= SDLK_KP9)
|
||||
|
@ -713,10 +714,16 @@ void EventHandler::handleKeyEvent(int unicode, SDLKey key, SDLMod mod, uInt8 sta
|
|||
else if (key == SDLK_BACKSPACE || key == SDLK_DELETE ||
|
||||
(key >= SDLK_UP && key <= SDLK_PAGEDOWN))
|
||||
unicode = key;
|
||||
else if (key >= 'a' && key <= 'z' && mod & KMOD_SHIFT)
|
||||
unicode = key & ~0x20;
|
||||
else if (key >= SDLK_NUMLOCK && key <= SDLK_UNDO)
|
||||
return;
|
||||
else
|
||||
unicode = key;
|
||||
*/
|
||||
if (key == SDLK_BACKSPACE || key == SDLK_DELETE ||
|
||||
(key >= SDLK_UP && key <= SDLK_PAGEDOWN))
|
||||
unicode = key;
|
||||
|
||||
switch((int)myState)
|
||||
{
|
||||
|
|
|
@ -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: Dialog.cxx,v 1.29 2005-08-31 19:15:10 stephena Exp $
|
||||
// $Id: Dialog.cxx,v 1.30 2005-09-29 18:50:51 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -156,12 +156,15 @@ void Dialog::buildFocusWidgetList(int id)
|
|||
if(!Widget::isWidgetInChain(_ourFocusList[0].focusList, _focusedWidget))
|
||||
_focusedWidget = _ourFocusList[_focusID].focusedWidget;
|
||||
}
|
||||
else
|
||||
_focusedWidget = 0;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Dialog::redrawFocus()
|
||||
{
|
||||
_focusedWidget = Widget::setFocusForChain(this, getFocusList(), _focusedWidget, 0);
|
||||
if(_focusedWidget)
|
||||
_focusedWidget = Widget::setFocusForChain(this, getFocusList(), _focusedWidget, 0);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -266,26 +269,30 @@ void Dialog::handleMouseWheel(int x, int y, int direction)
|
|||
void Dialog::handleKeyDown(int ascii, int keycode, int modifiers)
|
||||
{
|
||||
// Test for TAB character
|
||||
// Ctrl-Tab selects next tab
|
||||
// Shift-Ctrl-Tab selects previous tab
|
||||
// Shift-left/shift-right cursor selects next tab
|
||||
// Tab sets next widget in current tab
|
||||
// Shift-Tab sets previous widget in current tab
|
||||
//
|
||||
// Widgets are only cycled if currently focused key hasn't claimed
|
||||
// the TAB key
|
||||
// TODO - figure out workaround for this
|
||||
if(keycode == 9) // tab key
|
||||
if(_ourTab && instance()->eventHandler().kbdShift(modifiers))
|
||||
{
|
||||
if(_ourTab && instance()->eventHandler().kbdControl(modifiers))
|
||||
// these key-combos are never passed to the child widget
|
||||
if(ascii == 256 + 20) // left arrow
|
||||
{
|
||||
if(instance()->eventHandler().kbdShift(modifiers))
|
||||
_ourTab->cycleTab(-1);
|
||||
else
|
||||
_ourTab->cycleTab(+1);
|
||||
|
||||
return; // this key-combo is never passed to the child widget
|
||||
_ourTab->cycleTab(-1);
|
||||
return;
|
||||
}
|
||||
else if(_focusedWidget && !(_focusedWidget->getFlags() & WIDGET_WANTS_TAB))
|
||||
else if(ascii == 256 + 19) // right arrow
|
||||
{
|
||||
_ourTab->cycleTab(+1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(keycode == 9) // tab key
|
||||
{
|
||||
if(_focusedWidget && !(_focusedWidget->getFlags() & WIDGET_WANTS_TAB))
|
||||
{
|
||||
if(instance()->eventHandler().kbdShift(modifiers))
|
||||
_focusedWidget = Widget::setFocusForChain(this, getFocusList(),
|
||||
|
|
|
@ -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: EditableWidget.cxx,v 1.11 2005-09-23 23:35:02 stephena Exp $
|
||||
// $Id: EditableWidget.cxx,v 1.12 2005-09-29 18:50:51 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -165,7 +165,7 @@ int EditableWidget::getCaretOffset() const
|
|||
void EditableWidget::drawCaret()
|
||||
{
|
||||
// Only draw if item is visible
|
||||
if (!_editable || !isVisible() || !_boss->isVisible())
|
||||
if (!_editable || !isVisible() || !_boss->isVisible() || !_hasFocus)
|
||||
return;
|
||||
|
||||
GUI::Rect editRect = getEditRect();
|
||||
|
|
|
@ -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: GameInfoDialog.cxx,v 1.12 2005-09-28 22:49:06 stephena Exp $
|
||||
// $Id: GameInfoDialog.cxx,v 1.13 2005-09-29 18:50:51 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -41,7 +41,7 @@ GameInfoDialog::GameInfoDialog(
|
|||
lineHeight = font.getLineHeight();
|
||||
|
||||
const int vBorder = 4;
|
||||
int xpos, ypos, lwidth, tabID;
|
||||
int xpos, ypos, lwidth, fwidth, tabID;
|
||||
WidgetArray wid;
|
||||
|
||||
// The tab widget
|
||||
|
@ -51,26 +51,22 @@ GameInfoDialog::GameInfoDialog(
|
|||
// 1) Cartridge properties
|
||||
wid.clear();
|
||||
tabID = myTab->addTab("Cartridge");
|
||||
// myPrompt = new PromptWidget(myTab, 2, 2, widWidth, widHeight);
|
||||
// myTab->setParentWidget(tabID, myPrompt);
|
||||
// addToFocusList(myPrompt->getFocusList(), tabID);
|
||||
|
||||
xpos = 10;
|
||||
lwidth = font.getStringWidth("Manufacturer: ");
|
||||
fwidth = _w - xpos - lwidth - 10;
|
||||
new StaticTextWidget(myTab, xpos, ypos, lwidth, fontHeight,
|
||||
"Name:", kTextAlignLeft);
|
||||
myName = new EditTextWidget(myTab, xpos+lwidth, ypos, 100, fontHeight, "");
|
||||
myName = new EditTextWidget(myTab, xpos+lwidth, ypos, fwidth, fontHeight, "");
|
||||
wid.push_back(myName);
|
||||
|
||||
ypos += lineHeight + 3;
|
||||
new StaticTextWidget(myTab, xpos, ypos, lwidth, fontHeight,
|
||||
"MD5:", kTextAlignLeft);
|
||||
/*
|
||||
myMD5 = new StaticTextWidget(myTab, xpos, ypos,
|
||||
xpos+lwidth, fontHeight,
|
||||
"HAHA!", kTextAlignLeft);
|
||||
myMD5->setLabel("GAGA!");
|
||||
*/
|
||||
myMD5 = new StaticTextWidget(myTab, xpos+lwidth, ypos,
|
||||
fwidth, fontHeight,
|
||||
"", kTextAlignLeft);
|
||||
|
||||
ypos += lineHeight + 3;
|
||||
new StaticTextWidget(myTab, xpos, ypos, lwidth, fontHeight,
|
||||
"Manufacturer:", kTextAlignLeft);
|
||||
|
@ -88,30 +84,15 @@ GameInfoDialog::GameInfoDialog(
|
|||
ypos += lineHeight + 3;
|
||||
new StaticTextWidget(myTab, xpos, ypos, lwidth, fontHeight,
|
||||
"Rarity:", kTextAlignLeft);
|
||||
myRarity = new PopUpWidget(myTab, xpos+lwidth, ypos, 100, lineHeight,
|
||||
"", 0, 0);
|
||||
myRarity->appendEntry("(1) Common", 1);
|
||||
myRarity->appendEntry("(2) Common+", 2);
|
||||
myRarity->appendEntry("(3) Scarce", 3);
|
||||
myRarity->appendEntry("(4) Scarce+", 4);
|
||||
myRarity->appendEntry("(5) Rare", 5);
|
||||
/*
|
||||
myRarity->appendEntry("(6) Rare+", 6);
|
||||
myRarity->appendEntry("(7) Very Rare", 7);
|
||||
myRarity->appendEntry("(8) Very Rare+", 8);
|
||||
myRarity->appendEntry("(9) Extremely Rare", 9);
|
||||
myRarity->appendEntry("(10) Unbelievably Rare", 10);
|
||||
myRarity->appendEntry("(H) Homebrew", 11);
|
||||
myRarity->appendEntry("(R) Reproduction", 12);
|
||||
myRarity->appendEntry("(P) Prototype", 13);
|
||||
*/
|
||||
myRarity = new EditTextWidget(myTab, xpos+lwidth, ypos,
|
||||
100, fontHeight, "");
|
||||
wid.push_back(myRarity);
|
||||
|
||||
ypos += lineHeight + 3;
|
||||
new StaticTextWidget(myTab, xpos, ypos, lwidth, fontHeight,
|
||||
"Note:", kTextAlignLeft);
|
||||
myNote = new EditTextWidget(myTab, xpos+lwidth, ypos,
|
||||
100, fontHeight, "");
|
||||
fwidth, fontHeight, "");
|
||||
wid.push_back(myNote);
|
||||
|
||||
/*
|
||||
|
@ -134,15 +115,24 @@ GameInfoDialog::GameInfoDialog(
|
|||
addToFocusList(wid, tabID);
|
||||
|
||||
// 2) Console/Controller properties
|
||||
// myTab->addTab("Console");
|
||||
wid.clear();
|
||||
tabID = myTab->addTab("Console");
|
||||
|
||||
addToFocusList(wid, tabID);
|
||||
|
||||
|
||||
// 3) Controller properties
|
||||
// myTab->addTab("Controller");
|
||||
wid.clear();
|
||||
tabID = myTab->addTab("Controller");
|
||||
|
||||
addToFocusList(wid, tabID);
|
||||
|
||||
|
||||
// 4) Display properties
|
||||
// myTab->addTab("Display");
|
||||
wid.clear();
|
||||
tabID = myTab->addTab("Display");
|
||||
|
||||
addToFocusList(wid, tabID);
|
||||
|
||||
/*
|
||||
// Snapshot path
|
||||
|
@ -170,12 +160,16 @@ GameInfoDialog::GameInfoDialog(
|
|||
// Activate the first tab
|
||||
myTab->setActiveTab(0);
|
||||
|
||||
// Add OK & Cancel buttons
|
||||
// Add message concerning usage
|
||||
new StaticTextWidget(this, 10, _h - 20, 120, fontHeight,
|
||||
"(*) Requires a ROM reload", kTextAlignLeft);
|
||||
|
||||
// Add Defaults, OK and Cancel buttons
|
||||
#ifndef MAC_OSX
|
||||
addButton(_w - 2 *(kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
|
||||
addButton(_w - 2 * (kButtonWidth + 7), _h - 24, "OK", kOKCmd, 0);
|
||||
addButton(_w - (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
|
||||
#else
|
||||
addButton(_w - 2 *(kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
|
||||
addButton(_w - 2 * (kButtonWidth + 7), _h - 24, "Cancel", kCloseCmd, 0);
|
||||
addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
|
||||
#endif
|
||||
}
|
||||
|
@ -188,17 +182,27 @@ GameInfoDialog::~GameInfoDialog()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void GameInfoDialog::loadConfig()
|
||||
{
|
||||
cerr << "loadConfig()\n";
|
||||
/*
|
||||
string s;
|
||||
bool b;
|
||||
|
||||
s = instance()->settings().getString("romdir");
|
||||
myRomPath->setLabel(s);
|
||||
s = myGameProperties->get("Cartridge.Name");
|
||||
myName->setEditString(s);
|
||||
|
||||
s = instance()->settings().getString("ssdir");
|
||||
mySnapPath->setLabel(s);
|
||||
s = myGameProperties->get("Cartridge.MD5");
|
||||
myMD5->setLabel(s);
|
||||
|
||||
s = myGameProperties->get("Cartridge.Manufacturer");
|
||||
myManufacturer->setEditString(s);
|
||||
|
||||
s = myGameProperties->get("Cartridge.ModelNo");
|
||||
myModelNo->setEditString(s);
|
||||
|
||||
s = myGameProperties->get("Cartridge.Rarity");
|
||||
myRarity->setEditString(s);
|
||||
|
||||
s = myGameProperties->get("Cartridge.Note");
|
||||
myNote->setEditString(s);
|
||||
|
||||
/*
|
||||
s = instance()->settings().getString("ssname");
|
||||
if(s == "romname")
|
||||
mySnapTypePopup->setSelectedTag(1);
|
||||
|
@ -206,10 +210,8 @@ cerr << "loadConfig()\n";
|
|||
mySnapTypePopup->setSelectedTag(2);
|
||||
else
|
||||
mySnapTypePopup->setSelectedTag(0);
|
||||
|
||||
b = instance()->settings().getBool("sssingle");
|
||||
mySnapSingleCheckbox->setState(!b);
|
||||
*/
|
||||
|
||||
myTab->loadConfig();
|
||||
}
|
||||
|
||||
|
|
|
@ -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: GameInfoDialog.hxx,v 1.9 2005-09-28 22:49:06 stephena Exp $
|
||||
// $Id: GameInfoDialog.hxx,v 1.10 2005-09-29 18:50:51 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -54,7 +54,7 @@ class GameInfoDialog : public Dialog, public CommandSender
|
|||
StaticTextWidget* myMD5;
|
||||
EditTextWidget* myManufacturer;
|
||||
EditTextWidget* myModelNo;
|
||||
PopUpWidget* myRarity;
|
||||
EditTextWidget* myRarity;
|
||||
EditTextWidget* myNote;
|
||||
PopUpWidget* mySound;
|
||||
PopUpWidget* myType;
|
||||
|
|
|
@ -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: TabWidget.cxx,v 1.17 2005-08-10 12:23:42 stephena Exp $
|
||||
// $Id: TabWidget.cxx,v 1.18 2005-09-29 18:50:51 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -121,6 +121,9 @@ void TabWidget::updateActiveTab()
|
|||
_tabs[_activeTab].parentWidget->loadConfig();
|
||||
|
||||
setDirty(); draw();
|
||||
|
||||
// Redraw focused areas
|
||||
_boss->redrawFocus();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -194,7 +197,6 @@ void TabWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void TabWidget::loadConfig()
|
||||
{
|
||||
//cerr << "TabWidget::loadConfig()\n";
|
||||
if(_firstTime)
|
||||
{
|
||||
setActiveTab(_activeTab, true);
|
||||
|
@ -227,7 +229,6 @@ void TabWidget::box(int x, int y, int width, int height,
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void TabWidget::drawWidget(bool hilite)
|
||||
{
|
||||
//cerr << "TabWidget::drawWidget: " << _tabs[_activeTab].firstWidget << endl;
|
||||
// The tab widget is strange in that it acts as both a widget (obviously)
|
||||
// and a dialog (it contains other widgets). Because of the latter,
|
||||
// it must assume responsibility for refreshing all its children.
|
||||
|
@ -264,9 +265,6 @@ void TabWidget::drawWidget(bool hilite)
|
|||
fb.hLine(_x+1, _y + _h - 1, _x + _w - 2, kColor);
|
||||
fb.vLine(_x + _w - 2, _y + kTabHeight - 1, _y + _h - 2, kColor);
|
||||
fb.vLine(_x + _w - 1, _y + kTabHeight - 1, _y + _h - 2, kShadowColor);
|
||||
|
||||
// Redraw focused areas
|
||||
_boss->redrawFocus();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
Loading…
Reference in New Issue