diff --git a/BaseButtonInstance.cpp b/BaseButtonInstance.cpp index fac54ed..5259e99 100644 --- a/BaseButtonInstance.cpp +++ b/BaseButtonInstance.cpp @@ -4,6 +4,7 @@ bool floatBottom = false; bool floatRight = false; bool floatCenter = false; bool disabled = false; +bool selected = false; ButtonListener* listener = NULL; BaseButtonInstance::BaseButtonInstance(void) diff --git a/BaseButtonInstance.h b/BaseButtonInstance.h index 6cff6bf..688299c 100644 --- a/BaseButtonInstance.h +++ b/BaseButtonInstance.h @@ -16,6 +16,7 @@ public: bool floatRight; bool floatCenter; bool disabled; + bool selected; protected: bool mouseInArea(float, float, float, float, float, float); class ButtonListener* listener; diff --git a/ImageButtonInstance.cpp b/ImageButtonInstance.cpp index 58a579f..d5c9a85 100644 --- a/ImageButtonInstance.cpp +++ b/ImageButtonInstance.cpp @@ -49,6 +49,7 @@ ImageButtonInstance::~ImageButtonInstance(void) image_dn = NULL; delete listener; listener = NULL; + selected = false; } 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); } int renderimage = openGLID; - if(disabled) + if(selected == true && !image_dn.isNull()) + { + renderimage = openGLID_dn; + } + else if(disabled) { if(!image_ds.isNull()) renderimage = openGLID_ds; diff --git a/ImageButtonInstance.h b/ImageButtonInstance.h index ea73fed..eaad788 100644 --- a/ImageButtonInstance.h +++ b/ImageButtonInstance.h @@ -11,6 +11,7 @@ public: void drawObj(RenderDevice*, Vector2, bool); Vector2 size; Vector2 position; + G3D::TextureRef image; int openGLID; G3D::TextureRef image_ovr; diff --git a/main.cpp b/main.cpp index 6e1e94a..d7c01eb 100644 --- a/main.cpp +++ b/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() { TextButtonInstance* button = makeTextButton(); @@ -394,11 +423,15 @@ void initGUI() instance->size = Vector2(50,50); instance->position = Vector2(15, 90); 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->size = Vector2(40,40); instance->position = Vector2(0, 140); instance->parent = dataModel; + instance->name = "Resize"; + instance->setButtonListener(new ModeSelectionListener()); instance = makeImageButton( @@ -409,6 +442,8 @@ void initGUI() instance->size = Vector2(40,40); instance->position = Vector2(40, 140); instance->parent = dataModel; + instance->name = "Arrows"; + instance->setButtonListener(new ModeSelectionListener()); instance = makeImageButton( Texture::fromFile(GetFileInPath("/content/images/SelectionRotate.png")), @@ -935,8 +970,6 @@ void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, to.y + offsetSize, from.z - offsetSize), Vector3(from.x - offsetSize, to.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()); - - mode = RESIZE; if(mode == ARROWS) {