mirror of https://github.com/stella-emu/stella.git
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:
parent
e768e6f7dd
commit
f5684caa4a
|
@ -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: 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
|
### change to number of CPU's you have
|
||||||
NUMBER_CPU = 1
|
NUMBER_CPU = 1
|
||||||
|
|
||||||
|
|
||||||
##============================================================================
|
##============================================================================
|
||||||
## All done, type make to get a list of frontends
|
## All done, type make to get a list of frontends
|
||||||
## No configurable options below this line ...
|
## No configurable options below this line ...
|
||||||
|
|
|
@ -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: 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>
|
#include <algorithm>
|
||||||
|
@ -30,6 +30,7 @@
|
||||||
#include "OSystem.hxx"
|
#include "OSystem.hxx"
|
||||||
#include "Menu.hxx"
|
#include "Menu.hxx"
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
#include "GuiUtils.hxx"
|
||||||
|
|
||||||
#ifdef SNAPSHOT_SUPPORT
|
#ifdef SNAPSHOT_SUPPORT
|
||||||
#include "Snapshot.hxx"
|
#include "Snapshot.hxx"
|
||||||
|
@ -135,11 +136,11 @@ void EventHandler::poll() // FIXME - add modifiers for OSX
|
||||||
switch(int(key))
|
switch(int(key))
|
||||||
{
|
{
|
||||||
case SDLK_EQUALS:
|
case SDLK_EQUALS:
|
||||||
myOSystem->frameBuffer().resize(1);
|
myOSystem->frameBuffer().resize(NextSize);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_MINUS:
|
case SDLK_MINUS:
|
||||||
myOSystem->frameBuffer().resize(-1);
|
myOSystem->frameBuffer().resize(PreviousSize);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_RETURN:
|
case SDLK_RETURN:
|
||||||
|
@ -289,22 +290,18 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
|
||||||
#ifdef DEVELOPER_SUPPORT
|
#ifdef DEVELOPER_SUPPORT
|
||||||
case SDLK_END: // Alt-End increases XStart
|
case SDLK_END: // Alt-End increases XStart
|
||||||
myOSystem->console().changeXStart(1);
|
myOSystem->console().changeXStart(1);
|
||||||
myOSystem->frameBuffer().resize(0);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_HOME: // Alt-Home decreases XStart
|
case SDLK_HOME: // Alt-Home decreases XStart
|
||||||
myOSystem->console().changeXStart(0);
|
myOSystem->console().changeXStart(0);
|
||||||
myOSystem->frameBuffer().resize(0);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_PAGEUP: // Alt-PageUp increases YStart
|
case SDLK_PAGEUP: // Alt-PageUp increases YStart
|
||||||
myOSystem->console().changeYStart(1);
|
myOSystem->console().changeYStart(1);
|
||||||
myOSystem->frameBuffer().resize(0);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_PAGEDOWN: // Alt-PageDown decreases YStart
|
case SDLK_PAGEDOWN: // Alt-PageDown decreases YStart
|
||||||
myOSystem->console().changeYStart(0);
|
myOSystem->console().changeYStart(0);
|
||||||
myOSystem->frameBuffer().resize(0);
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -342,22 +339,18 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
|
||||||
#ifdef DEVELOPER_SUPPORT
|
#ifdef DEVELOPER_SUPPORT
|
||||||
case SDLK_END: // Ctrl-End increases Width
|
case SDLK_END: // Ctrl-End increases Width
|
||||||
myOSystem->console().changeWidth(1);
|
myOSystem->console().changeWidth(1);
|
||||||
myOSystem->frameBuffer().resize(0);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_HOME: // Ctrl-Home decreases Width
|
case SDLK_HOME: // Ctrl-Home decreases Width
|
||||||
myOSystem->console().changeWidth(0);
|
myOSystem->console().changeWidth(0);
|
||||||
myOSystem->frameBuffer().resize(0);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_PAGEUP: // Ctrl-PageUp increases Height
|
case SDLK_PAGEUP: // Ctrl-PageUp increases Height
|
||||||
myOSystem->console().changeHeight(1);
|
myOSystem->console().changeHeight(1);
|
||||||
myOSystem->frameBuffer().resize(0);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_PAGEDOWN: // Ctrl-PageDown decreases Height
|
case SDLK_PAGEDOWN: // Ctrl-PageDown decreases Height
|
||||||
myOSystem->console().changeHeight(0);
|
myOSystem->console().changeHeight(0);
|
||||||
myOSystem->frameBuffer().resize(0);
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case SDLK_s: // Ctrl-s saves properties to a file
|
case SDLK_s: // Ctrl-s saves properties to a file
|
||||||
|
|
|
@ -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: 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>
|
#include <sstream>
|
||||||
|
@ -270,24 +270,19 @@ void FrameBuffer::setupPalette()
|
||||||
theRedrawEntireFrameIndicator = true;
|
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
|
// Update the settings
|
||||||
myOSystem->settings().setBool("fullscreen", isFullscreen);
|
myOSystem->settings().setBool("fullscreen", enable);
|
||||||
|
|
||||||
if(isFullscreen)
|
if(enable)
|
||||||
mySDLFlags |= SDL_FULLSCREEN;
|
mySDLFlags |= SDL_FULLSCREEN;
|
||||||
else
|
else
|
||||||
mySDLFlags &= ~SDL_FULLSCREEN;
|
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
|
switch(size)
|
||||||
// Otherwise use 'mode' to pick the next zoom level
|
|
||||||
if(zoom != 0)
|
|
||||||
{
|
{
|
||||||
// if(myOSystem->settings().getBool("fullscreen"))
|
case PreviousSize: // decrease size
|
||||||
// return;
|
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)
|
if(zoom < 1)
|
||||||
theZoomLevel = 1;
|
theZoomLevel = 1;
|
||||||
else if((uInt32)zoom > theMaxZoomLevel)
|
else if((uInt32)zoom > theMaxZoomLevel)
|
||||||
theZoomLevel = theMaxZoomLevel;
|
theZoomLevel = theMaxZoomLevel;
|
||||||
else
|
else
|
||||||
theZoomLevel = zoom;
|
theZoomLevel = zoom;
|
||||||
}
|
break;
|
||||||
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;
|
|
||||||
|
|
||||||
if(theZoomLevel == theMaxZoomLevel)
|
default: // should never happen
|
||||||
theZoomLevel = 1;
|
|
||||||
else
|
|
||||||
theZoomLevel++;
|
|
||||||
}
|
|
||||||
else if(mode == -1) // decrease size
|
|
||||||
{
|
|
||||||
if(myOSystem->settings().getBool("fullscreen"))
|
|
||||||
return;
|
return;
|
||||||
|
break;
|
||||||
if(theZoomLevel == 1)
|
|
||||||
theZoomLevel = theMaxZoomLevel;
|
|
||||||
else
|
|
||||||
theZoomLevel--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!createScreen())
|
if(!createScreen())
|
||||||
|
|
|
@ -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: 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
|
#ifndef FRAMEBUFFER_HXX
|
||||||
|
@ -41,7 +41,7 @@ class OSystem;
|
||||||
All GUI elements (ala ScummVM) are drawn here as well.
|
All GUI elements (ala ScummVM) are drawn here as well.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@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
|
class FrameBuffer
|
||||||
{
|
{
|
||||||
|
@ -140,25 +140,29 @@ class FrameBuffer
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Toggles between fullscreen and window mode. either automatically
|
Toggles between fullscreen and window mode.
|
||||||
or based on the given flag. Grabmouse activated when in fullscreen mode.
|
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
|
|
||||||
*/
|
*/
|
||||||
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.
|
This routine is called when the user wants to resize the window.
|
||||||
Mode = '1' means window should increase in size
|
Size = 'PreviousSize' means window should decrease in size
|
||||||
Mode = '-1' means window should decrease in size
|
Size = 'NextSize' means window should increase in size
|
||||||
Mode = '0' means window should be resized to defaults
|
Size = 'GivenSize' means window should be resized to quantity given in 'zoom'
|
||||||
|
|
||||||
@param mode How the window should be resized
|
@param size Described above
|
||||||
@param zoom The zoom level to use if something other than 0
|
@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
|
Sets the state of the cursor (hidden or grabbed) based on the
|
||||||
|
|
|
@ -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: 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
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
Probably not very neat, but at least it works ...
|
Probably not very neat, but at least it works ...
|
||||||
|
|
||||||
@author Stephen Anthony
|
@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
|
#define kLineHeight 12
|
||||||
|
@ -41,7 +41,8 @@ enum OverlayColor {
|
||||||
kBGColor,
|
kBGColor,
|
||||||
kShadowColor,
|
kShadowColor,
|
||||||
kTextColor,
|
kTextColor,
|
||||||
kTextColorHi
|
kTextColorHi,
|
||||||
|
kTextColorEm
|
||||||
};
|
};
|
||||||
|
|
||||||
// The commands generated by various widgets
|
// The commands generated by various widgets
|
||||||
|
@ -60,6 +61,13 @@ enum {
|
||||||
kSoundEnableChanged
|
kSoundEnableChanged
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Indicates a three-way possibility when changing the size of some quantity
|
||||||
|
enum Size {
|
||||||
|
PreviousSize,
|
||||||
|
GivenSize,
|
||||||
|
NextSize
|
||||||
|
};
|
||||||
|
|
||||||
static const string EmptyString("");
|
static const string EmptyString("");
|
||||||
|
|
||||||
template<typename T> inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; }
|
template<typename T> inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; }
|
||||||
|
|
|
@ -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: 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
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -281,11 +281,11 @@ void VideoDialog::saveConfig()
|
||||||
// Zoom
|
// Zoom
|
||||||
i = (myZoomSlider->getValue() / 10) + 1;
|
i = (myZoomSlider->getValue() / 10) + 1;
|
||||||
instance()->settings().setInt("zoom", i);
|
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();
|
b = myFullscreenCheckbox->getState();
|
||||||
instance()->frameBuffer().toggleFullscreen(true, b);
|
instance()->frameBuffer().setFullscreen(b);
|
||||||
|
|
||||||
// Use desktop resolution in fullscreen mode
|
// Use desktop resolution in fullscreen mode
|
||||||
b = myUseDeskResCheckbox->getState();
|
b = myUseDeskResCheckbox->getState();
|
||||||
|
|
Loading…
Reference in New Issue