mirror of
https://github.com/scummvm/scummvm.git
synced 2026-05-21 05:40:43 +00:00
COMMON: Add getSafeOverlayArea as OSystem function
This will let the GUI know where to put its widgets to avoid notches.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "common/system.h"
|
||||
#include "common/noncopyable.h"
|
||||
#include "common/keyboard.h"
|
||||
#include "common/rect.h"
|
||||
#include "common/rotationmode.h"
|
||||
|
||||
#include "graphics/mode.h"
|
||||
@@ -104,6 +105,13 @@ public:
|
||||
virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) = 0;
|
||||
virtual int16 getOverlayHeight() const = 0;
|
||||
virtual int16 getOverlayWidth() const = 0;
|
||||
virtual Common::Rect getSafeOverlayArea(int16 *width, int16 *height) const {
|
||||
int16 w = getOverlayWidth(),
|
||||
h = getOverlayHeight();
|
||||
if (width) *width = w;
|
||||
if (height) *height = h;
|
||||
return Common::Rect(w, h);
|
||||
}
|
||||
virtual float getHiDPIScreenFactor() const { return 1.0f; }
|
||||
|
||||
virtual bool showMouse(bool visible) = 0;
|
||||
|
||||
@@ -253,6 +253,10 @@ int16 ModularGraphicsBackend::getOverlayWidth() const {
|
||||
return _graphicsManager->getOverlayWidth();
|
||||
}
|
||||
|
||||
Common::Rect ModularGraphicsBackend::getSafeOverlayArea(int16 *width, int16 *height) const {
|
||||
return _graphicsManager->getSafeOverlayArea(width, height);
|
||||
}
|
||||
|
||||
float ModularGraphicsBackend::getHiDPIScreenFactor() const {
|
||||
return _graphicsManager->getHiDPIScreenFactor();
|
||||
}
|
||||
|
||||
@@ -118,6 +118,7 @@ public:
|
||||
void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) override final;
|
||||
int16 getOverlayHeight() const override final;
|
||||
int16 getOverlayWidth() const override final;
|
||||
Common::Rect getSafeOverlayArea(int16 *width, int16 *height) const override final;
|
||||
|
||||
float getHiDPIScreenFactor() const override final;
|
||||
|
||||
|
||||
@@ -223,6 +223,14 @@ bool OSystem::setRotationMode(int rotation) {
|
||||
return setRotationMode(Common::parseRotationMode(rotation));
|
||||
}
|
||||
|
||||
Common::Rect OSystem::getSafeOverlayArea(int16 *width, int16 *height) const {
|
||||
int16 w = getOverlayWidth(),
|
||||
h = getOverlayHeight();
|
||||
if (width) *width = w;
|
||||
if (height) *height = h;
|
||||
return Common::Rect(w, h);
|
||||
}
|
||||
|
||||
void OSystem::fatalError() {
|
||||
quit();
|
||||
exit(1);
|
||||
|
||||
@@ -1448,6 +1448,19 @@ public:
|
||||
*/
|
||||
virtual int16 getOverlayWidth() const = 0;
|
||||
|
||||
/**
|
||||
* Return the safe area for the overlay.
|
||||
* This area does not interfere with any system UI elements
|
||||
* such as the notch or home indicator on mobile devices.
|
||||
* Also returns the full overlay size.
|
||||
*
|
||||
* @param width Returns the width of the overlay, if not nullptr
|
||||
* @param height Returns the height of the overlay, if not nullptr
|
||||
*
|
||||
* @return The safe area in overlay coordinates.
|
||||
*/
|
||||
virtual Common::Rect getSafeOverlayArea(int16 *width = nullptr, int16 *height = nullptr) const;
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user