diff --git a/Source/Editor/GUI/Dialogs/ColorPickerDialog.cs b/Source/Editor/GUI/Dialogs/ColorPickerDialog.cs index 0c81ecc51..161b3f4ae 100644 --- a/Source/Editor/GUI/Dialogs/ColorPickerDialog.cs +++ b/Source/Editor/GUI/Dialogs/ColorPickerDialog.cs @@ -1,10 +1,8 @@ // Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. using FlaxEditor.GUI.Input; -using FlaxEditor.Windows; using FlaxEngine; using FlaxEngine.GUI; -using System; namespace FlaxEditor.GUI.Dialogs { @@ -52,7 +50,7 @@ namespace FlaxEditor.GUI.Dialogs private TextBox _cHex; private Button _cCancel; private Button _cOK; - private IconButton _cEyedropper; + private Button _cEyedropper; /// /// Gets the selected color. @@ -109,7 +107,6 @@ namespace FlaxEditor.GUI.Dialogs { _initialValue = initialValue; _useDynamicEditing = useDynamicEditing; - _activeEyedropper = false; _value = Color.Transparent; _onChanged = colorChanged; _onClosed = pickerClosed; @@ -199,46 +196,41 @@ namespace FlaxEditor.GUI.Dialogs _cOK.Clicked += OnSubmit; // Eyedropper button - _cEyedropper = new IconButton(_cOK.X - EyedropperMargin, _cHex.Bottom + PickerMargin, Editor.Instance.Icons.Add64, hideBorder: false) + var style = Style.Current; + _cEyedropper = new Button(_cOK.X - EyedropperMargin, _cHex.Bottom + PickerMargin) { + TooltipText = "Eyedropper tool to pick a color directly from the screen", + BackgroundBrush = new SpriteBrush(Editor.Instance.Icons.Search32), + BackgroundColor = style.Foreground, + BackgroundColorHighlighted = style.Foreground.RGBMultiplied(0.9f), + BorderColor = Color.Transparent, + BorderColorHighlighted = style.BorderSelected, Parent = this, }; _cEyedropper.Clicked += OnEyedropStart; _cEyedropper.Height = (_cValue.Bottom - _cEyedropper.Y) * 0.5f; _cEyedropper.Width = _cEyedropper.Height; _cEyedropper.X -= _cEyedropper.Width; - //_cEyedropper.SetColors(_cEyedropper.BackgroundColor); // Set initial color SelectedColor = initialValue; } - private Color32 GetEyedropColor() + private void OnColorPicked(Color32 colorPicked) { - Int2 mousePosition = ScreenUtilities.GetScreenCursorPosition(); - Color32 pixelColor = ScreenUtilities.GetPixelAt(mousePosition.X, mousePosition.Y); - - return pixelColor; - } - - private void ColorPicked(Color32 colorPicked) - { - _activeEyedropper = false; - SelectedColor = colorPicked; - ScreenUtilities.PickColorDone -= ColorPicked; + if (_activeEyedropper) + { + _activeEyedropper = false; + SelectedColor = colorPicked; + ScreenUtilities.PickColorDone -= OnColorPicked; + } } private void OnEyedropStart() { _activeEyedropper = true; ScreenUtilities.PickColor(); - ScreenUtilities.PickColorDone += ColorPicked; - } - - private void UpdateEyedrop() - { - Color32 pixelColor = GetEyedropColor(); - SelectedColor = pixelColor; + ScreenUtilities.PickColorDone += OnColorPicked; } private void OnRGBAChanged() @@ -266,15 +258,16 @@ namespace FlaxEditor.GUI.Dialogs SelectedColor = color; } - /// public override void Update(float deltaTime) { base.Update(deltaTime); + // Update eye dropper tool if (_activeEyedropper) { - UpdateEyedrop(); + Float2 mousePosition = Platform.MousePosition; + SelectedColor = ScreenUtilities.GetColorAt(mousePosition); } } @@ -331,6 +324,20 @@ namespace FlaxEditor.GUI.Dialogs base.OnShow(); } + /// + public override bool OnKeyDown(KeyboardKeys key) + { + if (_activeEyedropper && key == KeyboardKeys.Escape) + { + // Cancel eye dropping + _activeEyedropper = false; + ScreenUtilities.PickColorDone -= OnColorPicked; + return true; + } + + return base.OnKeyDown(key); + } + /// public override void OnSubmit() { diff --git a/Source/Editor/GUI/Input/ColorValueBox.cs b/Source/Editor/GUI/Input/ColorValueBox.cs index bafa27c87..167cc65bb 100644 --- a/Source/Editor/GUI/Input/ColorValueBox.cs +++ b/Source/Editor/GUI/Input/ColorValueBox.cs @@ -57,6 +57,11 @@ namespace FlaxEditor.GUI.Input /// protected Color _value; + /// + /// Enables live preview of the selected value from the picker. Otherwise will update the value only when user confirms it on dialog closing. + /// + public bool UseDynamicEditing = true; + /// /// Occurs when value gets changed. /// @@ -143,7 +148,7 @@ namespace FlaxEditor.GUI.Input base.OnSubmit(); // Show color picker dialog - _currentDialog = ShowPickColorDialog?.Invoke(this, _value, OnColorChanged, OnPickerClosed); + _currentDialog = ShowPickColorDialog?.Invoke(this, _value, OnColorChanged, OnPickerClosed, UseDynamicEditing); } private void OnColorChanged(Color color, bool sliding) diff --git a/Source/Editor/Surface/Elements/ColorValue.cs b/Source/Editor/Surface/Elements/ColorValue.cs index 96069cfeb..19934581d 100644 --- a/Source/Editor/Surface/Elements/ColorValue.cs +++ b/Source/Editor/Surface/Elements/ColorValue.cs @@ -30,7 +30,7 @@ namespace FlaxEditor.Surface.Elements { ParentNode = parentNode; Archetype = archetype; - + UseDynamicEditing = false; ParentNode.ValuesChanged += OnNodeValuesChanged; } diff --git a/Source/Editor/Utilities/ScreenUtilities.cpp b/Source/Editor/Utilities/ScreenUtilities.cpp new file mode 100644 index 000000000..cff41f7bf --- /dev/null +++ b/Source/Editor/Utilities/ScreenUtilities.cpp @@ -0,0 +1,130 @@ +// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. + +#include "ScreenUtilities.h" +#include "Engine/Core/Math/Vector2.h" +#include "Engine/Core/Delegate.h" +#include "Engine/Core/Log.h" +#include "Engine/Profiler/ProfilerCPU.h" + +Delegate ScreenUtilities::PickColorDone; + +#if PLATFORM_WINDOWS + +#include + +#pragma comment(lib, "Gdi32.lib") + +static HHOOK MouseCallbackHook; + +LRESULT CALLBACK OnScreenUtilsMouseCallback(_In_ int nCode, _In_ WPARAM wParam, _In_ LPARAM lParam) +{ + if (nCode >= 0 && wParam == WM_LBUTTONDOWN) + { + UnhookWindowsHookEx(MouseCallbackHook); + + // Push event with the picked color + const Float2 cursorPos = Platform::GetMousePosition(); + const Color32 colorPicked = ScreenUtilities::GetColorAt(cursorPos); + ScreenUtilities::PickColorDone(colorPicked); + return 1; + } + return CallNextHookEx(NULL, nCode, wParam, lParam); +} + +Color32 ScreenUtilities::GetColorAt(const Float2& pos) +{ + PROFILE_CPU(); + HDC deviceContext = GetDC(NULL); + COLORREF color = GetPixel(deviceContext, (int)pos.X, (int)pos.Y); + ReleaseDC(NULL, deviceContext); + return Color32(GetRValue(color), GetGValue(color), GetBValue(color), 255); +} + +void ScreenUtilities::PickColor() +{ + MouseCallbackHook = SetWindowsHookEx(WH_MOUSE_LL, OnScreenUtilsMouseCallback, NULL, NULL); + if (MouseCallbackHook == NULL) + { + LOG(Warning, "Failed to set mouse hook."); + LOG(Warning, "Error: {0}", GetLastError()); + } +} + +#elif PLATFORM_LINUX + +#include "Engine/Platform/Linux/LinuxPlatform.h" +#include "Engine/Platform/Linux/IncludeX11.h" + +Color32 ScreenUtilities::GetColorAt(const Float2& pos) +{ + X11::XColor color; + + X11::Display* display = (X11::Display*) LinuxPlatform::GetXDisplay(); + int defaultScreen = X11::XDefaultScreen(display); + + X11::XImage* image; + image = X11::XGetImage(display, X11::XRootWindow(display, defaultScreen), x, y, 1, 1, AllPlanes, XYPixmap); + color.pixel = XGetPixel(image, 0, 0); + X11::XFree(image); + + X11::XQueryColor(display, X11::XDefaultColormap(display, defaultScreen), &color); + + Color32 outputColor; + outputColor.R = color.red / 256; + outputColor.G = color.green / 256; + outputColor.B = color.blue / 256; + return outputColor; +} + +void OnScreenUtilsXEventCallback(void* eventPtr) +{ + X11::XEvent* event = (X11::XEvent*) eventPtr; + X11::Display* display = (X11::Display*)LinuxPlatform::GetXDisplay(); + if (event->type == ButtonPress) + { + const Float2 cursorPos = Platform::GetMousePosition(); + const Color32 colorPicked = ScreenUtilities::GetColorAt(cursorPos); + X11::XUngrabPointer(display, CurrentTime); + ScreenUtilities::PickColorDone(colorPicked); + LinuxPlatform::xEventRecieved.Unbind(OnScreenUtilsXEventCallback); + } +} + +void ScreenUtilities::PickColor() +{ + PROFILE_CPU(); + X11::Display* display = (X11::Display*) LinuxPlatform::GetXDisplay(); + X11::Window rootWindow = X11::XRootWindow(display, X11::XDefaultScreen(display)); + + X11::Cursor cursor = XCreateFontCursor(display, 130); + int grabbedPointer = X11::XGrabPointer(display, rootWindow, 0, ButtonPressMask, GrabModeAsync, GrabModeAsync, rootWindow, cursor, CurrentTime); + if (grabbedPointer != GrabSuccess) + { + LOG(Error, "Failed to grab cursor for events."); + X11::XFreeCursor(display, cursor); + return; + } + + X11::XFreeCursor(display, cursor); + LinuxPlatform::xEventRecieved.Bind(OnScreenUtilsXEventCallback); +} + +#elif PLATFORM_MAC + +#include +#include + +Color32 ScreenUtilities::GetColorAt(const Float2& pos) +{ + // TODO: implement ScreenUtilities for macOS + return { 0, 0, 0, 255 }; +} + +void ScreenUtilities::PickColor() +{ + // This is what C# calls to start the color picking sequence + // This should stop mouse clicks from working for one click, and that click is on the selected color + // There is a class called NSColorSample that might implement that for you, but maybe not. +} + +#endif diff --git a/Source/Editor/Utilities/ScreenUtilities.h b/Source/Editor/Utilities/ScreenUtilities.h new file mode 100644 index 000000000..506dc8634 --- /dev/null +++ b/Source/Editor/Utilities/ScreenUtilities.h @@ -0,0 +1,33 @@ +// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. + +#pragma once + +#include "Engine/Core/Types/BaseTypes.h" +#include "Engine/Core/Math/Color32.h" +#include "Engine/Core/Math/Vector2.h" +#include "Engine/Core/Delegate.h" + +/// +/// Platform-dependent screen utilities. +/// +API_CLASS(Static) class FLAXENGINE_API ScreenUtilities +{ + DECLARE_SCRIPTING_TYPE_MINIMAL(ScreenUtilities); + + /// + /// Gets the pixel color at the specified coordinates. + /// + /// Screen-space coordinate to read. + /// Pixel color at the specified coordinates. + API_FUNCTION() static Color32 GetColorAt(const Float2& pos); + + /// + /// Starts async color picking. Color will be returned through PickColorDone event when the actions ends (user selected the final color with a mouse). When action is active, GetColorAt can be used to read the current value. + /// + API_FUNCTION() static void PickColor(); + + /// + /// Called when PickColor action is finished. + /// + API_EVENT() static Delegate PickColorDone; +}; diff --git a/Source/Editor/Utilities/ScreenUtilities/ScreenUtilities.h b/Source/Editor/Utilities/ScreenUtilities/ScreenUtilities.h deleted file mode 100644 index 01380e25b..000000000 --- a/Source/Editor/Utilities/ScreenUtilities/ScreenUtilities.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include "Engine/Core/Types/BaseTypes.h" -#include "Engine/Core/Delegate.h" - -API_INJECT_CODE(cpp, "#include \"Editor/Utilities/ScreenUtilities/ScreenUtilities.h\""); - -/// -/// Platform-dependent screen utilties. -/// -API_CLASS(Static, Name = "ScreenUtilities", Tag = "NativeInvokeUseName") -class FLAXENGINE_API ScreenUtilities -{ -public: - static struct FLAXENGINE_API ScriptingTypeInitializer TypeInitializer; - - /// - /// Gets the pixel color at the specified coordinates. - /// - /// X Coordinate to read. - /// Y Coordinate to read. - /// Pixel color at the specified coordinates. - API_FUNCTION() static Color32 GetPixelAt(int32 x, int32 y); - - /// - /// Gets the cursor position, in screen cooridnates. - /// - /// Cursor position, in screen coordinates. - API_FUNCTION() static Int2 GetScreenCursorPosition(); - - /// - /// Starts async color picking. Will return a color through ColorReturnCallback. - /// - /// Called when PickColor() is finished. - /// - API_EVENT() static Delegate PickColorDone; -}; diff --git a/Source/Editor/Utilities/ScreenUtilities/ScreenUtilitiesLinux.cpp b/Source/Editor/Utilities/ScreenUtilities/ScreenUtilitiesLinux.cpp deleted file mode 100644 index 6dc2103d9..000000000 --- a/Source/Editor/Utilities/ScreenUtilities/ScreenUtilitiesLinux.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#if PLATFORM_LINUX - -#include "ScreenUtilities.h" -#include "Engine/Core/Math/Color32.h" -#include "Engine/Core/Math/Vector2.h" -#include "Engine/Core/Delegate.h" -#include "Engine/Core/Log.h" -#include "Engine/Platform/Linux/LinuxPlatform.h" - -#include "Engine/Platform/Linux/IncludeX11.h" - -Color32 ScreenUtilities::GetPixelAt(int32 x, int32 y) -{ - X11::XColor color; - Color32 outputColor; - - X11::Display* display = (X11::Display*) LinuxPlatform::GetXDisplay(); - int defaultScreen = X11::XDefaultScreen(display); - - X11::XImage* image; - image = X11::XGetImage(display, X11::XRootWindow(display, defaultScreen), x, y, 1, 1, AllPlanes, XYPixmap); - color.pixel = XGetPixel(image, 0, 0); - X11::XFree(image); - - X11::XQueryColor(display, X11::XDefaultColormap(display, defaultScreen), &color); - outputColor.R = color.red / 256; - outputColor.G = color.green / 256; - outputColor.B = color.blue / 256; - - return outputColor; -} - -Int2 ScreenUtilities::GetScreenCursorPosition() -{ - Int2 cursorPosition = { 0, 0 }; - X11::Display* display = (X11::Display*) LinuxPlatform::GetXDisplay(); - X11::Window rootWindow = X11::XRootWindow(display, X11::XDefaultScreen(display)); - - // Buffers (Some useful, some not.) - X11::Window rootWindowBuffer; - int rootX, rootY; - int winXBuffer, winYBuffer; - unsigned int maskBuffer; - - int gotPointer = X11::XQueryPointer(display, rootWindow, &rootWindowBuffer, &rootWindowBuffer, &rootX, &rootY, &winXBuffer, &winYBuffer, &maskBuffer); - if (!gotPointer) { - LOG(Error, "Failed to find the mouse pointer (Are you using multiple displays?)"); - return cursorPosition; - } - - cursorPosition.X = rootX; - cursorPosition.Y = rootY; - - return cursorPosition; -} - -class ScreenUtilitiesLinux -{ -public: - static void BlockAndReadMouse(); - static void xEventHandler(void* event); -}; - -void ScreenUtilitiesLinux::xEventHandler(void* eventPtr) { - X11::XEvent* event = (X11::XEvent*) eventPtr; - - X11::Display* display = (X11::Display*) LinuxPlatform::GetXDisplay(); - - if (event->type == ButtonPress) { - Int2 cursorPosition = ScreenUtilities::GetScreenCursorPosition(); - Color32 colorPicked = ScreenUtilities::GetPixelAt(cursorPosition.X, cursorPosition.Y); - - ScreenUtilities::PickColorDone(colorPicked); // Run the callback for picking colors being complete. - LinuxPlatform::xEventRecieved.Unbind(xEventHandler); // Unbind the event, we only want to handle one click event - X11::XUngrabPointer(display, CurrentTime); - } -} - -void ScreenUtilitiesLinux::BlockAndReadMouse() -{ - X11::Display* display = (X11::Display*) LinuxPlatform::GetXDisplay(); - X11::Window rootWindow = X11::XRootWindow(display, X11::XDefaultScreen(display)); - - X11::Cursor cursor = XCreateFontCursor(display, 130); - int grabbedPointer = X11::XGrabPointer(display, rootWindow, 0, ButtonPressMask, GrabModeAsync, GrabModeAsync, rootWindow, cursor, CurrentTime); - if (grabbedPointer != GrabSuccess) { - LOG(Error, "Failed to grab cursor for events."); - - X11::XFreeCursor(display, cursor); - return; - } - - X11::XFreeCursor(display, cursor); - LinuxPlatform::xEventRecieved.Bind(xEventHandler); -} - -Delegate ScreenUtilities::PickColorDone; - -void ScreenUtilities::PickColor() -{ - ScreenUtilitiesLinux::BlockAndReadMouse(); -} - -#endif \ No newline at end of file diff --git a/Source/Editor/Utilities/ScreenUtilities/ScreenUtilitiesMac.cpp b/Source/Editor/Utilities/ScreenUtilities/ScreenUtilitiesMac.cpp deleted file mode 100644 index f774242ce..000000000 --- a/Source/Editor/Utilities/ScreenUtilities/ScreenUtilitiesMac.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#if PLATFORM_MAC -#include -#include - -#include "ScreenUtilities.h" -#include "Engine/Core/Math/Color32.h" -#include "Engine/Core/Math/Vector2.h" -#include "Engine/Core/Delegate.h" -#include "Engine/Core/Log.h" - -Color32 ScreenUtilities::GetPixelAt(int32 x, int32 y) -{ - // Called from C# for live updates to the color. - - return { 0, 0, 0, 255 }; -} - -Int2 ScreenUtilities::GetScreenCursorPosition() -{ - // Called from C# for live updates to the color. - - return { 0, 0 }; -} - -class ScreenUtilitiesMac -{ -public: - static void BlockAndReadMouse(); -}; - -void ScreenUtilitiesMac::BlockAndReadMouse() -{ - // Maybe you don't need this if you go with NSColorSampler -} - -Delegate ScreenUtilities::PickColorDone; - -void ScreenUtilities::PickColor() -{ - // This is what C# calls to start the color picking sequence - // This should stop mouse clicks from working for one click, and that click is on the selected color - // There is a class called NSColorSample that might implement that for you, but maybe not. - // It also might just work to copy the Linux Impl since Mac uses X as well, right? -} - -#endif diff --git a/Source/Editor/Utilities/ScreenUtilities/ScreenUtilitiesWindows.cpp b/Source/Editor/Utilities/ScreenUtilities/ScreenUtilitiesWindows.cpp deleted file mode 100644 index 5af695c4d..000000000 --- a/Source/Editor/Utilities/ScreenUtilities/ScreenUtilitiesWindows.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#if PLATFORM_WINDOWS - -#include "ScreenUtilities.h" -#include "Engine/Core/Math/Color32.h" -#include "Engine/Core/Math/Vector2.h" -#include "Engine/Core/Delegate.h" -#include "Engine/Core/Log.h" -#include "Engine/Scripting/ManagedCLR/MCore.h" - -#include - - -#pragma comment(lib, "Gdi32.lib") - - -Color32 ScreenUtilities::GetPixelAt(int32 x, int32 y) -{ - HDC deviceContext = GetDC(NULL); - COLORREF color = GetPixel(deviceContext, x, y); - ReleaseDC(NULL, deviceContext); - - Color32 returnColor = { GetRValue(color), GetGValue(color), GetBValue(color), 255 }; - return returnColor; -} - -Int2 ScreenUtilities::GetScreenCursorPosition() -{ - POINT cursorPos; - GetCursorPos(&cursorPos); - - Int2 returnCursorPos = { cursorPos.x, cursorPos.y }; - return returnCursorPos; -} - -class ScreenUtilitiesWindows -{ -public: - static void PickSelected(); - static void BlockAndReadMouse(); -}; - -void ScreenUtilitiesWindows::PickSelected() { - Int2 cursorPos = ScreenUtilities::GetScreenCursorPosition(); - Color32 colorPicked = ScreenUtilities::GetPixelAt(cursorPos.X, cursorPos.Y); - - // Push event with the picked color. - ScreenUtilities::PickColorDone(colorPicked); -} - -static HHOOK _mouseCallbackHook; -LRESULT CALLBACK ScreenUtilsMouseCallback( - _In_ int nCode, - _In_ WPARAM wParam, - _In_ LPARAM lParam -) -{ - if (wParam != WM_LBUTTONDOWN) { // Return as early as possible. - return CallNextHookEx(NULL, nCode, wParam, lParam); - } - - if (nCode < 0) { - return CallNextHookEx(NULL, nCode, wParam, lParam); - } - - - if (nCode >= 0 && wParam == WM_LBUTTONDOWN) { // Now try to run our code. - UnhookWindowsHookEx(_mouseCallbackHook); - - ScreenUtilitiesWindows::PickSelected(); - return 1; - } - - return CallNextHookEx(NULL, nCode, wParam, lParam); -} - -void ScreenUtilitiesWindows::BlockAndReadMouse() -{ - _mouseCallbackHook = SetWindowsHookEx(WH_MOUSE_LL, ScreenUtilsMouseCallback, NULL, NULL); - if (_mouseCallbackHook == NULL) - { - LOG(Warning, "Failed to set mouse hook."); - LOG(Warning, "Error: {0}", GetLastError()); - } -} - -Delegate ScreenUtilities::PickColorDone; - -void ScreenUtilities::PickColor() -{ - ScreenUtilitiesWindows::BlockAndReadMouse(); -} - - -#endif diff --git a/Source/Editor/Utilities/Utils.cs b/Source/Editor/Utilities/Utils.cs index acc0cf605..5f836e069 100644 --- a/Source/Editor/Utilities/Utils.cs +++ b/Source/Editor/Utilities/Utils.cs @@ -1037,9 +1037,7 @@ namespace FlaxEditor.Utilities /// The processed name path. public static string GetAssetNamePath(string path) { - var projectFolder = Globals.ProjectFolder; - if (path.StartsWith(projectFolder)) - path = path.Substring(projectFolder.Length + 1); + path = GetAssetNamePathWithExt(path); return StringUtils.GetPathWithoutExtension(path); } diff --git a/Source/Engine/Platform/Linux/LinuxPlatform.cpp b/Source/Engine/Platform/Linux/LinuxPlatform.cpp index e954dd784..92a26032d 100644 --- a/Source/Engine/Platform/Linux/LinuxPlatform.cpp +++ b/Source/Engine/Platform/Linux/LinuxPlatform.cpp @@ -5,7 +5,6 @@ #include "LinuxPlatform.h" #include "LinuxWindow.h" #include "LinuxInput.h" -#include "IncludeX11.h" #include "Engine/Core/Log.h" #include "Engine/Core/Types/Guid.h" #include "Engine/Core/Types/String.h" @@ -31,6 +30,7 @@ #include "Engine/Input/Input.h" #include "Engine/Input/Mouse.h" #include "Engine/Input/Keyboard.h" +#include "IncludeX11.h" #include #include #include @@ -88,6 +88,7 @@ X11::Cursor Cursors[(int32)CursorType::MAX]; X11::XcursorImage* CursorsImg[(int32)CursorType::MAX]; Dictionary KeyNameMap; Array KeyCodeMap; +Delegate LinuxPlatform::xEventRecieved; // Message boxes configuration #define LINUX_DIALOG_MIN_BUTTON_WIDTH 64 @@ -2217,8 +2218,6 @@ void LinuxPlatform::BeforeRun() { } -Delegate LinuxPlatform::xEventRecieved; - void LinuxPlatform::Tick() { UnixPlatform::Tick(); @@ -2233,12 +2232,12 @@ void LinuxPlatform::Tick() { X11::XEvent event; X11::XNextEvent(xDisplay, &event); - if (X11::XFilterEvent(&event, 0)) continue; - - xEventRecieved(&event); // Fire this event, since we recieved an event. - + + // External event handling + xEventRecieved(&event); + LinuxWindow* window; switch (event.type) { diff --git a/Source/Engine/Platform/Linux/LinuxPlatform.h b/Source/Engine/Platform/Linux/LinuxPlatform.h index 486674652..e995ab42d 100644 --- a/Source/Engine/Platform/Linux/LinuxPlatform.h +++ b/Source/Engine/Platform/Linux/LinuxPlatform.h @@ -34,7 +34,7 @@ public: static const String& GetHomeDirectory(); /// - /// An event that is fired when an XEvent is recieved by Flax. + /// An event that is fired when an XEvent is received during platform tick. /// static Delegate xEventRecieved; diff --git a/Source/Engine/UI/GUI/Common/IconButton.cs b/Source/Engine/UI/GUI/Common/IconButton.cs deleted file mode 100644 index e2652cd9f..000000000 --- a/Source/Engine/UI/GUI/Common/IconButton.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. - -using System; - -namespace FlaxEngine.GUI -{ - /// - /// Button with an icon. - /// - public class IconButton : Button - { - /// - /// The sprite rendered on the button. - /// - public SpriteHandle ButtonSprite { get; set; } - - /// - /// Whether or not to hide the border of the button. - /// - public bool HideBorder = true; - - /// - /// Initializes a new instance of the class. - /// - /// The sprite used by the button. - public IconButton(SpriteHandle buttonSprite) - : this(0, 0, buttonSprite) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Position X coordinate - /// Position Y coordinate - /// The sprite used by the button. - /// Width - /// Height - /// Whether or not to hide the border. - public IconButton(float x, float y, SpriteHandle buttonSprite, float width = 120, float height = DefaultHeight, bool hideBorder = true) - : base(x, y, width, height) - { - ButtonSprite = buttonSprite; - BackgroundBrush = new SpriteBrush(ButtonSprite); - HideBorder = hideBorder; - } - - /// - /// Initializes a new instance of the class. - /// - /// Position - /// Size - /// The sprite used by the button. - public IconButton(Float2 location, Float2 size, SpriteHandle buttonSprite) - : this(location.X, location.Y, buttonSprite, size.X, size.Y) - { - } - - /// - /// Sets the colors of the button, taking into account the field.> - /// - /// The color to use. - public override void SetColors(Color color) - { - BackgroundColor = color; - BackgroundColorSelected = color.RGBMultiplied(0.8f); - BackgroundColorHighlighted = color.RGBMultiplied(1.2f); - - BorderColor = HideBorder ? Color.Transparent : color.RGBMultiplied(0.5f); - BorderColorSelected = BorderColor; - BorderColorHighlighted = BorderColor; - } - } -} diff --git a/Source/Engine/Utilities/Screenshot.cpp b/Source/Engine/Utilities/Screenshot.cpp index fbde8043b..7e1d3d902 100644 --- a/Source/Engine/Utilities/Screenshot.cpp +++ b/Source/Engine/Utilities/Screenshot.cpp @@ -3,7 +3,6 @@ #include "Screenshot.h" #include "Engine/Core/Log.h" #include "Engine/Core/Math/Math.h" -#include "Engine/Core/Math/Color32.h" #include "Engine/Graphics/RenderTask.h" #include "Engine/Platform/FileSystem.h" #include "Engine/Graphics/Textures/TextureData.h" @@ -11,7 +10,6 @@ #include "Engine/Graphics/GPUResourceProperty.h" #include "Engine/Graphics/GPUDevice.h" #include "Engine/Graphics/GPUSwapChain.h" -#include "Engine/Engine/Engine.h" #include "Engine/Threading/ThreadPoolTask.h" #include "Engine/Engine/Globals.h" #if COMPILE_WITH_TEXTURE_TOOL