From b2b4f93a4650aa6b4adc06c2caaa78a2e0a767df Mon Sep 17 00:00:00 2001 From: skyjake Date: Fri, 25 Jan 2013 22:22:10 +0200 Subject: [PATCH] Shell: TextWidget manual redrawing Added a method for immediately redrawing and showing a text widget. --- .../tools/shell/libshell/include/de/shell/textcanvas.h | 3 ++- .../tools/shell/libshell/include/de/shell/textwidget.h | 8 ++++++++ doomsday/tools/shell/libshell/src/textwidget.cpp | 10 ++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/doomsday/tools/shell/libshell/include/de/shell/textcanvas.h b/doomsday/tools/shell/libshell/include/de/shell/textcanvas.h index a9b4c2120f..86c561d700 100644 --- a/doomsday/tools/shell/libshell/include/de/shell/textcanvas.h +++ b/doomsday/tools/shell/libshell/include/de/shell/textcanvas.h @@ -48,6 +48,7 @@ class DENG2_PUBLIC TextCanvas Bold = 0x1, Underline = 0x2, Reverse = 0x4, + Blink = 0x8, Dirty = 0x80000000, @@ -134,7 +135,7 @@ class DENG2_PUBLIC TextCanvas void put(Vector2i const &pos, Char const &ch); - void drawText(Vector2i const &pos, String const &text, Char::Attribs const &attribs); + void drawText(Vector2i const &pos, String const &text, Char::Attribs const &attribs = Char::DefaultAttributes); /** * Copies the contents of this canvas onto another canvas. diff --git a/doomsday/tools/shell/libshell/include/de/shell/textwidget.h b/doomsday/tools/shell/libshell/include/de/shell/textwidget.h index d4263ff592..1f0e8c833d 100644 --- a/doomsday/tools/shell/libshell/include/de/shell/textwidget.h +++ b/doomsday/tools/shell/libshell/include/de/shell/textwidget.h @@ -51,6 +51,14 @@ class DENG2_PUBLIC TextWidget : public QObject, public Widget TextCanvas *targetCanvas() const; + /** + * Draw this widget and all its children, and show the target canvas + * afterwards. Use this in special cases for faster redrawing of portions + * of the screen when only one widget's contents have changed and need + * updating. + */ + void drawAndShow(); + /** * Defines the placement of the widget on the target canvas. * diff --git a/doomsday/tools/shell/libshell/src/textwidget.cpp b/doomsday/tools/shell/libshell/src/textwidget.cpp index d5c2961c0d..f6ba8b5aed 100644 --- a/doomsday/tools/shell/libshell/src/textwidget.cpp +++ b/doomsday/tools/shell/libshell/src/textwidget.cpp @@ -66,6 +66,16 @@ TextCanvas *TextWidget::targetCanvas() const return d->canvas; } +void TextWidget::drawAndShow() +{ + if(targetCanvas()) + { + draw(); + notifyTree(&Widget::draw); + targetCanvas()->show(); + } +} + void TextWidget::setRule(RectangleRule *rule) { releaseRef(d->rule);