Some more tweaks to the GUI hLine and vLine methods.

Integrated some changes from the ScummVM 0.7,1 codebase wrt the
scrollbar widget.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@397 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-04-24 01:57:47 +00:00
parent 5e88a64305
commit 44bdcdeaf9
7 changed files with 44 additions and 39 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: FrameBufferGL.cxx,v 1.17 2005-04-04 02:19:20 stephena Exp $
// $Id: FrameBufferGL.cxx,v 1.18 2005-04-24 01:57:46 stephena Exp $
//============================================================================
#include <SDL.h>
@ -369,7 +369,7 @@ void FrameBufferGL::blendRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
myGUIPalette[color][1],
myGUIPalette[color][2],
0.7);
glRecti(x, y, x+w, y+h);
glRecti(x, y, x+w-1, y+h-1);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -381,7 +381,7 @@ void FrameBufferGL::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
myGUIPalette[color][1],
myGUIPalette[color][2],
1.0);
glRecti(x, y, x+w, y+h);
glRecti(x, y, x+w-1, y+h-1);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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: FrameBufferSoft.cxx,v 1.16 2005-04-04 02:19:20 stephena Exp $
// $Id: FrameBufferSoft.cxx,v 1.17 2005-04-24 01:57:46 stephena Exp $
//============================================================================
#include <SDL.h>
@ -336,7 +336,7 @@ void FrameBufferSoft::hLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color)
tmp.x = x * theZoomLevel;
tmp.y = y * theZoomLevel;
tmp.w = (x2 - x) * theZoomLevel;
tmp.h = 2;//theZoomLevel;
tmp.h = theZoomLevel;
SDL_FillRect(myScreen, &tmp, myGUIPalette[color]);
}
@ -348,7 +348,7 @@ void FrameBufferSoft::vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color)
// Vertical line
tmp.x = x * theZoomLevel;
tmp.y = y * theZoomLevel;
tmp.w = 2;//theZoomLevel;
tmp.w = theZoomLevel;
tmp.h = (y2 - y) * theZoomLevel;
SDL_FillRect(myScreen, &tmp, myGUIPalette[color]);
}

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.26 2005-04-06 23:47:07 stephena Exp $
// $Id: FrameBuffer.cxx,v 1.27 2005-04-24 01:57:47 stephena Exp $
//============================================================================
#include <sstream>
@ -47,7 +47,7 @@ FrameBuffer::FrameBuffer(OSystem* osystem)
myMessageTime(0),
myMessageText(""),
myMenuRedraws(2),
val(0) // FIXME
myNumRedraws(0)
{
// Add the framebuffer to the system
myOSystem->attach(this);

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.25 2005-04-04 02:19:21 stephena Exp $
// $Id: FrameBuffer.hxx,v 1.26 2005-04-24 01:57:47 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.25 2005-04-04 02:19:21 stephena Exp $
@version $Id: FrameBuffer.hxx,v 1.26 2005-04-24 01:57:47 stephena Exp $
*/
class FrameBuffer
{
@ -133,7 +133,7 @@ class FrameBuffer
*/
void refresh(bool now = false)
{
//cerr << "refresh() " << val++ << endl;
// cerr << "refresh() " << myNumRedraws++ << endl;
theRedrawEntireFrameIndicator = true;
myMenuRedraws = 2;
if(now) drawMediaSource();
@ -453,7 +453,9 @@ FIXME
// Number of times menu have been drawn
uInt32 myMenuRedraws;
int val; // FIXME - remove
// Indicates how many times the framebuffer has been redrawn
// Used only for debugging purposes
uInt32 myNumRedraws;
};
#endif

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: Dialog.cxx,v 1.9 2005-04-04 02:19:22 stephena Exp $
// $Id: Dialog.cxx,v 1.10 2005-04-24 01:57:47 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -40,6 +40,7 @@ Dialog::Dialog(OSystem* instance, uInt16 x, uInt16 y, uInt16 w, uInt16 h)
: GuiObject(instance, x, y, w, h),
_mouseWidget(0),
_focusedWidget(0),
_dragWidget(0),
_visible(true),
_openCount(0)
{
@ -144,14 +145,11 @@ void Dialog::handleMouseDown(int x, int y, int button, int clickCount)
Widget* w;
w = findWidget(x, y);
_dragWidget = w;
// If the click occured inside a widget which is not the currently
// focused one, change the focus to that widget.
// TODO: use the wantsFocus() method to objects, so that only fields
// that want it get the focus (like edit fields, list field...)
// However, right now we "abuse" the focus also for the click&drag
// behaviour of buttons. This should probably be changed by adding
// a nother field, e.g. _clickedWidget or _dragWidget.
if(w && w != _focusedWidget)
if(w && w != _focusedWidget && w->wantsFocus())
{
// The focus will change. Tell the old focused widget (if any)
// that it lost the focus.
@ -164,8 +162,8 @@ void Dialog::handleMouseDown(int x, int y, int button, int clickCount)
_focusedWidget = w;
}
if(w && w == _focusedWidget)
_focusedWidget->handleMouseDown(x - (_focusedWidget->getAbsX() - _x), y - (_focusedWidget->getAbsY() - _y), button, clickCount);
if(w)
w->handleMouseDown(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -175,17 +173,19 @@ void Dialog::handleMouseUp(int x, int y, int button, int clickCount)
if(_focusedWidget)
{
w = _focusedWidget;
//w = _focusedWidget;
// Lose focus on mouseup unless the widget requested to retain the focus
if(! (_focusedWidget->getFlags() & WIDGET_RETAIN_FOCUS ))
releaseFocus();
}
else
w = findWidget(x, y);
w = _dragWidget;
if(w)
w->handleMouseUp(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount);
_dragWidget = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -244,7 +244,7 @@ void Dialog::handleMouseMoved(int x, int y, int button)
{
Widget* w;
if(_focusedWidget)
if(_focusedWidget && !_dragWidget)
{
w = _focusedWidget;
int wx = w->getAbsX() - _x;
@ -255,6 +255,8 @@ void Dialog::handleMouseMoved(int x, int y, int button)
bool mouseInFocusedWidget = (x >= wx && x < wx + w->_w && y >= wy && y < wy + w->_h);
if(mouseInFocusedWidget && _mouseWidget != w)
{
if(_mouseWidget)
_mouseWidget->handleMouseLeft(button);
_mouseWidget = w;
w->handleMouseEntered(button);
}
@ -267,21 +269,23 @@ void Dialog::handleMouseMoved(int x, int y, int button)
w->handleMouseMoved(x - wx, y - wy, button);
}
// While a "drag" is in process (i.e. mouse is moved while a button is pressed),
// only deal with the widget in which the click originated.
if (_dragWidget)
w = _dragWidget;
else
w = findWidget(x, y);
if(_mouseWidget != w)
if (_mouseWidget != w)
{
if(_mouseWidget)
if (_mouseWidget)
_mouseWidget->handleMouseLeft(button);
if(w)
if (w)
w->handleMouseEntered(button);
_mouseWidget = w;
}
if(!w || !(w->getFlags() & WIDGET_TRACK_MOUSE))
return;
if (w && (w->getFlags() & WIDGET_TRACK_MOUSE))
w->handleMouseMoved(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button);
}

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: Dialog.hxx,v 1.7 2005-03-26 19:26:47 stephena Exp $
// $Id: Dialog.hxx,v 1.8 2005-04-24 01:57:47 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -35,7 +35,7 @@ class Menu;
This is the base class for all dialog boxes.
@author Stephen Anthony
@version $Id: Dialog.hxx,v 1.7 2005-03-26 19:26:47 stephena Exp $
@version $Id: Dialog.hxx,v 1.8 2005-04-24 01:57:47 stephena Exp $
*/
class Dialog : public GuiObject
{
@ -81,6 +81,7 @@ class Dialog : public GuiObject
protected:
Widget* _mouseWidget;
Widget* _focusedWidget;
Widget* _dragWidget;
bool _visible;
uInt32 _openCount;

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: ListWidget.cxx,v 1.1 2005-04-04 02:19:22 stephena Exp $
// $Id: ListWidget.cxx,v 1.2 2005-04-24 01:57:47 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -171,8 +171,6 @@ void ListWidget::handleMouseDown(Int32 x, Int32 y, Int32 button, Int32 clickCoun
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ListWidget::handleMouseUp(Int32 x, Int32 y, Int32 button, Int32 clickCount)
{
_scrollBar->handleMouseUp(x, y, button, clickCount);
// If this was a double click and the mouse is still over the selected item,
// send the double click command
if (clickCount == 2 && (_selectedItem == (y - 1) / kLineHeight + _currentPos))