From af00fd0f2f6bf5d8d1b9368397001f689abf09ed Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Sat, 28 Apr 2012 19:16:13 +0000 Subject: [PATCH] Add a move function for widgets. The code is used to experiment with a different approach of the implementation of a listbox. --- src/gui/widgets/widget.cpp | 6 ++++++ src/gui/widgets/widget.hpp | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp index 5c181941835..c9096b5e595 100644 --- a/src/gui/widgets/widget.cpp +++ b/src/gui/widgets/widget.cpp @@ -156,6 +156,12 @@ SDL_Rect twidget::get_dirty_rect() const : clip_rect_; } +void twidget::move(const int x_offset, const int y_offset) +{ + x_ += x_offset; + y_ += y_offset; +} + twindow* twidget::get_window() { // Go up into the parent tree until we find the top level diff --git a/src/gui/widgets/widget.hpp b/src/gui/widgets/widget.hpp index 730436e6c1b..231b3c83a98 100644 --- a/src/gui/widgets/widget.hpp +++ b/src/gui/widgets/widget.hpp @@ -409,6 +409,20 @@ public: y_ = origin.y; } + /** + * Moves a widget. + * + * This function can be used to move the widget without dirtying it. + * + * @todo Implement the function to all inherited classes. + * + * @param x_offset The amount of pixels to move the widget in + * the x direction. + * @param y_offset The amount of pixels to move the widget in + * the y direction. + */ + virtual void move(const int x_offset, const int y_offset); + int get_x() const { return x_; } int get_y() const { return y_; }