mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-01 20:18:15 +01:00
On the iPhone Duo's cover screen, the camera sits in a box in the top right corner, which gives a side inset down the whole right edge in portrait. The controls are far below it, so they lose width for nothing. iOS 27.1 reports the box as an occlusion region, and from that we report how far down the side insets are needed (SYSPROP_DISPLAY_SIDE_INSETS_BOTTOM). When that's within the top third, the game screen and the touch layout editor skip the side insets. The rest of the UI, including the FPS counter, still keeps them. The regions can show up after the size and insets have settled, so the insets are now recomputed on every layout, and a screen recreates its views when its layout mode changes, since the touch controls are placed for the bounds they were created in. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
106 lines
3.0 KiB
C++
106 lines
3.0 KiB
C++
#pragma once
|
|
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <deque>
|
|
|
|
#include "Common/Math/lin/vec3.h"
|
|
#include "Common/UI/Screen.h"
|
|
#include "Common/UI/ViewGroup.h"
|
|
|
|
using namespace Lin;
|
|
|
|
enum class ViewLayoutMode;
|
|
|
|
class I18NCategory;
|
|
namespace Draw {
|
|
class DrawContext;
|
|
}
|
|
|
|
class UIScreen : public Screen {
|
|
public:
|
|
UIScreen();
|
|
~UIScreen();
|
|
|
|
void update() override;
|
|
ScreenRenderFlags render(ScreenRenderMode mode) override;
|
|
void deviceLost() override;
|
|
void deviceRestored(Draw::DrawContext *draw) override;
|
|
|
|
bool touch(const TouchInput &touch) override;
|
|
bool key(const KeyInput &key) override;
|
|
void axis(const AxisInput &axis) override;
|
|
|
|
TouchInput transformTouch(const TouchInput &touch) override;
|
|
|
|
virtual void TriggerFinish(DialogResult result);
|
|
|
|
// Some useful default event handlers
|
|
void OnOK(UI::EventParams &e);
|
|
void OnCancel(UI::EventParams &e);
|
|
void OnBack(UI::EventParams &e);
|
|
|
|
virtual UI::Margins RootMargins() const { return UI::Margins(0); }
|
|
// Whether to keep the content off the edges of large screens (like TVs), and within MaxContentWidth.
|
|
// Off for screens that cover the whole display, like the game.
|
|
virtual bool LimitContentArea() const { return false; }
|
|
// Wider content is centered at this width. 0 for no limit.
|
|
virtual float MaxContentWidth() const { return 0.0f; }
|
|
|
|
virtual void focusChanged(ScreenFocusChange focusChange) override {
|
|
Screen::focusChanged(focusChange);
|
|
}
|
|
|
|
virtual bool AllowKeyboardNavigation() const { return true; }
|
|
|
|
// Process keyboard shortcuts even outside the game.
|
|
virtual InputMode PassInputToMapper() const override { return InputMode::Keyboard; }
|
|
|
|
protected:
|
|
virtual void CreateViews() = 0;
|
|
virtual bool AllowFocusMovement() const { return true; }
|
|
|
|
Bounds GetLayoutBounds(UIContext &dc) const;
|
|
// Where root_ goes: the layout bounds, less RootMargins and the limits above.
|
|
Bounds GetContentBounds(const UIContext &dc) const;
|
|
|
|
void RecreateViews() override { recreateViews_ = true; }
|
|
DeviceOrientation GetDeviceOrientation() const;
|
|
bool IsOnTop() const;
|
|
virtual ViewLayoutMode LayoutMode() const { return ViewLayoutMode::ApplyInsets; }
|
|
virtual bool UseImmersiveMode() const { return false; }
|
|
|
|
UI::ViewGroup *root_ = nullptr;
|
|
Vec3 translation_ = Vec3(0.0f);
|
|
Vec3 scale_ = Vec3(1.0f);
|
|
float alpha_ = 1.0f;
|
|
bool ignoreInput_ = false;
|
|
|
|
protected:
|
|
virtual void DrawBackground(UIContext &ui) {}
|
|
virtual void DrawForeground(UIContext &ui) {}
|
|
|
|
void DoRecreateViews();
|
|
|
|
bool recreateViews_ = true;
|
|
DeviceOrientation lastOrientation_ = DeviceOrientation::Landscape;
|
|
ViewLayoutMode lastLayoutMode_ = ViewLayoutMode::ApplyInsets;
|
|
};
|
|
|
|
class UIDialogScreen : public UIScreen {
|
|
public:
|
|
UIDialogScreen() : UIScreen(), finished_(false) {}
|
|
~UIDialogScreen() override;
|
|
void update() override {
|
|
UIScreen::update();
|
|
firstFrame_ = false;
|
|
}
|
|
bool key(const KeyInput &key) override;
|
|
void sendMessage(UIMessage message, const char *value) override;
|
|
|
|
protected:
|
|
bool firstFrame_ = true; // Since back button can toggle this screen, we need to make sure we don't immediately pop it on the first frame.
|
|
private:
|
|
bool finished_;
|
|
};
|