(svn r18130) -Codechange: initial steps into making the vehicle/group lists big font and RTL aware
This commit is contained in:
@@ -104,9 +104,9 @@ static const NWidgetPart _nested_group_widgets[] = {
|
||||
NWidget(WWT_PANEL, COLOUR_GREY, GRP_WIDGET_ALL_VEHICLES), SetMinimalSize(200, 13), EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY, GRP_WIDGET_DEFAULT_VEHICLES), SetMinimalSize(200, 13), EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_MATRIX, COLOUR_GREY, GRP_WIDGET_LIST_GROUP), SetMinimalSize(188, 117), SetDataTip(0x701, STR_GROUPS_CLICK_ON_GROUP_FOR_TOOLTIP),
|
||||
NWidget(WWT_MATRIX, COLOUR_GREY, GRP_WIDGET_LIST_GROUP), SetMinimalSize(188, 0), SetDataTip(0x701, STR_GROUPS_CLICK_ON_GROUP_FOR_TOOLTIP),
|
||||
SetFill(true, false), SetResize(0, 1),
|
||||
NWidget(WWT_SCROLL2BAR, COLOUR_GREY, GRP_WIDGET_LIST_GROUP_SCROLLBAR), SetMinimalSize(12, 117),
|
||||
NWidget(WWT_SCROLL2BAR, COLOUR_GREY, GRP_WIDGET_LIST_GROUP_SCROLLBAR), SetMinimalSize(12, 0),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, GRP_WIDGET_CREATE_GROUP), SetMinimalSize(24, 25), SetFill(false, true),
|
||||
@@ -129,8 +129,8 @@ static const NWidgetPart _nested_group_widgets[] = {
|
||||
NWidget(WWT_PANEL, COLOUR_GREY, GRP_WIDGET_EMPTY_TOP_RIGHT), SetMinimalSize(12, 12), SetResize(1, 0), EndContainer(),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_MATRIX, COLOUR_GREY, GRP_WIDGET_LIST_VEHICLE), SetMinimalSize(248, 156), SetDataTip(0x701, STR_NULL), SetResize(1, 1), SetFill(true, false),
|
||||
NWidget(WWT_SCROLLBAR, COLOUR_GREY, GRP_WIDGET_LIST_VEHICLE_SCROLLBAR), SetMinimalSize(12, 156),
|
||||
NWidget(WWT_MATRIX, COLOUR_GREY, GRP_WIDGET_LIST_VEHICLE), SetMinimalSize(248, 0), SetDataTip(0x701, STR_NULL), SetResize(1, 1), SetFill(true, false),
|
||||
NWidget(WWT_SCROLLBAR, COLOUR_GREY, GRP_WIDGET_LIST_VEHICLE_SCROLLBAR), SetMinimalSize(12, 0),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, GRP_WIDGET_AVAILABLE_VEHICLES), SetMinimalSize(106, 12), SetFill(false, true),
|
||||
@@ -154,6 +154,7 @@ private:
|
||||
VehicleID vehicle_sel; ///< Selected vehicle
|
||||
GroupID group_rename; ///< Group being renamed, INVALID_GROUP if none
|
||||
GUIGroupList groups; ///< List of groups
|
||||
uint tiny_step_height; ///< Step height for the group list
|
||||
|
||||
/**
|
||||
* (Re)Build the group list.
|
||||
@@ -252,13 +253,20 @@ public:
|
||||
{
|
||||
switch (widget) {
|
||||
case GRP_WIDGET_LIST_GROUP:
|
||||
resize->height = PLY_WND_PRC__SIZE_OF_ROW_TINY;
|
||||
size->height = this->vscroll2.GetCapacity() * resize->height;
|
||||
this->tiny_step_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP;
|
||||
resize->height = this->tiny_step_height;
|
||||
/* Minimum height is the height of the list widget minus all and default vehicles and a bit for the bottom bar */
|
||||
size->height = 4 * GetVehicleListHeight(this->vehicle_type, this->tiny_step_height) - 3 * this->tiny_step_height;
|
||||
break;
|
||||
|
||||
case GRP_WIDGET_ALL_VEHICLES:
|
||||
case GRP_WIDGET_DEFAULT_VEHICLES:
|
||||
size->height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP;
|
||||
break;
|
||||
|
||||
case GRP_WIDGET_LIST_VEHICLE:
|
||||
resize->height = (this->vehicle_type == VEH_TRAIN || this->vehicle_type == VEH_ROAD) ? PLY_WND_PRC__SIZE_OF_ROW_SMALL : PLY_WND_PRC__SIZE_OF_ROW_BIG;
|
||||
size->height = this->vscroll.GetCapacity() * resize->height;
|
||||
resize->height = GetVehicleListHeight(this->vehicle_type, FONT_HEIGHT_NORMAL + WD_MATRIX_TOP);
|
||||
size->height = 4 * resize->height;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -392,7 +400,7 @@ public:
|
||||
SetDParam(0, g->num_vehicle);
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y1 + 1, STR_TINY_COMMA, (this->group_sel == g->index) ? TC_WHITE : TC_BLACK, SA_RIGHT);
|
||||
|
||||
y1 += PLY_WND_PRC__SIZE_OF_ROW_TINY;
|
||||
y1 += this->tiny_step_height;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -436,7 +444,7 @@ public:
|
||||
break;
|
||||
|
||||
case GRP_WIDGET_LIST_GROUP: { // Matrix Group
|
||||
uint16 id_g = (pt.y - this->GetWidget<NWidgetBase>(GRP_WIDGET_LIST_GROUP)->pos_y) / PLY_WND_PRC__SIZE_OF_ROW_TINY;
|
||||
uint16 id_g = (pt.y - this->GetWidget<NWidgetBase>(GRP_WIDGET_LIST_GROUP)->pos_y) / (int)this->tiny_step_height;
|
||||
|
||||
if (id_g >= this->vscroll2.GetCapacity()) return;
|
||||
|
||||
@@ -529,7 +537,7 @@ public:
|
||||
break;
|
||||
|
||||
case GRP_WIDGET_LIST_GROUP: { // Maxtrix group
|
||||
uint16 id_g = (pt.y - this->GetWidget<NWidgetBase>(GRP_WIDGET_LIST_GROUP)->pos_y) / PLY_WND_PRC__SIZE_OF_ROW_TINY;
|
||||
uint16 id_g = (pt.y - this->GetWidget<NWidgetBase>(GRP_WIDGET_LIST_GROUP)->pos_y) / (int)this->tiny_step_height;
|
||||
const VehicleID vindex = this->vehicle_sel;
|
||||
|
||||
this->vehicle_sel = INVALID_VEHICLE;
|
||||
@@ -579,7 +587,7 @@ public:
|
||||
virtual void OnResize()
|
||||
{
|
||||
NWidgetCore *nwi = this->GetWidget<NWidgetCore>(GRP_WIDGET_LIST_GROUP);
|
||||
this->vscroll2.SetCapacity(nwi->current_y / PLY_WND_PRC__SIZE_OF_ROW_TINY);
|
||||
this->vscroll2.SetCapacity(nwi->current_y / this->tiny_step_height);
|
||||
nwi->widget_data = (this->vscroll2.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
|
||||
|
||||
nwi = this->GetWidget<NWidgetCore>(GRP_WIDGET_LIST_VEHICLE);
|
||||
|
Reference in New Issue
Block a user