Loading

temporary transparency

  1. Index: src/dock_gui.cpp
  2. ===================================================================
  3. --- src/dock_gui.cpp    (revision 27772)
  4. +++ src/dock_gui.cpp    (working copy)
  5. @@ -27,6 +27,7 @@
  6.  #include "hotkeys.h"
  7.  #include "gui.h"
  8.  #include "zoom_func.h"
  9. +#include "transparency.h"
  10.  
  11.  #include "widgets/dock_widget.h"
  12.  
  13. @@ -403,11 +404,14 @@
  14.     {
  15.         this->InitNested(TRANSPORT_WATER);
  16.         this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
  17. +       StartTempTransparency();
  18.     }
  19.  
  20.     virtual ~BuildDocksStationWindow()
  21.     {
  22. +      
  23.         DeleteWindowById(WC_SELECT_STATION, 0);
  24. +       StopTempTransparency();
  25.     }
  26.  
  27.     virtual void OnPaint()
  28. Index: src/transparency.h
  29. ===================================================================
  30. --- src/transparency.h  (revision 27772)
  31. +++ src/transparency.h  (working copy)
  32. @@ -37,7 +37,9 @@
  33.  
  34.  typedef uint TransparencyOptionBits; ///< transparency option bits
  35.  extern TransparencyOptionBits _transparency_opt;
  36. +extern TransparencyOptionBits _transparency_opt_tmp;
  37.  extern TransparencyOptionBits _transparency_lock;
  38. +extern TransparencyOptionBits _transparency_lock_tmp;
  39.  extern TransparencyOptionBits _invisibility_opt;
  40.  extern byte _display_opt;
  41.  
  42. @@ -71,6 +73,7 @@
  43.  static inline void ToggleTransparency(TransparencyOption to)
  44.  {
  45.     ToggleBit(_transparency_opt, to);
  46. +   if (_transparency_opt_tmp != NULL) ToggleBit(_transparency_opt_tmp, to);
  47.  }
  48.  
  49.  /**
  50. @@ -109,6 +112,7 @@
  51.  static inline void ToggleTransparencyLock(TransparencyOption to)
  52.  {
  53.     ToggleBit(_transparency_lock, to);
  54. +   if (_transparency_lock_tmp != NULL) ToggleBit(_transparency_lock_tmp, to);
  55.  }
  56.  
  57.  /** Set or clear all non-locked transparency options */
  58. @@ -126,4 +130,30 @@
  59.     MarkWholeScreenDirty();
  60.  }
  61.  
  62. +/**
  63. + * Temporarily store transparency options and locks for later
  64. + * restoration and set all non-locked transparency options.
  65. + */
  66. +static inline void StartTempTransparency()
  67. +{
  68. +   _transparency_opt_tmp = _transparency_opt;
  69. +   _transparency_lock_tmp = _transparency_opt_tmp | _transparency_lock;
  70. +   _transparency_opt |= GB(~_transparency_lock_tmp, 0, TO_END);
  71. +
  72. +   MarkWholeScreenDirty();
  73. +}
  74. +
  75. +/**
  76. + * Restore transparency options and clear temporary
  77. + * transparency options and locks.
  78. + */
  79. +static inline void StopTempTransparency()
  80. +{
  81. +   _transparency_opt &= _transparency_lock_tmp;
  82. +   _transparency_opt_tmp = NULL;
  83. +   _transparency_lock_tmp = NULL;
  84. +
  85. +   MarkWholeScreenDirty();
  86. +}
  87. +
  88.  #endif /* TRANSPARENCY_H */
  89. Index: src/transparency_gui.cpp
  90. ===================================================================
  91. --- src/transparency_gui.cpp    (revision 27772)
  92. +++ src/transparency_gui.cpp    (working copy)
  93. @@ -22,9 +22,11 @@
  94.  
  95.  #include "safeguards.h"
  96.  
  97. -TransparencyOptionBits _transparency_opt;  ///< The bits that should be transparent.
  98. -TransparencyOptionBits _transparency_lock; ///< Prevent these bits from flipping with X.
  99. -TransparencyOptionBits _invisibility_opt;  ///< The bits that should be invisible.
  100. +TransparencyOptionBits _transparency_opt;             ///< The bits that should be transparent.
  101. +TransparencyOptionBits _transparency_opt_tmp = NULL;  ///< Temporary bits that should be transparent while building.
  102. +TransparencyOptionBits _transparency_lock;            ///< Prevent these bits from flipping with X.
  103. +TransparencyOptionBits _transparency_lock_tmp = NULL; ///< Prevent temporary bits from flipping while building.
  104. +TransparencyOptionBits _invisibility_opt;             ///< The bits that should be invisible.
  105.  byte _display_opt; ///< What do we want to draw/do?
  106.  
  107.  class TransparenciesWindow : public Window

Comments