all repos — fluxbox @ 8c9818a84bb6d0da24e1f91bc227ebea655bfdb1

custom fork of the fluxbox windowmanager

reduced flicker with buffer
fluxgen fluxgen
commit

8c9818a84bb6d0da24e1f91bc227ebea655bfdb1

parent

69583dc2666906234707aef041629c7724f84371

2 files changed, 75 insertions(+), 13 deletions(-)

jump to
M src/FbTk/TextButton.ccsrc/FbTk/TextButton.cc

@@ -19,13 +19,11 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: TextButton.cc,v 1.1 2003/08/18 12:15:39 fluxgen Exp $ +// $Id: TextButton.cc,v 1.2 2003/09/10 21:36:37 fluxgen Exp $ #include "TextButton.hh" #include "Font.hh" - -#include <iostream> -using namespace std; +#include "GContext.hh" namespace FbTk {

@@ -35,8 +33,26 @@ const std::string &text):

FbTk::Button(parent, 0, 0, 10, 10), m_font(&font), m_text(text), - m_justify(FbTk::LEFT), m_bevel(1) { + m_justify(FbTk::LEFT), m_bevel(1), + m_buffer(drawable(), width(), height(), depth()) { + +} + +void TextButton::resize(unsigned int width, unsigned int height) { + m_buffer.resize(width, height); + if (backgroundPixmap() != ParentRelative) + FbWindow::setBackgroundPixmap(m_buffer.drawable()); + Button::resize(width, height); +} + +void TextButton::moveResize(int x, int y, + unsigned int width, unsigned int height) { + m_buffer.resize(width, height); + + if (backgroundPixmap() != ParentRelative) + FbWindow::setBackgroundPixmap(m_buffer.drawable()); + Button::moveResize(x, y, width, height); } void TextButton::setJustify(FbTk::Justify just) {

@@ -52,7 +68,6 @@ // no need to set new font if it's the same

if (&font == m_font) return; m_font = &font; - clear(); // redraw text with new font } /// set bevel and redraw text

@@ -64,8 +79,45 @@ }

/// clear window and redraw text void TextButton::clear() { - FbTk::Button::clear(); - drawText(); + TextButton::clearArea(0, 0, + width(), height()); +} + +void TextButton::clearArea(int x, int y, + unsigned int width, unsigned int height, + bool exposure) { + + if (backgroundPixmap() != ParentRelative) { + + if (backgroundPixmap()) { + m_buffer.copyArea(backgroundPixmap(), + gc(), + x, y, + x, y, + width, height); + + } else { // fill with background color + FbTk::GContext gc(drawable()); + gc.setForeground(backgroundColor()); + m_buffer.fillRectangle(gc.gc(), + x, y, + width, height); + } + + drawText(); + + FbWindow::setBackgroundPixmap(m_buffer.drawable()); + + Button::clearArea(x, y, width, height, exposure); + + } else { // parent relative + FbWindow::setBackgroundPixmap(backgroundPixmap()); + Button::clearArea(x, y, width, height, exposure); + drawText(); + } + + + } unsigned int TextButton::textWidth() const {

@@ -80,13 +132,12 @@ bevel(),

justify(), font(), text().c_str(), text().size(), - textlen // return new text len - ); + textlen); // return new text len // center text by default int center_pos = height()/2 + font().ascent()/2; - font().drawText(window(), // drawable + font().drawText(backgroundPixmap() == ParentRelative ? window() : m_buffer.drawable(), screenNumber(), gc(), // graphic context text().c_str(), textlen, // string and string size
M src/FbTk/TextButton.hhsrc/FbTk/TextButton.hh

@@ -19,13 +19,14 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: TextButton.hh,v 1.1 2003/08/18 12:15:38 fluxgen Exp $ +// $Id: TextButton.hh,v 1.2 2003/09/10 21:36:37 fluxgen Exp $ #ifndef FBTK_TEXTBUTTON_HH #define FBTK_TEXTBUTTON_HH #include "Button.hh" #include "Text.hh" +#include "FbPixmap.hh" #include <string>

@@ -43,8 +44,17 @@ void setJustify(FbTk::Justify just);

void setText(const std::string &text); void setFont(const FbTk::Font &font); void setBevel(int bevel); + + void resize(unsigned int width, unsigned int height); + void moveResize(int x, int y, + unsigned int width, unsigned int height); + /// clears window and redraw text void clear(); + /// clears area and redraws text + void clearArea(int x, int y, + unsigned int width, unsigned int height, + bool exposure = false); inline FbTk::Justify justify() const { return m_justify; } inline const std::string &text() const { return m_text; }

@@ -53,9 +63,10 @@ unsigned int textWidth() const;

int bevel() const { return m_bevel; } protected: - void drawText(int x_offset = 0, int y_offset = 0); + virtual void drawText(int x_offset = 0, int y_offset = 0); private: + FbTk::FbPixmap m_buffer; ///< for background buffer const FbTk::Font *m_font; std::string m_text; FbTk::Justify m_justify;