Import combined Enhanced viewport: zoom out, overlays & tooltips (r53_27127) patch
https://www.tt-forums.net/viewtopic.php?f=33&t=53394
This commit is contained in:

committed by
Jonathan G Rennison

parent
fd3388467f
commit
536a95dfd0
@@ -99,6 +99,7 @@ struct DropdownWindow : Window {
|
||||
int scrolling; ///< If non-zero, auto-scroll the item list (one time).
|
||||
Point position; ///< Position of the topleft corner of the window.
|
||||
Scrollbar *vscroll;
|
||||
DropDownSyncFocus sync_parent_focus; ///< Call parent window's OnFocus[Lost]().
|
||||
|
||||
/**
|
||||
* Create a dropdown menu.
|
||||
@@ -113,12 +114,15 @@ struct DropdownWindow : Window {
|
||||
* @param scroll Dropdown menu has a scrollbar.
|
||||
* @param widget Widgets of the dropdown menu window.
|
||||
*/
|
||||
DropdownWindow(Window *parent, const DropDownList *list, int selected, int button, bool instant_close, const Point &position, const Dimension &size, Colours wi_colour, bool scroll)
|
||||
DropdownWindow(Window *parent, const DropDownList *list, int selected, int button, bool instant_close, const Point &position, const Dimension &size, Colours wi_colour, bool scroll, DropDownSyncFocus sync_parent_focus)
|
||||
: Window(&_dropdown_desc)
|
||||
{
|
||||
assert(list->Length() > 0);
|
||||
|
||||
this->position = position;
|
||||
this->parent_wnd_class = parent->window_class;
|
||||
this->parent_wnd_num = parent->window_number;
|
||||
this->sync_parent_focus = sync_parent_focus;
|
||||
|
||||
this->CreateNestedTree();
|
||||
|
||||
@@ -148,8 +152,6 @@ struct DropdownWindow : Window {
|
||||
this->vscroll->SetCapacity(size.height * (uint16)list->Length() / list_height);
|
||||
this->vscroll->SetCount((uint16)list->Length());
|
||||
|
||||
this->parent_wnd_class = parent->window_class;
|
||||
this->parent_wnd_num = parent->window_number;
|
||||
this->parent_button = button;
|
||||
this->list = list;
|
||||
this->selected_index = selected;
|
||||
@@ -318,6 +320,22 @@ struct DropdownWindow : Window {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnFocus(Window *previously_focused_window)
|
||||
{
|
||||
if (this->sync_parent_focus & DDSF_RECV_FOCUS) {
|
||||
Window *parent = FindWindowById(this->parent_wnd_class, this->parent_wnd_num);
|
||||
if (parent) parent->OnFocus(previously_focused_window);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnFocusLost(Window *newly_focused_window)
|
||||
{
|
||||
if (this->sync_parent_focus & DDSF_LOST_FOCUS) {
|
||||
Window *parent = FindWindowById(this->parent_wnd_class, this->parent_wnd_num);
|
||||
if (parent) parent->OnFocusLost(newly_focused_window);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -334,7 +352,7 @@ struct DropdownWindow : Window {
|
||||
* @param instant_close Set to true if releasing mouse button should close the
|
||||
* list regardless of where the cursor is.
|
||||
*/
|
||||
void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width, bool instant_close)
|
||||
void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width, bool instant_close, DropDownSyncFocus sync_parent_focus)
|
||||
{
|
||||
DeleteWindowById(WC_DROPDOWN_MENU, 0);
|
||||
|
||||
@@ -382,7 +400,7 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b
|
||||
|
||||
Point dw_pos = { w->left + (_current_text_dir == TD_RTL ? wi_rect.right + 1 - width : wi_rect.left), top};
|
||||
Dimension dw_size = {width, height};
|
||||
new DropdownWindow(w, list, selected, button, instant_close, dw_pos, dw_size, wi_colour, scroll);
|
||||
new DropdownWindow(w, list, selected, button, instant_close, dw_pos, dw_size, wi_colour, scroll, sync_parent_focus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,7 +416,7 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b
|
||||
* @param instant_close Set to true if releasing mouse button should close the
|
||||
* list regardless of where the cursor is.
|
||||
*/
|
||||
void ShowDropDownList(Window *w, const DropDownList *list, int selected, int button, uint width, bool auto_width, bool instant_close)
|
||||
void ShowDropDownList(Window *w, const DropDownList *list, int selected, int button, uint width, bool auto_width, bool instant_close, DropDownSyncFocus sync_parent_focus)
|
||||
{
|
||||
/* Our parent's button widget is used to determine where to place the drop
|
||||
* down list window. */
|
||||
@@ -425,7 +443,7 @@ void ShowDropDownList(Window *w, const DropDownList *list, int selected, int but
|
||||
}
|
||||
}
|
||||
|
||||
ShowDropDownListAt(w, list, selected, button, wi_rect, wi_colour, auto_width, instant_close);
|
||||
ShowDropDownListAt(w, list, selected, button, wi_rect, wi_colour, auto_width, instant_close, sync_parent_focus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -439,7 +457,7 @@ void ShowDropDownList(Window *w, const DropDownList *list, int selected, int but
|
||||
* @param hidden_mask Bitmask for hidden items (items with their bit set are not copied to the dropdown list).
|
||||
* @param width Width of the dropdown menu. If \c 0, use the width of parent widget \a button.
|
||||
*/
|
||||
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width)
|
||||
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width, DropDownSyncFocus sync_parent_focus)
|
||||
{
|
||||
DropDownList *list = new DropDownList();
|
||||
|
||||
@@ -455,7 +473,7 @@ void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int butt
|
||||
return;
|
||||
}
|
||||
|
||||
ShowDropDownList(w, list, selected, button, width);
|
||||
ShowDropDownList(w, list, selected, button, width, false, false, sync_parent_focus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -482,3 +500,10 @@ int HideDropDownMenu(Window *pw)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void GetParentWindowInfo(Window *w, WindowClass &parent_wc, WindowNumber &parent_wn)
|
||||
{
|
||||
DropdownWindow *dw = dynamic_cast<DropdownWindow*>(w);
|
||||
assert(dw != NULL);
|
||||
parent_wc = dw->parent_wnd_class;
|
||||
parent_wn = dw->parent_wnd_num;
|
||||
}
|
||||
|
@@ -13,11 +13,14 @@
|
||||
#define WIDGETS_DROPDOWN_FUNC_H
|
||||
|
||||
#include "../window_gui.h"
|
||||
#include "dropdown_type.h"
|
||||
|
||||
/* Show drop down menu containing a fixed list of strings */
|
||||
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width = 0);
|
||||
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width = 0, DropDownSyncFocus sync_parent_focus = DDSF_NONE);
|
||||
|
||||
/* Hide drop down menu of a parent window */
|
||||
int HideDropDownMenu(Window *pw);
|
||||
|
||||
void GetParentWindowInfo(Window *w, WindowClass &parent_wc, WindowNumber &parent_wn);
|
||||
|
||||
#endif /* WIDGETS_DROPDOWN_FUNC_H */
|
||||
|
@@ -17,6 +17,13 @@
|
||||
#include "../core/smallvec_type.hpp"
|
||||
#include "table/strings.h"
|
||||
|
||||
enum DropDownSyncFocus {
|
||||
DDSF_NONE = 0,
|
||||
DDSF_RECV_FOCUS = 1,
|
||||
DDSF_LOST_FOCUS = 2,
|
||||
DDSF_ALL = DDSF_RECV_FOCUS | DDSF_LOST_FOCUS,
|
||||
};
|
||||
|
||||
/**
|
||||
* Base list item class from which others are derived. If placed in a list it
|
||||
* will appear as a horizontal line in the menu.
|
||||
@@ -85,8 +92,8 @@ public:
|
||||
*/
|
||||
typedef AutoDeleteSmallVector<const DropDownListItem *, 4> DropDownList;
|
||||
|
||||
void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width = false, bool instant_close = false);
|
||||
void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width = false, bool instant_close = false, DropDownSyncFocus sync_parent_focus = DDSF_NONE);
|
||||
|
||||
void ShowDropDownList(Window *w, const DropDownList *list, int selected, int button, uint width = 0, bool auto_width = false, bool instant_close = false);
|
||||
void ShowDropDownList(Window *w, const DropDownList *list, int selected, int button, uint width = 0, bool auto_width = false, bool instant_close = false, DropDownSyncFocus sync_parent_focus = DDSF_NONE);
|
||||
|
||||
#endif /* WIDGETS_DROPDOWN_TYPE_H */
|
||||
|
27
src/widgets/plans_widget.h
Normal file
27
src/widgets/plans_widget.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file plans_widget.h Types related to the plans widgets. */
|
||||
|
||||
#ifndef WIDGETS_PLANS_WIDGET_H
|
||||
#define WIDGETS_PLANS_WIDGET_H
|
||||
|
||||
/** Widgets of the #PlansWindow class. */
|
||||
enum PlansWidgets {
|
||||
WID_PLN_CAPTION, ///< Caption of the window.
|
||||
WID_PLN_LIST,
|
||||
WID_PLN_SCROLLBAR,
|
||||
WID_PLN_NEW,
|
||||
WID_PLN_ADD_LINES,
|
||||
WID_PLN_VISIBILITY,
|
||||
WID_PLN_HIDE_ALL,
|
||||
WID_PLN_DELETE,
|
||||
};
|
||||
|
||||
#endif /* WIDGETS_PLANS_WIDGET_H */
|
Reference in New Issue
Block a user