1
0
forked from 0ad/0ad

no message

This was SVN commit r23.
This commit is contained in:
janwas 2003-11-04 23:59:41 +00:00
parent df5cf51fa3
commit a6e23bb2e6
3 changed files with 13 additions and 14 deletions

View File

@ -31,9 +31,6 @@ using namespace std;
#include "input.h"
// JW: how about having each object export hit_test(x,y),
// instead of accessing the global mouse pos?
int gui_mouse_x, gui_mouse_y;
// called from main loop when (input) events are received.
// event is passed to other handlers if false is returned.
@ -49,7 +46,7 @@ bool gui_handler(const SDL_Event& ev)
bool CGUI::HandleEvent(const SDL_Event& ev)
{
if(ev.type == SDL_MOUSEMOTION)
gui_mouse_x = ev.motion.x, gui_mouse_y = ev.motion.y;
mouse_x = ev.motion.x, mouse_y = ev.motion.y;
// JW: (pre|post)process omitted; what're they for? why would we need any special button_released handling?

View File

@ -56,6 +56,10 @@ private:
// Private typedefs
typedef CGUIObject *(*ConstructObjectFunction)();
// don't want to pass this around with the ChooseMouseOverAndClosest broadcast -
// we'd need to pack this and pNearest in a struct
u16 mouse_x, mouse_y;
public:
CGUI();
~CGUI();
@ -158,7 +162,6 @@ private:
void Xerces_ReadSprite(XERCES_CPP_NAMESPACE::DOMElement *);
void Xerces_ReadImage(XERCES_CPP_NAMESPACE::DOMElement *, CGUISprite &parent);
private:
// Variables

View File

@ -6,6 +6,7 @@ gee@pyro.nu
//#include "stdafx."
#include "GUI.h"
#include "cgui.h"
///#include "Parser/parser.h"
#include <assert.h>
@ -166,24 +167,22 @@ void CGUIObject::SetupBaseSettingsInfo(map_Settings &SettingsInfo)
}
extern int gui_mouse_x, gui_mouse_y; // declared in cgui.cpp
// JW: how about MouseOver(mouse_x, mouse_y) instead of accessing the global mouse pos?
//-------------------------------------------------------------------
// Checks if mouse is over and returns result
// Input:
// x, y Absolute mouse position
// mouse_x, mouse_y defined in CGUI
//-------------------------------------------------------------------
bool CGUIObject::MouseOver()
{
if (!GetGUI())
CGUI* gui = GetGUI();
if(!gui)
throw PS_NEEDS_PGUI;
return (gui_mouse_x >= m_BaseSettings.m_Size.left &&
gui_mouse_x <= m_BaseSettings.m_Size.right &&
gui_mouse_y >= m_BaseSettings.m_Size.bottom &&
gui_mouse_y <= m_BaseSettings.m_Size.top);
return (gui->mouse_x >= m_BaseSettings.m_Size.left &&
gui->mouse_x <= m_BaseSettings.m_Size.right &&
gui->mouse_y >= m_BaseSettings.m_Size.bottom &&
gui->mouse_y <= m_BaseSettings.m_Size.top);
}
//-------------------------------------------------------------------