Removed GUI cruft, added 10 & 12pt fonts.

This commit is contained in:
Shamus Hammons 2014-03-25 10:45:09 -05:00
parent 63741c0714
commit c7beef2408
11 changed files with 2511 additions and 555 deletions

View File

@ -100,6 +100,8 @@ INCS = -I. -I./src
OBJS = \
obj/diskselector.o \
obj/font10pt.o \
obj/font12pt.o \
obj/font14pt.o \
obj/gui.o \
\

View File

@ -2,7 +2,7 @@
// Apple 2 SDL Portable Apple Emulator
//
// by James Hammons
// (C) 2005 Underground Software
// © 2014 Underground Software
//
// Loosely based on AppleWin by Tom Charlesworth which was based on AppleWin by
// Oliver Schmidt which was based on AppleWin by Michael O'Brien. :-) Parts are
@ -52,9 +52,6 @@
#include "mmu.h"
#include "gui/gui.h"
//#include "gui/window.h"
//#include "gui/draggablewindow2.h"
//#include "gui/textedit.h"
// Debug and misc. defines
@ -331,7 +328,7 @@ int main(int /*argc*/, char * /*argv*/[])
return -1;
}
GUI2::Init(sdlRenderer);
GUI::Init(sdlRenderer);
// Have to do this *after* video init but *before* sound init...!
//Shouldn't be necessary since we're not doing emulation in the ISR...
@ -868,17 +865,17 @@ else if (event.key.keysym.sym == SDLK_F10)
break;
case SDL_MOUSEBUTTONDOWN:
GUI2::MouseDown(event.motion.x, event.motion.y, event.motion.state);
GUI::MouseDown(event.motion.x, event.motion.y, event.motion.state);
break;
case SDL_MOUSEBUTTONUP:
GUI2::MouseUp(event.motion.x, event.motion.y, event.motion.state);
GUI::MouseUp(event.motion.x, event.motion.y, event.motion.state);
break;
case SDL_MOUSEMOTION:
GUI2::MouseMove(event.motion.x, event.motion.y, event.motion.state);
GUI::MouseMove(event.motion.x, event.motion.y, event.motion.state);
break;
case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_LEAVE)
GUI2::MouseMove(0, 0, 0);
GUI::MouseMove(0, 0, 0);
break;
case SDL_QUIT:
@ -889,7 +886,7 @@ else if (event.key.keysym.sym == SDLK_F10)
//#warning "!!! Taking MAJOR time hit with the video frame rendering !!!"
RenderVideoFrame();
RenderScreenBuffer();
GUI2::Render(sdlRenderer);
GUI::Render(sdlRenderer);
SDL_RenderPresent(sdlRenderer);
SetCallbackTime(FrameCallback, 16666.66666667);

View File

@ -20,7 +20,7 @@
#include <algorithm>
#include <string>
#include <vector>
#include "font14pt.h"
#include "font10pt.h"
#include "log.h"
#include "settings.h"
#include "video.h"
@ -87,7 +87,7 @@ void DiskSelector::Init(SDL_Renderer * renderer)
WriteLog("GUI (DiskSelector): Could not set blend mode for charStamp.\n");
for(uint32_t i=0; i<400*300; i++)
windowPixels[i] = 0xB000FF00;
windowPixels[i] = 0xEF00FF00;
SDL_UpdateTexture(window, NULL, windowPixels, 128 * sizeof(Uint32));
FindDisks(NULL);
@ -147,15 +147,23 @@ void DiskSelector::DrawFilenames(SDL_Renderer * renderer)
}
// 3 columns of 16 chars apiece (with 8X16 font), 18 rows
// 3 columns of 18 chars apiece (with 7X12 font), 24 rows
// 3 columns of 21 chars apiece (with 6X11 font), 27 rows
int count = 0;
while (count < imageList.size())
{
int currentX = (count / 18) * 17;
int currentY = (count % 18);
// int currentX = (count / 18) * 17;
// int currentY = (count % 18);
// int currentX = (count / 24) * 19;
// int currentY = (count % 24);
int currentX = (count / 27) * 22;
int currentY = (count % 27);
for(unsigned int i=0; i<16; i++)
// for(unsigned int i=0; i<16; i++)
// for(unsigned int i=0; i<18; i++)
for(unsigned int i=0; i<21; i++)
{
if (i >= imageList[count].length())
break;
@ -165,7 +173,9 @@ void DiskSelector::DrawFilenames(SDL_Renderer * renderer)
count++;
if (count >= (18 * 3))
// if (count >= (18 * 3))
// if (count >= (24 * 3))
if (count >= (27 * 3))
break;
}
@ -191,8 +201,8 @@ void DiskSelector::DrawCharacter(SDL_Renderer * renderer, int x, int y, uint8_t
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00);
#else
uint32_t pixel = 0xFFCFA000;
uint8_t * ptr = (uint8_t *)&font2[(c - 0x20) * FONT_WIDTH * FONT_HEIGHT];
uint32_t pixel = 0xFFFFA000;
uint8_t * ptr = (uint8_t *)&font10pt[(c - 0x20) * FONT_WIDTH * FONT_HEIGHT];
SDL_Rect dst;
dst.x = x * FONT_WIDTH, dst.y = y * FONT_HEIGHT, dst.w = FONT_WIDTH, dst.h = FONT_HEIGHT;

1161
src/gui/font10pt.cpp Normal file

File diff suppressed because it is too large Load Diff

12
src/gui/font10pt.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef __FONT10PT_H__
#define __FONT10PT_H__
#define FONT_WIDTH 6
#define FONT_HEIGHT 11
#include <stdint.h>
extern uint8_t font10pt[];
#endif // __FONT10PT_H__

1256
src/gui/font12pt.cpp Normal file

File diff suppressed because it is too large Load Diff

12
src/gui/font12pt.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef __FONT12PT_H__
#define __FONT12PT_H__
#define FONT_WIDTH 7
#define FONT_HEIGHT 12
#include <stdint.h>
extern uint8_t font12pt[];
#endif // __FONT12PT_H__

View File

@ -2,7 +2,9 @@
// This file was automagically generated by rawfont2c (by James Hammons)
//
char font2[] = {
#include <stdint.h>
uint8_t font2[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

View File

@ -4,7 +4,9 @@
#define FONT_WIDTH 8
#define FONT_HEIGHT 16
extern char font2[];
#include <stdint.h>
extern uint8_t font2[];
#endif // __FONT14PT_H__

View File

@ -3,6 +3,7 @@
//
// Graphical User Interface support
// by James Hammons
// © 2014 Underground Software
//
// JLH = James Hammons <jlhamm@acm.org>
//
@ -11,6 +12,7 @@
// JLH 02/03/2006 Created this file
// JLH 03/13/2006 Added functions to allow shutting down GUI externally
// JLH 03/22/2006 Finalized basic multiple window support
// JLH 03/03/2014 Refactored GUI to use SDL 2, more modern approach as well
//
// STILL TO DO:
//
@ -18,490 +20,6 @@
// - Multiple window handling [DONE]
//
#if 0
#include "gui.h"
#include "menu.h" // Element class methods are pulled in here...
#include "window.h"
#include "button.h"
#include "text.h"
#include "diskselector.h"
#include "diskwindow.h"
#include "video.h"
#include "apple2.h"
#include "applevideo.h"
// Debug support
//#define DEBUG_MAIN_LOOP
// New main screen buffering
// This works, but the colors are rendered incorrectly. Also, it seems that there's
// fullscreen blitting still going on--dragging the disk is fast at first but then
// gets painfully slow. Not sure what's going on there.
//#define USE_NEW_MAINBUFFERING
//#ifdef DEBUG_MAIN_LOOP
#include "log.h"
//#endif
/*
Work flow: Draw floppy drive.
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.
*/
GUI::GUI(SDL_Surface * surface): menuItem(new MenuItems())
{
Element::SetScreen(surface);
// windowList.push_back(new Menu());
// Create drive windows, and config windows here...
windowList.push_back(new Window(30, 30, 200, 100));
windowList.push_back(new Window(30, 140, 200, 100));
windowList.push_back(new Button(30, 250, "Click!"));
windowList.push_back(new Text(30, 20, floppyDrive.ImageName(0)));
windowList.push_back(new Text(30, 130, floppyDrive.ImageName(1)));
windowList.push_back(new DiskWindow(&floppyDrive, 240, 20));
}
GUI::~GUI()
{
// Clean up menuItem, if any
if (menuItem)
delete menuItem;
// Clean up the rest
for(std::list<Element *>::iterator i=windowList.begin(); i!=windowList.end(); i++)
if (*i)
delete *i;
}
void GUI::AddMenuTitle(const char * title)
{
menuItem->title = title;
menuItem->item.clear();
}
void GUI::AddMenuItem(const char * item, Element * (* a)(void)/*= NULL*/, SDL_Scancode k/*= SDLK_UNKNOWN*/)
{
menuItem->item.push_back(NameAction(item, a, k));
}
void GUI::CommitItemsToMenu(void)
{
//We could just do a simple check here to see if more than one item is in the list,
//and if so fail. Make it so you build the menu first before allowing any other action. [DONE]
//Right now, we just silently fail...
if (windowList.size() > 1)
{
WriteLog("GUI: Can't find menu--more than one item in windowList!\n");
return;
}
((Menu *)(*windowList.begin()))->Add(*menuItem);
}
void GUI::Run(void)
{
exitGUI = false;
showMouse = true;
SDL_Event event;
std::list<Element *>::iterator i;
// Not sure what replaces this in SDL2...
// SDL_EnableKeyRepeat(150, 75);
// Also: Need to pick up backbuffer (for those windows that have them)
// BEFORE drawing...
// Initial update... [Now handled correctly in the constructor]
// Uh, still needed here, though... Only makes sense that it should
for(i=windowList.begin(); i!=windowList.end(); i++)
(*i)->Draw();
#ifndef USE_NEW_MAINBUFFERING
RenderScreenBuffer();
#else
FlipMainScreen();
#endif
// Main loop
while (!exitGUI)
{
// if (SDL_PollEvent(&event))
if (SDL_WaitEvent(&event))
{
#ifdef DEBUG_MAIN_LOOP
WriteLog("An event was found!");
#endif
if (event.type == SDL_USEREVENT)
{
#ifdef DEBUG_MAIN_LOOP
WriteLog(" -- SDL_USEREVENT\n");
#endif
//Mebbe add another user event for screen refresh? Why not!
if (event.user.code == WINDOW_CLOSE)
{
for(i=windowList.begin(); i!=windowList.end(); i++)
{
if (*i == (Element *)event.user.data1)
{
delete *i;
windowList.erase(i);
break;
}
}
}
else if (event.user.code == MENU_ITEM_CHOSEN)
{
// Confused? Let me enlighten... What we're doing here is casting
// data1 as a pointer to a function which returns a Element pointer and
// which takes no parameters (the "(Element *(*)(void))" part), then
// derefencing it (the "*" in front of that) in order to call the
// function that it points to. Clear as mud? Yeah, I hate function
// pointers too, but what else are you gonna do?
Element * window = (*(Element *(*)(void))event.user.data1)();
if (window)
windowList.push_back(window);
while (SDL_PollEvent(&event)); // Flush the event queue...
event.type = SDL_MOUSEMOTION;
int mx, my;
SDL_GetMouseState(&mx, &my);
event.motion.x = mx, event.motion.y = my;
SDL_PushEvent(&event); // & update mouse position...!
oldMouse.x = mouse.x, oldMouse.y = mouse.y;
mouse.x = mx, mouse.y = my; // This prevents "mouse flash"...
}
//There's a *small* problem with the following approach--if a window and a bunch of
//child widgets send this message, we'll get a bunch of unnecessary refresh events...
//This could be controlled by having the main window refresh itself intelligently...
//What we could do instead is set a variable in Element and check it after the fact
//to see whether or not a refresh is needed.
//[This is what we do now.]
//Dirty rectangle is also possible...
else if (event.user.code == SCREEN_REFRESH_NEEDED)
#ifndef USE_NEW_MAINBUFFERING
RenderScreenBuffer();
#else
FlipMainScreen();
#endif
}
//Not sure what to do here for SDL2...
#if 0
else if (event.type == SDL_ACTIVEEVENT)
{
//Need to do a screen refresh here...
if (event.active.state == SDL_APPMOUSEFOCUS)
showMouse = (event.active.gain ? true : false);
#ifndef USE_NEW_MAINBUFFERING
RenderScreenBuffer();
#else
FlipMainScreen();
#endif
}
#endif
else if (event.type == SDL_KEYDOWN)
{
#ifdef DEBUG_MAIN_LOOP
WriteLog(" -- SDL_KEYDOWN\n");
#endif
if (event.key.keysym.sym == SDLK_F1)
exitGUI = true;
//Not sure that this is the right way to handle this...
//Probably should only give this to the top level window...
// for(i=windowList.begin(); i!=windowList.end(); i++)
// (*i)->HandleKey(event.key.keysym.sym);
windowList.back()->HandleKey(event.key.keysym.scancode);
}
else if (event.type == SDL_MOUSEMOTION)
{
#ifdef DEBUG_MAIN_LOOP
WriteLog(" -- SDL_MOUSEMOTION\n");
#endif
//This is for tracking a custom mouse cursor, which we're not doing--YET.
oldMouse.x = mouse.x, oldMouse.y = mouse.y;
mouse.x = event.motion.x, mouse.y = event.motion.y;
//Not sure that this is the right way to handle this...
//Right now, we should probably only do mouseover for the last item in the list...
//And now we do!
//Though, it seems to screw other things up. Maybe it IS better to pass it to all windows?
//Or maybe to just the ones that aren't completely obscured?
//Probably. Right now, a disk's close button that should be obscured by one sitting on
//top of it gets redrawn. Not good. !!! FIX !!!
for(i=windowList.begin(); i!=windowList.end(); i++)
(*i)->HandleMouseMove(mouse.x, mouse.y);
// windowList.back()->HandleMouseMove(mouse.x, mouse.y);
}
else if (event.type == SDL_MOUSEBUTTONDOWN)
{
#ifdef DEBUG_MAIN_LOOP
WriteLog(" -- SDL_MOUSEBUTTONDOWN\n");
#endif
//Not sure that this is the right way to handle this...
// What we should do here is ensure that whatever has been clicked on gets moved to the
// highest priority--in our current data schema that would be the end of the list... !!! FIX !!!
//[DONE]
/*
We could do the following:
- Go through list and find which window has been clicked on (if any). If more
than one is clicked on, take the one highest in the Z order (closer to the end
of the list).
- If item is highest in Z order, pass click through to window and exit.
- Otherwise, restore backing store on each window in reverse order.
- Remove item clicked on from the list. Put removed item at the end of the list.
- Go through list and pass click through to each window in the list. Also do a
blit to backing store and a Draw() for each window.
Could also do a check (if not clicked on highest Z window) to see which windows
it overlaps and just do restore/redraw for those that overlap. To wit:
- Create new list containing only those windows that overlap the clicking on window.
- Go through list and do a blit to backing store and a Draw() for each window.
- Go through list and pass click through to each window in the list.
*/
#if 0
#if 0
for(i=windowList.begin(); i!=windowList.end(); i++)
(*i)->HandleMouseButton(event.button.x, event.button.y, true);
#else
// We use the 1st algorithm here, since it's simpler. If we need to, we can optimize
// to the 2nd...
// Walk backward through the list and see if a window was hit.
// This will automagically return us the window with the highest Z.
std::list<Element *>::reverse_iterator ri;
std::list<Element *>::iterator hit;// = windowList.end();
for(ri=windowList.rbegin(); ri!=windowList.rend(); ri++)
{
if ((*ri)->Inside(event.button.x, event.button.y))
{
// Here's a bit of STL weirdness: Converting from a reverse
// iterator to a regular iterator requires backing the iterator
// up a position after grabbing it's base() OR going forward
// one position with the reverse iterator before grabbing base().
// Ugly, but it gets the job done...
hit = (++ri).base();
// Put it back where we found it, so the tests following this
// don't fail...
ri--;
break;
}
}
// If we hit the highest in the list, then pass the event through
// to the window for handling. if we hit no windows, then pass the
// event to all windows. Otherwise, we need to shuffle windows.
//NOTE: We need to pass the click to all windows regardless of whether they're topmost or not...
if (ri == windowList.rbegin())
{
for(i=windowList.begin(); i!=windowList.end(); i++)
(*i)->HandleMouseButton(event.button.x, event.button.y, true);
}
else if (ri == windowList.rend())
{
for(i=windowList.begin(); i!=windowList.end(); i++)
(*i)->HandleMouseButton(event.button.x, event.button.y, true);
}
else
{
// - Otherwise, restore backing store on each window in reverse order.
for(ri=windowList.rbegin(); ri!=windowList.rend(); ri++)
(*ri)->RestoreScreenFromBackstore();
// At this point, the screen has been restored...
// - Remove item clicked on from the list. Put removed item at the end of the list.
windowList.push_back(*hit);
windowList.erase(hit);
// - Go through list and pass click through to each window in the list. Also do a
// blit to backing store and a Draw() for each window.
for(i=windowList.begin(); i!= windowList.end(); i++)
{
// Grab bg into backstore
(*i)->SaveScreenToBackstore();
// Pass click
(*i)->HandleMouseButton(event.button.x, event.button.y, true);
// Draw?
(*i)->Draw();
}
}
#endif
#endif
/*
A slightly different way to handle this would be to loop through all windows, compare
all those above it to see if they obscure it; if so then subdivide it's update rectangle
to eliminate drawing the parts that aren't shown. The beauty of this approach is that
you don't have to care what order the windows are drawn in and you don't need to worry
about the order of restoring the backing store.
You *do* still need to determine the Z-order of the windows, in order to get the subdivisions
correct, but that's not too terrible.
Also, when doing a window drag, the coverage lists for all windows have to be regenerated.
*/
std::list<Element *>::reverse_iterator ri;
bool movedWindow = false;
for(ri=windowList.rbegin(); ri!=windowList.rend(); ri++)
{
if ((*ri)->Inside(event.button.x, event.button.y))
{
// Remove item clicked on from the list & put removed item at the
// end of the list, thus putting the window at the top of the Z
// order. But IFF window is not already topmost!
if (ri != windowList.rbegin())
{
windowList.push_back(*ri);
// Here's a bit of STL weirdness: Converting from a reverse
// iterator to a regular iterator requires backing the iterator
// up a position after grabbing it's base() OR going forward
// one position with the reverse iterator before grabbing base().
// Ugly, but it get the job done...
windowList.erase((++ri).base());
movedWindow = true;
}
break;
}
}
//Small problem here: we should only pass the *hit* to the topmost window and pass
//*misses* to everyone else... Otherwise, you can have overlapping draggable windows
//and be able to drag both by clicking on a point that intersects both...
//(though that may be an interesting way to handle things!)
//The thing is that you want to do it on purpose (like with a special grouping widget)
//instead of by accident. So, !!! FIX !!!
// Pass the click on to all windows
// for(i=windowList.begin(); i!=windowList.end(); i++)
// (*i)->HandleMouseButton(event.button.x, event.button.y, true);
windowList.back()->HandleMouseButton(event.button.x, event.button.y, true);
// // & bail if nothing changed...
if (movedWindow)
// return;
{
// Check for overlap/build coverage lists [O((n^2)/2) algorithm!]
//One way to optimize this would be to only reset coverage lists from the point in
//the Z order where the previous window was.
for(i=windowList.begin(); i!=windowList.end(); i++)
{
//One other little quirk: Probably need to clear the backing store as well!
//Not sure...
(*i)->ResetCoverageList();
// This looks odd, but it's just a consequence of iterator weirdness.
// Otherwise we could just stick a j+1 in the for loop below. :-P
std::list<Element *>::iterator j = i;
j++;
for(; j!=windowList.end(); j++)
(*i)->AdjustCoverageList((*j)->GetExtents());
// (*i)->HandleMouseButton(event.button.x, event.button.y, true);
(*i)->Draw();
}
}
}
else if (event.type == SDL_MOUSEBUTTONUP)
{
#ifdef DEBUG_MAIN_LOOP
WriteLog(" -- SDL_MOUSEBUTTONUP\n");
#endif
//Not sure that this is the right way to handle this...
for(i=windowList.begin(); i!=windowList.end(); i++)
(*i)->HandleMouseButton(event.button.x, event.button.y, false);
//I think we should only do topmost here...
//Or should we???
// windowList.back()->HandleMouseButton(event.button.x, event.button.y, false);
}
#ifdef DEBUG_MAIN_LOOP
else
WriteLog(" -- Unknown event\n");
#endif
if (Element::ScreenNeedsRefreshing())
{
#ifndef USE_NEW_MAINBUFFERING
#ifdef DEBUG_MAIN_LOOP
WriteLog("Screen refresh called!\n");
#endif
RenderScreenBuffer();
Element::ScreenWasRefreshed();
#else
FlipMainScreen();
Element::ScreenWasRefreshed();
#endif
}
}
//hm. Works, but slows things way down.
//Now we use WaitEvents() instead. Yay!
//SDL_Delay(10);
}
// Not sure what to do for this in SDL 2...
// SDL_EnableKeyRepeat(0, 0);
// return false;
}
void GUI::Stop(void)
{
exitGUI = true;
}
#endif
//
// NEW GUI STARTS HERE
//
// Okay, this is ugly but works and I can't think of any better way to handle
// this. So what we do when we pass the GIMP bitmaps into a function is pass
// them as a (void *) and then cast them as type (Bitmap *) in order to use
// them. Yes, it's ugly. Come up with something better!
struct Bitmap {
unsigned int width;
unsigned int height;
unsigned int bytesPerPixel; // 3:RGB, 4:RGBA
unsigned char pixelData[];
};
#include "gui.h"
#include "apple2.h"
#include "applevideo.h"
@ -522,6 +40,19 @@ struct Bitmap {
#include "gfx/config-icon.c"
// Okay, this is ugly but works and I can't think of any better way to handle
// this. So what we do when we pass the GIMP bitmaps into a function is pass
// them as a (void *) and then cast them as type (Bitmap *) in order to use
// them. Yes, it's ugly. Come up with something better!
struct Bitmap {
unsigned int width;
unsigned int height;
unsigned int bytesPerPixel; // 3:RGB, 4:RGBA
unsigned char pixelData[];
};
const char numeralOne[(7 * 7) + 1] =
" @@ "
" @@@ "
@ -560,12 +91,12 @@ const char driveLight[(5 * 5) + 1] =
enum { SBS_SHOWING, SBS_HIDING, SBS_SHOWN, SBS_HIDDEN };
SDL_Texture * GUI2::overlay = NULL;
SDL_Rect GUI2::olDst;
int GUI2::sidebarState = SBS_HIDDEN;
int32_t GUI2::dx = 0;
int32_t GUI2::iconSelected = -1;
bool GUI2::hasKeyboardFocus = false;
SDL_Texture * GUI::overlay = NULL;
SDL_Rect GUI::olDst;
int GUI::sidebarState = SBS_HIDDEN;
int32_t GUI::dx = 0;
int32_t GUI::iconSelected = -1;
bool GUI::hasKeyboardFocus = false;
int32_t lastIconSelected = -1;
SDL_Texture * iconSelection = NULL;
SDL_Texture * diskIcon = NULL;
@ -588,17 +119,17 @@ const char iconHelp[7][80] = { "Turn emulated Apple off/on",
#define SIDEBAR_X_POS (VIRTUAL_SCREEN_WIDTH - 80)
GUI2::GUI2(void)
GUI::GUI(void)
{
}
GUI2::~GUI2(void)
GUI::~GUI(void)
{
}
void GUI2::Init(SDL_Renderer * renderer)
void GUI::Init(SDL_Renderer * renderer)
{
overlay = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888,
SDL_TEXTUREACCESS_TARGET, 128, 380);
@ -657,7 +188,7 @@ void GUI2::Init(SDL_Renderer * renderer)
}
SDL_Texture * GUI2::CreateTexture(SDL_Renderer * renderer, const void * source)
SDL_Texture * GUI::CreateTexture(SDL_Renderer * renderer, const void * source)
{
Bitmap * bitmap = (Bitmap *)source;
SDL_Texture * texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888,
@ -671,17 +202,17 @@ SDL_Texture * GUI2::CreateTexture(SDL_Renderer * renderer, const void * source)
}
void GUI2::MouseDown(int32_t x, int32_t y, uint32_t buttons)
void GUI::MouseDown(int32_t x, int32_t y, uint32_t buttons)
{
}
void GUI2::MouseUp(int32_t x, int32_t y, uint32_t buttons)
void GUI::MouseUp(int32_t x, int32_t y, uint32_t buttons)
{
}
void GUI2::MouseMove(int32_t x, int32_t y, uint32_t buttons)
void GUI::MouseMove(int32_t x, int32_t y, uint32_t buttons)
{
if (sidebarState != SBS_SHOWN)
{
@ -739,7 +270,7 @@ void GUI2::MouseMove(int32_t x, int32_t y, uint32_t buttons)
}
void GUI2::HandleIconSelection(SDL_Renderer * renderer)
void GUI::HandleIconSelection(SDL_Renderer * renderer)
{
// Set up drive icons in their current states
AssembleDriveIcon(renderer, 0);
@ -769,7 +300,7 @@ void GUI2::HandleIconSelection(SDL_Renderer * renderer)
}
void GUI2::AssembleDriveIcon(SDL_Renderer * renderer, int driveNumber)
void GUI::AssembleDriveIcon(SDL_Renderer * renderer, int driveNumber)
{
SDL_Texture * drive[2] = { disk1Icon, disk2Icon };
const char * number[2] = { numeralOne, numeralTwo };
@ -799,7 +330,7 @@ void GUI2::AssembleDriveIcon(SDL_Renderer * renderer, int driveNumber)
}
void GUI2::DrawEjectButton(SDL_Renderer * renderer, int driveNumber)
void GUI::DrawEjectButton(SDL_Renderer * renderer, int driveNumber)
{
if (floppyDrive.IsEmpty(driveNumber))
return;
@ -808,7 +339,7 @@ void GUI2::DrawEjectButton(SDL_Renderer * renderer, int driveNumber)
}
void GUI2::DrawDriveLight(SDL_Renderer * renderer, int driveNumber)
void GUI::DrawDriveLight(SDL_Renderer * renderer, int driveNumber)
{
int lightState = floppyDrive.DriveLightStatus(driveNumber);
int r = 0x77, g = 0x00, b = 0x00;
@ -823,7 +354,7 @@ void GUI2::DrawDriveLight(SDL_Renderer * renderer, int driveNumber)
}
void GUI2::DrawCharArray(SDL_Renderer * renderer, const char * array, int x,
void GUI::DrawCharArray(SDL_Renderer * renderer, const char * array, int x,
int y, int w, int h, int r, int g, int b)
{
SDL_SetRenderDrawColor(renderer, r, g, b, 0xFF);
@ -841,7 +372,7 @@ void GUI2::DrawCharArray(SDL_Renderer * renderer, const char * array, int x,
}
void GUI2::HandleGUIState(void)
void GUI::HandleGUIState(void)
{
olDst.x += dx;
@ -860,7 +391,7 @@ void GUI2::HandleGUIState(void)
}
void GUI2::DrawSidebarIcons(SDL_Renderer * renderer)
void GUI::DrawSidebarIcons(SDL_Renderer * renderer)
{
SDL_Texture * icons[7] = { powerOnIcon, disk1Icon, disk2Icon, diskSwapIcon,
stateSaveIcon, stateLoadIcon, configIcon };
@ -876,7 +407,7 @@ void GUI2::DrawSidebarIcons(SDL_Renderer * renderer)
}
void GUI2::Render(SDL_Renderer * renderer)
void GUI::Render(SDL_Renderer * renderer)
{
if (!overlay)
return;

View File

@ -8,40 +8,12 @@
#define __GUI_H__
#include <SDL2/SDL.h>
#include <list>
#if 0
class Menu; // Now *this* should work, since we've got pointers...
class MenuItems;
class Element;
class GUI
{
public:
GUI(SDL_Surface *);
GUI();
~GUI();
void AddMenuTitle(const char *);
void AddMenuItem(const char *, Element * (* a)(void) = NULL, SDL_Scancode k = SDL_SCANCODE_UNKNOWN);
void CommitItemsToMenu(void);
void Run(void);
void Stop(void);
private:
// Menu * mainMenu;
MenuItems * menuItem;
std::list<Element *> windowList;
bool exitGUI;
bool showMouse;
SDL_Rect mouse, oldMouse;
};
#endif
class GUI2
{
public:
GUI2();
~GUI2();
// Everything else is a class method...
static void Init(SDL_Renderer *);
@ -68,6 +40,5 @@ class GUI2
static bool hasKeyboardFocus;
};
#endif // __GUI_H__