From a6c39ed766537b267bd60fb95584d856041b5519 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Tue, 3 Feb 2009 04:25:02 +0000 Subject: [PATCH] Preliminary workings of a disk handling window. Added element visibility, fixed bug in text that ignored position in a container. --- Makefile | 1 + src/gui/button.cpp | 9 +++++++++ src/gui/element.cpp | 9 +++++++-- src/gui/element.h | 2 ++ src/gui/gui.cpp | 4 +++- src/gui/text.cpp | 5 ++++- 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index c0697cb..5fc33bb 100755 --- a/Makefile +++ b/Makefile @@ -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 \ diff --git a/src/gui/button.cpp b/src/gui/button.cpp index 731b038..be7caaa 100755 --- a/src/gui/button.cpp +++ b/src/gui/button.cpp @@ -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... diff --git a/src/gui/element.cpp b/src/gui/element.cpp index c9401cf..cf60ac3 100755 --- a/src/gui/element.cpp +++ b/src/gui/element.cpp @@ -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 // diff --git a/src/gui/element.h b/src/gui/element.h index a090a96..305b90e 100755 --- a/src/gui/element.h +++ b/src/gui/element.h @@ -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 coverList; + bool visible; // Class variables... static SDL_Surface * screen; diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index d61cfe4..7c6e219 100755 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -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() diff --git a/src/gui/text.cpp b/src/gui/text.cpp index 2dbae7e..cd65a6a 100644 --- a/src/gui/text.cpp +++ b/src/gui/text.cpp @@ -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()); + } } -- 2.37.2