106 lines
5.0 KiB
Diff
106 lines
5.0 KiB
Diff
From 747ad8e3e5bce77bc409fcc141ed37ab25b55104 Mon Sep 17 00:00:00 2001
|
|
From: Juanjo <juanjo.ng.83@gmail.com>
|
|
Date: Sun, 21 Jul 2013 22:03:46 +0200
|
|
Subject: [PATCH 187/249] Add min sizing on smallmap window.
|
|
|
|
---
|
|
src/smallmap_gui.cpp | 20 +++++++++++---------
|
|
src/smallmap_gui.h | 3 ++-
|
|
2 files changed, 13 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
|
|
index 99097c5..06087a0 100644
|
|
--- a/src/smallmap_gui.cpp
|
|
+++ b/src/smallmap_gui.cpp
|
|
@@ -1045,7 +1045,10 @@ void SmallMapWindow::SetupWidgetData()
|
|
this->GetWidget<NWidgetStacked>(WID_SM_SELECT_BUTTONS)->SetDisplayedPlane(plane);
|
|
}
|
|
|
|
-SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) : Window(desc), refresh(FORCE_REFRESH_PERIOD)
|
|
+SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) :
|
|
+ Window(desc),
|
|
+ row_height(GetMinSizing(NWST_STEP, FONT_HEIGHT_SMALL)),
|
|
+ refresh(FORCE_REFRESH_PERIOD)
|
|
{
|
|
_smallmap_industry_highlight = INVALID_INDUSTRYTYPE;
|
|
this->overlay = new LinkGraphOverlay(this, WID_SM_MAP);
|
|
@@ -1155,9 +1158,8 @@ SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) : Window(des
|
|
bool rtl = _current_text_dir == TD_RTL;
|
|
uint y_org = r.top + WD_FRAMERECT_TOP;
|
|
uint x = rtl ? r.right - this->column_width - WD_FRAMERECT_RIGHT : r.left + WD_FRAMERECT_LEFT;
|
|
- uint y = y_org;
|
|
+ uint y = Center(y_org, this->row_height, FONT_HEIGHT_SMALL);
|
|
uint i = 0; // Row counter for industry legend.
|
|
- uint row_height = FONT_HEIGHT_SMALL;
|
|
|
|
uint text_left = rtl ? 0 : LEGEND_BLOB_WIDTH + WD_FRAMERECT_LEFT;
|
|
uint text_right = this->column_width - 1 - (rtl ? LEGEND_BLOB_WIDTH + WD_FRAMERECT_RIGHT : 0);
|
|
@@ -1184,7 +1186,7 @@ SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) : Window(des
|
|
/* Column break needed, continue at top, COLUMN_WIDTH pixels
|
|
* (one "row") to the right. */
|
|
x += rtl ? -(int)this->column_width : this->column_width;
|
|
- y = y_org;
|
|
+ y = Center(y_org, this->row_height, FONT_HEIGHT_SMALL);
|
|
i = 1;
|
|
}
|
|
|
|
@@ -1212,7 +1214,7 @@ SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) : Window(des
|
|
DrawString(x + text_left, x + text_right, y, string, TC_GREY);
|
|
} else {
|
|
DrawString(x + text_left, x + text_right, y, string, TC_BLACK);
|
|
- GfxFillRect(x + blob_left, y + 1, x + blob_right, y + row_height - 1, PC_BLACK); // Outer border of the legend colour
|
|
+ GfxFillRect(x + blob_left, y + 1, x + blob_right, y + FONT_HEIGHT_SMALL - 1, PC_BLACK); // Outer border of the legend colour
|
|
}
|
|
break;
|
|
}
|
|
@@ -1220,13 +1222,13 @@ SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) : Window(des
|
|
default:
|
|
if (this->map_type == SMT_CONTOUR) SetDParam(0, tbl->height * TILE_HEIGHT_STEP);
|
|
/* Anything that is not an industry or a company is using normal process */
|
|
- GfxFillRect(x + blob_left, y + 1, x + blob_right, y + row_height - 1, PC_BLACK);
|
|
+ GfxFillRect(x + blob_left, y + 1, x + blob_right, y + FONT_HEIGHT_SMALL - 1, PC_BLACK);
|
|
DrawString(x + text_left, x + text_right, y, tbl->legend);
|
|
break;
|
|
}
|
|
- GfxFillRect(x + blob_left + 1, y + 2, x + blob_right - 1, y + row_height - 2, legend_colour); // Legend colour
|
|
+ GfxFillRect(x + blob_left + 1, y + 2, x + blob_right - 1, y + FONT_HEIGHT_SMALL - 2, legend_colour); // Legend colour
|
|
|
|
- y += row_height;
|
|
+ y += this->row_height;
|
|
}
|
|
}
|
|
}
|
|
@@ -1319,7 +1321,7 @@ void SmallMapWindow::SetOverlayCargoMask()
|
|
int SmallMapWindow::GetPositionOnLegend(Point pt)
|
|
{
|
|
const NWidgetBase *wi = this->GetWidget<NWidgetBase>(WID_SM_LEGEND);
|
|
- uint line = (pt.y - wi->pos_y - WD_FRAMERECT_TOP) / FONT_HEIGHT_SMALL;
|
|
+ uint line = (pt.y - wi->pos_y - WD_FRAMERECT_TOP) / this->row_height;
|
|
uint columns = this->GetNumberColumnsLegend(wi->current_x);
|
|
uint number_of_rows = this->GetNumberRowsLegend(columns);
|
|
if (line >= number_of_rows) return -1;
|
|
diff --git a/src/smallmap_gui.h b/src/smallmap_gui.h
|
|
index 4b180f5..f62c516 100644
|
|
--- a/src/smallmap_gui.h
|
|
+++ b/src/smallmap_gui.h
|
|
@@ -71,6 +71,7 @@ protected:
|
|
uint min_number_of_columns; ///< Minimal number of columns in legends.
|
|
uint min_number_of_fixed_rows; ///< Minimal number of rows in the legends for the fixed layouts only (all except #SMT_INDUSTRY).
|
|
uint column_width; ///< Width of a column in the #WID_SM_LEGEND widget.
|
|
+ const uint row_height; ///< Heigth of each row in the #WID_SM_LEGEND widget.
|
|
|
|
int32 scroll_x; ///< Horizontal world coordinate of the base tile left of the top-left corner of the smallmap display.
|
|
int32 scroll_y; ///< Vertical world coordinate of the base tile left of the top-left corner of the smallmap display.
|
|
@@ -132,7 +133,7 @@ protected:
|
|
inline uint GetLegendHeight(uint num_columns) const
|
|
{
|
|
return WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM +
|
|
- this->GetNumberRowsLegend(num_columns) * FONT_HEIGHT_SMALL;
|
|
+ this->GetNumberRowsLegend(num_columns) * this->row_height;
|
|
}
|
|
|
|
uint GetNumberRowsLegend(uint columns) const;
|
|
--
|
|
1.8.1.2
|
|
|