Add min sizing on smallmap window.

This commit is contained in:
Juanjo
2013-07-21 22:03:46 +02:00
committed by pelya
parent 0442649289
commit f63ed5b6e7
2 changed files with 13 additions and 10 deletions

View File

@@ -1046,7 +1046,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, 0, this->GetOverlayCompanyMask(), 1);
@@ -1156,9 +1159,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);
@@ -1185,7 +1187,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;
}
@@ -1213,7 +1215,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;
}
@@ -1221,13 +1223,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;