# HG changeset patch # Parent 2415d464b5bacd2193242b911e474841781da0f4 diff -r 2415d464b5ba src/rail_gui.cpp --- a/src/rail_gui.cpp Thu Sep 05 13:28:29 2013 +0200 +++ b/src/rail_gui.cpp Thu Sep 05 13:28:57 2013 +0200 @@ -1452,6 +1452,8 @@ struct BuildSignalWindow : public PickerWindowBase { private: + Dimension sig_sprite_size; + /** * Draw dynamic a signal-sprite in a button in the signal GUI * Draw the sprite +1px to the right and down if the button is lowered @@ -1504,6 +1506,31 @@ } } + virtual void OnInit() + { + /* Calculate maximum signal sprite size. */ + this->sig_sprite_size.width = 0; + this->sig_sprite_size.height = 0; + const RailtypeInfo *rti = GetRailTypeInfo(_cur_railtype); + for (uint type = SIGTYPE_NORMAL; type < SIGTYPE_END; type++) { + for (uint variant = SIG_ELECTRIC; variant <= SIG_SEMAPHORE; variant++) { + for (uint lowered = 0; lowered < 2; lowered++) { + const Sprite *sprite = GetSprite(rti->gui_sprites.signals[type][variant][lowered], ST_NORMAL); + this->sig_sprite_size.width = max(this->sig_sprite_size.width, UnScaleByZoom(sprite->width, ZOOM_LVL_GUI)); + this->sig_sprite_size.height = max(this->sig_sprite_size.height, UnScaleByZoom(sprite->height, ZOOM_LVL_GUI)); + } + } + } + } + + virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) + { + if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) { + size->width = max(size->width, this->sig_sprite_size.width + padding.width + WD_IMGBTN_LEFT + WD_IMGBTN_RIGHT); + size->height = max(size->height, this->sig_sprite_size.height + padding.height + WD_IMGBTN_TOP + WD_IMGBTN_BOTTOM); + } + } + virtual void DrawWidget(const Rect &r, int widget) const { if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) {