]> Shamusworld >> Repos - apple2/commitdiff
Preliminary workings of a disk handling window. Added element visibility,
authorShamus Hammons <jlhamm@acm.org>
Tue, 3 Feb 2009 04:25:02 +0000 (04:25 +0000)
committerShamus Hammons <jlhamm@acm.org>
Tue, 3 Feb 2009 04:25:02 +0000 (04:25 +0000)
fixed bug in text that ignored position in a container.

Makefile
src/gui/button.cpp
src/gui/element.cpp
src/gui/element.h
src/gui/gui.cpp
src/gui/text.cpp

index c0697cbc76ea16808f3008d6585ca7e52538258a..5fc33bb459dc8129493cb24e951255e37e786ed5 100755 (executable)
--- 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         \
index 731b0389a63f382f61c74abbc403e5ce3d770bba..be7caaad04b342841eec2cc5085c85ee436c7fb9 100755 (executable)
@@ -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...
 
index c9401cf8ecd7c5a24972395426052bb04c626ba1..cf60ac3af3a6f45a9c526e97ea6202ab484f5ca3 100755 (executable)
@@ -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
 //
index a090a968c2164b9f92f1f912268d171cc3210c41..305b90e2d342c840e3be3b268e5a2f762912f5c7 100755 (executable)
@@ -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;
index d61cfe4e620cd870b143a095754a3aa1d7a229c0..7c6e219782d001fbd2c7c7680964c0abb341b267 100755 (executable)
@@ -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()
index 2dbae7eaa0ab12ddfa22bc055152484f16efc196..cd65a6ac60b0a8751329509caef282d07e231872 100644 (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());
+       }
 }