Change WindowBase to allow for better code sharing for platforms without advanced windowing
This commit is contained in:
@@ -6,17 +6,8 @@
|
||||
#include "Engine/Graphics/RenderTask.h"
|
||||
#include <Engine/Main/Android/android_native_app_glue.h>
|
||||
|
||||
#define DefaultDPI 96
|
||||
|
||||
AndroidWindow::AndroidWindow(const CreateWindowSettings& settings)
|
||||
: WindowBase(settings)
|
||||
{
|
||||
_clientSize = settings.Size;
|
||||
_dpi = DefaultDPI;
|
||||
_dpiScale = (float)_dpi / (float)DefaultDPI;
|
||||
}
|
||||
|
||||
AndroidWindow::~AndroidWindow()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -52,27 +43,6 @@ void AndroidWindow::Hide()
|
||||
}
|
||||
}
|
||||
|
||||
void AndroidWindow::Minimize()
|
||||
{
|
||||
}
|
||||
|
||||
void AndroidWindow::Maximize()
|
||||
{
|
||||
}
|
||||
|
||||
void AndroidWindow::Restore()
|
||||
{
|
||||
}
|
||||
|
||||
void AndroidWindow::BringToFront(bool force)
|
||||
{
|
||||
}
|
||||
|
||||
bool AndroidWindow::IsClosed() const
|
||||
{
|
||||
return _isClosing;
|
||||
}
|
||||
|
||||
void AndroidWindow::SetClientBounds(const Rectangle& clientArea)
|
||||
{
|
||||
if (Vector2::NearEqual(_clientSize, clientArea.Size))
|
||||
@@ -84,55 +54,4 @@ void AndroidWindow::SetClientBounds(const Rectangle& clientArea)
|
||||
OnResize(width, height);
|
||||
}
|
||||
|
||||
void AndroidWindow::SetPosition(const Vector2& position)
|
||||
{
|
||||
}
|
||||
|
||||
void AndroidWindow::SetClientPosition(const Vector2& position)
|
||||
{
|
||||
}
|
||||
|
||||
Vector2 AndroidWindow::GetPosition() const
|
||||
{
|
||||
return Vector2::Zero;
|
||||
}
|
||||
|
||||
Vector2 AndroidWindow::GetSize() const
|
||||
{
|
||||
return _clientSize;
|
||||
}
|
||||
|
||||
Vector2 AndroidWindow::GetClientSize() const
|
||||
{
|
||||
return _clientSize;
|
||||
}
|
||||
|
||||
Vector2 AndroidWindow::ScreenToClient(const Vector2& screenPos) const
|
||||
{
|
||||
return screenPos;
|
||||
}
|
||||
|
||||
Vector2 AndroidWindow::ClientToScreen(const Vector2& clientPos) const
|
||||
{
|
||||
return clientPos;
|
||||
}
|
||||
|
||||
void AndroidWindow::SetTitle(const StringView& title)
|
||||
{
|
||||
_title = title;
|
||||
}
|
||||
|
||||
DragDropEffect AndroidWindow::DoDragDrop(const StringView& data)
|
||||
{
|
||||
return DragDropEffect::None;
|
||||
}
|
||||
|
||||
void AndroidWindow::StartTrackingMouse(bool useMouseScreenOffset)
|
||||
{
|
||||
}
|
||||
|
||||
void AndroidWindow::EndTrackingMouse()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,34 +21,13 @@ public:
|
||||
/// <param name="settings">The initial window settings.</param>
|
||||
AndroidWindow(const CreateWindowSettings& settings);
|
||||
|
||||
/// <summary>
|
||||
/// Finalizes an instance of the <see cref="AndroidWindow"/> class.
|
||||
/// </summary>
|
||||
~AndroidWindow();
|
||||
|
||||
public:
|
||||
|
||||
// [Window]
|
||||
void* GetNativePtr() const override;
|
||||
void Show() override;
|
||||
void Hide() override;
|
||||
void Minimize() override;
|
||||
void Maximize() override;
|
||||
void Restore() override;
|
||||
bool IsClosed() const override;
|
||||
void BringToFront(bool force = false) override;
|
||||
void SetClientBounds(const Rectangle& clientArea) override;
|
||||
void SetPosition(const Vector2& position) override;
|
||||
void SetClientPosition(const Vector2& position) override;
|
||||
Vector2 GetPosition() const override;
|
||||
Vector2 GetSize() const override;
|
||||
Vector2 GetClientSize() const override;
|
||||
Vector2 ScreenToClient(const Vector2& screenPos) const override;
|
||||
Vector2 ClientToScreen(const Vector2& clientPos) const override;
|
||||
void SetTitle(const StringView& title) override;
|
||||
DragDropEffect DoDragDrop(const StringView& data) override;
|
||||
void StartTrackingMouse(bool useMouseScreenOffset) override;
|
||||
void EndTrackingMouse() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -81,19 +81,20 @@ WindowBase::WindowBase(const CreateWindowSettings& settings)
|
||||
, _minimized(false)
|
||||
, _maximized(false)
|
||||
, _isClosing(false)
|
||||
, _showAfterFirstPaint(settings.ShowAfterFirstPaint)
|
||||
, _focused(false)
|
||||
, _swapChain(nullptr)
|
||||
, _settings(settings)
|
||||
, _title(settings.Title)
|
||||
, _cursor(CursorType::Default)
|
||||
, _clientSize(settings.Size)
|
||||
, _dpi(96)
|
||||
, _dpiScale(1.0f)
|
||||
, _trackingMouseOffset(Vector2::Zero)
|
||||
, _isUsingMouseOffset(false)
|
||||
, _isTrackingMouse(false)
|
||||
, RenderTask(nullptr)
|
||||
{
|
||||
_showAfterFirstPaint = settings.ShowAfterFirstPaint;
|
||||
_clientSize = Vector2(settings.Size.X, settings.Size.Y);
|
||||
|
||||
// Update window location based on start location
|
||||
if (settings.StartPosition == WindowStartPosition::CenterParent
|
||||
|| settings.StartPosition == WindowStartPosition::CenterScreen)
|
||||
@@ -522,6 +523,8 @@ void WindowBase::Show()
|
||||
|
||||
void WindowBase::Hide()
|
||||
{
|
||||
if (!_visible)
|
||||
return;
|
||||
_visible = false;
|
||||
_showAfterFirstPaint = _settings.ShowAfterFirstPaint;
|
||||
Hidden();
|
||||
|
||||
@@ -435,17 +435,23 @@ public:
|
||||
/// <summary>
|
||||
/// Minimizes the window.
|
||||
/// </summary>
|
||||
API_FUNCTION() virtual void Minimize() = 0;
|
||||
API_FUNCTION() virtual void Minimize()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maximizes the window.
|
||||
/// </summary>
|
||||
API_FUNCTION() virtual void Maximize() = 0;
|
||||
API_FUNCTION() virtual void Maximize()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restores the window state before minimizing or maximizing.
|
||||
/// </summary>
|
||||
API_FUNCTION() virtual void Restore() = 0;
|
||||
API_FUNCTION() virtual void Restore()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the window.
|
||||
@@ -456,8 +462,10 @@ public:
|
||||
/// <summary>
|
||||
/// Checks if window is closed.
|
||||
/// </summary>
|
||||
/// <returns>True if window is closed, otherwise false.</returns>
|
||||
API_PROPERTY() virtual bool IsClosed() const = 0;
|
||||
API_PROPERTY() virtual bool IsClosed() const
|
||||
{
|
||||
return _isClosing;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if window is foreground (the window with which the user is currently working).
|
||||
@@ -470,7 +478,6 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the client bounds of the window (client area not including border).
|
||||
/// </summary>
|
||||
/// <returns>Client bounds.</returns>
|
||||
API_PROPERTY() FORCE_INLINE Rectangle GetClientBounds() const
|
||||
{
|
||||
return Rectangle(GetClientPosition(), GetClientSize());
|
||||
@@ -480,24 +487,29 @@ public:
|
||||
/// Sets the client bounds of the window (client area not including border).
|
||||
/// </summary>
|
||||
/// <param name="clientArea">The client area.</param>
|
||||
API_PROPERTY() virtual void SetClientBounds(const Rectangle& clientArea) = 0;
|
||||
API_PROPERTY() virtual void SetClientBounds(const Rectangle& clientArea)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the window position (in screen coordinates).
|
||||
/// </summary>
|
||||
/// <returns>Window position.</returns>
|
||||
API_PROPERTY() virtual Vector2 GetPosition() const = 0;
|
||||
API_PROPERTY() virtual Vector2 GetPosition() const
|
||||
{
|
||||
return Vector2::Zero;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the window position (in screen coordinates).
|
||||
/// </summary>
|
||||
/// <param name="position">The position.</param>
|
||||
API_PROPERTY() virtual void SetPosition(const Vector2& position) = 0;
|
||||
API_PROPERTY() virtual void SetPosition(const Vector2& position)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the client position of the window (client area not including border).
|
||||
/// </summary>
|
||||
/// <returns>The client area position.</returns>
|
||||
API_PROPERTY() FORCE_INLINE Vector2 GetClientPosition() const
|
||||
{
|
||||
return ClientToScreen(Vector2::Zero);
|
||||
@@ -507,19 +519,25 @@ public:
|
||||
/// Sets the client position of the window (client area not including border)
|
||||
/// </summary>
|
||||
/// <param name="position">The client area position.</param>
|
||||
API_PROPERTY() virtual void SetClientPosition(const Vector2& position) = 0;
|
||||
API_PROPERTY() virtual void SetClientPosition(const Vector2& position)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the window size (including border).
|
||||
/// </summary>
|
||||
/// <returns>The window size</returns>
|
||||
API_PROPERTY() virtual Vector2 GetSize() const = 0;
|
||||
API_PROPERTY() virtual Vector2 GetSize() const
|
||||
{
|
||||
return _clientSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size of the client area of the window (not including border).
|
||||
/// </summary>
|
||||
/// <returns>The window client area size.</returns>
|
||||
API_PROPERTY() virtual Vector2 GetClientSize() const = 0;
|
||||
API_PROPERTY() virtual Vector2 GetClientSize() const
|
||||
{
|
||||
return _clientSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the size of the client area of the window (not including border).
|
||||
@@ -535,14 +553,20 @@ public:
|
||||
/// </summary>
|
||||
/// <param name="screenPos">The screen position.</param>
|
||||
/// <returns>The client space position.</returns>
|
||||
API_FUNCTION() virtual Vector2 ScreenToClient(const Vector2& screenPos) const = 0;
|
||||
API_FUNCTION() virtual Vector2 ScreenToClient(const Vector2& screenPos) const
|
||||
{
|
||||
return screenPos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts window space location into screen space coordinates.
|
||||
/// </summary>
|
||||
/// <param name="clientPos">The client position.</param>
|
||||
/// <returns>The screen space position.</returns>
|
||||
API_FUNCTION() virtual Vector2 ClientToScreen(const Vector2& clientPos) const = 0;
|
||||
API_FUNCTION() virtual Vector2 ClientToScreen(const Vector2& clientPos) const
|
||||
{
|
||||
return clientPos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the window DPI setting.
|
||||
@@ -582,7 +606,6 @@ public:
|
||||
/// <summary>
|
||||
/// Gets window opacity value (valid only for windows created with SupportsTransparency flag). Opacity values are normalized to range [0;1].
|
||||
/// </summary>
|
||||
/// <returns>Window opacity.</returns>
|
||||
API_PROPERTY() virtual float GetOpacity() const
|
||||
{
|
||||
return 1.0f;
|
||||
@@ -599,7 +622,6 @@ public:
|
||||
/// <summary>
|
||||
/// Determines whether this window is focused.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if this window is focused; otherwise, <c>false</c>.</returns>
|
||||
API_PROPERTY() FORCE_INLINE bool IsFocused() const
|
||||
{
|
||||
return _focused;
|
||||
|
||||
Reference in New Issue
Block a user