Skip to content
Snippets Groups Projects
Commit 21b3f14e authored by jsiegle's avatar jsiegle
Browse files

EditorViewportButton is now free of OpenGL calls

parent 50815631
Branches
Tags
No related merge requests found
......@@ -421,6 +421,8 @@ bool UIComponent::perform (const InvocationInfo& info)
EditorViewportButton::EditorViewportButton(UIComponent* ui) : UI(ui)
{
open = true;
buttonFont = Font("Default Light", 25, Font::plain);
}
EditorViewportButton::~EditorViewportButton()
......@@ -428,55 +430,41 @@ EditorViewportButton::~EditorViewportButton()
}
void EditorViewportButton::newOpenGLContextCreated()
{
setUp2DCanvas();
activateAntiAliasing();
setClearColor(darkgrey);
//glClearColor(0.23f, 0.23f, 0.23f, 1.0f);
}
void EditorViewportButton::paint(Graphics& g)
{
g.fillAll(Colour(58,58,58));
void EditorViewportButton::renderOpenGL()
{
glClear(GL_COLOR_BUFFER_BIT);
drawName();
drawButton();
}
g.setColour(Colours::white);
g.setFont(buttonFont);
g.drawText("SIGNAL CHAIN", 10, 0, getWidth(), getHeight(), Justification::left, false);
void EditorViewportButton::drawName()
{
glColor4f(1.0f,1.0f,1.0f,1.0f);
glRasterPos2f(8.0/getWidth(),0.75f);
getFont(cpmono_light)->FaceSize(23);
getFont(cpmono_light)->Render("SIGNAL CHAIN");
}
g.setColour(Colours::white);
void EditorViewportButton::drawButton()
{
glColor4f(1.0f,1.0f,1.0f,1.0f);
glLineWidth(1.0f);
Path p;
glBegin(GL_LINE_LOOP);
float h = getHeight();
float w = getWidth()-5;
if (open)
{
glVertex2f(0.90,0.65);
glVertex2f(0.925,0.35);
p.addTriangle(w-h+0.2f*h, 0.8f*h,
w-h+0.5f*h, 0.2f*h,
w-h+0.8f*h, 0.8f*h);
} else {
glVertex2f(0.95,0.35);
glVertex2f(0.90,0.5);
p.addTriangle(w-h+0.2f*h, 0.5f*h,
w-h+0.8f*h, 0.2f*h,
w-h+0.8f*h, 0.8f*h);
}
glVertex2f(0.95,0.65);
glEnd();
PathStrokeType pst = PathStrokeType(1.0f, PathStrokeType::curved, PathStrokeType::rounded);
g.strokePath(p, pst);
}
void EditorViewportButton::mouseDown(const MouseEvent& e)
{
open = !open;
......
......@@ -183,7 +183,7 @@ private:
*/
class EditorViewportButton : public OpenGLCanvas
class EditorViewportButton : public Component
{
public:
EditorViewportButton(UIComponent* ui);
......@@ -192,17 +192,8 @@ public:
/** Returns the open/closed state of the button. */
bool isOpen() {return open;}
/** Configures a new OpenGL context for drawing. */
void newOpenGLContextCreated();
/** Draws the button. */
void renderOpenGL();
/** Draws the name of the button. */
void drawName();
/** Draws the button. */
void drawButton();
void paint(Graphics& g);
/** Switches the open/closed state of the button. */
void toggleState();
......@@ -216,6 +207,8 @@ private:
UIComponent* UI;
bool open;
Font buttonFont;
};
#endif // __UICOMPONENT_H_D97C73CF__
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment