2020-03-08 14:49:29 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
2020-08-02 23:02:30 +02:00
|
|
|
#include <functional>
|
2020-08-02 23:09:04 +02:00
|
|
|
|
2020-10-04 20:48:47 +02:00
|
|
|
#include "Common/UI/Context.h"
|
2020-10-01 09:36:43 +02:00
|
|
|
#include "Common/Input/InputState.h"
|
2020-03-08 14:49:29 +01:00
|
|
|
|
|
|
|
|
namespace UI {
|
|
|
|
|
|
2020-03-08 15:16:32 +01:00
|
|
|
// 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, bool force = false);
|
|
|
|
|
void RemoveQueuedEventsByEvent(Event *e);
|
|
|
|
|
void RemoveQueuedEventsByView(View * v);
|
|
|
|
|
|
|
|
|
|
void EventTriggered(Event *e, EventParams params);
|
|
|
|
|
void DispatchEvents();
|
|
|
|
|
|
2020-03-08 14:49:29 +01:00
|
|
|
class ViewGroup;
|
|
|
|
|
|
2020-05-31 23:20:13 +02:00
|
|
|
void LayoutViewHierarchy(const UIContext &dc, ViewGroup *root, bool ignoreInsets);
|
2020-03-08 14:49:29 +01:00
|
|
|
void UpdateViewHierarchy(ViewGroup *root);
|
2023-05-26 11:49:50 +02:00
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-08 14:49:29 +01:00
|
|
|
// Hooks arrow keys for navigation
|
2023-05-26 11:49:50 +02:00
|
|
|
KeyEventResult UnsyncKeyEvent(const KeyInput &key, ViewGroup *root);
|
|
|
|
|
|
2023-07-14 12:01:38 +02:00
|
|
|
bool KeyEvent(const KeyInput &key, ViewGroup *root);
|
2023-05-26 11:49:50 +02:00
|
|
|
void TouchEvent(const TouchInput &touch, ViewGroup *root);
|
|
|
|
|
void AxisEvent(const AxisInput &axis, ViewGroup *root);
|
2020-03-08 14:49:29 +01:00
|
|
|
|
2020-08-02 23:02:30 +02:00
|
|
|
enum class UISound {
|
2020-08-03 11:29:54 +02:00
|
|
|
SELECT = 0,
|
2020-08-02 23:02:30 +02:00
|
|
|
BACK,
|
|
|
|
|
CONFIRM,
|
2020-08-03 11:29:54 +02:00
|
|
|
TOGGLE_ON,
|
|
|
|
|
TOGGLE_OFF,
|
2023-07-12 19:18:56 +02:00
|
|
|
ACHIEVEMENT_UNLOCKED,
|
|
|
|
|
LEADERBOARD_SUBMITTED,
|
2020-08-03 11:29:54 +02:00
|
|
|
COUNT,
|
2020-08-02 23:02:30 +02:00
|
|
|
};
|
|
|
|
|
|
2020-08-03 11:58:55 +02:00
|
|
|
void SetSoundEnabled(bool enabled);
|
2023-07-12 19:18:56 +02:00
|
|
|
void SetSoundCallback(std::function<void(UISound, float)> func);
|
2020-08-02 23:02:30 +02:00
|
|
|
|
2023-07-16 21:43:49 +02:00
|
|
|
// This is only meant for actual UI navigation sound, not achievements.
|
|
|
|
|
// Call directly into the player for other UI effects.
|
2023-07-12 19:18:56 +02:00
|
|
|
void PlayUISound(UISound sound, float volume = 0.25f);
|
2020-08-02 23:02:30 +02:00
|
|
|
|
2020-03-08 15:16:32 +01:00
|
|
|
} // namespace UI
|