From 3009f08a768f45ac3e56717d57fbda15f29f0d37 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sun, 3 Feb 2013 13:39:34 +0000 Subject: [PATCH] Add slider colour modifier and active-highlight --- pui/slider.cpp | 20 +++++++++++--------- pui/slider.h | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pui/slider.cpp b/pui/slider.cpp index 6111658..a1bbd8f 100644 --- a/pui/slider.cpp +++ b/pui/slider.cpp @@ -89,7 +89,7 @@ void HSlider::OnPaint() const glBindTexture(GL_TEXTURE_2D, tex->tex[t]); glBegin(GL_QUADS); - glColor4f(1.0, 0.0, 0.0, 0.5); + if (this->colour.a) glColor4f(colour.r, colour.g, colour.b, colour.a); glTexCoord2f(0.0, 0.0); glVertex2f( mx, my); glTexCoord2f(0.0, 1.0); @@ -196,7 +196,7 @@ void VSlider::OnPaint() const glBindTexture(GL_TEXTURE_2D, tex->tex[t]); glBegin(GL_QUADS); - if (big) glColor3f(1.f, 0.f, 0.f); + if (this->colour.a) glColor4f(colour.r, colour.g, colour.b, colour.a); glTexCoord2f(0.0, 0.0); glVertex2f( mx, my); glTexCoord2f(0.0, 1.0); @@ -209,12 +209,14 @@ void VSlider::OnPaint() const glDisable(GL_TEXTURE_2D); -/* glBegin(GL_QUADS); - glColor4f(0.5f, 0.3f, 0.5f, 0.5f); - glVertex2f( x, y); - glVertex2f( x, h + y); - glVertex2f(w + x, h + y); - glVertex2f(w + x, y); - glEnd();*/ + if (this->active) { + glBegin(GL_LINE_LOOP); + glColor4f(1.f, 1.f, 1.0f, 0.25f); + glVertex2f( x + .5f, y + .5f); + glVertex2f( x + .5f, h + y - .5f); + glVertex2f(w + x - .5f, h + y - .5f); + glVertex2f(w + x - .5f, y + .5f); + glEnd(); + } } diff --git a/pui/slider.h b/pui/slider.h index 1be180c..03e8d6c 100644 --- a/pui/slider.h +++ b/pui/slider.h @@ -2,6 +2,7 @@ #define SLIDER_H struct Slider : Widget { + Colour colour; bool big; };