Browse Source

FlagSet<> update:

* Use URHO3D_FLAGSET() macro for enabling flagsets on enums.
* Use EnumFlags alias instead of FlagSet<Enum>.
* Naming changes.
Rokas Kupstys 7 years ago
parent
commit
6ed3e46646
42 changed files with 105 additions and 101 deletions
  1. 1 1
      Source/Tools/OgreImporter/OgreImporterUtils.h
  2. 12 8
      Source/Urho3D/Container/FlagSet.h
  3. 3 3
      Source/Urho3D/Core/Attribute.h
  4. 1 1
      Source/Urho3D/Engine/DebugHud.cpp
  5. 1 1
      Source/Urho3D/Graphics/AnimatedModel.h
  6. 1 1
      Source/Urho3D/Graphics/Animation.cpp
  7. 2 2
      Source/Urho3D/Graphics/Animation.h
  8. 1 1
      Source/Urho3D/Graphics/CustomGeometry.cpp
  9. 1 1
      Source/Urho3D/Graphics/CustomGeometry.h
  10. 3 3
      Source/Urho3D/Graphics/DecalSet.cpp
  11. 1 1
      Source/Urho3D/Graphics/Direct3D11/D3D11Graphics.cpp
  12. 1 1
      Source/Urho3D/Graphics/Direct3D9/D3D9Graphics.cpp
  13. 1 1
      Source/Urho3D/Graphics/Graphics.h
  14. 2 2
      Source/Urho3D/Graphics/GraphicsDefs.h
  15. 1 1
      Source/Urho3D/Graphics/Model.cpp
  16. 1 1
      Source/Urho3D/Graphics/Model.h
  17. 4 4
      Source/Urho3D/Graphics/OcclusionBuffer.cpp
  18. 1 1
      Source/Urho3D/Graphics/OpenGL/OGLGraphics.cpp
  19. 1 1
      Source/Urho3D/Graphics/RenderPath.h
  20. 1 1
      Source/Urho3D/Graphics/Skeleton.cpp
  21. 2 2
      Source/Urho3D/Graphics/Skeleton.h
  22. 1 1
      Source/Urho3D/Graphics/VertexBuffer.cpp
  23. 2 2
      Source/Urho3D/Graphics/VertexBuffer.h
  24. 4 4
      Source/Urho3D/Input/Input.cpp
  25. 3 3
      Source/Urho3D/Input/Input.h
  26. 2 2
      Source/Urho3D/Input/InputConstants.h
  27. 1 1
      Source/Urho3D/Scene/LogicComponent.h
  28. 1 1
      Source/Urho3D/Scene/SmoothedTransform.h
  29. 1 1
      Source/Urho3D/UI/Button.cpp
  30. 1 1
      Source/Urho3D/UI/Button.h
  31. 1 1
      Source/Urho3D/UI/CheckBox.cpp
  32. 1 1
      Source/Urho3D/UI/CheckBox.h
  33. 1 1
      Source/Urho3D/UI/LineEdit.cpp
  34. 1 1
      Source/Urho3D/UI/LineEdit.h
  35. 1 1
      Source/Urho3D/UI/ListView.cpp
  36. 1 1
      Source/Urho3D/UI/ListView.h
  37. 2 2
      Source/Urho3D/UI/ScrollView.cpp
  38. 2 2
      Source/Urho3D/UI/ScrollView.h
  39. 17 17
      Source/Urho3D/UI/UI.cpp
  40. 12 12
      Source/Urho3D/UI/UI.h
  41. 2 2
      Source/Urho3D/UI/UIElement.cpp
  42. 6 6
      Source/Urho3D/UI/UIElement.h

+ 1 - 1
Source/Tools/OgreImporter/OgreImporterUtils.h

@@ -111,7 +111,7 @@ struct ModelVertex
 
 
 struct ModelVertexBuffer
 struct ModelVertexBuffer
 {
 {
-    FlagSet<VertexMask> elementMask_;
+    VertexMaskFlags elementMask_;
     unsigned morphStart_;
     unsigned morphStart_;
     unsigned morphCount_;
     unsigned morphCount_;
     Vector<ModelVertex> vertices_;
     Vector<ModelVertex> vertices_;

+ 12 - 8
Source/Urho3D/Container/FlagSet.h

@@ -30,13 +30,17 @@ namespace Urho3D
 {
 {
 
 
 /// Bitwise Type trait which enables against Enum value. for consumption by flagset class and it's global operators.
 /// Bitwise Type trait which enables against Enum value. for consumption by flagset class and it's global operators.
-template<typename T> struct is_flagset
+template<typename T> struct IsFlagSet
 {
 {
-    constexpr static bool value = false;
+    constexpr static bool value_ = false;
 };
 };
 
 
+#define URHO3D_FLAGSET(enumName, flagsetName) \
+    template<> struct IsFlagSet<enumName> { constexpr static bool value_ = true; }; \
+    using flagsetName = FlagSet<enumName>
+
 /// A set of flags defined by an Enum.
 /// A set of flags defined by an Enum.
-template <class E, class = typename std::enable_if<is_flagset<E>::value>::type>
+template <class E, class = typename std::enable_if<IsFlagSet<E>::value_>::type>
 class FlagSet
 class FlagSet
 {
 {
 public:
 public:
@@ -198,7 +202,7 @@ public:
     }
     }
 
 
     /// Returns true if specified enum value is set.
     /// Returns true if specified enum value is set.
-    inline bool is(const Enum value) const
+    inline bool Is(const Enum value) const
     {
     {
         Integer flags = (Integer) value;
         Integer flags = (Integer) value;
         return (value_ & flags) == flags && (flags != 0 || value_ == flags);
         return (value_ & flags) == flags && (flags != 0 || value_ == flags);
@@ -212,28 +216,28 @@ protected:
 }
 }
 
 
 /// Bitwise Operator OR for against Enum value.s
 /// Bitwise Operator OR for against Enum value.s
-template <class Enum, class = typename std::enable_if<Urho3D::is_flagset<Enum>::value>::type>
+template <class Enum, class = typename std::enable_if<Urho3D::IsFlagSet<Enum>::value_>::type>
 Urho3D::FlagSet<Enum> operator |(const Enum lhs, const Enum rhs)
 Urho3D::FlagSet<Enum> operator |(const Enum lhs, const Enum rhs)
 {
 {
     return Urho3D::FlagSet<Enum>(lhs) | rhs;
     return Urho3D::FlagSet<Enum>(lhs) | rhs;
 }
 }
 
 
 /// Bitwise Operator AND for against Enum value.s
 /// Bitwise Operator AND for against Enum value.s
-template <class Enum, class = typename std::enable_if<Urho3D::is_flagset<Enum>::value>::type>
+template <class Enum, class = typename std::enable_if<Urho3D::IsFlagSet<Enum>::value_>::type>
 Urho3D::FlagSet<Enum> operator & (const Enum lhs, const Enum rhs)
 Urho3D::FlagSet<Enum> operator & (const Enum lhs, const Enum rhs)
 {
 {
     return Urho3D::FlagSet<Enum>(lhs) & rhs;
     return Urho3D::FlagSet<Enum>(lhs) & rhs;
 }
 }
 
 
 /// Bitwise Operator XOR for against Enum value.s
 /// Bitwise Operator XOR for against Enum value.s
-template <class Enum, class = typename std::enable_if<Urho3D::is_flagset<Enum>::value>::type>
+template <class Enum, class = typename std::enable_if<Urho3D::IsFlagSet<Enum>::value_>::type>
 Urho3D::FlagSet<Enum> operator ^ (const Enum lhs, const Enum rhs)
 Urho3D::FlagSet<Enum> operator ^ (const Enum lhs, const Enum rhs)
 {
 {
     return Urho3D::FlagSet<Enum>(lhs) ^ rhs;
     return Urho3D::FlagSet<Enum>(lhs) ^ rhs;
 }
 }
 
 
 /// Bitwise Operator RESET for against Enum value.s
 /// Bitwise Operator RESET for against Enum value.s
-template <class Enum, class = typename std::enable_if<Urho3D::is_flagset<Enum>::value>::type>
+template <class Enum, class = typename std::enable_if<Urho3D::IsFlagSet<Enum>::value_>::type>
 Urho3D::FlagSet<Enum> operator ~ (const Enum rhs)
 Urho3D::FlagSet<Enum> operator ~ (const Enum rhs)
 {
 {
     return (Enum)(~(typename std::underlying_type<Enum>::type)rhs);
     return (Enum)(~(typename std::underlying_type<Enum>::type)rhs);

+ 3 - 3
Source/Urho3D/Core/Attribute.h

@@ -52,7 +52,7 @@ enum AttributeMode
     /// Attribute is readonly. Can't be used with binary serialized objects.
     /// Attribute is readonly. Can't be used with binary serialized objects.
     AM_FILEREADONLY = 0x81,
     AM_FILEREADONLY = 0x81,
 };
 };
-template<> struct is_flagset<AttributeMode> { constexpr static bool value = true; };
+URHO3D_FLAGSET(AttributeMode, AttributeModeFlags);
 
 
 class Serializable;
 class Serializable;
 
 
@@ -73,7 +73,7 @@ struct AttributeInfo
     AttributeInfo() = default;
     AttributeInfo() = default;
 
 
     /// Construct attribute.
     /// Construct attribute.
-    AttributeInfo(VariantType type, const char* name, const SharedPtr<AttributeAccessor>& accessor, const char** enumNames, const Variant& defaultValue, FlagSet<AttributeMode> mode) :
+    AttributeInfo(VariantType type, const char* name, const SharedPtr<AttributeAccessor>& accessor, const char** enumNames, const Variant& defaultValue, AttributeModeFlags mode) :
         type_(type),
         type_(type),
         name_(name),
         name_(name),
         enumNames_(enumNames),
         enumNames_(enumNames),
@@ -107,7 +107,7 @@ struct AttributeInfo
     /// Default value for network replication.
     /// Default value for network replication.
     Variant defaultValue_;
     Variant defaultValue_;
     /// Attribute mode: whether to use for serialization, network replication, or both.
     /// Attribute mode: whether to use for serialization, network replication, or both.
-    FlagSet<AttributeMode> mode_ = AM_DEFAULT;
+    AttributeModeFlags mode_ = AM_DEFAULT;
     /// Attribute metadata.
     /// Attribute metadata.
     VariantMap metadata_;
     VariantMap metadata_;
     /// Attribute data pointer if elsewhere than in the Serializable.
     /// Attribute data pointer if elsewhere than in the Serializable.

+ 1 - 1
Source/Urho3D/Engine/DebugHud.cpp

@@ -166,7 +166,7 @@ void DebugHud::Update()
         String mode;
         String mode;
         mode.AppendWithFormat("Tex:%s Mat:%s Spec:%s Shadows:%s Size:%i Quality:%s Occlusion:%s Instancing:%s API:%s",
         mode.AppendWithFormat("Tex:%s Mat:%s Spec:%s Shadows:%s Size:%i Quality:%s Occlusion:%s Instancing:%s API:%s",
             qualityTexts[renderer->GetTextureQuality()],
             qualityTexts[renderer->GetTextureQuality()],
-            qualityTexts[Min(renderer->GetMaterialQuality(), 3)],
+            qualityTexts[Min((unsigned)renderer->GetMaterialQuality(), 3)],
             renderer->GetSpecularLighting() ? "On" : "Off",
             renderer->GetSpecularLighting() ? "On" : "Off",
             renderer->GetDrawShadows() ? "On" : "Off",
             renderer->GetDrawShadows() ? "On" : "Off",
             renderer->GetShadowMapSize(),
             renderer->GetShadowMapSize(),

+ 1 - 1
Source/Urho3D/Graphics/AnimatedModel.h

@@ -232,7 +232,7 @@ private:
     /// The frame number animation LOD distance was last calculated on.
     /// The frame number animation LOD distance was last calculated on.
     unsigned animationLodFrameNumber_;
     unsigned animationLodFrameNumber_;
     /// Morph vertex element mask.
     /// Morph vertex element mask.
-    FlagSet<VertexMask> morphElementMask_;
+    VertexMaskFlags morphElementMask_;
     /// Animation LOD bias.
     /// Animation LOD bias.
     float animationLodBias_;
     float animationLodBias_;
     /// Animation LOD timer.
     /// Animation LOD timer.

+ 1 - 1
Source/Urho3D/Graphics/Animation.cpp

@@ -143,7 +143,7 @@ bool Animation::BeginLoad(Deserializer& source)
     for (unsigned i = 0; i < tracks; ++i)
     for (unsigned i = 0; i < tracks; ++i)
     {
     {
         AnimationTrack* newTrack = CreateTrack(source.ReadString());
         AnimationTrack* newTrack = CreateTrack(source.ReadString());
-        newTrack->channelMask_ = FlagSet<AnimationChannel>(source.ReadUByte());
+        newTrack->channelMask_ = AnimationChannelFlags(source.ReadUByte());
 
 
         unsigned keyFrames = source.ReadUInt();
         unsigned keyFrames = source.ReadUInt();
         newTrack->keyFrames_.Resize(keyFrames);
         newTrack->keyFrames_.Resize(keyFrames);

+ 2 - 2
Source/Urho3D/Graphics/Animation.h

@@ -38,7 +38,7 @@ enum AnimationChannel : unsigned char
     CHANNEL_ROTATION = 0x2,
     CHANNEL_ROTATION = 0x2,
     CHANNEL_SCALE = 0x4,
     CHANNEL_SCALE = 0x4,
 };
 };
-template<> struct is_flagset<AnimationChannel> { constexpr static bool value = true; };
+URHO3D_FLAGSET(AnimationChannel, AnimationChannelFlags);
 
 
 /// Skeletal animation keyframe.
 /// Skeletal animation keyframe.
 struct AnimationKeyFrame
 struct AnimationKeyFrame
@@ -89,7 +89,7 @@ struct URHO3D_API AnimationTrack
     /// Name hash.
     /// Name hash.
     StringHash nameHash_;
     StringHash nameHash_;
     /// Bitmask of included data (position, rotation, scale.)
     /// Bitmask of included data (position, rotation, scale.)
-    FlagSet<AnimationChannel> channelMask_{};
+    AnimationChannelFlags channelMask_{};
     /// Keyframes.
     /// Keyframes.
     Vector<AnimationKeyFrame> keyFrames_;
     Vector<AnimationKeyFrame> keyFrames_;
 };
 };

+ 1 - 1
Source/Urho3D/Graphics/CustomGeometry.cpp

@@ -454,7 +454,7 @@ void CustomGeometry::SetGeometryDataAttr(const PODVector<unsigned char>& value)
     MemoryBuffer buffer(value);
     MemoryBuffer buffer(value);
 
 
     SetNumGeometries(buffer.ReadVLE());
     SetNumGeometries(buffer.ReadVLE());
-    elementMask_ = FlagSet<VertexMask>(buffer.ReadUInt());
+    elementMask_ = VertexMaskFlags(buffer.ReadUInt());
 
 
     for (unsigned i = 0; i < geometries_.Size(); ++i)
     for (unsigned i = 0; i < geometries_.Size(); ++i)
     {
     {

+ 1 - 1
Source/Urho3D/Graphics/CustomGeometry.h

@@ -136,7 +136,7 @@ private:
     /// Vertex buffer.
     /// Vertex buffer.
     SharedPtr<VertexBuffer> vertexBuffer_;
     SharedPtr<VertexBuffer> vertexBuffer_;
     /// Element mask used so far.
     /// Element mask used so far.
-    FlagSet<VertexMask> elementMask_;
+    VertexMaskFlags elementMask_;
     /// Current geometry being updated.
     /// Current geometry being updated.
     unsigned geometryIndex_;
     unsigned geometryIndex_;
     /// Material list attribute.
     /// Material list attribute.

+ 3 - 3
Source/Urho3D/Graphics/DecalSet.cpp

@@ -56,8 +56,8 @@ static const unsigned MIN_INDICES = 6;
 static const unsigned MAX_VERTICES = 65536;
 static const unsigned MAX_VERTICES = 65536;
 static const unsigned DEFAULT_MAX_VERTICES = 512;
 static const unsigned DEFAULT_MAX_VERTICES = 512;
 static const unsigned DEFAULT_MAX_INDICES = 1024;
 static const unsigned DEFAULT_MAX_INDICES = 1024;
-static const FlagSet<VertexMask> STATIC_ELEMENT_MASK = MASK_POSITION | MASK_NORMAL | MASK_TEXCOORD1 | MASK_TANGENT;
-static const FlagSet<VertexMask> SKINNED_ELEMENT_MASK = MASK_POSITION | MASK_NORMAL | MASK_TEXCOORD1 | MASK_TANGENT |
+static const VertexMaskFlags STATIC_ELEMENT_MASK = MASK_POSITION | MASK_NORMAL | MASK_TEXCOORD1 | MASK_TANGENT;
+static const VertexMaskFlags SKINNED_ELEMENT_MASK = MASK_POSITION | MASK_NORMAL | MASK_TEXCOORD1 | MASK_TANGENT |
     MASK_BLENDWEIGHTS | MASK_BLENDINDICES;
     MASK_BLENDWEIGHTS | MASK_BLENDINDICES;
 
 
 static DecalVertex ClipEdge(const DecalVertex& v0, const DecalVertex& v1, float d0, float d1, bool skinned)
 static DecalVertex ClipEdge(const DecalVertex& v0, const DecalVertex& v1, float d0, float d1, bool skinned)
@@ -577,7 +577,7 @@ void DecalSet::SetDecalsAttr(const PODVector<unsigned char>& value)
             Bone& newBone = bones_[i];
             Bone& newBone = bones_[i];
 
 
             newBone.name_ = buffer.ReadString();
             newBone.name_ = buffer.ReadString();
-            newBone.collisionMask_ = FlagSet<BoneCollisionShape>(buffer.ReadUByte());
+            newBone.collisionMask_ = BoneCollisionShapeFlags(buffer.ReadUByte());
             if (newBone.collisionMask_ & BONECOLLISION_SPHERE)
             if (newBone.collisionMask_ & BONECOLLISION_SPHERE)
                 newBone.radius_ = buffer.ReadFloat();
                 newBone.radius_ = buffer.ReadFloat();
             if (newBone.collisionMask_ & BONECOLLISION_BOX)
             if (newBone.collisionMask_ & BONECOLLISION_BOX)

+ 1 - 1
Source/Urho3D/Graphics/Direct3D11/D3D11Graphics.cpp

@@ -590,7 +590,7 @@ void Graphics::EndFrame()
     CleanupScratchBuffers();
     CleanupScratchBuffers();
 }
 }
 
 
-void Graphics::Clear(FlagSet<Urho3D::Clear> flags, const Color& color, float depth, unsigned stencil)
+void Graphics::Clear(ClearFlags flags, const Color& color, float depth, unsigned stencil)
 {
 {
     IntVector2 rtSize = GetRenderTargetDimensions();
     IntVector2 rtSize = GetRenderTargetDimensions();
 
 

+ 1 - 1
Source/Urho3D/Graphics/Direct3D9/D3D9Graphics.cpp

@@ -771,7 +771,7 @@ void Graphics::EndFrame()
     CleanupScratchBuffers();
     CleanupScratchBuffers();
 }
 }
 
 
-void Graphics::Clear(FlagSet<Urho3D::Clear> flags, const Color& color, float depth, unsigned stencil)
+void Graphics::Clear(ClearFlags flags, const Color& color, float depth, unsigned stencil)
 {
 {
     DWORD d3dFlags = 0;
     DWORD d3dFlags = 0;
     if (flags & CLEAR_COLOR)
     if (flags & CLEAR_COLOR)

+ 1 - 1
Source/Urho3D/Graphics/Graphics.h

@@ -125,7 +125,7 @@ public:
     /// End frame rendering and swap buffers.
     /// End frame rendering and swap buffers.
     void EndFrame();
     void EndFrame();
     /// Clear any or all of rendertarget, depth buffer and stencil buffer.
     /// Clear any or all of rendertarget, depth buffer and stencil buffer.
-    void Clear(FlagSet<Urho3D::Clear> flags, const Color& color = Color(0.0f, 0.0f, 0.0f, 0.0f), float depth = 1.0f, unsigned stencil = 0);
+    void Clear(ClearFlags flags, const Color& color = Color(0.0f, 0.0f, 0.0f, 0.0f), float depth = 1.0f, unsigned stencil = 0);
     /// Resolve multisampled backbuffer to a texture rendertarget. The texture's size should match the viewport size.
     /// Resolve multisampled backbuffer to a texture rendertarget. The texture's size should match the viewport size.
     bool ResolveToTexture(Texture2D* destination, const IntRect& viewport);
     bool ResolveToTexture(Texture2D* destination, const IntRect& viewport);
     /// Resolve a multisampled texture on itself.
     /// Resolve a multisampled texture on itself.

+ 2 - 2
Source/Urho3D/Graphics/GraphicsDefs.h

@@ -445,7 +445,7 @@ enum Clear : unsigned
     CLEAR_DEPTH = 0x2,
     CLEAR_DEPTH = 0x2,
     CLEAR_STENCIL = 0x4,
     CLEAR_STENCIL = 0x4,
 };
 };
-template<> struct is_flagset<Clear> { constexpr static bool value = true; };
+URHO3D_FLAGSET(Clear, ClearFlags);
 
 
 // Legacy vertex element bitmasks.
 // Legacy vertex element bitmasks.
 enum VertexMask : unsigned
 enum VertexMask : unsigned
@@ -466,7 +466,7 @@ enum VertexMask : unsigned
     MASK_INSTANCEMATRIX3 = 0x1000,
     MASK_INSTANCEMATRIX3 = 0x1000,
     MASK_OBJECTINDEX = 0x2000,
     MASK_OBJECTINDEX = 0x2000,
 };
 };
-template<> struct is_flagset<VertexMask> { constexpr static bool value = true; };
+URHO3D_FLAGSET(VertexMask, VertexMaskFlags);
 
 
 static const int MAX_RENDERTARGETS = 4;
 static const int MAX_RENDERTARGETS = 4;
 static const int MAX_VERTEX_STREAMS = 4;
 static const int MAX_VERTEX_STREAMS = 4;

+ 1 - 1
Source/Urho3D/Graphics/Model.cpp

@@ -268,7 +268,7 @@ bool Model::BeginLoad(Deserializer& source)
             VertexBufferMorph newBuffer;
             VertexBufferMorph newBuffer;
             unsigned bufferIndex = source.ReadUInt();
             unsigned bufferIndex = source.ReadUInt();
 
 
-            newBuffer.elementMask_ = FlagSet<VertexMask>(source.ReadUInt());
+            newBuffer.elementMask_ = VertexMaskFlags(source.ReadUInt());
             newBuffer.vertexCount_ = source.ReadUInt();
             newBuffer.vertexCount_ = source.ReadUInt();
 
 
             // Base size: size of each vertex index
             // Base size: size of each vertex index

+ 1 - 1
Source/Urho3D/Graphics/Model.h

@@ -41,7 +41,7 @@ class VertexBuffer;
 struct VertexBufferMorph
 struct VertexBufferMorph
 {
 {
     /// Vertex elements.
     /// Vertex elements.
-    FlagSet<VertexMask> elementMask_;
+    VertexMaskFlags elementMask_;
     /// Number of vertices.
     /// Number of vertices.
     unsigned vertexCount_;
     unsigned vertexCount_;
     /// Morphed vertices data size as bytes.
     /// Morphed vertices data size as bytes.

+ 4 - 4
Source/Urho3D/Graphics/OcclusionBuffer.cpp

@@ -42,7 +42,7 @@ enum ClipMask : unsigned
     CLIPMASK_Z_POS = 0x10,
     CLIPMASK_Z_POS = 0x10,
     CLIPMASK_Z_NEG = 0x20,
     CLIPMASK_Z_NEG = 0x20,
 };
 };
-template<> struct is_flagset<ClipMask> { constexpr static bool value = true; };
+URHO3D_FLAGSET(ClipMask, ClipMaskFlags);
 
 
 void DrawOcclusionBatchWork(const WorkItem* item, unsigned threadIndex)
 void DrawOcclusionBatchWork(const WorkItem* item, unsigned threadIndex)
 {
 {
@@ -588,15 +588,15 @@ void OcclusionBuffer::CalculateViewport()
 
 
 void OcclusionBuffer::DrawTriangle(Vector4* vertices, unsigned threadIndex)
 void OcclusionBuffer::DrawTriangle(Vector4* vertices, unsigned threadIndex)
 {
 {
-    FlagSet<ClipMask> clipMask{};
-    FlagSet<ClipMask> andClipMask{};
+    ClipMaskFlags clipMask{};
+    ClipMaskFlags andClipMask{};
     bool drawOk = false;
     bool drawOk = false;
     Vector3 projected[3];
     Vector3 projected[3];
 
 
     // Build the clip plane mask for the triangle
     // Build the clip plane mask for the triangle
     for (unsigned i = 0; i < 3; ++i)
     for (unsigned i = 0; i < 3; ++i)
     {
     {
-        FlagSet<ClipMask> vertexClipMask{};
+        ClipMaskFlags vertexClipMask{};
 
 
         if (vertices[i].x_ > vertices[i].w_)
         if (vertices[i].x_ > vertices[i].w_)
             vertexClipMask |= CLIPMASK_X_POS;
             vertexClipMask |= CLIPMASK_X_POS;

+ 1 - 1
Source/Urho3D/Graphics/OpenGL/OGLGraphics.cpp

@@ -659,7 +659,7 @@ void Graphics::EndFrame()
     CleanupScratchBuffers();
     CleanupScratchBuffers();
 }
 }
 
 
-void Graphics::Clear(FlagSet<Urho3D::Clear> flags, const Color& color, float depth, unsigned stencil)
+void Graphics::Clear(ClearFlags flags, const Color& color, float depth, unsigned stencil)
 {
 {
     PrepareDraw();
     PrepareDraw();
 
 

+ 1 - 1
Source/Urho3D/Graphics/RenderPath.h

@@ -161,7 +161,7 @@ struct URHO3D_API RenderPathCommand
     /// Depth-stencil output name.
     /// Depth-stencil output name.
     String depthStencilName_;
     String depthStencilName_;
     /// Clear flags. Affects clear command only.
     /// Clear flags. Affects clear command only.
-    FlagSet<Clear> clearFlags_{};
+    ClearFlags clearFlags_{};
     /// Clear color. Affects clear command only.
     /// Clear color. Affects clear command only.
     Color clearColor_;
     Color clearColor_;
     /// Clear depth. Affects clear command only.
     /// Clear depth. Affects clear command only.

+ 1 - 1
Source/Urho3D/Graphics/Skeleton.cpp

@@ -59,7 +59,7 @@ bool Skeleton::Load(Deserializer& source)
         source.Read(&newBone.offsetMatrix_.m00_, sizeof(Matrix3x4));
         source.Read(&newBone.offsetMatrix_.m00_, sizeof(Matrix3x4));
 
 
         // Read bone collision data
         // Read bone collision data
-        newBone.collisionMask_ = FlagSet<BoneCollisionShape>(source.ReadUByte());
+        newBone.collisionMask_ = BoneCollisionShapeFlags(source.ReadUByte());
         if (newBone.collisionMask_ & BONECOLLISION_SPHERE)
         if (newBone.collisionMask_ & BONECOLLISION_SPHERE)
             newBone.radius_ = source.ReadFloat();
             newBone.radius_ = source.ReadFloat();
         if (newBone.collisionMask_ & BONECOLLISION_BOX)
         if (newBone.collisionMask_ & BONECOLLISION_BOX)

+ 2 - 2
Source/Urho3D/Graphics/Skeleton.h

@@ -34,7 +34,7 @@ enum BoneCollisionShape : unsigned char
     BONECOLLISION_SPHERE = 0x1,
     BONECOLLISION_SPHERE = 0x1,
     BONECOLLISION_BOX = 0x2,
     BONECOLLISION_BOX = 0x2,
 };
 };
-template<> struct is_flagset<BoneCollisionShape> { constexpr static bool value = true; };
+URHO3D_FLAGSET(BoneCollisionShape, BoneCollisionShapeFlags);
 
 
 class Deserializer;
 class Deserializer;
 class ResourceCache;
 class ResourceCache;
@@ -71,7 +71,7 @@ struct Bone
     /// Animation enable flag.
     /// Animation enable flag.
     bool animated_;
     bool animated_;
     /// Supported collision types.
     /// Supported collision types.
-    FlagSet<BoneCollisionShape> collisionMask_ = BONECOLLISION_NONE;
+    BoneCollisionShapeFlags collisionMask_ = BONECOLLISION_NONE;
     /// Radius.
     /// Radius.
     float radius_;
     float radius_;
     /// Local-space bounding box.
     /// Local-space bounding box.

+ 1 - 1
Source/Urho3D/Graphics/VertexBuffer.cpp

@@ -106,7 +106,7 @@ void VertexBuffer::UpdateOffsets()
         {
         {
             const VertexElement& legacy = LEGACY_VERTEXELEMENTS[j];
             const VertexElement& legacy = LEGACY_VERTEXELEMENTS[j];
             if (i->type_ == legacy.type_ && i->semantic_ == legacy.semantic_ && i->index_ == legacy.index_)
             if (i->type_ == legacy.type_ && i->semantic_ == legacy.semantic_ && i->index_ == legacy.index_)
-                elementMask_ |= FlagSet<VertexMask>(1u << j);
+                elementMask_ |= VertexMaskFlags(1u << j);
         }
         }
     }
     }
 
 

+ 2 - 2
Source/Urho3D/Graphics/VertexBuffer.h

@@ -100,7 +100,7 @@ public:
     unsigned GetElementOffset(VertexElementType type, VertexElementSemantic semantic, unsigned char index = 0) const { const VertexElement* element = GetElement(type, semantic, index); return element ? element->offset_ : M_MAX_UNSIGNED; }
     unsigned GetElementOffset(VertexElementType type, VertexElementSemantic semantic, unsigned char index = 0) const { const VertexElement* element = GetElement(type, semantic, index); return element ? element->offset_ : M_MAX_UNSIGNED; }
 
 
     /// Return legacy vertex element mask. Note that both semantic and type must match the legacy element for a mask bit to be set.
     /// Return legacy vertex element mask. Note that both semantic and type must match the legacy element for a mask bit to be set.
-    FlagSet<VertexMask> GetElementMask() const { return elementMask_; }
+    VertexMaskFlags GetElementMask() const { return elementMask_; }
 
 
     /// Return CPU memory shadow data.
     /// Return CPU memory shadow data.
     unsigned char* GetShadowData() const { return shadowData_.Get(); }
     unsigned char* GetShadowData() const { return shadowData_.Get(); }
@@ -155,7 +155,7 @@ private:
     /// Vertex element hash.
     /// Vertex element hash.
     unsigned long long elementHash_{};
     unsigned long long elementHash_{};
     /// Vertex element legacy bitmask.
     /// Vertex element legacy bitmask.
-    FlagSet<VertexMask> elementMask_{};
+    VertexMaskFlags elementMask_{};
     /// Buffer locking state.
     /// Buffer locking state.
     LockState lockState_{LOCK_NONE};
     LockState lockState_{LOCK_NONE};
     /// Lock start vertex.
     /// Lock start vertex.

+ 4 - 4
Source/Urho3D/Input/Input.cpp

@@ -1351,12 +1351,12 @@ bool Input::GetScancodePress(Scancode scancode) const
 
 
 bool Input::GetMouseButtonDown(MouseButton button) const
 bool Input::GetMouseButtonDown(MouseButton button) const
 {
 {
-    return (mouseButtonDown_ & button) != 0;
+    return mouseButtonDown_ & button;
 }
 }
 
 
 bool Input::GetMouseButtonPress(MouseButton button) const
 bool Input::GetMouseButtonPress(MouseButton button) const
 {
 {
-    return (mouseButtonPress_ & button) != 0;
+    return mouseButtonPress_ & button;
 }
 }
 
 
 bool Input::GetQualifierDown(Qualifier qualifier) const
 bool Input::GetQualifierDown(Qualifier qualifier) const
@@ -1383,9 +1383,9 @@ bool Input::GetQualifierPress(Qualifier qualifier) const
     return false;
     return false;
 }
 }
 
 
-FlagSet<Qualifier> Input::GetQualifiers() const
+QualifierFlags Input::GetQualifiers() const
 {
 {
-    FlagSet<Qualifier> ret;
+    QualifierFlags ret;
     if (GetQualifierDown(QUAL_SHIFT))
     if (GetQualifierDown(QUAL_SHIFT))
         ret |= QUAL_SHIFT;
         ret |= QUAL_SHIFT;
     if (GetQualifierDown(QUAL_CTRL))
     if (GetQualifierDown(QUAL_CTRL))

+ 3 - 3
Source/Urho3D/Input/Input.h

@@ -241,7 +241,7 @@ public:
     /// Check if a qualifier key has been pressed on this frame.
     /// Check if a qualifier key has been pressed on this frame.
     bool GetQualifierPress(Qualifier qualifier) const;
     bool GetQualifierPress(Qualifier qualifier) const;
     /// Return the currently held down qualifiers.
     /// Return the currently held down qualifiers.
-    int GetQualifiers() const;
+    QualifierFlags GetQualifiers() const;
     /// Return mouse position within window. Should only be used with a visible mouse cursor. Uses the backbuffer (Graphics width/height) coordinates.
     /// Return mouse position within window. Should only be used with a visible mouse cursor. Uses the backbuffer (Graphics width/height) coordinates.
     IntVector2 GetMousePosition() const;
     IntVector2 GetMousePosition() const;
     /// Return mouse movement since last frame.
     /// Return mouse movement since last frame.
@@ -379,9 +379,9 @@ private:
     /// Opened joysticks.
     /// Opened joysticks.
     HashMap<SDL_JoystickID, JoystickState> joysticks_;
     HashMap<SDL_JoystickID, JoystickState> joysticks_;
     /// Mouse buttons' down state.
     /// Mouse buttons' down state.
-    unsigned mouseButtonDown_;
+    MouseButtonFlags mouseButtonDown_;
     /// Mouse buttons' pressed state.
     /// Mouse buttons' pressed state.
-    unsigned mouseButtonPress_;
+    MouseButtonFlags mouseButtonPress_;
     /// Last mouse position for calculating movement.
     /// Last mouse position for calculating movement.
     IntVector2 lastMousePosition_;
     IntVector2 lastMousePosition_;
     /// Last mouse position before being set to not visible.
     /// Last mouse position before being set to not visible.

+ 2 - 2
Source/Urho3D/Input/InputConstants.h

@@ -44,7 +44,7 @@ enum MouseButton : unsigned
     MOUSEB_X2 = SDL_BUTTON_X2MASK,
     MOUSEB_X2 = SDL_BUTTON_X2MASK,
     MOUSEB_ANY = M_MAX_UNSIGNED
     MOUSEB_ANY = M_MAX_UNSIGNED
 };
 };
-template<> struct is_flagset<MouseButton> { constexpr static bool value = true; };
+URHO3D_FLAGSET(MouseButton, MouseButtonFlags);
 
 
 enum Qualifier : unsigned
 enum Qualifier : unsigned
 {
 {
@@ -54,7 +54,7 @@ enum Qualifier : unsigned
     QUAL_ALT = 4,
     QUAL_ALT = 4,
     QUAL_ANY = 8
     QUAL_ANY = 8
 };
 };
-template<> struct is_flagset<Qualifier> { constexpr static bool value = true; };
+URHO3D_FLAGSET(Qualifier, QualifierFlags);
 
 
 
 
 enum Key : unsigned
 enum Key : unsigned

+ 1 - 1
Source/Urho3D/Scene/LogicComponent.h

@@ -41,7 +41,7 @@ enum UseEvent : unsigned
     /// Bitmask for using the physics post-update event.
     /// Bitmask for using the physics post-update event.
     USE_FIXEDPOSTUPDATE = 0x8,
     USE_FIXEDPOSTUPDATE = 0x8,
 };
 };
-template<> struct is_flagset<UseEvent> { constexpr static bool value = true; };
+URHO3D_FLAGSET(UseEvent, UseEventFlags);
 
 
 /// Helper base class for user-defined game logic components that hooks up to update events and forwards them to virtual functions similar to ScriptInstance class.
 /// Helper base class for user-defined game logic components that hooks up to update events and forwards them to virtual functions similar to ScriptInstance class.
 class URHO3D_API LogicComponent : public Component
 class URHO3D_API LogicComponent : public Component

+ 1 - 1
Source/Urho3D/Scene/SmoothedTransform.h

@@ -36,7 +36,7 @@ enum SmoothingType : unsigned
     /// Ongoing rotation smoothing.
     /// Ongoing rotation smoothing.
     SMOOTH_ROTATION = 2,
     SMOOTH_ROTATION = 2,
 };
 };
-template<> struct is_flagset<SmoothingType> { constexpr static bool value = true; };
+URHO3D_FLAGSET(SmoothingType, SmoothingTypeFlags);
 
 
 /// Transform smoothing component for network updates.
 /// Transform smoothing component for network updates.
 class URHO3D_API SmoothedTransform : public Component
 class URHO3D_API SmoothedTransform : public Component

+ 1 - 1
Source/Urho3D/UI/Button.cpp

@@ -146,7 +146,7 @@ void Button::OnDragMove(const IntVector2& position, const IntVector2& screenPosi
     SetPressed(true);
     SetPressed(true);
 }
 }
 
 
-void Button::OnKey(Key key, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers)
+void Button::OnKey(Key key, MouseButtonFlags buttons, QualifierFlags qualifiers)
 {
 {
     if (HasFocus() && (key == KEY_RETURN || key == KEY_RETURN2 || key == KEY_KP_ENTER || key == KEY_SPACE))
     if (HasFocus() && (key == KEY_RETURN || key == KEY_RETURN2 || key == KEY_KP_ENTER || key == KEY_SPACE))
     {
     {

+ 1 - 1
Source/Urho3D/UI/Button.h

@@ -56,7 +56,7 @@ public:
         (const IntVector2& position, const IntVector2& screenPosition, const IntVector2& deltaPos, int buttons, int qualifiers,
         (const IntVector2& position, const IntVector2& screenPosition, const IntVector2& deltaPos, int buttons, int qualifiers,
             Cursor* cursor) override;
             Cursor* cursor) override;
     /// React to a key press.
     /// React to a key press.
-    void OnKey(Key key, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers) override;
+    void OnKey(Key key, MouseButtonFlags buttons, QualifierFlags qualifiers) override;
 
 
     /// Set offset to image rectangle used when pressed.
     /// Set offset to image rectangle used when pressed.
     void SetPressedOffset(const IntVector2& offset);
     void SetPressedOffset(const IntVector2& offset);

+ 1 - 1
Source/Urho3D/UI/CheckBox.cpp

@@ -74,7 +74,7 @@ void CheckBox::OnClickBegin(const IntVector2& position, const IntVector2& screen
         SetChecked(!checked_);
         SetChecked(!checked_);
 }
 }
 
 
-void CheckBox::OnKey(Key key, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers)
+void CheckBox::OnKey(Key key, MouseButtonFlags buttons, QualifierFlags qualifiers)
 {
 {
     if (HasFocus() && key == KEY_SPACE)
     if (HasFocus() && key == KEY_SPACE)
     {
     {

+ 1 - 1
Source/Urho3D/UI/CheckBox.h

@@ -46,7 +46,7 @@ public:
     void OnClickBegin
     void OnClickBegin
         (const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor) override;
         (const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor) override;
     /// React to a key press.
     /// React to a key press.
-    void OnKey(Key key, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers) override;
+    void OnKey(Key key, MouseButtonFlags buttons, FlagSet<Qualifier> qualifiers) override;
 
 
     /// Set checked state.
     /// Set checked state.
     void SetChecked(bool enable);
     void SetChecked(bool enable);

+ 1 - 1
Source/Urho3D/UI/LineEdit.cpp

@@ -204,7 +204,7 @@ bool LineEdit::OnDragDropFinish(UIElement* source)
     return false;
     return false;
 }
 }
 
 
-void LineEdit::OnKey(Key key, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers)
+void LineEdit::OnKey(Key key, MouseButtonFlags buttons, QualifierFlags qualifiers)
 {
 {
     bool changed = false;
     bool changed = false;
     bool cursorMoved = false;
     bool cursorMoved = false;

+ 1 - 1
Source/Urho3D/UI/LineEdit.h

@@ -65,7 +65,7 @@ public:
     /// React to drag and drop finish. Return true to signal that the drop was accepted.
     /// React to drag and drop finish. Return true to signal that the drop was accepted.
     bool OnDragDropFinish(UIElement* source) override;
     bool OnDragDropFinish(UIElement* source) override;
     /// React to a key press.
     /// React to a key press.
-    void OnKey(Key key, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers) override;
+    void OnKey(Key key, MouseButtonFlags buttons, QualifierFlags qualifiers) override;
     /// React to text input event.
     /// React to text input event.
     void OnTextInput(const String& text) override;
     void OnTextInput(const String& text) override;
 
 

+ 1 - 1
Source/Urho3D/UI/ListView.cpp

@@ -203,7 +203,7 @@ void ListView::RegisterObject(Context* context)
     URHO3D_ACCESSOR_ATTRIBUTE("Select On Click End", GetSelectOnClickEnd, SetSelectOnClickEnd, bool, false, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Select On Click End", GetSelectOnClickEnd, SetSelectOnClickEnd, bool, false, AM_FILE);
 }
 }
 
 
-void ListView::OnKey(Key key, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers)
+void ListView::OnKey(Key key, MouseButtonFlags buttons, QualifierFlags qualifiers)
 {
 {
     // If no selection, can not move with keys
     // If no selection, can not move with keys
     unsigned numItems = GetNumItems();
     unsigned numItems = GetNumItems();

+ 1 - 1
Source/Urho3D/UI/ListView.h

@@ -54,7 +54,7 @@ public:
     static void RegisterObject(Context* context);
     static void RegisterObject(Context* context);
 
 
     /// React to a key press.
     /// React to a key press.
-    void OnKey(Key key, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers) override;
+    void OnKey(Key key, MouseButtonFlags buttons, QualifierFlags qualifiers) override;
     /// React to resize.
     /// React to resize.
     void OnResize(const IntVector2& newSize, const IntVector2& delta) override;
     void OnResize(const IntVector2& newSize, const IntVector2& delta) override;
 
 

+ 2 - 2
Source/Urho3D/UI/ScrollView.cpp

@@ -186,7 +186,7 @@ void ScrollView::ApplyAttributes()
     SetViewPosition(viewPositionAttr_);
     SetViewPosition(viewPositionAttr_);
 }
 }
 
 
-void ScrollView::OnWheel(int delta, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers)
+void ScrollView::OnWheel(int delta, MouseButtonFlags buttons, QualifierFlags qualifiers)
 {
 {
     if (delta > 0)
     if (delta > 0)
         verticalScrollBar_->StepBack();
         verticalScrollBar_->StepBack();
@@ -194,7 +194,7 @@ void ScrollView::OnWheel(int delta, FlagSet<MouseButton> buttons, FlagSet<Qualif
         verticalScrollBar_->StepForward();
         verticalScrollBar_->StepForward();
 }
 }
 
 
-void ScrollView::OnKey(Key key, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers)
+void ScrollView::OnKey(Key key, MouseButtonFlags buttons, QualifierFlags qualifiers)
 {
 {
     switch (key)
     switch (key)
     {
     {

+ 2 - 2
Source/Urho3D/UI/ScrollView.h

@@ -48,9 +48,9 @@ public:
     /// Apply attribute changes that can not be applied immediately.
     /// Apply attribute changes that can not be applied immediately.
     void ApplyAttributes() override;
     void ApplyAttributes() override;
     /// React to mouse wheel.
     /// React to mouse wheel.
-    void OnWheel(int delta, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers) override;
+    void OnWheel(int delta, MouseButtonFlags buttons, QualifierFlags qualifiers) override;
     /// React to a key press.
     /// React to a key press.
-    void OnKey(Key key, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers) override;
+    void OnKey(Key key, MouseButtonFlags buttons, QualifierFlags qualifiers) override;
     /// React to resize.
     /// React to resize.
     void OnResize(const IntVector2& newSize, const IntVector2& delta) override;
     void OnResize(const IntVector2& newSize, const IntVector2& delta) override;
 
 

+ 17 - 17
Source/Urho3D/UI/UI.cpp

@@ -67,7 +67,7 @@
 
 
 #include "../DebugNew.h"
 #include "../DebugNew.h"
 
 
-#define TOUCHID_MASK(id) FlagSet<MouseButton>(1u << (unsigned)(id))
+#define TOUCHID_MASK(id) MouseButtonFlags(1u << (unsigned)(id))
 
 
 namespace Urho3D
 namespace Urho3D
 {
 {
@@ -1268,7 +1268,7 @@ void UI::ReleaseFontFaces()
         fonts[i]->ReleaseFaces();
         fonts[i]->ReleaseFaces();
 }
 }
 
 
-void UI::ProcessHover(const IntVector2& windowCursorPos, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers, Cursor* cursor)
+void UI::ProcessHover(const IntVector2& windowCursorPos, MouseButtonFlags buttons, QualifierFlags qualifiers, Cursor* cursor)
 {
 {
     IntVector2 cursorPos;
     IntVector2 cursorPos;
     WeakPtr<UIElement> element(GetElementAt(windowCursorPos, true, &cursorPos));
     WeakPtr<UIElement> element(GetElementAt(windowCursorPos, true, &cursorPos));
@@ -1357,7 +1357,7 @@ void UI::ProcessHover(const IntVector2& windowCursorPos, FlagSet<MouseButton> bu
     }
     }
 }
 }
 
 
-void UI::ProcessClickBegin(const IntVector2& windowCursorPos, MouseButton button, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers, Cursor* cursor, bool cursorVisible)
+void UI::ProcessClickBegin(const IntVector2& windowCursorPos, MouseButton button, MouseButtonFlags buttons, QualifierFlags qualifiers, Cursor* cursor, bool cursorVisible)
 {
 {
     if (cursorVisible)
     if (cursorVisible)
     {
     {
@@ -1439,7 +1439,7 @@ void UI::ProcessClickBegin(const IntVector2& windowCursorPos, MouseButton button
     }
     }
 }
 }
 
 
-void UI::ProcessClickEnd(const IntVector2& windowCursorPos, MouseButton button, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers, Cursor* cursor, bool cursorVisible)
+void UI::ProcessClickEnd(const IntVector2& windowCursorPos, MouseButton button, MouseButtonFlags buttons, QualifierFlags qualifiers, Cursor* cursor, bool cursorVisible)
 {
 {
     WeakPtr<UIElement> element;
     WeakPtr<UIElement> element;
     IntVector2 cursorPos = windowCursorPos;
     IntVector2 cursorPos = windowCursorPos;
@@ -1505,7 +1505,7 @@ void UI::ProcessClickEnd(const IntVector2& windowCursorPos, MouseButton button,
     }
     }
 }
 }
 
 
-void UI::ProcessMove(const IntVector2& windowCursorPos, const IntVector2& cursorDeltaPos, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers, Cursor* cursor,
+void UI::ProcessMove(const IntVector2& windowCursorPos, const IntVector2& cursorDeltaPos, MouseButtonFlags buttons, QualifierFlags qualifiers, Cursor* cursor,
     bool cursorVisible)
     bool cursorVisible)
 {
 {
     if (cursorVisible && dragElementsCount_ > 0 && buttons)
     if (cursorVisible && dragElementsCount_ > 0 && buttons)
@@ -1619,7 +1619,7 @@ void UI::SendDragOrHoverEvent(StringHash eventType, UIElement* element, const In
 }
 }
 
 
 void UI::SendClickEvent(StringHash eventType, UIElement* beginElement, UIElement* endElement, const IntVector2& pos, MouseButton button,
 void UI::SendClickEvent(StringHash eventType, UIElement* beginElement, UIElement* endElement, const IntVector2& pos, MouseButton button,
-    FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers)
+    MouseButtonFlags buttons, QualifierFlags qualifiers)
 {
 {
     VariantMap& eventData = GetEventDataMap();
     VariantMap& eventData = GetEventDataMap();
     eventData[UIMouseClick::P_ELEMENT] = endElement;
     eventData[UIMouseClick::P_ELEMENT] = endElement;
@@ -1647,7 +1647,7 @@ void UI::SendClickEvent(StringHash eventType, UIElement* beginElement, UIElement
 }
 }
 
 
 void UI::SendDoubleClickEvent(UIElement* beginElement, UIElement* endElement, const IntVector2& firstPos, const IntVector2& secondPos, MouseButton button,
 void UI::SendDoubleClickEvent(UIElement* beginElement, UIElement* endElement, const IntVector2& firstPos, const IntVector2& secondPos, MouseButton button,
-    FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers)
+    MouseButtonFlags buttons, QualifierFlags qualifiers)
 {
 {
     VariantMap& eventData = GetEventDataMap();
     VariantMap& eventData = GetEventDataMap();
     eventData[UIMouseDoubleClick::P_ELEMENT] = endElement;
     eventData[UIMouseDoubleClick::P_ELEMENT] = endElement;
@@ -1685,8 +1685,8 @@ void UI::HandleMouseButtonDown(StringHash eventType, VariantMap& eventData)
 {
 {
     using namespace MouseButtonDown;
     using namespace MouseButtonDown;
 
 
-    mouseButtons_ = FlagSet<MouseButton>(eventData[P_BUTTONS].GetUInt());
-    qualifiers_ = FlagSet<Qualifier>(eventData[P_QUALIFIERS].GetUInt());
+    mouseButtons_ = MouseButtonFlags(eventData[P_BUTTONS].GetUInt());
+    qualifiers_ = QualifierFlags(eventData[P_QUALIFIERS].GetUInt());
     usingTouchInput_ = false;
     usingTouchInput_ = false;
 
 
     IntVector2 cursorPos;
     IntVector2 cursorPos;
@@ -1699,15 +1699,15 @@ void UI::HandleMouseButtonDown(StringHash eventType, VariantMap& eventData)
     auto* input = GetSubsystem<Input>();
     auto* input = GetSubsystem<Input>();
 
 
     if (!input->IsMouseGrabbed())
     if (!input->IsMouseGrabbed())
-        ProcessClickBegin(cursorPos, FlagSet<MouseButton>(eventData[P_BUTTON].GetUInt()), mouseButtons_, qualifiers_, cursor_, cursorVisible);
+        ProcessClickBegin(cursorPos, MouseButtonFlags(eventData[P_BUTTON].GetUInt()), mouseButtons_, qualifiers_, cursor_, cursorVisible);
 }
 }
 
 
 void UI::HandleMouseButtonUp(StringHash eventType, VariantMap& eventData)
 void UI::HandleMouseButtonUp(StringHash eventType, VariantMap& eventData)
 {
 {
     using namespace MouseButtonUp;
     using namespace MouseButtonUp;
 
 
-    mouseButtons_ = FlagSet<MouseButton>(eventData[P_BUTTONS].GetUInt());
-    qualifiers_ = FlagSet<Qualifier>(eventData[P_QUALIFIERS].GetUInt());
+    mouseButtons_ = MouseButtonFlags(eventData[P_BUTTONS].GetUInt());
+    qualifiers_ = QualifierFlags(eventData[P_QUALIFIERS].GetUInt());
 
 
     IntVector2 cursorPos;
     IntVector2 cursorPos;
     bool cursorVisible;
     bool cursorVisible;
@@ -1720,8 +1720,8 @@ void UI::HandleMouseMove(StringHash eventType, VariantMap& eventData)
 {
 {
     using namespace MouseMove;
     using namespace MouseMove;
 
 
-    mouseButtons_ = FlagSet<MouseButton>(eventData[P_BUTTONS].GetUInt());
-    qualifiers_ = FlagSet<Qualifier>(eventData[P_QUALIFIERS].GetUInt());
+    mouseButtons_ = MouseButtonFlags(eventData[P_BUTTONS].GetUInt());
+    qualifiers_ = QualifierFlags(eventData[P_QUALIFIERS].GetUInt());
     usingTouchInput_ = false;
     usingTouchInput_ = false;
 
 
     auto* input = GetSubsystem<Input>();
     auto* input = GetSubsystem<Input>();
@@ -1769,8 +1769,8 @@ void UI::HandleMouseWheel(StringHash eventType, VariantMap& eventData)
 
 
     using namespace MouseWheel;
     using namespace MouseWheel;
 
 
-    mouseButtons_ = FlagSet<MouseButton>(eventData[P_BUTTONS].GetInt());
-    qualifiers_ = FlagSet<Qualifier>(eventData[P_QUALIFIERS].GetInt());
+    mouseButtons_ = MouseButtonFlags(eventData[P_BUTTONS].GetInt());
+    qualifiers_ = QualifierFlags(eventData[P_QUALIFIERS].GetInt());
     int delta = eventData[P_WHEEL].GetInt();
     int delta = eventData[P_WHEEL].GetInt();
     usingTouchInput_ = false;
     usingTouchInput_ = false;
 
 
@@ -1881,7 +1881,7 @@ void UI::HandleKeyDown(StringHash eventType, VariantMap& eventData)
 {
 {
     using namespace KeyDown;
     using namespace KeyDown;
 
 
-    mouseButtons_ = FlagSet<MouseButton>(eventData[P_BUTTONS].GetUInt());
+    mouseButtons_ = MouseButtonFlags(eventData[P_BUTTONS].GetUInt());
     qualifiers_ = FlagSet<Qualifier>(eventData[P_QUALIFIERS].GetUInt());
     qualifiers_ = FlagSet<Qualifier>(eventData[P_QUALIFIERS].GetUInt());
     auto key = (Key)eventData[P_KEY].GetUInt();
     auto key = (Key)eventData[P_KEY].GetUInt();
 
 

+ 12 - 12
Source/Urho3D/UI/UI.h

@@ -224,7 +224,7 @@ public:
     struct DragData
     struct DragData
     {
     {
         /// Which button combo initiated the drag.
         /// Which button combo initiated the drag.
-        FlagSet<MouseButton> dragButtons;
+        MouseButtonFlags dragButtons;
         /// How many buttons initiated the drag.
         /// How many buttons initiated the drag.
         int numDragButtons;
         int numDragButtons;
         /// Sum of all touch locations
         /// Sum of all touch locations
@@ -282,25 +282,25 @@ private:
     /// Force release of font faces when global font properties change.
     /// Force release of font faces when global font properties change.
     void ReleaseFontFaces();
     void ReleaseFontFaces();
     /// Handle button or touch hover.
     /// Handle button or touch hover.
-    void ProcessHover(const IntVector2& windowCursorPos, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers, Cursor* cursor);
+    void ProcessHover(const IntVector2& windowCursorPos, MouseButtonFlags buttons, QualifierFlags qualifiers, Cursor* cursor);
     /// Handle button or touch begin.
     /// Handle button or touch begin.
     void
     void
-        ProcessClickBegin(const IntVector2& windowCursorPos, MouseButton button, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers, Cursor* cursor, bool cursorVisible);
+        ProcessClickBegin(const IntVector2& windowCursorPos, MouseButton button, MouseButtonFlags buttons, QualifierFlags qualifiers, Cursor* cursor, bool cursorVisible);
     /// Handle button or touch end.
     /// Handle button or touch end.
-    void ProcessClickEnd(const IntVector2& windowCursorPos, MouseButton button, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers, Cursor* cursor, bool cursorVisible);
+    void ProcessClickEnd(const IntVector2& windowCursorPos, MouseButton button, MouseButtonFlags buttons, QualifierFlags qualifiers, Cursor* cursor, bool cursorVisible);
     /// Handle mouse or touch move.
     /// Handle mouse or touch move.
-    void ProcessMove(const IntVector2& windowCursorPos, const IntVector2& cursorDeltaPos, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers, Cursor* cursor,
+    void ProcessMove(const IntVector2& windowCursorPos, const IntVector2& cursorDeltaPos, MouseButtonFlags buttons, QualifierFlags qualifiers, Cursor* cursor,
         bool cursorVisible);
         bool cursorVisible);
     /// Send a UI element drag or hover begin event.
     /// Send a UI element drag or hover begin event.
     void SendDragOrHoverEvent
     void SendDragOrHoverEvent
         (StringHash eventType, UIElement* element, const IntVector2& screenPos, const IntVector2& deltaPos, UI::DragData* dragData);
         (StringHash eventType, UIElement* element, const IntVector2& screenPos, const IntVector2& deltaPos, UI::DragData* dragData);
     /// Send a UI click event.
     /// Send a UI click event.
     void SendClickEvent
     void SendClickEvent
-        (StringHash eventType, UIElement* beginElement, UIElement* endElement, const IntVector2& pos, MouseButton button, FlagSet<MouseButton> buttons,
-            FlagSet<Qualifier> qualifiers);
+        (StringHash eventType, UIElement* beginElement, UIElement* endElement, const IntVector2& pos, MouseButton button, MouseButtonFlags buttons,
+            QualifierFlags qualifiers);
 
 
     /// Send a UI double click event
     /// Send a UI double click event
-    void SendDoubleClickEvent(UIElement* beginElement, UIElement* endElement, const IntVector2& firstPos, const IntVector2& secondPos, MouseButton button, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers);
+    void SendDoubleClickEvent(UIElement* beginElement, UIElement* endElement, const IntVector2& firstPos, const IntVector2& secondPos, MouseButton button, MouseButtonFlags buttons, QualifierFlags qualifiers);
     
     
     /// Handle screen mode event.
     /// Handle screen mode event.
     void HandleScreenMode(StringHash eventType, VariantMap& eventData);
     void HandleScreenMode(StringHash eventType, VariantMap& eventData);
@@ -376,11 +376,11 @@ private:
     /// Drag begin event distance threshold in pixels.
     /// Drag begin event distance threshold in pixels.
     int dragBeginDistance_;
     int dragBeginDistance_;
     /// Mouse buttons held down.
     /// Mouse buttons held down.
-    FlagSet<MouseButton> mouseButtons_;
+    MouseButtonFlags mouseButtons_;
     /// Last mouse button pressed.
     /// Last mouse button pressed.
-    FlagSet<MouseButton> lastMouseButtons_;
+    MouseButtonFlags lastMouseButtons_;
     /// Qualifier keys held down.
     /// Qualifier keys held down.
-    FlagSet<Qualifier> qualifiers_;
+    QualifierFlags qualifiers_;
     /// Font texture maximum size.
     /// Font texture maximum size.
     int maxFontTextureSize_;
     int maxFontTextureSize_;
     /// Initialized flag.
     /// Initialized flag.
@@ -424,7 +424,7 @@ private:
     /// Number of elements in dragElements_ with dragPending = false.
     /// Number of elements in dragElements_ with dragPending = false.
     int dragConfirmedCount_;
     int dragConfirmedCount_;
     /// UI elements that are being touched with touch input.
     /// UI elements that are being touched with touch input.
-    HashMap<WeakPtr<UIElement>, FlagSet<MouseButton>> touchDragElements_;
+    HashMap<WeakPtr<UIElement>, MouseButtonFlags> touchDragElements_;
     /// Confirmed drag elements cache.
     /// Confirmed drag elements cache.
     Vector<UIElement*> dragElementsConfirmed_;
     Vector<UIElement*> dragElementsConfirmed_;
     /// Current scale of UI.
     /// Current scale of UI.

+ 2 - 2
Source/Urho3D/UI/UIElement.cpp

@@ -145,7 +145,7 @@ void UIElement::RegisterObject(Context* context)
     URHO3D_ACCESSOR_ATTRIBUTE("Clip Children", GetClipChildren, SetClipChildren, bool, false, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Clip Children", GetClipChildren, SetClipChildren, bool, false, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Use Derived Opacity", GetUseDerivedOpacity, SetUseDerivedOpacity, bool, true, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Use Derived Opacity", GetUseDerivedOpacity, SetUseDerivedOpacity, bool, true, AM_FILE);
     URHO3D_ENUM_ACCESSOR_ATTRIBUTE("Focus Mode", GetFocusMode, SetFocusMode, FocusMode, focusModes, FM_NOTFOCUSABLE, AM_FILE);
     URHO3D_ENUM_ACCESSOR_ATTRIBUTE("Focus Mode", GetFocusMode, SetFocusMode, FocusMode, focusModes, FM_NOTFOCUSABLE, AM_FILE);
-    URHO3D_ENUM_ACCESSOR_ATTRIBUTE("Drag And Drop Mode", GetDragDropMode, SetDragDropMode, FlagSet<DragAndDropMode>, dragDropModes, DD_DISABLED, AM_FILE);
+    URHO3D_ENUM_ACCESSOR_ATTRIBUTE("Drag And Drop Mode", GetDragDropMode, SetDragDropMode, DragAndDropModeFlags, dragDropModes, DD_DISABLED, AM_FILE);
     URHO3D_ENUM_ACCESSOR_ATTRIBUTE("Layout Mode", GetLayoutMode, SetLayoutMode, LayoutMode, layoutModes, LM_FREE, AM_FILE);
     URHO3D_ENUM_ACCESSOR_ATTRIBUTE("Layout Mode", GetLayoutMode, SetLayoutMode, LayoutMode, layoutModes, LM_FREE, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Layout Spacing", GetLayoutSpacing, SetLayoutSpacing, int, 0, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Layout Spacing", GetLayoutSpacing, SetLayoutSpacing, int, 0, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Layout Border", GetLayoutBorder, SetLayoutBorder, IntRect, IntRect::ZERO, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Layout Border", GetLayoutBorder, SetLayoutBorder, IntRect, IntRect::ZERO, AM_FILE);
@@ -986,7 +986,7 @@ void UIElement::SetVisible(bool enable)
     }
     }
 }
 }
 
 
-void UIElement::SetDragDropMode(FlagSet<DragAndDropMode> mode)
+void UIElement::SetDragDropMode(DragAndDropModeFlags mode)
 {
 {
     dragDropMode_ = mode;
     dragDropMode_ = mode;
 }
 }

+ 6 - 6
Source/Urho3D/UI/UIElement.h

@@ -110,7 +110,7 @@ enum DragAndDropMode : unsigned
     /// Drag and drop source and target.
     /// Drag and drop source and target.
     DD_SOURCE_AND_TARGET = 0x3,
     DD_SOURCE_AND_TARGET = 0x3,
 };
 };
-template<> struct is_flagset<DragAndDropMode> { constexpr static bool value = true; };
+URHO3D_FLAGSET(DragAndDropMode, DragAndDropModeFlags);
 
 
 class Cursor;
 class Cursor;
 class ResourceCache;
 class ResourceCache;
@@ -180,9 +180,9 @@ public:
     /// React to drag and drop finish. Return true to signal that the drop was accepted.
     /// React to drag and drop finish. Return true to signal that the drop was accepted.
     virtual bool OnDragDropFinish(UIElement* source);
     virtual bool OnDragDropFinish(UIElement* source);
     /// React to mouse wheel.
     /// React to mouse wheel.
-    virtual void OnWheel(int delta, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers) { }
+    virtual void OnWheel(int delta, MouseButtonFlags buttons, QualifierFlags qualifiers) { }
     /// React to a key press.
     /// React to a key press.
-    virtual void OnKey(Key key, FlagSet<MouseButton> buttons, FlagSet<Qualifier> qualifiers) { }
+    virtual void OnKey(Key key, MouseButtonFlags buttons, QualifierFlags qualifiers) { }
     /// React to text input event.
     /// React to text input event.
     virtual void OnTextInput(const String& text) { }
     virtual void OnTextInput(const String& text) { }
 
 
@@ -314,7 +314,7 @@ public:
     /// Set focus mode.
     /// Set focus mode.
     void SetFocusMode(FocusMode mode);
     void SetFocusMode(FocusMode mode);
     /// Set drag and drop flags.
     /// Set drag and drop flags.
-    void SetDragDropMode(FlagSet<DragAndDropMode> mode);
+    void SetDragDropMode(DragAndDropModeFlags mode);
     /// Set style from an XML file. Find the style element by name. If the style file is not explicitly provided, use the default style from parental chain. Return true if the style is applied successfully.
     /// Set style from an XML file. Find the style element by name. If the style file is not explicitly provided, use the default style from parental chain. Return true if the style is applied successfully.
     bool SetStyle(const String& styleName, XMLFile* file = nullptr);
     bool SetStyle(const String& styleName, XMLFile* file = nullptr);
     /// Set style from an XML element. Return true if the style is applied successfully.
     /// Set style from an XML element. Return true if the style is applied successfully.
@@ -536,7 +536,7 @@ public:
     FocusMode GetFocusMode() const { return focusMode_; }
     FocusMode GetFocusMode() const { return focusMode_; }
 
 
     /// Return drag and drop flags.
     /// Return drag and drop flags.
-    FlagSet<DragAndDropMode> GetDragDropMode() const { return dragDropMode_; }
+    DragAndDropModeFlags GetDragDropMode() const { return dragDropMode_; }
 
 
     /// Return applied style name. Return an empty string when the applied style is an 'auto' style (i.e. style derived from instance's type).
     /// Return applied style name. Return an empty string when the applied style is an 'auto' style (i.e. style derived from instance's type).
     const String& GetAppliedStyle() const;
     const String& GetAppliedStyle() const;
@@ -710,7 +710,7 @@ protected:
     /// Focus mode.
     /// Focus mode.
     FocusMode focusMode_{FM_NOTFOCUSABLE};
     FocusMode focusMode_{FM_NOTFOCUSABLE};
     /// Drag and drop flags.
     /// Drag and drop flags.
-    FlagSet<DragAndDropMode> dragDropMode_{DD_DISABLED};
+    DragAndDropModeFlags dragDropMode_{DD_DISABLED};
     /// Layout mode.
     /// Layout mode.
     LayoutMode layoutMode_{LM_FREE};
     LayoutMode layoutMode_{LM_FREE};
     /// Layout spacing.
     /// Layout spacing.