Changeset - r13158:008df0730a98
[Not reviewed]
master
0 6 0
rubidium - 15 years ago 2009-09-30 21:00:35
rubidium@openttd.org
(svn r17673) -Codechange: make InvalidateThisWindowData a function of the window class
6 files changed with 18 insertions and 22 deletions:
0 comments (0 inline, 0 general)
src/main_gui.cpp
Show inline comments
 
@@ -163,15 +163,14 @@ bool DoZoomInOutWindow(int how, Window *
 
			break;
 
	}
 
	if (vp != NULL) { // the vp can be null when how == ZOOM_NONE
 
		vp->virtual_left = w->viewport->scrollpos_x;
 
		vp->virtual_top = w->viewport->scrollpos_y;
 
	}
 
	w->SetDirty();
 
	/* Update the windows that have zoom-buttons to perhaps disable their buttons */
 
	InvalidateThisWindowData(w);
 
	w->InvalidateData();
 
	return true;
 
}
 

	
 
void ZoomInOrOutToCursorWindow(bool in, Window *w)
 
{
 
	assert(w != NULL);
src/newgrf_gui.cpp
Show inline comments
 
@@ -341,13 +341,13 @@ public:
 
					this->sel = this->grfs[i];
 
					this->sel_pos = i;
 
				} else {
 
					this->sel = NULL;
 
					this->sel_pos = -1;
 
				}
 
				InvalidateThisWindowData(this, 1);
 
				this->InvalidateData(1);
 
				break;
 
			}
 

	
 
			case ANGRFW_ADD: // Add selection to list
 
				if (this->sel != NULL) {
 
					const GRFConfig *src = this->sel;
 
@@ -376,13 +376,13 @@ public:
 
					InvalidateWindowData(WC_GAME_OPTIONS, 0);
 
				}
 
				break;
 

	
 
			case ANGRFW_RESCAN: // Rescan list
 
				ScanNewGRFFiles();
 
				InvalidateThisWindowData(this, 0);
 
				this->InvalidateData();
 
				break;
 
		}
 
	}
 

	
 
	virtual void OnMouseLoop()
 
	{
 
@@ -434,24 +434,23 @@ public:
 

	
 
		if (this->grfs.Length() == 0) this->sel_pos = -1;
 
		if (this->sel_pos >= 0) {
 
			this->sel = this->grfs[this->sel_pos];
 

	
 
			this->ScrollToSelected();
 

	
 
			InvalidateThisWindowData(this, 1);
 
			this->InvalidateData(1);
 
		}
 

	
 
		return ES_HANDLED;
 
	}
 

	
 
	virtual void OnOSKInput(int wid)
 
	{
 
		this->grfs.SetFilterState(!StrEmpty(this->edit_str_buf));
 
		this->grfs.ForceRebuild();
 
		InvalidateThisWindowData(this, 1);
 
		this->InvalidateData(1);
 
	}
 
};
 

	
 
Listing NewGRFAddWindow::last_sorting = {false, 0};
 
Filtering NewGRFAddWindow::last_filtering = {false, 0};
 

	
src/vehicle_gui.cpp
Show inline comments
 
@@ -660,13 +660,13 @@ void InitializeGUI()
 
static inline void ChangeVehicleWindow(WindowClass window_class, VehicleID from_index, VehicleID to_index)
 
{
 
	Window *w = FindWindowById(window_class, from_index);
 
	if (w != NULL) {
 
		w->window_number = to_index;
 
		if (w->viewport != NULL) w->viewport->follow_vehicle = to_index;
 
		if (to_index != INVALID_VEHICLE) InvalidateThisWindowData(w, 0);
 
		if (to_index != INVALID_VEHICLE) w->InvalidateData();
 
	}
 
}
 

	
 
/**
 
 * Report a change in vehicle IDs (due to autoreplace) to affected vehicle windows.
 
 * @param from_index the old vehicle ID
src/window.cpp
Show inline comments
 
@@ -2474,33 +2474,22 @@ void SetWindowClassesDirty(WindowClass c
 
	FOR_ALL_WINDOWS_FROM_BACK(w) {
 
		if (w->window_class == cls) w->SetDirty();
 
	}
 
}
 

	
 
/**
 
 * Mark window data as invalid (in need of re-computing)
 
 * @param w Window with invalid data
 
 * @param data The data to invalidate with
 
 */
 
void InvalidateThisWindowData(Window *w, int data)
 
{
 
	w->OnInvalidateData(data);
 
	w->SetDirty();
 
}
 

	
 
/**
 
 * Mark window data of the window of a given class and specific window number as invalid (in need of re-computing)
 
 * @param cls Window class
 
 * @param number Window number within the class
 
 * @param data The data to invalidate with
 
 */
 
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data)
 
{
 
	Window *w;
 
	FOR_ALL_WINDOWS_FROM_BACK(w) {
 
		if (w->window_class == cls && w->window_number == number) InvalidateThisWindowData(w, data);
 
		if (w->window_class == cls && w->window_number == number) w->InvalidateData(data);
 
	}
 
}
 

	
 
/**
 
 * Mark window data of all windows of a given class as invalid (in need of re-computing)
 
 * @param cls Window class
 
@@ -2508,13 +2497,13 @@ void InvalidateWindowData(WindowClass cl
 
 */
 
void InvalidateWindowClassesData(WindowClass cls, int data)
 
{
 
	Window *w;
 

	
 
	FOR_ALL_WINDOWS_FROM_BACK(w) {
 
		if (w->window_class == cls) InvalidateThisWindowData(w, data);
 
		if (w->window_class == cls) w->InvalidateData(data);
 
	}
 
}
 

	
 
/**
 
 * Dispatch WE_TICK event over all windows
 
 */
src/window_func.h
Show inline comments
 
@@ -24,13 +24,12 @@ int PositionMainToolbar(Window *w);
 
void InitWindowSystem();
 
void UnInitWindowSystem();
 
void ResetWindowSystem();
 
void SetupColoursAndInitialWindow();
 
void InputLoop();
 

	
 
void InvalidateThisWindowData(Window *w, int data = 0);
 
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data = 0);
 
void InvalidateWindowClassesData(WindowClass cls, int data = 0);
 

	
 
void DeleteNonVitalWindows();
 
void DeleteAllNonVitalWindows();
 
void DeleteConstructionWindows();
src/window_gui.h
Show inline comments
 
@@ -631,12 +631,22 @@ public:
 

	
 
	void DeleteChildWindows() const;
 

	
 
	void SetDirty() const;
 
	void ReInit();
 

	
 
	/**
 
	 * Mark this window's data as invalid (in need of re-computing)
 
	 * @param data The data to invalidate with
 
	 */
 
	void InvalidateData(int data = 0)
 
	{
 
		this->SetDirty();
 
		this->OnInvalidateData(data);
 
	}
 

	
 
	/*** Event handling ***/
 

	
 
	/**
 
	 * The window must be repainted.
 
	 * @note This method should not change any state, it should only use drawing functions.
 
	 */
0 comments (0 inline, 0 general)