From df0afdf0dca6b3d4f621248ada2aed73d7481c66 Mon Sep 17 00:00:00 2001 From: truebrain Date: Thu, 15 Dec 2011 19:54:23 +0000 Subject: (svn r23525) -Codechange: make Window::flags4 WindowFlags instead of uint16, with only values known in WindowFlags (and move out 2 timers to their own variable) -Codechange: rename Window::flags4 to Window::flags -Codechange: move some non-inline functions from .hpp to .cpp --- src/window_gui.h | 94 +++++++++++++++++++++++++++----------------------------- 1 file changed, 46 insertions(+), 48 deletions(-) (limited to 'src/window_gui.h') diff --git a/src/window_gui.h b/src/window_gui.h index 461d6652b..f60b39d01 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -205,6 +205,27 @@ enum SortButtonState { SBS_UP, ///< Sort descending. }; +/** + * Window flags. + */ +enum WindowFlags { + WF_TIMEOUT = 1 << 0, ///< Window timeout counter. + + WF_DRAGGING = 1 << 3, ///< Window is being dragged. + WF_SIZING_RIGHT = 1 << 4, ///< Window is being resized towards the right. + WF_SIZING_LEFT = 1 << 5, ///< Window is being resized towards the left. + WF_SIZING = WF_SIZING_RIGHT | WF_SIZING_LEFT, ///< Window is being resized. + WF_STICKY = 1 << 6, ///< Window is made sticky by user + WF_DISABLE_VP_SCROLL = 1 << 7, ///< Window does not do autoscroll, @see HandleAutoscroll(). + WF_WHITE_BORDER = 1 << 8, ///< Window white border counter bit mask. + + WF_CENTERED = 1 << 10, ///< Window is centered and shall stay centered after ReInit. +}; +DECLARE_ENUM_AS_BIT_SET(WindowFlags) + +static const int TIMEOUT_DURATION = 7; ///< The initial timeout value for WF_TIMEOUT. +static const int WHITE_BORDER_DURATION = 3; ///< The initial timeout value for WF_WHITE_BORDER. + /** * Data structure for a window viewport. * A viewport is either following a vehicle (its id in then in #follow_vehicle), or it aims to display a specific @@ -256,10 +277,13 @@ public: { } - uint16 flags4; ///< Window flags, @see WindowFlags + WindowFlags flags; ///< Window flags WindowClass window_class; ///< Window class WindowNumber window_number; ///< Window number within the window class + uint8 timeout_timer; ///< Timer value of the WF_TIMEOUT for flags. + uint8 white_border_timer; ///< Timervalue of the WF_WHITE_BORDER for flags. + int left; ///< x position of left edge of the window int top; ///< y position of top edge of the window int width; ///< width of the window (number of pixels to the right in x direction) @@ -278,7 +302,7 @@ public: NWidgetStacked *shade_select; ///< Selection widget (#NWID_SELECTION) to use for shading the window. If \c NULL, window cannot shade. Dimension unshaded_size; ///< Last known unshaded size (only valid while shaded). - int scrolling_scrollbar; ///< Widgetindex of just being dragged scrollbar. -1 of none is active. + int scrolling_scrollbar; ///< Widgetindex of just being dragged scrollbar. -1 if none is active. Window *parent; ///< Parent window. Window *z_front; ///< The window in front of us in z-order. @@ -296,6 +320,24 @@ public: void CreateNestedTree(const WindowDesc *desc, bool fill_nested = true); void FinishInitNested(const WindowDesc *desc, WindowNumber window_number = 0); + /** + * Set the timeout flag of the window and initiate the timer. + */ + inline void SetTimeout() + { + this->flags |= WF_TIMEOUT; + this->timeout_timer = TIMEOUT_DURATION; + } + + /** + * Set the timeout flag of the window and initiate the timer. + */ + inline void SetWhiteBorder() + { + this->flags |= WF_WHITE_BORDER; + this->white_border_timer = WHITE_BORDER_DURATION; + } + /** * Sets the enabled/disabled status of a widget. * By default, widgets are enabled. @@ -438,31 +480,8 @@ public: void SetShaded(bool make_shaded); - /** - * Mark this window's data as invalid (in need of re-computing) - * @param data The data to invalidate with - * @param gui_scope Whether the funtion is called from GUI scope. - */ - void InvalidateData(int data = 0, bool gui_scope = true) - { - this->SetDirty(); - if (!gui_scope) { - /* Schedule GUI-scope invalidation for next redraw. */ - *this->scheduled_invalidation_data.Append() = data; - } - this->OnInvalidateData(data, gui_scope); - } - - /** - * Process all scheduled invalidations. - */ - void ProcessScheduledInvalidations() - { - for (int *data = this->scheduled_invalidation_data.Begin(); this->window_class != WC_INVALID && data != this->scheduled_invalidation_data.End(); data++) { - this->OnInvalidateData(*data, true); - } - this->scheduled_invalidation_data.Clear(); - } + void InvalidateData(int data = 0, bool gui_scope = true); + void ProcessScheduledInvalidations(); /*** Event handling ***/ @@ -773,27 +792,6 @@ public: virtual ~PickerWindowBase(); }; -/** - * Window flags - */ -enum WindowFlags { - WF_TIMEOUT_TRIGGER = 1, ///< When the timeout should start triggering - WF_TIMEOUT_BEGIN = 7, ///< The initial value for the timeout - WF_TIMEOUT_MASK = 7, ///< Window timeout counter bit mask (3 bits) - WF_DRAGGING = 1 << 3, ///< Window is being dragged - WF_SIZING_RIGHT = 1 << 4, ///< Window is being resized towards the right. - WF_SIZING_LEFT = 1 << 5, ///< Window is being resized towards the left. - WF_SIZING = WF_SIZING_RIGHT | WF_SIZING_LEFT, ///< Window is being resized. - WF_STICKY = 1 << 6, ///< Window is made sticky by user - - WF_DISABLE_VP_SCROLL = 1 << 7, ///< Window does not do autoscroll, @see HandleAutoscroll() - - WF_WHITE_BORDER_ONE = 1 << 8, - WF_WHITE_BORDER_MASK = 1 << 9 | WF_WHITE_BORDER_ONE, - - WF_CENTERED = 1 << 10, ///< Window is centered and shall stay centered after ReInit -}; - Window *BringWindowToFrontById(WindowClass cls, WindowNumber number); Window *FindWindowFromPt(int x, int y); -- cgit v1.2.3-70-g09d2