"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] = ' ';
|
dirtyString[i] = ' ';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// if less than ascii 20 or greater than ascii 126, delete
|
|
||||||
if (numeric && (dirtyString[i] < '0' || dirtyString[i] > '9'))
|
if (numeric && (dirtyString[i] < '0' || dirtyString[i] > '9'))
|
||||||
{
|
{
|
||||||
dirtyString.erase(i, 1);
|
dirtyString.erase(i, 1);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
// if less than ascii 20 or greater than ascii 126, delete
|
||||||
else if (ascii && (dirtyString[i] < ' ' || dirtyString[i] > '~'))
|
else if (ascii && (dirtyString[i] < ' ' || dirtyString[i] > '~'))
|
||||||
{
|
{
|
||||||
dirtyString.erase(i, 1);
|
dirtyString.erase(i, 1);
|
||||||
|
@ -8,7 +8,6 @@ namespace ui {
|
|||||||
|
|
||||||
Button::Button(Point position, Point size, std::string buttonText, std::string toolTip):
|
Button::Button(Point position, Point size, std::string buttonText, std::string toolTip):
|
||||||
Component(position, size),
|
Component(position, size),
|
||||||
Enabled(true),
|
|
||||||
ButtonText(buttonText),
|
ButtonText(buttonText),
|
||||||
toolTip(toolTip),
|
toolTip(toolTip),
|
||||||
isButtonDown(false),
|
isButtonDown(false),
|
||||||
|
@ -24,8 +24,6 @@ public:
|
|||||||
Button(Point position = Point(0, 0), Point size = Point(0, 0), std::string buttonText = "", std::string toolTip = "");
|
Button(Point position = Point(0, 0), Point size = Point(0, 0), std::string buttonText = "", std::string toolTip = "");
|
||||||
virtual ~Button();
|
virtual ~Button();
|
||||||
|
|
||||||
bool Enabled;
|
|
||||||
|
|
||||||
virtual void OnMouseClick(int x, int y, unsigned int button);
|
virtual void OnMouseClick(int x, int y, unsigned int button);
|
||||||
virtual void OnMouseUnclick(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);
|
//virtual void OnMouseUp(int x, int y, unsigned int button);
|
||||||
|
@ -19,7 +19,7 @@ Component::Component(Window* parent_state):
|
|||||||
menu(NULL),
|
menu(NULL),
|
||||||
Position(Point(0,0)),
|
Position(Point(0,0)),
|
||||||
Size(Point(0,0)),
|
Size(Point(0,0)),
|
||||||
Locked(false),
|
Enabled(true),
|
||||||
Visible(true)
|
Visible(true)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ Component::Component(Point position, Point size):
|
|||||||
menu(NULL),
|
menu(NULL),
|
||||||
Position(position),
|
Position(position),
|
||||||
Size(size),
|
Size(size),
|
||||||
Locked(false),
|
Enabled(true),
|
||||||
Visible(true)
|
Visible(true)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ Component::Component():
|
|||||||
menu(NULL),
|
menu(NULL),
|
||||||
Position(Point(0,0)),
|
Position(Point(0,0)),
|
||||||
Size(Point(0,0)),
|
Size(Point(0,0)),
|
||||||
Locked(false),
|
Enabled(true),
|
||||||
Visible(true)
|
Visible(true)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ namespace ui
|
|||||||
|
|
||||||
Point Position;
|
Point Position;
|
||||||
Point Size;
|
Point Size;
|
||||||
bool Locked;
|
bool Enabled;
|
||||||
bool Visible;
|
bool Visible;
|
||||||
|
|
||||||
ui::Appearance Appearance;
|
ui::Appearance Appearance;
|
||||||
|
@ -193,8 +193,8 @@ void Panel::OnMouseClick(int localx, int localy, unsigned button)
|
|||||||
//check if clicked a child
|
//check if clicked a child
|
||||||
for(int i = children.size()-1; i >= 0 ; --i)
|
for(int i = children.size()-1; i >= 0 ; --i)
|
||||||
{
|
{
|
||||||
//child must be unlocked
|
//child must be enabled
|
||||||
if(!children[i]->Locked)
|
if(children[i]->Enabled)
|
||||||
{
|
{
|
||||||
//is mouse inside?
|
//is mouse inside?
|
||||||
if( localx >= children[i]->Position.X + ViewportPosition.X &&
|
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);
|
XOnMouseDown(x, y, button);
|
||||||
for (size_t i = 0; i < children.size(); ++i)
|
for (size_t i = 0; i < children.size(); ++i)
|
||||||
{
|
{
|
||||||
if(!children[i]->Locked)
|
if(children[i]->Enabled)
|
||||||
children[i]->OnMouseDown(x, y, button);
|
children[i]->OnMouseDown(x, y, button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ void Panel::OnMouseHover(int localx, int localy)
|
|||||||
// check if hovering on children
|
// check if hovering on children
|
||||||
for (int i = children.size() - 1; i >= 0; --i)
|
for (int i = children.size() - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
if (!children[i]->Locked)
|
if (children[i]->Enabled)
|
||||||
{
|
{
|
||||||
if( localx >= children[i]->Position.X &&
|
if( localx >= children[i]->Position.X &&
|
||||||
localy >= children[i]->Position.Y &&
|
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);
|
XOnMouseMoved(localx, localy, dx, dy);
|
||||||
for (size_t i = 0; i < children.size(); ++i)
|
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);
|
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;
|
mouseInside = true;
|
||||||
for (size_t i = 0; i < children.size(); ++i)
|
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)
|
Point local (localx - children[i]->Position.X - ViewportPosition.X, localy - children[i]->Position.Y - ViewportPosition.Y)
|
||||||
, prevlocal (local.X - dx, local.Y - dy);
|
, 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)
|
for(int i = children.size()-1; i >= 0 ; --i)
|
||||||
{
|
{
|
||||||
//child must be unlocked
|
//child must be unlocked
|
||||||
if(!children[i]->Locked)
|
if(children[i]->Enabled)
|
||||||
{
|
{
|
||||||
//is mouse inside?
|
//is mouse inside?
|
||||||
if( localx >= children[i]->Position.X + ViewportPosition.X &&
|
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);
|
XOnMouseUp(x, y, button);
|
||||||
for (size_t i = 0; i < children.size(); ++i)
|
for (size_t i = 0; i < children.size(); ++i)
|
||||||
{
|
{
|
||||||
if (!children[i]->Locked)
|
if (children[i]->Enabled)
|
||||||
children[i]->OnMouseUp(x, y, button);
|
children[i]->OnMouseUp(x, y, button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -364,7 +364,7 @@ void Panel::OnMouseWheel(int localx, int localy, int d)
|
|||||||
XOnMouseWheel(localx, localy, d);
|
XOnMouseWheel(localx, localy, d);
|
||||||
for (size_t i = 0; i < children.size(); ++i)
|
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);
|
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)
|
for (int i = children.size()-1; i >= 0 ; --i)
|
||||||
{
|
{
|
||||||
//child must be unlocked
|
//child must be unlocked
|
||||||
if (!children[i]->Locked)
|
if (children[i]->Enabled)
|
||||||
{
|
{
|
||||||
//is mouse inside?
|
//is mouse inside?
|
||||||
if (localx >= children[i]->Position.X + ViewportPosition.X &&
|
if (localx >= children[i]->Position.X + ViewportPosition.X &&
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Format.h"
|
#include "Format.h"
|
||||||
//#include "Misc.h"
|
|
||||||
#include "gui/interface/Point.h"
|
#include "gui/interface/Point.h"
|
||||||
#include "gui/interface/Textbox.h"
|
#include "gui/interface/Textbox.h"
|
||||||
#include "gui/interface/Keys.h"
|
#include "gui/interface/Keys.h"
|
||||||
|
@ -236,7 +236,7 @@ void Window::DoTick(float dt)
|
|||||||
//on mouse hover
|
//on mouse hover
|
||||||
for (int i = Components.size() - 1; i >= 0 && !halt; --i)
|
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().GetMouseX() >= Components[i]->Position.X+Position.X &&
|
||||||
ui::Engine::Ref().GetMouseY() >= Components[i]->Position.Y+Position.Y &&
|
ui::Engine::Ref().GetMouseY() >= Components[i]->Position.Y+Position.Y &&
|
||||||
ui::Engine::Ref().GetMouseX() < Components[i]->Position.X+Position.X + Components[i]->Size.X &&
|
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
|
//on key press
|
||||||
if (focusedComponent_ != NULL)
|
if (focusedComponent_ != NULL)
|
||||||
{
|
{
|
||||||
if (!focusedComponent_->Locked && focusedComponent_->Visible)
|
if (focusedComponent_->Enabled && focusedComponent_->Visible)
|
||||||
focusedComponent_->OnKeyPress(key, character, shift, ctrl, alt);
|
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
|
//on key unpress
|
||||||
if (focusedComponent_ != NULL)
|
if (focusedComponent_ != NULL)
|
||||||
{
|
{
|
||||||
if (!focusedComponent_->Locked && focusedComponent_->Visible)
|
if (focusedComponent_->Enabled && focusedComponent_->Visible)
|
||||||
focusedComponent_->OnKeyRelease(key, character, shift, ctrl, alt);
|
focusedComponent_->OnKeyRelease(key, character, shift, ctrl, alt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,7 +396,7 @@ void Window::DoMouseDown(int x_, int y_, unsigned button)
|
|||||||
bool clickState = false;
|
bool clickState = false;
|
||||||
for (int i = Components.size() - 1; i > -1 && !halt; --i)
|
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)
|
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
|
//on mouse down
|
||||||
for (int i = Components.size() - 1; i > -1 && !halt; --i)
|
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);
|
Components[i]->OnMouseDown(x, y, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ void Window::DoMouseMove(int x_, int y_, int dx, int dy)
|
|||||||
#endif
|
#endif
|
||||||
for (int i = Components.size() - 1; i > -1 && !halt; --i)
|
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 local(x - Components[i]->Position.X, y - Components[i]->Position.Y);
|
||||||
Point a(local.X - dx, local.Y - dy);
|
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);
|
Components[i]->OnMouseEnter(local.X, local.Y);
|
||||||
}
|
}
|
||||||
hoverComponent = Components[i];
|
if (Components[i]->Enabled)
|
||||||
|
hoverComponent = Components[i];
|
||||||
}
|
}
|
||||||
else if (!halt)
|
else if (!halt)
|
||||||
{
|
{
|
||||||
@ -503,7 +504,7 @@ void Window::DoMouseUp(int x_, int y_, unsigned button)
|
|||||||
//on mouse unclick
|
//on mouse unclick
|
||||||
for (int i = Components.size() - 1; i >= 0 && !halt; --i)
|
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)
|
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
|
//on mouse up
|
||||||
for (int i = Components.size() - 1; i >= 0 && !halt; --i)
|
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);
|
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 (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);
|
Components[i]->OnMouseWheelInside(x - Components[i]->Position.X, y - Components[i]->Position.Y, d);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -548,7 +549,7 @@ void Window::DoMouseWheel(int x_, int y_, int d)
|
|||||||
//on mouse wheel
|
//on mouse wheel
|
||||||
for (int i = Components.size() - 1; i >= 0 && !halt; --i)
|
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);
|
Components[i]->OnMouseWheel(x - Components[i]->Position.X, y - Components[i]->Position.Y, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user