Changeset - r19690:8d473afad5d8
[Not reviewed]
master
0 1 0
frosch - 12 years ago 2012-10-27 15:26:34
frosch@openttd.org
(svn r24633) -Add: Autoexpand the adv. settings tree, if a filter term is entered immediately after opening the window without any manual expanding/collapsing.
1 file changed with 11 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/settings_gui.cpp
Show inline comments
 
@@ -1893,12 +1893,13 @@ struct GameSettingsWindow : QueryStringB
 
	SettingEntry *clicked_entry;       ///< If non-NULL, pointer to a clicked numeric setting (with a depressed left or right button).
 
	SettingEntry *last_clicked;        ///< If non-NULL, pointer to the last clicked setting.
 
	SettingEntry *valuedropdown_entry; ///< If non-NULL, pointer to the value for which a dropdown window is currently opened.
 
	bool closing_dropdown;             ///< True, if the dropdown list is currently closing.
 

	
 
	StringFilter string_filter;        ///< Text filter for settings.
 
	bool manually_changed_folding;     ///< Whether the user expanded/collapsed something manually.
 

	
 
	Scrollbar *vscroll;
 

	
 
	GameSettingsWindow(const WindowDesc *desc) : QueryStringBaseWindow(50)
 
	{
 
		static bool first_time = true;
 
@@ -1915,12 +1916,13 @@ struct GameSettingsWindow : QueryStringB
 

	
 
		this->valuewindow_entry = NULL; // No setting entry for which a entry window is opened
 
		this->clicked_entry = NULL; // No numeric setting buttons are depressed
 
		this->last_clicked = NULL;
 
		this->valuedropdown_entry = NULL;
 
		this->closing_dropdown = false;
 
		this->manually_changed_folding = false;
 

	
 
		this->CreateNestedTree(desc);
 
		this->vscroll = this->GetScrollbar(WID_GS_SCROLLBAR);
 
		this->FinishInitNested(desc, WN_GAME_OPTIONS_GAME_SETTINGS);
 

	
 
		this->text.Initialize(this->edit_str_buf, this->edit_str_size);
 
@@ -2019,17 +2021,19 @@ struct GameSettingsWindow : QueryStringB
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		switch (widget) {
 
			case WID_GS_EXPAND_ALL:
 
				this->manually_changed_folding = true;
 
				_settings_main_page.UnFoldAll();
 
				this->InvalidateData();
 
				break;
 

	
 
			case WID_GS_COLLAPSE_ALL:
 
				this->manually_changed_folding = true;
 
				_settings_main_page.FoldAll();
 
				this->InvalidateData();
 
				break;
 
		}
 

	
 
		if (widget != WID_GS_OPTIONSPANEL) return;
 
@@ -2046,12 +2050,14 @@ struct GameSettingsWindow : QueryStringB
 
		if (x < 0) return;  // Clicked left of the entry
 

	
 
		if ((pe->flags & SEF_KIND_MASK) == SEF_SUBTREE_KIND) {
 
			this->SetDisplayedHelpText(NULL);
 
			pe->d.sub.folded = !pe->d.sub.folded; // Flip 'folded'-ness of the sub-page
 

	
 
			this->manually_changed_folding = true;
 

	
 
			this->InvalidateData();
 
			return;
 
		}
 

	
 
		assert((pe->flags & SEF_KIND_MASK) == SEF_SETTING_KIND);
 
		const SettingDesc *sd = pe->d.entry.setting;
 
@@ -2275,12 +2281,17 @@ struct GameSettingsWindow : QueryStringB
 
		return state;
 
	}
 

	
 
	virtual void OnOSKInput(int wid)
 
	{
 
		string_filter.SetFilterTerm(this->edit_str_buf);
 
		if (!string_filter.IsEmpty() && !this->manually_changed_folding) {
 
			/* User never expanded/collapsed single pages and entered a filter term.
 
			 * Expand everything, to save weird expand clicks, */
 
			_settings_main_page.UnFoldAll();
 
		}
 
		this->InvalidateData();
 
	}
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, WID_GS_OPTIONSPANEL, SETTINGTREE_TOP_OFFSET + SETTINGTREE_BOTTOM_OFFSET);
0 comments (0 inline, 0 general)