Loading

Paste #peistqkuh

  1. Index: src/widget.cpp
  2. ===================================================================
  3. --- src/widget.cpp  (revision 27118)
  4. +++ src/widget.cpp  (working copy)
  5. @@ -535,16 +535,19 @@
  6.   * @param colour Colour of the window.
  7.   * @param owner  'Owner' of the window.
  8.   * @param str    Text to draw in the bar.
  9. + * @param focus  Whether the window is focussed.
  10.   */
  11. -void DrawCaption(const Rect &r, Colours colour, Owner owner, StringID str)
  12. +void DrawCaption(const Rect &r, Colours colour, Owner owner, StringID str, bool focus)
  13.  {
  14.     bool company_owned = owner < MAX_COMPANIES;
  15.  
  16.     DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, FR_BORDERONLY);
  17. -   DrawFrameRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, colour, company_owned ? FR_LOWERED | FR_DARKENED | FR_BORDERONLY : FR_LOWERED | FR_DARKENED);
  18. +   DrawFrameRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, colour,
  19. +           company_owned ? FR_LOWERED | FR_DARKENED | FR_BORDERONLY :
  20. +           focus ? FR_LOWERED : FR_LOWERED | FR_DARKENED);
  21.  
  22.     if (company_owned) {
  23. -       GfxFillRect(r.left + 2, r.top + 2, r.right - 2, r.bottom - 2, _colour_gradient[_company_colours[owner]][4]);
  24. +       GfxFillRect(r.left + 2, r.top + 2, r.right - 2, r.bottom - 2, _colour_gradient[_company_colours[owner]][focus ? 6 : 4]);
  25.     }
  26.  
  27.     if (str != STR_NULL) {
  28. @@ -2462,7 +2465,7 @@
  29.  
  30.         case WWT_CAPTION:
  31.             if (this->index >= 0) w->SetStringParameters(this->index);
  32. -           DrawCaption(r, this->colour, w->owner, this->widget_data);
  33. +           DrawCaption(r, this->colour, w->owner, this->widget_data, _focused_window == w);
  34.             break;
  35.  
  36.         case WWT_SHADEBOX:
  37. Index: src/widgets/dropdown.cpp
  38. ===================================================================
  39. --- src/widgets/dropdown.cpp    (revision 27118)
  40. +++ src/widgets/dropdown.cpp    (working copy)
  41. @@ -82,7 +82,7 @@
  42.  static WindowDesc _dropdown_desc(
  43.     WDP_MANUAL, NULL, 0, 0,
  44.     WC_DROPDOWN_MENU, WC_NONE,
  45. -   0,
  46. +   WDF_NO_FOCUS,
  47.     _nested_dropdown_menu_widgets, lengthof(_nested_dropdown_menu_widgets)
  48.  );
  49.  
  50. Index: src/main_gui.cpp
  51. ===================================================================
  52. --- src/main_gui.cpp    (revision 27118)
  53. +++ src/main_gui.cpp    (working copy)
  54. @@ -340,7 +340,18 @@
  55.                 break;
  56.             }
  57.  
  58. -           case GHK_RESET_OBJECT_TO_PLACE: ResetObjectToPlace(); break;
  59. +           case GHK_RESET_OBJECT_TO_PLACE:
  60. +               if (_thd.place_mode != HT_NONE) {
  61. +                   ResetObjectToPlace();
  62. +               } else if (_focused_window != NULL &&
  63. +                       _focused_window->window_class != WC_MAIN_WINDOW &&
  64. +                       _focused_window->window_class != WC_SELECT_GAME &&
  65. +                       _focused_window->window_class != WC_MAIN_TOOLBAR &&
  66. +                       _focused_window->window_class != WC_STATUS_BAR &&
  67. +                       _focused_window->window_class != WC_TOOLTIPS) {
  68. +                   delete _focused_window;
  69. +               }
  70. +               break;
  71.             case GHK_DELETE_WINDOWS: DeleteNonVitalWindows(); break;
  72.             case GHK_DELETE_NONVITAL_WINDOWS: DeleteAllNonVitalWindows(); break;
  73.             case GHK_REFRESH_SCREEN: MarkWholeScreenDirty(); break;
  74. Index: src/window.cpp
  75. ===================================================================
  76. --- src/window.cpp  (revision 27118)
  77. +++ src/window.cpp  (working copy)
  78. @@ -415,7 +415,7 @@
  79.  
  80.     /* Invalidate focused widget */
  81.     if (_focused_window != NULL) {
  82. -       if (_focused_window->nested_focus != NULL) _focused_window->nested_focus->SetDirty(_focused_window);
  83. +       _focused_window->SetDirty();
  84.     }
  85.  
  86.     /* Remember which window was previously focused */
  87. @@ -424,7 +424,10 @@
  88.  
  89.     /* So we can inform it that it lost focus */
  90.     if (old_focused != NULL) old_focused->OnFocusLost();
  91. -   if (_focused_window != NULL) _focused_window->OnFocus();
  92. +   if (_focused_window != NULL) {
  93. +       _focused_window->OnFocus();
  94. +       _focused_window->SetDirty();
  95. +   }
  96.  }
  97.  
  98.  /**
  99. @@ -1046,8 +1049,10 @@
  100.  
  101.     /* Make sure we don't try to access this window as the focused window when it doesn't exist anymore. */
  102.     if (_focused_window == this) {
  103. -       this->OnFocusLost();
  104. -       _focused_window = NULL;
  105. +       Window *p = this->parent;
  106. +       if (p == NULL && this->window_desc->parent_cls != 0) p = FindWindowById(this->window_desc->parent_cls, this->window_number);
  107. +       SetFocusedWindow(p);
  108. +       assert(_focused_window != this);
  109.     }
  110.  
  111.     this->DeleteChildWindows();
  112. @@ -1417,7 +1422,8 @@
  113.     /* Give focus to the opened window unless a text box
  114.      * of focused window has focus (so we don't interrupt typing). But if the new
  115.      * window has a text box, then take focus anyway. */
  116. -   if (!EditBoxInGlobalFocus() || this->nested_root->GetWidgetOfType(WWT_EDITBOX) != NULL) SetFocusedWindow(this);
  117. +   if ((!EditBoxInGlobalFocus() || this->nested_root->GetWidgetOfType(WWT_EDITBOX) != NULL) &&
  118. +           !(this->window_desc->flags & WDF_NO_FOCUS)) SetFocusedWindow(this);
  119.  
  120.     /* Insert the window into the correct location in the z-ordering. */
  121.     AddWindowToZOrdering(this);
  122. Index: src/misc_gui.cpp
  123. ===================================================================
  124. --- src/misc_gui.cpp    (revision 27118)
  125. +++ src/misc_gui.cpp    (working copy)
  126. @@ -632,7 +632,7 @@
  127.  static WindowDesc _tool_tips_desc(
  128.     WDP_MANUAL, NULL, 0, 0, // Coordinates and sizes are not used,
  129.     WC_TOOLTIPS, WC_NONE,
  130. -   0,
  131. +   WDF_NO_FOCUS,
  132.     _nested_tooltips_widgets, lengthof(_nested_tooltips_widgets)
  133.  );
  134.  
  135. Index: src/window_gui.h
  136. ===================================================================
  137. --- src/window_gui.h    (revision 27118)
  138. +++ src/window_gui.h    (working copy)
  139. @@ -142,7 +142,7 @@
  140.  
  141.  /* widget.cpp */
  142.  void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags);
  143. -void DrawCaption(const Rect &r, Colours colour, Owner owner, StringID str);
  144. +void DrawCaption(const Rect &r, Colours colour, Owner owner, StringID str, bool focus);
  145.  
  146.  /* window.cpp */
  147.  extern Window *_z_front_window;
  148. Index: src/news_gui.cpp
  149. ===================================================================
  150. --- src/news_gui.cpp    (revision 27118)
  151. +++ src/news_gui.cpp    (working copy)
  152. @@ -360,7 +360,7 @@
  153.     {
  154.         switch (widget) {
  155.             case WID_N_CAPTION:
  156. -               DrawCaption(r, COLOUR_LIGHT_BLUE, this->owner, STR_NEWS_MESSAGE_CAPTION);
  157. +               DrawCaption(r, COLOUR_LIGHT_BLUE, this->owner, STR_NEWS_MESSAGE_CAPTION, false);
  158.                 break;
  159.  
  160.             case WID_N_PANEL:
  161.  

Comments