Fixed crash when entering the debugger in software mode.

Some cleanup of the various enum's in the UI classes.

Fixed issues with ordering when adding dialog boxes; this fixes a
bug when adding a dialog from another dialogs ::loadConfig(), in
which case the first one is placed below the second and can't be
seen (mostly applies to MessageBoxes).

Fixed bug in handling OSystem::setBaseDir(); if the directory didn't
exist, then the newly created one wouldn't have a slash appended at the
end.  This causes all further (sub)directories to be created/named
incorrectly.

Started work on extending BrowerDialog to load files as well as
directories, and to allow editing of the items from within the dialog
itself.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2713 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2013-05-01 16:56:43 +00:00
parent ab6276a9cc
commit 86b6191570
18 changed files with 70 additions and 76 deletions

View File

@ -308,8 +308,8 @@ void DebuggerDialog::addRomArea()
// Disassembly area
xpos = r.left + vBorder; ypos += myRam->getHeight() + 5;
const int tabWidth = r.width() - vBorder;
const int tabHeight = r.height() - ypos;
const int tabWidth = r.width() - vBorder - 1;
const int tabHeight = r.height() - ypos - 1;
int tabID;
// Since there are two tab widgets in this dialog, we specifically

View File

@ -405,7 +405,8 @@ void RomListWidget::handleCommand(CommandSender* sender, int cmd, int data, int
case kCheckActionCmd:
// We let the parent class handle this
// Pass it as a kRLBreakpointChangedCmd command, since that's the intent
sendCommand(kRLBreakpointChangedCmd, myCheckList[id]->getState(), _currentPos+id);
sendCommand(RomListWidget::kBreakpointChangedCmd,
myCheckList[id]->getState(), _currentPos+id);
break;
case kSetPositionCmd:
@ -597,7 +598,7 @@ void RomListWidget::endEditMode()
// Send a message that editing finished with a return/enter key press
// The parent then calls getEditString() to get the newly entered data
_editMode = false;
sendCommand(kRLRomChangedCmd, _selectedItem, _id);
sendCommand(RomListWidget::kRomChangedCmd, _selectedItem, _id);
// Reset to normal data entry
EditableWidget::endEditMode();

View File

@ -32,17 +32,18 @@ class CheckListWidget;
#include "CartDebug.hxx"
#include "EditableWidget.hxx"
// Some special commands for this widget
enum {
kRLBreakpointChangedCmd = 'RLbp', // click on the checkbox for a breakpoint
kRLRomChangedCmd = 'RLpr' // ROM item data changed - 'data' will be item index
};
/** RomListWidget */
class RomListWidget : public EditableWidget
{
friend class RomWidget;
public:
enum {
kBreakpointChangedCmd = 'RLbp', // click on the checkbox for a breakpoint
kRomChangedCmd = 'RLpr' // ROM item data changed - 'data' will be
// item index
};
public:
RomListWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h);

View File

@ -139,7 +139,7 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
{
switch(cmd)
{
case kRLBreakpointChangedCmd:
case RomListWidget::kBreakpointChangedCmd:
// 'id' is the line in the disassemblylist to be accessed
// 'data' is the state of the breakpoint at 'id'
setBreak(id, data);
@ -149,12 +149,12 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
myRomList->draw();
break;
case kRLRomChangedCmd:
case RomListWidget::kRomChangedCmd:
// 'data' is the line in the disassemblylist to be accessed
patchROM(data, myRomList->getEditString());
break;
case kCMenuItemSelectedCmd:
case ContextMenu::kItemSelectedCmd:
{
const string& rmb = myRomList->myMenu->getSelectedTag();

View File

@ -87,7 +87,7 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in
switch(cmd)
{
case kCMenuItemSelectedCmd:
case ContextMenu::kItemSelectedCmd:
{
const string& rmb = myMenu->getSelectedTag();

View File

@ -200,7 +200,7 @@ void TiaZoomWidget::handleCommand(CommandSender* sender, int cmd, int data, int
{
switch(cmd)
{
case kCMenuItemSelectedCmd:
case ContextMenu::kItemSelectedCmd:
{
int level = (int) atoi(myMenu->getSelectedTag().c_str());
if(level > 0)

View File

@ -385,9 +385,10 @@ void OSystem::setUIPalette()
void OSystem::setBaseDir(const string& basedir)
{
FilesystemNode node(basedir);
myBaseDir = node.getPath();
if(!node.isDirectory())
node.makeDir();
myBaseDir = node.getPath();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -823,6 +824,7 @@ void OSystem::validatePath(string& path, const string& setting,
FilesystemNode node(s);
if(!node.isDirectory())
node.makeDir();
path = node.getPath();
mySettings->setString(setting, node.getShortPath());
}

View File

@ -47,19 +47,18 @@ BrowserDialog::BrowserDialog(GuiObject* boss, const GUI::Font& font,
_fileList(NULL),
_currentPath(NULL),
_nodeList(NULL),
_mode(FilesystemNode::kListDirectoriesOnly)
_mode(FilesystemNode::kListAll)
{
// Set real dimensions
_w = max_w;
_h = max_h;
const int lineHeight = font.getLineHeight(),
buttonWidth = font.getStringWidth("Defaults") + 20,
buttonHeight = font.getLineHeight() + 4;
int xpos, ypos;
ButtonWidget* b;
// Set real dimensions
// This is one dialog that can take as much space as is available
_w = BSPF_min(max_w, 480);
_h = BSPF_min(max_h, 380);
xpos = 10; ypos = 4;
_title = new StaticTextWidget(this, font, xpos, ypos,
_w - 2 * xpos, lineHeight,
@ -123,18 +122,6 @@ BrowserDialog::~BrowserDialog()
void BrowserDialog::show(const string& title, const string& startpath,
FilesystemNode::ListMode mode, int cmd)
{
// TODO - dialog has to be added before any settings are changed,
// since (for example) changing the title triggers a redraw,
// and the dialog must be added (so it exists) for that to happen
// Fixing this requires changes to the underlying widget classes
// (ie, changing a widgets contents should signal its dialog that a
// redraw is necessary; it shouldn't be responsible for redraw itself)
//
// Doing it this way has the unfortunate side effect that a previous
// title is temporarily visible when re-using the browser for different
// purposes
open();
_title->setLabel(title);
_cmd = cmd;
_mode = mode;
@ -151,6 +138,9 @@ void BrowserDialog::show(const string& title, const string& startpath,
// Alway refresh file list
updateListing();
// Finally, open the dialog after it has been fully updated
open();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -208,7 +198,7 @@ void BrowserDialog::handleCommand(CommandSender* sender, int cmd,
case kChooseCmd:
// Send a signal to the calling class that a selection has been made
// Since we aren't derived from a widget, we don't have a 'data' or 'id'
if(_cmd) sendCommand(_cmd, 0, 0);
if(_cmd) sendCommand(_cmd, -1, -1);
close();
break;

View File

@ -36,6 +36,13 @@ class GameList;
class BrowserDialog : public Dialog, public CommandSender
{
public:
enum ListMode {
kFileLoad, // File selector, no input from user
kFileSave, // File selector, filename changable by user
kDirectoryOpen // Directories only, no input from user
};
public:
BrowserDialog(GuiObject* boss, const GUI::Font& font, int max_w, int max_h);
virtual ~BrowserDialog();

View File

@ -202,7 +202,7 @@ bool ContextMenu::sendSelectionUp()
return false;
_selectedItem--;
sendCommand(_cmd ? _cmd : kCMenuItemSelectedCmd, _selectedItem, -1);
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1);
return true;
}
@ -213,7 +213,7 @@ bool ContextMenu::sendSelectionDown()
return false;
_selectedItem++;
sendCommand(_cmd ? _cmd : kCMenuItemSelectedCmd, _selectedItem, -1);
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1);
return true;
}
@ -224,7 +224,7 @@ bool ContextMenu::sendSelectionFirst()
return false;
_selectedItem = 0;
sendCommand(_cmd ? _cmd : kCMenuItemSelectedCmd, _selectedItem, -1);
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1);
return true;
}
@ -235,7 +235,7 @@ bool ContextMenu::sendSelectionLast()
return false;
_selectedItem = _entries.size() - 1;
sendCommand(_cmd ? _cmd : kCMenuItemSelectedCmd, _selectedItem, -1);
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1);
return true;
}
@ -396,7 +396,7 @@ void ContextMenu::sendSelection()
// Send any command associated with the selection
_selectedItem = item;
sendCommand(_cmd ? _cmd : kCMenuItemSelectedCmd, _selectedItem, -1);
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -27,10 +27,6 @@
#include "Command.hxx"
#include "Dialog.hxx"
enum {
kCMenuItemSelectedCmd = 'CMsl'
};
/**
* Popup context menu which, when clicked, "pop up" a list of items and
* lets the user pick on of them.
@ -43,6 +39,11 @@ enum {
*/
class ContextMenu : public Dialog, public CommandSender
{
public:
enum {
kItemSelectedCmd = 'CMsl'
};
public:
ContextMenu(GuiObject* boss, const GUI::Font& font,
const StringMap& items, int cmd = 0);

View File

@ -80,6 +80,7 @@ void Dialog::open(bool refresh)
uInt32 surfaceID = instance().frameBuffer().allocateSurface(_w, _h, _isBase);
_surface = instance().frameBuffer().surface(surfaceID);
}
parent().addDialog(this);
center();
loadConfig();
@ -90,7 +91,8 @@ void Dialog::open(bool refresh)
_visible = true;
parent().addDialog(this, refresh);
if(refresh)
instance().frameBuffer().refresh();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -106,7 +108,10 @@ void Dialog::close(bool refresh)
_visible = false;
parent().removeDialog(refresh);
parent().removeDialog();
if(refresh)
instance().frameBuffer().refresh();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -112,27 +112,19 @@ void DialogContainer::draw(bool full)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DialogContainer::addDialog(Dialog* d, bool refresh)
void DialogContainer::addDialog(Dialog* d)
{
const GUI::Rect& screen = myOSystem->frameBuffer().screenRect();
assert(d->getWidth() <= screen.width() && d->getHeight() <= screen.height());
myDialogStack.push(d);
if(refresh)
myOSystem->frameBuffer().refresh();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DialogContainer::removeDialog(bool refresh)
void DialogContainer::removeDialog()
{
if(!myDialogStack.empty())
{
myDialogStack.pop();
if(refresh)
myOSystem->frameBuffer().refresh();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -141,12 +141,12 @@ class DialogContainer
/**
Add a dialog box to the stack.
*/
void addDialog(Dialog* d, bool refresh);
void addDialog(Dialog* d);
/**
Remove the topmost dialog box from the stack.
*/
void removeDialog(bool refresh);
void removeDialog();
protected:
OSystem* myOSystem;

View File

@ -174,7 +174,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
mySelectedItem = 0; // Highlight 'Rom Listing'
// Create an options dialog, similar to the in-game one
myOptions = new OptionsDialog(osystem, parent, this, w, h, true); // not in game mode
myOptions = new OptionsDialog(osystem, parent, this, w * 0.8, h * 0.8, true);
// Create a game list, which contains all the information about a ROM that
// the launcher needs
@ -619,7 +619,7 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
updateListing();
break;
case kCMenuItemSelectedCmd:
case ContextMenu::kItemSelectedCmd:
handleContextMenu();
break;

View File

@ -39,7 +39,7 @@ Menu::Menu(OSystem* osystem)
}
else
{
dw = 640; dh = 420;
dw = 480; dh = 380;
}
myBaseDialog = new OptionsDialog(myOSystem, this, 0, dw, dh, false); // in game mode
}

View File

@ -68,15 +68,12 @@ Widget::~Widget()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Widget::draw()
{
if(!_dirty)
if(!_dirty || !isVisible() || !_boss->isVisible())
return;
_dirty = false;
FBSurface& s = _boss->dialog().surface();
if(!isVisible() || !_boss->isVisible())
return;
FBSurface& s = _boss->dialog().surface();
bool hasBorder = _flags & WIDGET_BORDER;
int oldX = _x, oldY = _y, oldW = _w, oldH = _h;

View File

@ -57,6 +57,10 @@ void FilesystemNodePOSIX::setFlags()
{
_isDirectory = S_ISDIR(st.st_mode);
_isFile = S_ISREG(st.st_mode);
// Add a trailing slash, if necessary
if (_isDirectory && _path.length() > 0 && _path[_path.length()-1] != '/')
_path += '/';
}
else
_isDirectory = _isFile = false;
@ -94,14 +98,8 @@ FilesystemNodePOSIX::FilesystemNodePOSIX(const string& p, bool verify)
_displayName = lastPathComponent(_path);
if (verify)
{
if(verify)
setFlags();
// Add a trailing slash, if necessary
if (_isDirectory && _path.length() > 0 && _path[_path.length()-1] != '/')
_path += '/';
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -184,6 +182,9 @@ bool FilesystemNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode,
entry._isDirectory = (dp->d_type == DT_DIR);
entry._isFile = (dp->d_type == DT_REG);
}
if (entry._isDirectory)
entry._path += "/";
}
#endif
@ -197,9 +198,6 @@ bool FilesystemNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode,
(mode == FilesystemNode::kListDirectoriesOnly && !entry._isDirectory))
continue;
if (entry._isDirectory)
entry._path += "/";
myList.push_back(new FilesystemNodePOSIX(entry));
}
closedir(dirp);