Added "disabled" bool to button
Changed null check
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
bool floatBottom;
|
bool floatBottom;
|
||||||
bool floatRight;
|
bool floatRight;
|
||||||
bool floatCenter;
|
bool floatCenter;
|
||||||
|
bool disabled;
|
||||||
|
|
||||||
BaseButtonInstance::BaseButtonInstance(void)
|
BaseButtonInstance::BaseButtonInstance(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ public:
|
|||||||
bool floatBottom;
|
bool floatBottom;
|
||||||
bool floatRight;
|
bool floatRight;
|
||||||
bool floatCenter;
|
bool floatCenter;
|
||||||
|
bool disabled;
|
||||||
protected:
|
protected:
|
||||||
bool mouseInArea(float, float, float, float, float, float);
|
bool mouseInArea(float, float, float, float, float, float);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,23 +5,30 @@ G3D::TextureRef image_ovr = NULL;
|
|||||||
int openGLID_ovr = 0;
|
int openGLID_ovr = 0;
|
||||||
G3D::TextureRef image_dn = NULL;
|
G3D::TextureRef image_dn = NULL;
|
||||||
int openGLID_dn = 0;
|
int openGLID_dn = 0;
|
||||||
|
G3D::TextureRef image_ds = NULL;
|
||||||
|
int openGLID_ds = 0;
|
||||||
Vector2 size;
|
Vector2 size;
|
||||||
Vector2 position;
|
Vector2 position;
|
||||||
ImageButtonInstance::ImageButtonInstance(G3D::TextureRef newImage = NULL, G3D::TextureRef overImage = NULL, G3D::TextureRef downImage = NULL, G3D::TextureRef disableImage = NULL)
|
ImageButtonInstance::ImageButtonInstance(G3D::TextureRef newImage, G3D::TextureRef overImage = NULL, G3D::TextureRef downImage = NULL, G3D::TextureRef disableImage = NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
image = newImage;
|
image = newImage;
|
||||||
openGLID = image->getOpenGLID();
|
openGLID = image->getOpenGLID();
|
||||||
image_ovr = overImage;
|
image_ovr = overImage;
|
||||||
|
if(!image_ovr.isNull())
|
||||||
openGLID_ovr = image_ovr->getOpenGLID();
|
openGLID_ovr = image_ovr->getOpenGLID();
|
||||||
image_dn = downImage;
|
image_dn = downImage;
|
||||||
|
if(!image_dn.isNull())
|
||||||
openGLID_dn = image_dn->getOpenGLID();
|
openGLID_dn = image_dn->getOpenGLID();
|
||||||
|
image_ds = disableImage;
|
||||||
|
if(!image_ds.isNull())
|
||||||
|
openGLID_ds = image_ds->getOpenGLID();
|
||||||
Vector2 size = Vector2(0,0);
|
Vector2 size = Vector2(0,0);
|
||||||
Vector2 position = Vector2(0,0);
|
Vector2 position = Vector2(0,0);
|
||||||
floatCenter = false;
|
floatCenter = false;
|
||||||
floatBottom = false;
|
floatBottom = false;
|
||||||
floatRight = false;
|
floatRight = false;
|
||||||
|
disabled = false;
|
||||||
className = "ImageButton";
|
className = "ImageButton";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,13 +52,18 @@ void ImageButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouse
|
|||||||
positionRelative = Vector2(rd->getWidth() + position.x, position.y);
|
positionRelative = Vector2(rd->getWidth() + position.x, position.y);
|
||||||
}
|
}
|
||||||
int renderimage = openGLID;
|
int renderimage = openGLID;
|
||||||
if(mouseInArea(positionRelative.x, positionRelative.y, positionRelative.x + size.x, positionRelative.y + size.y, mousePos.x, mousePos.y))
|
if(disabled)
|
||||||
{
|
{
|
||||||
if(mouseDown && openGLID_dn != 0)
|
if(openGLID_ds != 0)
|
||||||
|
renderimage = openGLID;
|
||||||
|
}
|
||||||
|
else if(mouseInArea(positionRelative.x, positionRelative.y, positionRelative.x + size.x, positionRelative.y + size.y, mousePos.x, mousePos.y))
|
||||||
|
{
|
||||||
|
if(mouseDown && !image_dn.isNull())
|
||||||
{
|
{
|
||||||
renderimage = openGLID_dn;
|
renderimage = openGLID_dn;
|
||||||
}
|
}
|
||||||
else if(openGLID_ovr != 0)
|
else if(!image_ovr.isNull())
|
||||||
{
|
{
|
||||||
renderimage = openGLID_ovr;
|
renderimage = openGLID_ovr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ TextButtonInstance::TextButtonInstance(void)
|
|||||||
floatCenter = false;
|
floatCenter = false;
|
||||||
visible = true;
|
visible = true;
|
||||||
className = "TextButton";
|
className = "TextButton";
|
||||||
|
disabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextButtonInstance::setAllColorsSame()
|
void TextButtonInstance::setAllColorsSame()
|
||||||
|
|||||||
4
main.cpp
4
main.cpp
@@ -351,7 +351,7 @@ void initGUI()
|
|||||||
instance = makeImageButton(
|
instance = makeImageButton(
|
||||||
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate.png")),
|
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate.png")),
|
||||||
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate_ovr.png")),
|
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate_ovr.png")),
|
||||||
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate_ovr.png")),
|
NULL,
|
||||||
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate_ds.png")));
|
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate_ds.png")));
|
||||||
instance->size = Vector2(30,30);
|
instance->size = Vector2(30,30);
|
||||||
instance->position = Vector2(10, 175);
|
instance->position = Vector2(10, 175);
|
||||||
@@ -360,7 +360,7 @@ void initGUI()
|
|||||||
instance = makeImageButton(
|
instance = makeImageButton(
|
||||||
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt.png")),
|
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt.png")),
|
||||||
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt_ovr.png")),
|
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt_ovr.png")),
|
||||||
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt_ovr.png")),
|
NULL,
|
||||||
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt_ds.png")));
|
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt_ds.png")));
|
||||||
instance->size = Vector2(30,30);
|
instance->size = Vector2(30,30);
|
||||||
instance->position = Vector2(40, 175);
|
instance->position = Vector2(40, 175);
|
||||||
|
|||||||
Reference in New Issue
Block a user