Preliminary workings of a disk handling window. Added element visibility,

fixed bug in text that ignored position in a container.
This commit is contained in:
Shamus Hammons 2009-02-03 04:25:02 +00:00
parent a13cd9b31d
commit a6c39ed766
6 changed files with 26 additions and 4 deletions

View File

@ -72,6 +72,7 @@ INCS = -I. -I./src -I/usr/local/include -I/usr/include
OBJS = \
obj/button.o \
obj/diskwindow.o \
obj/draggablewindow.o \
obj/draggablewindow2.o \
obj/element.o \

View File

@ -157,6 +157,9 @@ void Button::HandleKey(SDLKey key)
void Button::HandleMouseMove(uint32 x, uint32 y)
{
if (!visible)
return;
SaveStateVariables();
inside = Inside(x, y);
CheckStateAndRedrawIfNeeded();
@ -164,6 +167,9 @@ void Button::HandleMouseMove(uint32 x, uint32 y)
void Button::HandleMouseButton(uint32 x, uint32 y, bool mouseDown)
{
if (!visible)
return;
SaveStateVariables();
if (inside)
@ -191,6 +197,9 @@ void Button::Draw(void)
#ifdef DEBUG_GUI_BUTTON
WriteLog("Button::Draw()...\n");
#endif
if (!visible)
return;
if (buttonUp == NULL)
return; // Bail out if no surface was created...

View File

@ -41,7 +41,7 @@ SDL_Surface * Element::screen = NULL;
bool Element::needToRefreshScreen = false;
Element::Element(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*/,
Element * parentElement/*= NULL*/): parent(parentElement), backstore(NULL)
Element * parentElement/*= NULL*/): parent(parentElement), backstore(NULL), visible(true)
{
extents.x = x,
extents.y = y,
@ -53,7 +53,7 @@ Element::Element(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*=
Element::Element(uint32 x, uint32 y, uint32 w, uint32 h,
uint8 fgR/*= 0xFF*/, uint8 fgG/*= 0xFF*/, uint8 fgB/*= 0xFF*/, uint8 fgA/*= 0xFF*/,
uint8 bgR/*= 0x00*/, uint8 bgG/*= 0x00*/, uint8 bgB/*= 0x00*/, uint8 bgA/*= 0xFF*/,
Element * parentElement/*= NULL*/): parent(parentElement), backstore(NULL)
Element * parentElement/*= NULL*/): parent(parentElement), backstore(NULL), visible(true)
{
extents.x = x,
extents.y = y,
@ -292,6 +292,11 @@ Steps:
}
}
void Element::SetVisible(bool visibility)
{
visible = visibility;
}
//
// Class methods
//

View File

@ -46,6 +46,7 @@ class Element
void ResetCoverageList(void);
//Need something to prevent this on Elements that don't have mouseover effects...
void AdjustCoverageList(SDL_Rect r);
void SetVisible(bool);
// Class methods...
static void SetScreen(SDL_Surface *);
static bool ScreenNeedsRefreshing(void);
@ -59,6 +60,7 @@ class Element
uint32 bgColor;
SDL_Surface * backstore;
std::list<SDL_Rect> coverList;
bool visible;
// Class variables...
static SDL_Surface * screen;

View File

@ -23,6 +23,7 @@
#include "window.h"
#include "button.h"
#include "text.h"
#include "diskwindow.h"
#include "video.h"
#include "apple2.h"
@ -45,7 +46,7 @@ If disk in drive, MO shows eject graphic, otherwise show load graphic.
If hit 'new blank image':
If disk in drive, ask if want to save if modified
else, load it
If hit 'swap disks', swap disks.
*/
@ -60,6 +61,7 @@ GUI::GUI(SDL_Surface * surface): menuItem(new MenuItems())
windowList.push_back(new Button(30, 250, "Click!"));
windowList.push_back(new Text(30, 20, floppyDrive.GetImageName(0)));
windowList.push_back(new Text(30, 130, floppyDrive.GetImageName(1)));
windowList.push_back(new DiskWindow(&floppyDrive, 240, 20));
}
GUI::~GUI()

View File

@ -23,6 +23,9 @@ Text::Text(uint32 x, uint32 y, std::string s, uint32 fg/*= 0xFF8484FF*/, uint32
void Text::Draw(void)
{
if (text.length() > 0)
{
// DrawString(screenBuffer, extents.x + offsetX, extents.y + offsetY, false, "%s", text.c_str());
DrawStringOpaque(screen, extents.x, extents.y, fgColor, bgColor, "%s", text.c_str());
SDL_Rect r = GetScreenCoords();
DrawStringOpaque(screen, r.x, r.y, fgColor, bgColor, "%s", text.c_str());
}
}