Changeset - r28310:7fedf4bea966
[Not reviewed]
master
0 13 0
Peter Nelson - 12 months ago 2023-12-19 23:21:12
peter1138@openttd.org
Codechange: Add Rect version of FillDrawPixelInfo().

This simplifies most callers as they longer have to split out a rect.
13 files changed with 25 insertions and 20 deletions:
0 comments (0 inline, 0 general)
src/dock_gui.cpp
Show inline comments
 
@@ -549,7 +549,7 @@ public:
 
			case WID_BDD_Y: {
 
				Axis axis = widget == WID_BDD_X ? AXIS_X : AXIS_Y;
 

	
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
				if (FillDrawPixelInfo(&tmp_dpi, r)) {
 
					AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
 
					int x = (r.Width()  - ScaleSpriteTrad(96)) / 2;
 
					int y = (r.Height() - ScaleSpriteTrad(64)) / 2;
src/gfx_func.h
Show inline comments
 
@@ -153,6 +153,11 @@ void CheckBlitter();
 

	
 
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height);
 

	
 
static inline bool FillDrawPixelInfo(DrawPixelInfo *n, const Rect &r)
 
{
 
	return FillDrawPixelInfo(n, r.left, r.top, r.Width(), r.Height());
 
}
 

	
 
/**
 
 * Determine where to draw a centred object inside a widget.
 
 * @param min The top or left coordinate.
src/industry_gui.cpp
Show inline comments
 
@@ -1675,7 +1675,7 @@ public:
 

	
 
				/* Setup a clipping rectangle... */
 
				DrawPixelInfo tmp_dpi;
 
				if (!FillDrawPixelInfo(&tmp_dpi, ir.left, ir.top, ir.Width(), ir.Height())) return;
 
				if (!FillDrawPixelInfo(&tmp_dpi, ir)) return;
 
				/* ...but keep coordinates relative to the window. */
 
				tmp_dpi.left += ir.left;
 
				tmp_dpi.top += ir.top;
 
@@ -2982,7 +2982,7 @@ struct IndustryCargoesWindow : public Wi
 

	
 
		Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
 
		DrawPixelInfo tmp_dpi;
 
		if (!FillDrawPixelInfo(&tmp_dpi, ir.left, ir.top, ir.Width(), ir.Height())) return;
 
		if (!FillDrawPixelInfo(&tmp_dpi, ir)) return;
 
		AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
 

	
 
		int left_pos = WidgetDimensions::scaled.frametext.left - WidgetDimensions::scaled.bevel.left;
src/misc_gui.cpp
Show inline comments
 
@@ -799,7 +799,7 @@ void QueryString::DrawEditBox(const Wind
 
	fr = fr.Shrink(WidgetDimensions::scaled.framerect);
 
	/* Limit the drawing of the string inside the widget boundaries */
 
	DrawPixelInfo dpi;
 
	if (!FillDrawPixelInfo(&dpi, fr.left, fr.top, fr.Width(), fr.Height())) return;
 
	if (!FillDrawPixelInfo(&dpi, fr)) return;
 

	
 
	AutoRestoreBackup dpi_backup(_cur_dpi, &dpi);
 

	
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -912,7 +912,7 @@ struct SpriteAlignerWindow : Window {
 
				}
 

	
 
				DrawPixelInfo new_dpi;
 
				if (!FillDrawPixelInfo(&new_dpi, ir.left, ir.top, ir.Width(), ir.Height())) break;
 
				if (!FillDrawPixelInfo(&new_dpi, ir)) break;
 
				AutoRestoreBackup dpi_backup(_cur_dpi, &new_dpi);
 

	
 
				DrawSprite(this->current_sprite, PAL_NONE, x, y, nullptr, SpriteAlignerWindow::zoom);
src/object_gui.cpp
Show inline comments
 
@@ -337,7 +337,7 @@ public:
 

	
 
				DrawPixelInfo tmp_dpi;
 
				/* Set up a clipping area for the preview. */
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
				if (FillDrawPixelInfo(&tmp_dpi, r)) {
 
					AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
 
					if (spec->grf_prop.grffile == nullptr) {
 
						extern const DrawTileSprites _objects[];
 
@@ -362,7 +362,7 @@ public:
 
				}
 
				DrawPixelInfo tmp_dpi;
 
				/* Set up a clipping area for the preview. */
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
				if (FillDrawPixelInfo(&tmp_dpi, r)) {
 
					AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
 
					if (spec->grf_prop.grffile == nullptr) {
 
						extern const DrawTileSprites _objects[];
src/rail_gui.cpp
Show inline comments
 
@@ -1243,7 +1243,7 @@ public:
 
		switch (GB(widget, 0, 16)) {
 
			case WID_BRAS_PLATFORM_DIR_X:
 
				/* Set up a clipping area for the '/' station preview */
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
				if (FillDrawPixelInfo(&tmp_dpi, r)) {
 
					AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
 
					int x = (r.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
					int y = (r.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
 
@@ -1255,7 +1255,7 @@ public:
 

	
 
			case WID_BRAS_PLATFORM_DIR_Y:
 
				/* Set up a clipping area for the '\' station preview */
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
				if (FillDrawPixelInfo(&tmp_dpi, r)) {
 
					AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
 
					int x = (r.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
					int y = (r.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
 
@@ -1290,7 +1290,7 @@ public:
 
				}
 

	
 
				/* Set up a clipping area for the station preview. */
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
				if (FillDrawPixelInfo(&tmp_dpi, r)) {
 
					AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
 
					int x = (r.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
					int y = (r.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
 
@@ -1905,7 +1905,7 @@ struct BuildRailDepotWindow : public Pic
 
		if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return;
 

	
 
		DrawPixelInfo tmp_dpi;
 
		if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
		if (FillDrawPixelInfo(&tmp_dpi, r)) {
 
			AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
 
			int x = (r.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
			int y = (r.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
 
@@ -2095,7 +2095,7 @@ struct BuildRailWaypointWindow : PickerW
 
				const StationSpec *statspec = this->waypoints->GetSpec(type);
 

	
 
				DrawPixelInfo tmp_dpi;
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
				if (FillDrawPixelInfo(&tmp_dpi, r)) {
 
					AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
 
					int x = (r.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
					int y = (r.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
src/road_gui.cpp
Show inline comments
 
@@ -1029,7 +1029,7 @@ struct BuildRoadDepotWindow : public Pic
 
		if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
 

	
 
		DrawPixelInfo tmp_dpi;
 
		if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
		if (FillDrawPixelInfo(&tmp_dpi, r)) {
 
			AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
 
			int x = (r.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
			int y = (r.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
 
@@ -1417,7 +1417,7 @@ public:
 
				const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type);
 
				bool disabled = (spec != nullptr && widget < WID_BROS_STATION_X && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY));
 
				DrawPixelInfo tmp_dpi;
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
				if (FillDrawPixelInfo(&tmp_dpi, r)) {
 
					AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
 
					int x = (r.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
					int y = (r.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
 
@@ -1459,7 +1459,7 @@ public:
 

	
 
				/* Set up a clipping area for the sprite preview. */
 
				DrawPixelInfo tmp_dpi;
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
				if (FillDrawPixelInfo(&tmp_dpi, r)) {
 
					AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
 
					int x = (r.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
					int y = (r.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
src/roadveh_gui.cpp
Show inline comments
 
@@ -128,7 +128,7 @@ void DrawRoadVehImage(const Vehicle *v, 
 
	DrawPixelInfo tmp_dpi;
 
	int max_width = r.Width();
 

	
 
	if (!FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) return;
 
	if (!FillDrawPixelInfo(&tmp_dpi, r)) return;
 

	
 
	AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
 

	
src/smallmap_gui.cpp
Show inline comments
 
@@ -1543,7 +1543,7 @@ public:
 
			case WID_SM_MAP: {
 
				Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
 
				DrawPixelInfo new_dpi;
 
				if (!FillDrawPixelInfo(&new_dpi, ir.left, ir.top, ir.Width(), ir.Height())) return;
 
				if (!FillDrawPixelInfo(&new_dpi, ir)) return;
 
				this->DrawSmallMap(&new_dpi);
 
				break;
 
			}
src/story_gui.cpp
Show inline comments
 
@@ -688,7 +688,7 @@ public:
 

	
 
		/* Set up a clipping region for the panel. */
 
		DrawPixelInfo tmp_dpi;
 
		if (!FillDrawPixelInfo(&tmp_dpi, fr.left, fr.top, fr.Width(), fr.Height())) return;
 
		if (!FillDrawPixelInfo(&tmp_dpi, fr)) return;
 

	
 
		AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
 

	
src/textfile_gui.cpp
Show inline comments
 
@@ -555,7 +555,7 @@ void TextfileWindow::AfterLoadMarkdown()
 
	Rect fr = r.Shrink(WidgetDimensions::scaled.frametext);
 

	
 
	DrawPixelInfo new_dpi;
 
	if (!FillDrawPixelInfo(&new_dpi, fr.left, fr.top, fr.Width(), fr.Height())) return;
 
	if (!FillDrawPixelInfo(&new_dpi, fr)) return;
 
	AutoRestoreBackup dpi_backup(_cur_dpi, &new_dpi);
 

	
 
	/* Draw content (now coordinates given to DrawString* are local to the new clipping region). */
src/train_gui.cpp
Show inline comments
 
@@ -101,7 +101,7 @@ void DrawTrainImage(const Train *v, cons
 
	int highlight_r = 0;
 
	int max_width = r.Width();
 

	
 
	if (!FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) return;
 
	if (!FillDrawPixelInfo(&tmp_dpi, r)) return;
 

	
 
	{
 
		AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
0 comments (0 inline, 0 general)