Added selected in button class
Basically active, it will probably be renamed
This commit is contained in:
@@ -4,6 +4,7 @@ bool floatBottom = false;
|
|||||||
bool floatRight = false;
|
bool floatRight = false;
|
||||||
bool floatCenter = false;
|
bool floatCenter = false;
|
||||||
bool disabled = false;
|
bool disabled = false;
|
||||||
|
bool selected = false;
|
||||||
ButtonListener* listener = NULL;
|
ButtonListener* listener = NULL;
|
||||||
|
|
||||||
BaseButtonInstance::BaseButtonInstance(void)
|
BaseButtonInstance::BaseButtonInstance(void)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public:
|
|||||||
bool floatRight;
|
bool floatRight;
|
||||||
bool floatCenter;
|
bool floatCenter;
|
||||||
bool disabled;
|
bool disabled;
|
||||||
|
bool selected;
|
||||||
protected:
|
protected:
|
||||||
bool mouseInArea(float, float, float, float, float, float);
|
bool mouseInArea(float, float, float, float, float, float);
|
||||||
class ButtonListener* listener;
|
class ButtonListener* listener;
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ ImageButtonInstance::~ImageButtonInstance(void)
|
|||||||
image_dn = NULL;
|
image_dn = NULL;
|
||||||
delete listener;
|
delete listener;
|
||||||
listener = NULL;
|
listener = NULL;
|
||||||
|
selected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImageButtonInstance::mouseInButton(float mousex, float mousey, RenderDevice* rd)
|
bool ImageButtonInstance::mouseInButton(float mousex, float mousey, RenderDevice* rd)
|
||||||
@@ -93,7 +94,11 @@ 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(disabled)
|
if(selected == true && !image_dn.isNull())
|
||||||
|
{
|
||||||
|
renderimage = openGLID_dn;
|
||||||
|
}
|
||||||
|
else if(disabled)
|
||||||
{
|
{
|
||||||
if(!image_ds.isNull())
|
if(!image_ds.isNull())
|
||||||
renderimage = openGLID_ds;
|
renderimage = openGLID_ds;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public:
|
|||||||
void drawObj(RenderDevice*, Vector2, bool);
|
void drawObj(RenderDevice*, Vector2, bool);
|
||||||
Vector2 size;
|
Vector2 size;
|
||||||
Vector2 position;
|
Vector2 position;
|
||||||
|
|
||||||
G3D::TextureRef image;
|
G3D::TextureRef image;
|
||||||
int openGLID;
|
int openGLID;
|
||||||
G3D::TextureRef image_ovr;
|
G3D::TextureRef image_ovr;
|
||||||
|
|||||||
37
main.cpp
37
main.cpp
@@ -251,6 +251,35 @@ void CameraButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ModeSelectionListener : public ButtonListener {
|
||||||
|
public:
|
||||||
|
void onButton1MouseClick(BaseButtonInstance*);
|
||||||
|
};
|
||||||
|
|
||||||
|
void ModeSelectionListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||||
|
{
|
||||||
|
CoordinateFrame frame = usableApp->debugCamera.getCoordinateFrame();
|
||||||
|
|
||||||
|
|
||||||
|
for(size_t i = 0; i < instances_2D.size(); i++)
|
||||||
|
{
|
||||||
|
if(instances_2D.at(i)->name == "Cursor" || instances_2D.at(i)->name == "Resize" || instances_2D.at(i)->name == "Arrows")
|
||||||
|
{
|
||||||
|
BaseButtonInstance* button = (BaseButtonInstance*)instances_2D.at(i);
|
||||||
|
button->selected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
button->selected = true;
|
||||||
|
if(button->name == "Cursor")
|
||||||
|
mode = CURSOR;
|
||||||
|
else if(button->name == "Resize")
|
||||||
|
mode = RESIZE;
|
||||||
|
else if(button->name == "Arrows")
|
||||||
|
mode = ARROWS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void initGUI()
|
void initGUI()
|
||||||
{
|
{
|
||||||
TextButtonInstance* button = makeTextButton();
|
TextButtonInstance* button = makeTextButton();
|
||||||
@@ -394,11 +423,15 @@ void initGUI()
|
|||||||
instance->size = Vector2(50,50);
|
instance->size = Vector2(50,50);
|
||||||
instance->position = Vector2(15, 90);
|
instance->position = Vector2(15, 90);
|
||||||
instance->parent = dataModel;
|
instance->parent = dataModel;
|
||||||
|
instance->name = "Cursor";
|
||||||
|
instance->setButtonListener(new ModeSelectionListener());
|
||||||
|
|
||||||
instance = makeImageButton(Texture::fromFile(GetFileInPath("/content/images/ScaleTool.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_ovr.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_dn.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_ds.png")));
|
instance = makeImageButton(Texture::fromFile(GetFileInPath("/content/images/ScaleTool.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_ovr.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_dn.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_ds.png")));
|
||||||
instance->size = Vector2(40,40);
|
instance->size = Vector2(40,40);
|
||||||
instance->position = Vector2(0, 140);
|
instance->position = Vector2(0, 140);
|
||||||
instance->parent = dataModel;
|
instance->parent = dataModel;
|
||||||
|
instance->name = "Resize";
|
||||||
|
instance->setButtonListener(new ModeSelectionListener());
|
||||||
|
|
||||||
|
|
||||||
instance = makeImageButton(
|
instance = makeImageButton(
|
||||||
@@ -409,6 +442,8 @@ void initGUI()
|
|||||||
instance->size = Vector2(40,40);
|
instance->size = Vector2(40,40);
|
||||||
instance->position = Vector2(40, 140);
|
instance->position = Vector2(40, 140);
|
||||||
instance->parent = dataModel;
|
instance->parent = dataModel;
|
||||||
|
instance->name = "Arrows";
|
||||||
|
instance->setButtonListener(new ModeSelectionListener());
|
||||||
|
|
||||||
instance = makeImageButton(
|
instance = makeImageButton(
|
||||||
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate.png")),
|
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate.png")),
|
||||||
@@ -936,8 +971,6 @@ void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters
|
|||||||
Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y + offsetSize, from.z - offsetSize), Vector3(to.x - offsetSize, from.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
|
Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y + offsetSize, from.z - offsetSize), Vector3(to.x - offsetSize, from.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
|
||||||
Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, to.y + offsetSize, from.z - offsetSize), Vector3(to.x - offsetSize, to.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
|
Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, to.y + offsetSize, from.z - offsetSize), Vector3(to.x - offsetSize, to.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
|
||||||
|
|
||||||
mode = RESIZE;
|
|
||||||
|
|
||||||
if(mode == ARROWS)
|
if(mode == ARROWS)
|
||||||
{
|
{
|
||||||
rd->setLight(0, NULL);
|
rd->setLight(0, NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user