diff --git a/Flax.flaxproj b/Flax.flaxproj index cc643346f..681c1dc55 100644 --- a/Flax.flaxproj +++ b/Flax.flaxproj @@ -3,7 +3,7 @@ "Version": { "Major": 1, "Minor": 1, - "Build": 6217 + "Build": 6218 }, "Company": "Flax", "Copyright": "Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.", diff --git a/Source/Engine/Core/Collections/Array.h b/Source/Engine/Core/Collections/Array.h index 6a841bac5..3819323a9 100644 --- a/Source/Engine/Core/Collections/Array.h +++ b/Source/Engine/Core/Collections/Array.h @@ -2,6 +2,7 @@ #pragma once +#include #include "Engine/Platform/Platform.h" #include "Engine/Core/Memory/Memory.h" #include "Engine/Core/Memory/Allocation.h" @@ -47,6 +48,20 @@ public: _allocation.Allocate(capacity); } + /// + /// Initializes a new instance of the class. + /// + /// The initial values defined in the array. + Array(std::initializer_list initList) + { + _count = _capacity = (int32)initList.size(); + if (_count > 0) + { + _allocation.Allocate(_count); + Memory::ConstructItems(Get(), initList.begin(), _count); + } + } + /// /// Initializes a new instance of the class. /// @@ -123,6 +138,24 @@ public: _allocation.Swap(other._allocation); } + /// + /// The assignment operator that deletes the current collection of items and the copies items from the initializer list. + /// + /// The other collection to copy. + /// The reference to this. + Array& operator=(std::initializer_list initList) noexcept + { + Memory::DestructItems(Get(), _count); + + _count = _capacity = (int32)initList.size(); + if (_capacity > 0) + { + _allocation.Allocate(_capacity); + Memory::ConstructItems(Get(), initList.begin(), _count); + } + return *this; + } + /// /// The assignment operator that deletes the current collection of items and the copies items from the other array. /// diff --git a/Source/Engine/Platform/Linux/LinuxPlatform.cpp b/Source/Engine/Platform/Linux/LinuxPlatform.cpp index 2d55fa296..8c212314c 100644 --- a/Source/Engine/Platform/Linux/LinuxPlatform.cpp +++ b/Source/Engine/Platform/Linux/LinuxPlatform.cpp @@ -1382,6 +1382,7 @@ DragDropEffect LinuxWindow::DoDragDrop(const StringView& data) X11::Window previousWindow = 0; DragDropEffect result = DragDropEffect::None; float lastDraw = Platform::GetTimeSeconds(); + float startTime = lastDraw; while (true) { X11::XNextEvent(xDisplay, &event); @@ -1559,7 +1560,7 @@ DragDropEffect LinuxWindow::DoDragDrop(const StringView& data) if (!(event.xclient.data.l[1]&1) && status != Unaware) status = Unreceptive; } - else if (event.type == ButtonRelease && event.xbutton.button == 1) + else if (event.type == ButtonRelease && event.xbutton.button == Button1) { if (status == CanDrop) { @@ -1597,11 +1598,46 @@ DragDropEffect LinuxWindow::DoDragDrop(const StringView& data) // Redraw const float time = Platform::GetTimeSeconds(); - if (time - lastDraw >= 1.0f / 60.0f) + if (time - lastDraw >= 1.0f / 20.0f) { lastDraw = time; Engine::OnDraw(); } + + // Prevent dead-loop + if (time - startTime >= 10.0f) + { + break; + } + } + + // Drag end + if (previousWindow != 0 && previousVersion != -1) + { + // Send drag left event + auto ww = WindowsManager::GetByNativePtr((void*)previousWindow); + if (ww) + { + ww->_dragOver = false; + ww->OnDragLeave(); + } + else + { + X11::XClientMessageEvent m; + memset(&m, 0, sizeof(m)); + m.type = ClientMessage; + m.display = event.xclient.display; + m.window = previousWindow; + m.message_type = xAtomXdndLeave; + m.format = 32; + m.data.l[0] = _window; + m.data.l[1] = 0; + m.data.l[2] = 0; + m.data.l[3] = 0; + m.data.l[4] = 0; + X11::XSendEvent(xDisplay, previousWindow, 0, NoEventMask, (X11::XEvent*)&m); + X11::XFlush(xDisplay); + } } // End grabbing diff --git a/Source/Engine/UI/GUI/Common/ProgressBar.cs b/Source/Engine/UI/GUI/Common/ProgressBar.cs index 21cce7faa..881bbc161 100644 --- a/Source/Engine/UI/GUI/Common/ProgressBar.cs +++ b/Source/Engine/UI/GUI/Common/ProgressBar.cs @@ -39,9 +39,6 @@ namespace FlaxEngine.GUI /// /// Gets a value indicating whether use progress value smoothing. /// - /// - /// true if use progress value smoothing; otherwise, false. - /// public bool UseSmoothing => !Mathf.IsZero(SmoothingScale); /// @@ -91,8 +88,6 @@ namespace FlaxEngine.GUI if (!Mathf.NearEqual(value, _value)) { _value = value; - - // Check if skip smoothing if (!UseSmoothing) { _current = _value; @@ -138,22 +133,22 @@ namespace FlaxEngine.GUI /// public override void Update(float deltaTime) { - bool isDeltaSlow = deltaTime > (1 / 20.0f); - - // Ensure progress bar is visible if (Visible) { // Value smoothing + var value = _value; if (Mathf.Abs(_current - _value) > 0.01f) { // Lerp or not if running slow - float value; + bool isDeltaSlow = deltaTime > (1 / 20.0f); if (!isDeltaSlow && UseSmoothing) value = Mathf.Lerp(_current, _value, Mathf.Saturate(deltaTime * 5.0f * SmoothingScale)); - else - value = _value; _current = value; } + else + { + _current = _value; + } } base.Update(deltaTime); diff --git a/Source/FlaxEngine.Gen.cs b/Source/FlaxEngine.Gen.cs index 6f8878d25..62d40ad9a 100644 --- a/Source/FlaxEngine.Gen.cs +++ b/Source/FlaxEngine.Gen.cs @@ -13,5 +13,5 @@ using System.Runtime.InteropServices; [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("b8442186-4a70-7c85-704a-857c262d00f6")] -[assembly: AssemblyVersion("1.1.6217")] -[assembly: AssemblyFileVersion("1.1.6217")] +[assembly: AssemblyVersion("1.1.6218")] +[assembly: AssemblyFileVersion("1.1.6218")] diff --git a/Source/FlaxEngine.Gen.h b/Source/FlaxEngine.Gen.h index 7a888ae1f..eff8449cc 100644 --- a/Source/FlaxEngine.Gen.h +++ b/Source/FlaxEngine.Gen.h @@ -3,11 +3,11 @@ #pragma once #define FLAXENGINE_NAME "FlaxEngine" -#define FLAXENGINE_VERSION Version(1, 1, 6217) -#define FLAXENGINE_VERSION_TEXT "1.1.6217" +#define FLAXENGINE_VERSION Version(1, 1, 6218) +#define FLAXENGINE_VERSION_TEXT "1.1.6218" #define FLAXENGINE_VERSION_MAJOR 1 #define FLAXENGINE_VERSION_MINOR 1 -#define FLAXENGINE_VERSION_BUILD 6217 +#define FLAXENGINE_VERSION_BUILD 6218 #define FLAXENGINE_COMPANY "Flax" #define FLAXENGINE_COPYRIGHT "Copyright (c) 2012-2021 Wojciech Figat. All rights reserved." diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs index b98dc1266..1f8ab4249 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs @@ -1349,7 +1349,13 @@ namespace Flax.Build.Bindings if (fieldInfo.Getter != null) GenerateCppWrapperFunction(buildData, contents, classInfo, fieldInfo.Getter, "{0}"); if (fieldInfo.Setter != null) - GenerateCppWrapperFunction(buildData, contents, classInfo, fieldInfo.Setter, "{0} = {1}"); + { + var callFormat = "{0} = {1}"; + var type = fieldInfo.Setter.Parameters[0].Type; + if (type.IsArray) + callFormat = $"auto __tmp = {{1}}; for (int32 i = 0; i < {type.ArraySize}; i++) {{0}}[i] = __tmp[i]"; + GenerateCppWrapperFunction(buildData, contents, classInfo, fieldInfo.Setter, callFormat); + } } // Properties diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.cs index 742aa6f63..f8d26314f 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.cs @@ -623,9 +623,6 @@ namespace Flax.Build.Bindings if (!fieldInfo.IsReadOnly) { - if (fieldInfo.Type.IsArray) - throw new NotImplementedException("Use ReadOnly on field. TODO: add support for setter for fixed-array fields."); - fieldInfo.Setter = new FunctionInfo { Name = "Set" + fieldInfo.Name,