mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-08-31 09:45:24 +02:00
Unlike the directional moves, this doesn't look at where anything ended up on screen - it walks the hierarchy in the order views were added, flattening nested groups in place. That's what makes it predictable in the layouts where "what's to the right of this" has no good answer. A view is a stop if it's focusable and enabled, the same test the directional moves apply, so the two agree on what's reachable. Hidden subtrees are skipped whole, which is what keeps a TabHolder's inactive tabs - V_GONE rather than removed - out of the order without any special casing. Containers are gated on visibility only, not enabled, matching Key/Touch/Axis: disabling a container doesn't stop its children being interactive anywhere else either. Ctrl+Tab stays with ChoiceStrip, which uses it to switch tabs. focusMoves now holds FocusMove rather than raw keycodes, so the direction is decided in one place while the modifiers are still around, and a held key repeats in the direction it was originally pressed with - the synthesized repeat has no modifiers of its own. That also retires the keycode switch in UpdateViewHierarchy and IsScrollKey, which had no other callers. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SfY7iFJEjmRXf1XGrTs4MF
67 lines
2.0 KiB
C++
67 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include <functional>
|
|
|
|
#include "Common/UI/Context.h"
|
|
#include "Common/Input/InputState.h"
|
|
#include "Common/UI/Screen.h"
|
|
|
|
namespace UI {
|
|
|
|
struct Margins;
|
|
enum class FocusFlags;
|
|
enum class FocusMove;
|
|
|
|
// The ONLY global is the currently focused item.
|
|
// Can be and often is null.
|
|
void EnableFocusMovement(bool enable);
|
|
bool IsFocusMovementEnabled();
|
|
View *GetFocusedView();
|
|
void SetFocusedView(View *view, FocusFlags cause, bool force = false);
|
|
void RemoveQueuedEventsByEvent(Event *e);
|
|
void RemoveQueuedEventsByView(View * v);
|
|
|
|
void EventTriggered(Event *e, EventParams params);
|
|
DialogResult DispatchEvents();
|
|
|
|
class ViewGroup;
|
|
|
|
// Where Tab (FocusMove::NEXT) and Shift+Tab (FocusMove::PREV) move the focus to, wrapping around
|
|
// at the ends. See ViewGroup::CollectTabOrder for what counts as a stop and in what order.
|
|
// nullptr if there's nothing focusable at all. Exposed mainly so it can be tested directly.
|
|
View *FindTabOrderNeighbor(ViewGroup *root, View *focusedView, FocusMove direction);
|
|
|
|
void LayoutViewHierarchy(const UIContext &dc, const UI::Margins &rootMargins, UI::ViewGroup *root, ViewLayoutMode layoutMode, bool immersiveMode);
|
|
DialogResult UpdateViewHierarchy(ViewGroup *root, bool canEnableFocusMovement = true);
|
|
|
|
enum class KeyEventResult {
|
|
IGNORE_KEY, // Don't let it be processed.
|
|
PASS_THROUGH, // Let it be processed, but return false.
|
|
ACCEPT, // Let it be processed, but return true.
|
|
};
|
|
|
|
KeyEventResult KeyEventToFocusMoves(const KeyInput &key);
|
|
|
|
bool KeyEvent(const KeyInput &key, ViewGroup *root);
|
|
void TouchEvent(const TouchInput &touch, ViewGroup *root);
|
|
void AxisEvent(const AxisInput &axis, ViewGroup *root);
|
|
|
|
enum class UISound {
|
|
SELECT = 0,
|
|
BACK,
|
|
CONFIRM,
|
|
TOGGLE_ON,
|
|
TOGGLE_OFF,
|
|
ACHIEVEMENT_UNLOCKED,
|
|
LEADERBOARD_SUBMITTED,
|
|
COUNT,
|
|
};
|
|
|
|
void SetSoundCallback(std::function<void(UISound)> func);
|
|
|
|
// This is only meant for actual UI navigation sound, not achievements.
|
|
// Call directly into the player for other UI effects.
|
|
void PlayUISound(UISound sound);
|
|
|
|
} // namespace UI
|