"Enabled" setting of button is now the old unused "Locked" setting of Components, also fix graphical bug with disabled buttons
This commit is contained in:
parent
37f8038fcd
commit
15537d4eff
@ -106,12 +106,12 @@ std::string format::CleanString(std::string dirtyString, bool ascii, bool color,
|
||||
dirtyString[i] = ' ';
|
||||
break;
|
||||
default:
|
||||
// if less than ascii 20 or greater than ascii 126, delete
|
||||
if (numeric && (dirtyString[i] < '0' || dirtyString[i] > '9'))
|
||||
{
|
||||
dirtyString.erase(i, 1);
|
||||
i--;
|
||||
}
|
||||
// if less than ascii 20 or greater than ascii 126, delete
|
||||
else if (ascii && (dirtyString[i] < ' ' || dirtyString[i] > '~'))
|
||||
{
|
||||
dirtyString.erase(i, 1);
|
||||
|
@ -8,7 +8,6 @@ namespace ui {
|
||||
|
||||
Button::Button(Point position, Point size, std::string buttonText, std::string toolTip):
|
||||
Component(position, size),
|
||||
Enabled(true),
|
||||
ButtonText(buttonText),
|
||||
toolTip(toolTip),
|
||||
isButtonDown(false),
|
||||
|
@ -24,8 +24,6 @@ public:
|
||||
Button(Point position = Point(0, 0), Point size = Point(0, 0), std::string buttonText = "", std::string toolTip = "");
|
||||
virtual ~Button();
|
||||
|
||||
bool Enabled;
|
||||
|
||||
virtual void OnMouseClick(int x, int y, unsigned int button);
|
||||
virtual void OnMouseUnclick(int x, int y, unsigned int button);
|
||||
//virtual void OnMouseUp(int x, int y, unsigned int button);
|
||||
|
@ -19,7 +19,7 @@ Component::Component(Window* parent_state):
|
||||
menu(NULL),
|
||||
Position(Point(0,0)),
|
||||
Size(Point(0,0)),
|
||||
Locked(false),
|
||||
Enabled(true),
|
||||
Visible(true)
|
||||
{
|
||||
|
||||
@ -35,7 +35,7 @@ Component::Component(Point position, Point size):
|
||||
menu(NULL),
|
||||
Position(position),
|
||||
Size(size),
|
||||
Locked(false),
|
||||
Enabled(true),
|
||||
Visible(true)
|
||||
{
|
||||
|
||||
@ -51,7 +51,7 @@ Component::Component():
|
||||
menu(NULL),
|
||||
Position(Point(0,0)),
|
||||
Size(Point(0,0)),
|
||||
Locked(false),
|
||||
Enabled(true),
|
||||
Visible(true)
|
||||
{
|
||||
|
||||
|
@ -41,7 +41,7 @@ namespace ui
|
||||
|
||||
Point Position;
|
||||
Point Size;
|
||||
bool Locked;
|
||||
bool Enabled;
|
||||
bool Visible;
|
||||
|
||||
ui::Appearance Appearance;
|
||||
|
@ -193,8 +193,8 @@ void Panel::OnMouseClick(int localx, int localy, unsigned button)
|
||||
//check if clicked a child
|
||||
for(int i = children.size()-1; i >= 0 ; --i)
|
||||
{
|
||||
//child must be unlocked
|
||||
if(!children[i]->Locked)
|
||||
//child must be enabled
|
||||
if(children[i]->Enabled)
|
||||
{
|
||||
//is mouse inside?
|
||||
if( localx >= children[i]->Position.X + ViewportPosition.X &&
|
||||
@ -223,7 +223,7 @@ void Panel::OnMouseDown(int x, int y, unsigned button)
|
||||
XOnMouseDown(x, y, button);
|
||||
for (size_t i = 0; i < children.size(); ++i)
|
||||
{
|
||||
if(!children[i]->Locked)
|
||||
if(children[i]->Enabled)
|
||||
children[i]->OnMouseDown(x, y, button);
|
||||
}
|
||||
}
|
||||
@ -233,7 +233,7 @@ void Panel::OnMouseHover(int localx, int localy)
|
||||
// check if hovering on children
|
||||
for (int i = children.size() - 1; i >= 0; --i)
|
||||
{
|
||||
if (!children[i]->Locked)
|
||||
if (children[i]->Enabled)
|
||||
{
|
||||
if( localx >= children[i]->Position.X &&
|
||||
localy >= children[i]->Position.Y &&
|
||||
@ -255,7 +255,7 @@ void Panel::OnMouseMoved(int localx, int localy, int dx, int dy)
|
||||
XOnMouseMoved(localx, localy, dx, dy);
|
||||
for (size_t i = 0; i < children.size(); ++i)
|
||||
{
|
||||
if(!children[i]->Locked)
|
||||
if(children[i]->Enabled)
|
||||
children[i]->OnMouseMoved(localx - children[i]->Position.X - ViewportPosition.X, localy - children[i]->Position.Y - ViewportPosition.Y, dx, dy);
|
||||
}
|
||||
}
|
||||
@ -265,7 +265,7 @@ void Panel::OnMouseMovedInside(int localx, int localy, int dx, int dy)
|
||||
mouseInside = true;
|
||||
for (size_t i = 0; i < children.size(); ++i)
|
||||
{
|
||||
if (!children[i]->Locked)
|
||||
if (children[i]->Enabled)
|
||||
{
|
||||
Point local (localx - children[i]->Position.X - ViewportPosition.X, localy - children[i]->Position.Y - ViewportPosition.Y)
|
||||
, prevlocal (local.X - dx, local.Y - dy);
|
||||
@ -327,7 +327,7 @@ void Panel::OnMouseUnclick(int localx, int localy, unsigned button)
|
||||
for(int i = children.size()-1; i >= 0 ; --i)
|
||||
{
|
||||
//child must be unlocked
|
||||
if(!children[i]->Locked)
|
||||
if(children[i]->Enabled)
|
||||
{
|
||||
//is mouse inside?
|
||||
if( localx >= children[i]->Position.X + ViewportPosition.X &&
|
||||
@ -354,7 +354,7 @@ void Panel::OnMouseUp(int x, int y, unsigned button)
|
||||
XOnMouseUp(x, y, button);
|
||||
for (size_t i = 0; i < children.size(); ++i)
|
||||
{
|
||||
if (!children[i]->Locked)
|
||||
if (children[i]->Enabled)
|
||||
children[i]->OnMouseUp(x, y, button);
|
||||
}
|
||||
}
|
||||
@ -364,7 +364,7 @@ void Panel::OnMouseWheel(int localx, int localy, int d)
|
||||
XOnMouseWheel(localx, localy, d);
|
||||
for (size_t i = 0; i < children.size(); ++i)
|
||||
{
|
||||
if (!children[i]->Locked)
|
||||
if (children[i]->Enabled)
|
||||
children[i]->OnMouseWheel(localx - children[i]->Position.X - ViewportPosition.X, localy - children[i]->Position.Y - ViewportPosition.Y, d);
|
||||
}
|
||||
}
|
||||
@ -376,7 +376,7 @@ void Panel::OnMouseWheelInside(int localx, int localy, int d)
|
||||
for (int i = children.size()-1; i >= 0 ; --i)
|
||||
{
|
||||
//child must be unlocked
|
||||
if (!children[i]->Locked)
|
||||
if (children[i]->Enabled)
|
||||
{
|
||||
//is mouse inside?
|
||||
if (localx >= children[i]->Position.X + ViewportPosition.X &&
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include <stdexcept>
|
||||
#include "Config.h"
|
||||
#include "Format.h"
|
||||
//#include "Misc.h"
|
||||
#include "gui/interface/Point.h"
|
||||
#include "gui/interface/Textbox.h"
|
||||
#include "gui/interface/Keys.h"
|
||||
|
@ -236,7 +236,7 @@ void Window::DoTick(float dt)
|
||||
//on mouse hover
|
||||
for (int i = Components.size() - 1; i >= 0 && !halt; --i)
|
||||
{
|
||||
if (!Components[i]->Locked &&
|
||||
if (Components[i]->Enabled &&
|
||||
ui::Engine::Ref().GetMouseX() >= Components[i]->Position.X+Position.X &&
|
||||
ui::Engine::Ref().GetMouseY() >= Components[i]->Position.Y+Position.Y &&
|
||||
ui::Engine::Ref().GetMouseX() < Components[i]->Position.X+Position.X + Components[i]->Size.X &&
|
||||
@ -352,7 +352,7 @@ void Window::DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool a
|
||||
//on key press
|
||||
if (focusedComponent_ != NULL)
|
||||
{
|
||||
if (!focusedComponent_->Locked && focusedComponent_->Visible)
|
||||
if (focusedComponent_->Enabled && focusedComponent_->Visible)
|
||||
focusedComponent_->OnKeyPress(key, character, shift, ctrl, alt);
|
||||
}
|
||||
|
||||
@ -378,7 +378,7 @@ void Window::DoKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool
|
||||
//on key unpress
|
||||
if (focusedComponent_ != NULL)
|
||||
{
|
||||
if (!focusedComponent_->Locked && focusedComponent_->Visible)
|
||||
if (focusedComponent_->Enabled && focusedComponent_->Visible)
|
||||
focusedComponent_->OnKeyRelease(key, character, shift, ctrl, alt);
|
||||
}
|
||||
|
||||
@ -396,7 +396,7 @@ void Window::DoMouseDown(int x_, int y_, unsigned button)
|
||||
bool clickState = false;
|
||||
for (int i = Components.size() - 1; i > -1 && !halt; --i)
|
||||
{
|
||||
if (!Components[i]->Locked && Components[i]->Visible)
|
||||
if (Components[i]->Enabled && Components[i]->Visible)
|
||||
{
|
||||
if (x >= Components[i]->Position.X && y >= Components[i]->Position.Y && x < Components[i]->Position.X + Components[i]->Size.X && y < Components[i]->Position.Y + Components[i]->Size.Y)
|
||||
{
|
||||
@ -422,7 +422,7 @@ void Window::DoMouseDown(int x_, int y_, unsigned button)
|
||||
//on mouse down
|
||||
for (int i = Components.size() - 1; i > -1 && !halt; --i)
|
||||
{
|
||||
if (!Components[i]->Locked && Components[i]->Visible)
|
||||
if (Components[i]->Enabled && Components[i]->Visible)
|
||||
Components[i]->OnMouseDown(x, y, button);
|
||||
}
|
||||
|
||||
@ -447,7 +447,7 @@ void Window::DoMouseMove(int x_, int y_, int dx, int dy)
|
||||
#endif
|
||||
for (int i = Components.size() - 1; i > -1 && !halt; --i)
|
||||
{
|
||||
if (!Components[i]->Locked && Components[i]->Visible)
|
||||
if (Components[i]->Enabled && Components[i]->Visible)
|
||||
{
|
||||
Point local(x - Components[i]->Position.X, y - Components[i]->Position.Y);
|
||||
Point a(local.X - dx, local.Y - dy);
|
||||
@ -469,7 +469,8 @@ void Window::DoMouseMove(int x_, int y_, int dx, int dy)
|
||||
{
|
||||
Components[i]->OnMouseEnter(local.X, local.Y);
|
||||
}
|
||||
hoverComponent = Components[i];
|
||||
if (Components[i]->Enabled)
|
||||
hoverComponent = Components[i];
|
||||
}
|
||||
else if (!halt)
|
||||
{
|
||||
@ -503,7 +504,7 @@ void Window::DoMouseUp(int x_, int y_, unsigned button)
|
||||
//on mouse unclick
|
||||
for (int i = Components.size() - 1; i >= 0 && !halt; --i)
|
||||
{
|
||||
if (!Components[i]->Locked && Components[i]->Visible)
|
||||
if (Components[i]->Enabled && Components[i]->Visible)
|
||||
{
|
||||
if (x >= Components[i]->Position.X && y >= Components[i]->Position.Y && x < Components[i]->Position.X + Components[i]->Size.X && y < Components[i]->Position.Y + Components[i]->Size.Y)
|
||||
{
|
||||
@ -516,7 +517,7 @@ void Window::DoMouseUp(int x_, int y_, unsigned button)
|
||||
//on mouse up
|
||||
for (int i = Components.size() - 1; i >= 0 && !halt; --i)
|
||||
{
|
||||
if (!Components[i]->Locked && Components[i]->Visible)
|
||||
if (Components[i]->Enabled && Components[i]->Visible)
|
||||
Components[i]->OnMouseUp(x, y, button);
|
||||
}
|
||||
|
||||
@ -539,7 +540,7 @@ void Window::DoMouseWheel(int x_, int y_, int d)
|
||||
{
|
||||
if (x >= Components[i]->Position.X && y >= Components[i]->Position.Y && x < Components[i]->Position.X + Components[i]->Size.X && y < Components[i]->Position.Y + Components[i]->Size.Y)
|
||||
{
|
||||
if (!Components[i]->Locked && Components[i]->Visible)
|
||||
if (Components[i]->Enabled && Components[i]->Visible)
|
||||
Components[i]->OnMouseWheelInside(x - Components[i]->Position.X, y - Components[i]->Position.Y, d);
|
||||
break;
|
||||
}
|
||||
@ -548,7 +549,7 @@ void Window::DoMouseWheel(int x_, int y_, int d)
|
||||
//on mouse wheel
|
||||
for (int i = Components.size() - 1; i >= 0 && !halt; --i)
|
||||
{
|
||||
if (!Components[i]->Locked && Components[i]->Visible)
|
||||
if (Components[i]->Enabled && Components[i]->Visible)
|
||||
Components[i]->OnMouseWheel(x - Components[i]->Position.X, y - Components[i]->Position.Y, d);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user