diff --git a/Source/Editor/GUI/Dialogs/ColorPickerDialog.cs b/Source/Editor/GUI/Dialogs/ColorPickerDialog.cs
index 53eabebb4..8df064581 100644
--- a/Source/Editor/GUI/Dialogs/ColorPickerDialog.cs
+++ b/Source/Editor/GUI/Dialogs/ColorPickerDialog.cs
@@ -112,9 +112,6 @@ namespace FlaxEditor.GUI.Dialogs
_onChanged = colorChanged;
_onClosed = pickerClosed;
- // Register the event for eyedropper pixels being read.
- Screenshot.PixelReadDelegate += PixelDataRead;
-
// Selector
_cSelector = new ColorSelectorWithSliders(180, 18)
{
@@ -204,7 +201,7 @@ namespace FlaxEditor.GUI.Dialogs
{
Parent = this,
};
- _cEyedropper.Clicked += OnEyedropColor;
+ _cEyedropper.Clicked += OnEyedropStart;
_cEyedropper.Height = (_cValue.Bottom - _cEyedropper.Y) * 0.5f;
_cEyedropper.Width = _cEyedropper.Height;
_cEyedropper.X -= _cEyedropper.Width;
@@ -214,18 +211,21 @@ namespace FlaxEditor.GUI.Dialogs
SelectedColor = initialValue;
}
- private void PixelDataRead(Color32 pixel_color)
+ private Color32 GetEyedropColor()
{
- Color color = pixel_color;
- Editor.Log(string.Format("Color: {0} {1} {2}", color.R, color.G, color.B));
+ Int2 mousePosition = ScreenUtils.GetScreenCursorPosition();
+ Color32 pixelColor = ScreenUtils.GetPixelAt(mousePosition.X, mousePosition.Y);
+
+ return pixelColor;
}
- private void OnEyedropColor()
+ private void OnEyedropStart()
{
- Float2 mousePosition = FlaxEngine.Input.MouseScreenPosition;
- Screenshot.GetPixelAt(Mathf.FloorToInt(mousePosition.X), Mathf.FloorToInt(mousePosition.Y));
+ Color32 pixelColor = GetEyedropColor();
+ Editor.Log(string.Format("Pixel Color: ({0}, {1}, {2})", pixelColor.R, pixelColor.G, pixelColor.B));
}
+
private void OnRGBAChanged()
{
if (_disableEvents)
@@ -251,6 +251,14 @@ namespace FlaxEditor.GUI.Dialogs
SelectedColor = color;
}
+
+ ///
+ public override void Update(float deltaTime)
+ {
+ base.Update(deltaTime);
+
+ }
+
///
public override void Draw()
{
diff --git a/Source/Engine/Platform/Base/ScreenUtilsBase.cpp b/Source/Engine/Platform/Base/ScreenUtilsBase.cpp
index e69de29bb..081c65bf4 100644
--- a/Source/Engine/Platform/Base/ScreenUtilsBase.cpp
+++ b/Source/Engine/Platform/Base/ScreenUtilsBase.cpp
@@ -0,0 +1,11 @@
+#include "ScreenUtilsBase.h"
+#include "Engine/Core/Math/Color32.h"
+#include "Engine/Core/Math/Vector2.h"
+
+Color32 ScreenUtilsBase::GetPixelAt(int32 x, int32 y) {
+ return Color32::Black;
+}
+
+Int2 ScreenUtilsBase::GetScreenCursorPosition() {
+ return { 0, 0 };
+}
diff --git a/Source/Engine/Platform/Base/ScreenUtilsBase.h b/Source/Engine/Platform/Base/ScreenUtilsBase.h
index e69de29bb..ddfa4f329 100644
--- a/Source/Engine/Platform/Base/ScreenUtilsBase.h
+++ b/Source/Engine/Platform/Base/ScreenUtilsBase.h
@@ -0,0 +1,29 @@
+#pragma once
+
+#include "Engine/Core/Types/BaseTypes.h"
+
+API_INJECT_CODE(cpp, "#include \"Engine/Platform/ScreenUtils.h\"");
+
+///
+/// Platform-dependent screen utilties.
+///
+API_CLASS(Static, Name = "ScreenUtils", Tag = "NativeInvokeUseName")
+class FLAXENGINE_API ScreenUtilsBase
+{
+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();
+};
diff --git a/Source/Engine/Platform/ScreenUtils.h b/Source/Engine/Platform/ScreenUtils.h
index 91192dd41..3033d2118 100644
--- a/Source/Engine/Platform/ScreenUtils.h
+++ b/Source/Engine/Platform/ScreenUtils.h
@@ -9,9 +9,3 @@
#endif
#include "Types.h"
-#include "Engine/Scripting/ScriptingType.h"
-
-API_CLASS(Static) class FLAXENGINE_API ScreenUtils
-{
- DECLARE_SCRIPTING_TYPE_NO_SPAWN(ScreenUtils);
-};
diff --git a/Source/Engine/Platform/Windows/WindowsScreenUtils.cpp b/Source/Engine/Platform/Windows/WindowsScreenUtils.cpp
index 8f9798184..a4c4127bd 100644
--- a/Source/Engine/Platform/Windows/WindowsScreenUtils.cpp
+++ b/Source/Engine/Platform/Windows/WindowsScreenUtils.cpp
@@ -4,7 +4,11 @@
#include
-Color32 PlatformScreenUtils::GetPixelAt(int32 x, int32 y) {
+#if PLATFORM_WINDOWS
+#pragma comment(lib, "Gdi32.lib")
+#endif
+
+Color32 ScreenUtils::GetPixelAt(int32 x, int32 y) {
HDC deviceContext = GetDC(NULL);
COLORREF color = GetPixel(deviceContext, x, y);
ReleaseDC(NULL, deviceContext);
@@ -13,7 +17,7 @@ Color32 PlatformScreenUtils::GetPixelAt(int32 x, int32 y) {
return returnColor;
}
-Int2 PlatformScreenUtils::GetScreenCursorPosition() {
+Int2 ScreenUtils::GetScreenCursorPosition() {
POINT cursorPos;
GetCursorPos(&cursorPos);
diff --git a/Source/Engine/Platform/Windows/WindowsScreenUtils.h b/Source/Engine/Platform/Windows/WindowsScreenUtils.h
index 690be0b88..8f03e033f 100644
--- a/Source/Engine/Platform/Windows/WindowsScreenUtils.h
+++ b/Source/Engine/Platform/Windows/WindowsScreenUtils.h
@@ -1,9 +1,16 @@
#pragma once
-#include "Engine/Core/Math/Color32.h"
-class PlatformScreenUtils {
+#if PLATFORM_WINDOWS
+
+#include "Engine/Core/Math/Color32.h"
+#include "Engine/Platform/Base/ScreenUtilsBase.h"
+
+class FLAXENGINE_API ScreenUtils : public ScreenUtilsBase {
public:
+
+ // [ScreenUtilsBase]
static Color32 GetPixelAt(int32 x, int32 y);
static Int2 GetScreenCursorPosition();
};
+#endif