From ceafbff5f48f20af552c8f610e6a53a85a4f425f Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Tue, 5 Feb 2013 19:15:41 +0000 Subject: [PATCH] Handle widget outline in base class. --- pui/knob.cpp | 1 + pui/slider.cpp | 10 +--------- pui/widget.cpp | 13 +++++++++++++ pui/widget.h | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/pui/knob.cpp b/pui/knob.cpp index 33fee73..eeae845 100644 --- a/pui/knob.cpp +++ b/pui/knob.cpp @@ -144,5 +144,6 @@ void Knob::OnPaint(const PUi *pui) const pui->font->Render(tmp); glPopMatrix(); + Widget::OnPaint(pui); } diff --git a/pui/slider.cpp b/pui/slider.cpp index a9f80f6..c7d6596 100644 --- a/pui/slider.cpp +++ b/pui/slider.cpp @@ -232,14 +232,6 @@ void VSlider::OnPaint(const PUi *pui) const pui->font->Render(tmp); glPopMatrix(); - 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(); - } + Widget::OnPaint(pui); } diff --git a/pui/widget.cpp b/pui/widget.cpp index 796367a..d61de3e 100644 --- a/pui/widget.cpp +++ b/pui/widget.cpp @@ -24,6 +24,19 @@ void Widget::Pad(int xpad, int ypad) this->h -= ypad + ypad; } +void Widget::OnPaint(const PUi *pui) const +{ + 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(); + } +} + void Frame::OnPaint(const PUi *pui) const { glBegin(GL_QUADS); diff --git a/pui/widget.h b/pui/widget.h index 0f0e056..8abba06 100644 --- a/pui/widget.h +++ b/pui/widget.h @@ -47,7 +47,7 @@ struct Widget : Rect { virtual float GetNewValue(int x, int y) { return this->value; } virtual bool SetValue(float newvalue); - virtual void OnPaint(const PUi *pui) const {} + virtual void OnPaint(const PUi *pui) const; void Pad(int xpad, int ypad); };