Cleaned up the FrameBuffer::resize and FrameBuffer::xxxFullscreen API's.

Functionality is exactly the same; but it just uses cleaner code.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@403 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-05-01 20:11:07 +00:00
parent e768e6f7dd
commit f5684caa4a
6 changed files with 76 additions and 86 deletions

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: makefile,v 1.72 2005-04-28 19:28:31 stephena Exp $
## $Id: makefile,v 1.73 2005-05-01 20:11:06 stephena Exp $
##============================================================================
##============================================================================
@ -46,6 +46,7 @@ OPTIMIZATIONS =
### change to number of CPU's you have
NUMBER_CPU = 1
##============================================================================
## All done, type make to get a list of frontends
## No configurable options below this line ...

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: EventHandler.cxx,v 1.46 2005-05-01 18:57:20 stephena Exp $
// $Id: EventHandler.cxx,v 1.47 2005-05-01 20:11:07 stephena Exp $
//============================================================================
#include <algorithm>
@ -30,6 +30,7 @@
#include "OSystem.hxx"
#include "Menu.hxx"
#include "bspf.hxx"
#include "GuiUtils.hxx"
#ifdef SNAPSHOT_SUPPORT
#include "Snapshot.hxx"
@ -135,11 +136,11 @@ void EventHandler::poll() // FIXME - add modifiers for OSX
switch(int(key))
{
case SDLK_EQUALS:
myOSystem->frameBuffer().resize(1);
myOSystem->frameBuffer().resize(NextSize);
break;
case SDLK_MINUS:
myOSystem->frameBuffer().resize(-1);
myOSystem->frameBuffer().resize(PreviousSize);
break;
case SDLK_RETURN:
@ -289,22 +290,18 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
#ifdef DEVELOPER_SUPPORT
case SDLK_END: // Alt-End increases XStart
myOSystem->console().changeXStart(1);
myOSystem->frameBuffer().resize(0);
break;
case SDLK_HOME: // Alt-Home decreases XStart
myOSystem->console().changeXStart(0);
myOSystem->frameBuffer().resize(0);
break;
case SDLK_PAGEUP: // Alt-PageUp increases YStart
myOSystem->console().changeYStart(1);
myOSystem->frameBuffer().resize(0);
break;
case SDLK_PAGEDOWN: // Alt-PageDown decreases YStart
myOSystem->console().changeYStart(0);
myOSystem->frameBuffer().resize(0);
break;
#endif
}
@ -342,22 +339,18 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
#ifdef DEVELOPER_SUPPORT
case SDLK_END: // Ctrl-End increases Width
myOSystem->console().changeWidth(1);
myOSystem->frameBuffer().resize(0);
break;
case SDLK_HOME: // Ctrl-Home decreases Width
myOSystem->console().changeWidth(0);
myOSystem->frameBuffer().resize(0);
break;
case SDLK_PAGEUP: // Ctrl-PageUp increases Height
myOSystem->console().changeHeight(1);
myOSystem->frameBuffer().resize(0);
break;
case SDLK_PAGEDOWN: // Ctrl-PageDown decreases Height
myOSystem->console().changeHeight(0);
myOSystem->frameBuffer().resize(0);
break;
#endif
case SDLK_s: // Ctrl-s saves properties to a file

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: FrameBuffer.cxx,v 1.29 2005-05-01 18:57:20 stephena Exp $
// $Id: FrameBuffer.cxx,v 1.30 2005-05-01 20:11:07 stephena Exp $
//============================================================================
#include <sstream>
@ -270,24 +270,19 @@ void FrameBuffer::setupPalette()
theRedrawEntireFrameIndicator = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::toggleFullscreen()
{
setFullscreen(!myOSystem->settings().getBool("fullscreen"));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::toggleFullscreen(bool given, bool toggle)
void FrameBuffer::setFullscreen(bool enable)
{
bool isFullscreen;
if(given)
{
if(myOSystem->settings().getBool("fullscreen") == toggle)
return;
isFullscreen = toggle;
}
else
isFullscreen = !myOSystem->settings().getBool("fullscreen");
// Update the settings
myOSystem->settings().setBool("fullscreen", isFullscreen);
myOSystem->settings().setBool("fullscreen", enable);
if(isFullscreen)
if(enable)
mySDLFlags |= SDL_FULLSCREEN;
else
mySDLFlags &= ~SDL_FULLSCREEN;
@ -299,51 +294,40 @@ void FrameBuffer::toggleFullscreen(bool given, bool toggle)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::resize(Int8 mode, Int8 zoom)
void FrameBuffer::resize(Size size, Int8 zoom)
{
// Use the specific zoom level if one is given
// Otherwise use 'mode' to pick the next zoom level
if(zoom != 0)
switch(size)
{
// if(myOSystem->settings().getBool("fullscreen"))
// return;
case PreviousSize: // decrease size
if(myOSystem->settings().getBool("fullscreen"))
return;
if(theZoomLevel == 1)
theZoomLevel = theMaxZoomLevel;
else
theZoomLevel--;
break;
case NextSize: // increase size
if(myOSystem->settings().getBool("fullscreen"))
return;
if(theZoomLevel == theMaxZoomLevel)
theZoomLevel = 1;
else
theZoomLevel++;
break;
case GivenSize: // use 'zoom' quantity
if(zoom < 1)
theZoomLevel = 1;
else if((uInt32)zoom > theMaxZoomLevel)
theZoomLevel = theMaxZoomLevel;
else
theZoomLevel = zoom;
}
else
{
// reset size to that given in properties
// this is a special case of allowing a resize while in fullscreen mode
if(mode == 0)
{
myScreenDim.w = myBaseDim.w;
myScreenDim.h = myBaseDim.h;
}
else if(mode == 1) // increase size
{
if(myOSystem->settings().getBool("fullscreen"))
return;
break;
if(theZoomLevel == theMaxZoomLevel)
theZoomLevel = 1;
else
theZoomLevel++;
}
else if(mode == -1) // decrease size
{
if(myOSystem->settings().getBool("fullscreen"))
default: // should never happen
return;
if(theZoomLevel == 1)
theZoomLevel = theMaxZoomLevel;
else
theZoomLevel--;
}
break;
}
if(!createScreen())

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: FrameBuffer.hxx,v 1.26 2005-04-24 01:57:47 stephena Exp $
// $Id: FrameBuffer.hxx,v 1.27 2005-05-01 20:11:07 stephena Exp $
//============================================================================
#ifndef FRAMEBUFFER_HXX
@ -41,7 +41,7 @@ class OSystem;
All GUI elements (ala ScummVM) are drawn here as well.
@author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.26 2005-04-24 01:57:47 stephena Exp $
@version $Id: FrameBuffer.hxx,v 1.27 2005-05-01 20:11:07 stephena Exp $
*/
class FrameBuffer
{
@ -140,25 +140,29 @@ class FrameBuffer
}
/**
Toggles between fullscreen and window mode. either automatically
or based on the given flag. Grabmouse activated when in fullscreen mode.
@param given Indicates whether to use the specified 'toggle' or
decide based on current status
@param toggle Set the fullscreen mode to this value
Toggles between fullscreen and window mode.
Grabmouse activated when in fullscreen mode.
*/
void toggleFullscreen(bool given = false, bool toggle = false);
void toggleFullscreen();
/**
Enables/disables fullscreen mode.
Grabmouse activated when in fullscreen mode.
@param enable Set the fullscreen mode to this value
*/
void setFullscreen(bool enable);
/**
This routine is called when the user wants to resize the window.
Mode = '1' means window should increase in size
Mode = '-1' means window should decrease in size
Mode = '0' means window should be resized to defaults
Size = 'PreviousSize' means window should decrease in size
Size = 'NextSize' means window should increase in size
Size = 'GivenSize' means window should be resized to quantity given in 'zoom'
@param mode How the window should be resized
@param zoom The zoom level to use if something other than 0
@param size Described above
@param zoom The zoom level to use if size is set to 'sGiven'
*/
void resize(Int8 mode, Int8 zoom = 0);
void resize(Size size, Int8 zoom = 0);
/**
Sets the state of the cursor (hidden or grabbed) based on the

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: GuiUtils.hxx,v 1.6 2005-04-04 02:19:22 stephena Exp $
// $Id: GuiUtils.hxx,v 1.7 2005-05-01 20:11:07 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -29,7 +29,7 @@
Probably not very neat, but at least it works ...
@author Stephen Anthony
@version $Id: GuiUtils.hxx,v 1.6 2005-04-04 02:19:22 stephena Exp $
@version $Id: GuiUtils.hxx,v 1.7 2005-05-01 20:11:07 stephena Exp $
*/
#define kLineHeight 12
@ -41,7 +41,8 @@ enum OverlayColor {
kBGColor,
kShadowColor,
kTextColor,
kTextColorHi
kTextColorHi,
kTextColorEm
};
// The commands generated by various widgets
@ -60,6 +61,13 @@ enum {
kSoundEnableChanged
};
// Indicates a three-way possibility when changing the size of some quantity
enum Size {
PreviousSize,
GivenSize,
NextSize
};
static const string EmptyString("");
template<typename T> inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; }

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: VideoDialog.cxx,v 1.7 2005-04-29 19:05:06 stephena Exp $
// $Id: VideoDialog.cxx,v 1.8 2005-05-01 20:11:07 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -281,11 +281,11 @@ void VideoDialog::saveConfig()
// Zoom
i = (myZoomSlider->getValue() / 10) + 1;
instance()->settings().setInt("zoom", i);
instance()->frameBuffer().resize(0, i);
instance()->frameBuffer().resize(GivenSize, i);
// Fullscreen (the toggleFullscreen function takes care of updating settings)
// Fullscreen (the setFullscreen method takes care of updating settings)
b = myFullscreenCheckbox->getState();
instance()->frameBuffer().toggleFullscreen(true, b);
instance()->frameBuffer().setFullscreen(b);
// Use desktop resolution in fullscreen mode
b = myUseDeskResCheckbox->getState();