From 962669c960cb0a1bffc13306a9ae532f9bb8aa97 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Fri, 27 Feb 2004 13:24:21 +0000 Subject: improved transparency rendering speed --- src/FbTk/Button.cc | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/src/FbTk/Button.cc b/src/FbTk/Button.cc index f31e6b4..75bda59 100644 --- a/src/FbTk/Button.cc +++ b/src/FbTk/Button.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Button.cc,v 1.17 2004/01/08 22:05:12 fluxgen Exp $ +// $Id: Button.cc,v 1.18 2004/02/27 13:24:21 fluxgen Exp $ #include "Button.hh" @@ -94,36 +94,48 @@ void Button::setBackgroundPixmap(Pixmap pm) { } void Button::buttonPressEvent(XButtonEvent &event) { - if (m_pressed_pm != 0) + bool update = false; + if (m_pressed_pm != 0) { + update = true; FbWindow::setBackgroundPixmap(m_pressed_pm); - else if (m_pressed_color.isAllocated()) + } else if (m_pressed_color.isAllocated()) { + update = true; FbWindow::setBackgroundColor(m_pressed_color); + } m_pressed = true; - clear(); - updateTransparent(); + if (update) { + clear(); + } } void Button::buttonReleaseEvent(XButtonEvent &event) { m_pressed = false; - if (m_background_pm) - setBackgroundPixmap(m_background_pm); - else + bool update = false; + if (m_background_pm) { + if (m_pressed_pm != 0) { + update = true; + setBackgroundPixmap(m_background_pm); + } + } else if (m_pressed_color.isAllocated()) { + update = true; setBackgroundColor(m_background_color); + } - clear(); // clear background + if (update) { + clear(); // clear background - if (m_foreground_pm) { // draw foreground pixmap - Display *disp = App::instance()->display(); + if (m_foreground_pm) { // draw foreground pixmap + Display *disp = App::instance()->display(); - if (m_gc == 0) // get default gc if we dont have one - m_gc = DefaultGC(disp, screenNumber()); + if (m_gc == 0) // get default gc if we dont have one + m_gc = DefaultGC(disp, screenNumber()); + + XCopyArea(disp, m_foreground_pm, window(), m_gc, 0, 0, width(), height(), 0, 0); + } - XCopyArea(disp, m_foreground_pm, window(), m_gc, 0, 0, width(), height(), 0, 0); } - updateTransparent(); - // finaly, execute command (this must be done last since this object might be deleted by the command) if (event.button > 0 && event.button <= 5 && event.x > 0 && event.x < static_cast(width()) && @@ -135,13 +147,14 @@ void Button::buttonReleaseEvent(XButtonEvent &event) { } void Button::exposeEvent(XExposeEvent &event) { + /* if (m_background_pm) setBackgroundPixmap(m_background_pm); else setBackgroundColor(m_background_color); - + */ clearArea(event.x, event.y, event.width, event.height); - updateTransparent(event.x, event.y, event.width, event.height); + // updateTransparent(event.x, event.y, event.width, event.height); } }; // end namespace FbTk -- cgit v0.11.2