Loading

Paste #pho6l0czv

  1. Index: src/network/network_chat_gui.cpp
  2. ===================================================================
  3. --- src/network/network_chat_gui.cpp    (revision 27145)
  4. +++ src/network/network_chat_gui.cpp    (working copy)
  5. @@ -21,6 +21,7 @@
  6.  #include "../querystring_gui.h"
  7.  #include "../town.h"
  8.  #include "../window_func.h"
  9. +#include "../toolbar_gui.h"
  10.  #include "../core/geometry_func.hpp"
  11.  #include "network.h"
  12.  #include "network_client.h"
  13. @@ -321,6 +322,11 @@
  14.         InvalidateWindowData(WC_NEWS_WINDOW, 0, 0);
  15.     }
  16.  
  17. +   virtual void FindWindowPlacementAndResize(int def_width, int def_height)
  18. +   {
  19. +       Window::FindWindowPlacementAndResize(_toolbar_width, def_height);
  20. +   }
  21. +
  22.     /**
  23.      * Find the next item of the list of things that can be auto-completed.
  24.      * @param item The current indexed item to return. This function can, and most
  25. @@ -536,7 +542,7 @@
  26.  
  27.  /** The description of the chat window. */
  28.  static WindowDesc _chat_window_desc(
  29. -   WDP_MANUAL, NULL, 640, 14, // x, y, width, height
  30. +   WDP_MANUAL, NULL, 0, 0,
  31.     WC_SEND_NETWORK_MSG, WC_NONE,
  32.     0,
  33.     _nested_chat_window_widgets, lengthof(_nested_chat_window_widgets)
  34. Index: src/toolbar_gui.cpp
  35. ===================================================================
  36. --- src/toolbar_gui.cpp (revision 27145)
  37. +++ src/toolbar_gui.cpp (working copy)
  38. @@ -46,6 +46,7 @@
  39.  #include "game/game.hpp"
  40.  #include "goal_base.h"
  41.  #include "story_base.h"
  42. +#include "toolbar_gui.h"
  43.  
  44.  #include "widgets/toolbar_widget.h"
  45.  
  46. @@ -56,6 +57,9 @@
  47.  #include "safeguards.h"
  48.  
  49.  
  50. +/** Width of the toolbar, shared by statusbar. */
  51. +uint _toolbar_width = 0;
  52. +
  53.  RailType _last_built_railtype;
  54.  RoadType _last_built_roadtype;
  55.  
  56. @@ -1350,7 +1354,7 @@
  57.                 child_wid->current_x = child_wid->smallest_x;
  58.             }
  59.         }
  60. -       w->window_desc->default_width = nbuttons * this->smallest_x;
  61. +       _toolbar_width = nbuttons * this->smallest_x;
  62.     }
  63.  
  64.     void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
  65. @@ -1526,7 +1530,7 @@
  66.  
  67.             assert(i < lengthof(this->panel_widths));
  68.             this->panel_widths[i++] = child_wid->current_x;
  69. -           w->window_desc->default_width += child_wid->current_x;
  70. +           _toolbar_width += child_wid->current_x;
  71.         }
  72.     }
  73.  
  74. @@ -1666,6 +1670,11 @@
  75.         DoZoomInOutWindow(ZOOM_NONE, this);
  76.     }
  77.  
  78. +   virtual void FindWindowPlacementAndResize(int def_width, int def_height)
  79. +   {
  80. +       Window::FindWindowPlacementAndResize(_toolbar_width, def_height);
  81. +   }
  82. +
  83.     virtual void OnPaint()
  84.     {
  85.         /* If spectator, disable all construction buttons
  86. @@ -1900,7 +1909,7 @@
  87.  };
  88.  
  89.  static WindowDesc _toolb_normal_desc(
  90. -   WDP_MANUAL, NULL, 640, 22,
  91. +   WDP_MANUAL, NULL, 0, 0,
  92.     WC_MAIN_TOOLBAR, WC_NONE,
  93.     WDF_NO_FOCUS,
  94.     _nested_toolbar_normal_widgets, lengthof(_nested_toolbar_normal_widgets),
  95. @@ -2211,7 +2220,7 @@
  96.  };
  97.  
  98.  static WindowDesc _toolb_scen_desc(
  99. -   WDP_MANUAL, NULL, 640, 22,
  100. +   WDP_MANUAL, NULL, 0, 0,
  101.     WC_MAIN_TOOLBAR, WC_NONE,
  102.     WDF_NO_FOCUS,
  103.     _nested_toolb_scen_widgets, lengthof(_nested_toolb_scen_widgets),
  104. Index: src/statusbar_gui.cpp
  105. ===================================================================
  106. --- src/statusbar_gui.cpp   (revision 27145)
  107. +++ src/statusbar_gui.cpp   (working copy)
  108. @@ -24,6 +24,7 @@
  109.  #include "saveload/saveload.h"
  110.  #include "window_func.h"
  111.  #include "statusbar_gui.h"
  112. +#include "toolbar_gui.h"
  113.  #include "core/geometry_func.hpp"
  114.  
  115.  #include "widgets/statusbar_widget.h"
  116. @@ -101,6 +102,11 @@
  117.         return pt;
  118.     }
  119.  
  120. +   virtual void FindWindowPlacementAndResize(int def_width, int def_height)
  121. +   {
  122. +       Window::FindWindowPlacementAndResize(_toolbar_width, def_height);
  123. +   }
  124. +
  125.     virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
  126.     {
  127.         Dimension d;
  128. @@ -238,7 +244,7 @@
  129.  };
  130.  
  131.  static WindowDesc _main_status_desc(
  132. -   WDP_MANUAL, NULL, 640, 12,
  133. +   WDP_MANUAL, NULL, 0, 0,
  134.     WC_STATUS_BAR, WC_NONE,
  135.     WDF_NO_FOCUS,
  136.     _nested_main_status_widgets, lengthof(_nested_main_status_widgets)
  137. Index: src/toolbar_gui.h
  138. ===================================================================
  139. --- src/toolbar_gui.h   (revision 27145)
  140. +++ src/toolbar_gui.h   (working copy)
  141. @@ -16,4 +16,6 @@
  142.  void ToggleBoundingBoxes();
  143.  void ToggleDirtyBlocks();
  144.  
  145. +extern uint _toolbar_width;
  146. +
  147.  #endif /* TOOLBAR_GUI_H */
  148. Index: src/window.cpp
  149. ===================================================================
  150. --- src/window.cpp  (revision 27145)
  151. +++ src/window.cpp  (working copy)
  152. @@ -3388,7 +3388,7 @@
  153.                 continue;
  154.  
  155.             case WC_MAIN_TOOLBAR:
  156. -               ResizeWindow(w, min(neww, w->window_desc->default_width) - w->width, 0, false);
  157. +               ResizeWindow(w, min(neww, _toolbar_width) - w->width, 0, false);
  158.  
  159.                 top = w->top;
  160.                 left = PositionMainToolbar(w); // changes toolbar orientation
  161. @@ -3400,14 +3400,15 @@
  162.                 break;
  163.  
  164.             case WC_STATUS_BAR:
  165. -               ResizeWindow(w, min(neww, w->window_desc->default_width) - w->width, 0, false);
  166. +               ResizeWindow(w, min(neww, _toolbar_width) - w->width, 0, false);
  167.  
  168.                 top = newh - w->height;
  169.                 left = PositionStatusbar(w);
  170.                 break;
  171.  
  172.             case WC_SEND_NETWORK_MSG:
  173. -               ResizeWindow(w, Clamp(neww, 320, 640) - w->width, 0, false);
  174. +               ResizeWindow(w, min(neww, _toolbar_width) - w->width, 0, false);
  175. +
  176.                 top = newh - w->height - FindWindowById(WC_STATUS_BAR, 0)->height;
  177.                 left = PositionNetworkChatWindow(w);
  178.                 break;
  179. Index: src/window_gui.h
  180. ===================================================================
  181. --- src/window_gui.h    (revision 27145)
  182. +++ src/window_gui.h    (working copy)
  183. @@ -271,7 +271,7 @@
  184.  protected:
  185.     void InitializeData(WindowNumber window_number);
  186.     void InitializePositionSize(int x, int y, int min_width, int min_height);
  187. -   void FindWindowPlacementAndResize(int def_width, int def_height);
  188. +   virtual void FindWindowPlacementAndResize(int def_width, int def_height);
  189.  
  190.     SmallVector<int, 4> scheduled_invalidation_data;  ///< Data of scheduled OnInvalidateData() calls.
  191.  
  192.  

Comments