stella/src/gui/Dialog.hxx

151 lines
4.3 KiB
C++
Raw Normal View History

//============================================================================
//
// 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-2014 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id$
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
//============================================================================
#ifndef DIALOG_HXX
#define DIALOG_HXX
class FBSurface;
class OSystem;
class DialogContainer;
class TabWidget;
#include "Command.hxx"
#include "Widget.hxx"
#include "GuiObject.hxx"
#include "StellaKeys.hxx"
#include "bspf.hxx"
/**
This is the base class for all dialog boxes.
@author Stephen Anthony
@version $Id$
*/
class Dialog : public GuiObject
{
friend class DialogContainer;
public:
Dialog(OSystem* instance, DialogContainer* parent,
int x, int y, int w, int h);
virtual ~Dialog();
void open(bool refresh = true);
void close(bool refresh = true);
bool isVisible() const { return _visible; }
OK, some huge changes across the board, so lets see if I get it all: After much request, added ability to access the settings menu from the ROM browser dialog. This menu now contains almost all items that can be selected in Stella, and can be accessed in-game as before. Completely removed pause functionality from the core code. It made sense back when Stella was a single-mode program: there were two modes; emulation and pause. Now that there are other event modes, the EventHandler state machine is getting too complicated. If you want to pause, you can simply enter one of the in-game menus. Related to this, when the app is minimized, Stella enters the menu dialog state. Previously, minimizing the app caused a pause, but since there was no onscreen feedback, many people assumed the app locked up. Added centering to all Dialog boxes, which is done dynamically, as they're placed on the dialog stack to be drawn to the screen. Cleaned up the API of Console/FrameBuffer/OSystem classes wrt to palettes and timing. Parts of each were being done in different classes; now it should be more consistent. Started infrastructure for user-selectable UI palettes. For now, there's no way to change it in the GUI, and it defaults to the normal palette. Eventually, there will be several choices selectable from an in-game menu. Removed '-channels' commandline argument, since that feature can be set from the ROM properties. Added '128' to the choices for fragment size in AudioDialog. Tweaked the OpenGL dynamic loading code to test both the given GL lib, and if that fails to use auto-detection. It seems in the OSX port, the first approach works for some people, and not the other (and vice-versa), git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1255 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-12-30 22:26:29 +00:00
virtual void center();
virtual void drawDialog();
virtual void loadConfig() {}
virtual void saveConfig() {}
virtual void setDefaults() {}
void addFocusWidget(Widget* w);
void addToFocusList(WidgetArray& list);
void addToFocusList(WidgetArray& list, TabWidget* w, int tabId);
void addBGroupToFocusList(WidgetArray& list) { _buttonGroup = list; }
void redrawFocus();
void addTabWidget(TabWidget* w);
void addOKWidget(Widget* w) { _okWidget = w; }
void addCancelWidget(Widget* w) { _cancelWidget = w; }
void setFocus(Widget* w);
FBSurface& surface() const { return *_surface; }
protected:
virtual void draw();
void releaseFocus();
virtual void handleKeyDown(StellaKey key, StellaMod modifiers, char ascii);
virtual void handleKeyUp(StellaKey key, StellaMod modifiers, char ascii);
virtual void handleMouseDown(int x, int y, int button, int clickCount);
virtual void handleMouseUp(int x, int y, int button, int clickCount);
virtual void handleMouseWheel(int x, int y, int direction);
virtual void handleMouseMoved(int x, int y, int button);
virtual bool handleMouseClicks(int x, int y, int button);
virtual void handleJoyDown(int stick, int button);
virtual void handleJoyUp(int stick, int button);
virtual void handleJoyAxis(int stick, int axis, int value);
virtual bool handleJoyHat(int stick, int hat, int value);
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
Widget* findWidget(int x, int y); // Find the widget at pos x,y if any
void addOKCancelBGroup(WidgetArray& wid, const GUI::Font& font,
const string& okText = "",
const string& cancelText = "");
void processCancelWithoutWidget(bool state) { _processCancel = state; }
private:
void buildCurrentFocusList(int tabID = -1);
bool handleNavEvent(Event::Type e);
void getTabIdForWidget(Widget* w);
bool cycleTab(int direction);
protected:
Widget* _mouseWidget;
Widget* _focusedWidget;
Widget* _dragWidget;
Widget* _okWidget;
Widget* _cancelWidget;
bool _visible;
bool _processCancel;
private:
struct Focus {
Widget* widget;
WidgetArray list;
Focus(Widget* w = 0);
virtual ~Focus();
};
typedef Common::Array<Focus> FocusList;
struct TabFocus {
TabWidget* widget;
FocusList focus;
uInt32 currentTab;
TabFocus(TabWidget* w = 0);
virtual ~TabFocus();
void appendFocusList(WidgetArray& list);
void saveCurrentFocus(Widget* w);
Widget* getNewFocus();
};
typedef Common::Array<TabFocus> TabFocusList;
Focus _myFocus; // focus for base dialog
TabFocusList _myTabList; // focus for each tab (if any)
WidgetArray _buttonGroup;
FBSurface* _surface;
int _tabID;
};
#endif