2013-06-06 08:05:31 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <list>
|
2017-02-27 20:57:46 +00:00
|
|
|
#include <mutex>
|
2013-06-06 08:05:31 +00:00
|
|
|
|
2020-10-03 22:25:21 +00:00
|
|
|
#include "Common/Math/geom2d.h"
|
2020-10-04 18:48:47 +00:00
|
|
|
#include "Common/UI/View.h"
|
2023-06-19 13:50:36 +00:00
|
|
|
#include "Common/UI/UIScreen.h"
|
2023-06-20 12:40:46 +00:00
|
|
|
#include "Common/System/System.h"
|
2014-12-31 15:50:23 +00:00
|
|
|
|
2023-07-07 13:23:19 +00:00
|
|
|
#ifdef ERROR
|
|
|
|
#undef ERROR
|
|
|
|
#endif
|
|
|
|
|
2013-05-22 16:00:06 +00:00
|
|
|
class DrawBuffer;
|
|
|
|
|
2023-06-19 13:50:36 +00:00
|
|
|
// Infrastructure for rendering overlays.
|
|
|
|
|
2014-12-31 15:50:23 +00:00
|
|
|
class OnScreenMessagesView : public UI::InertView {
|
|
|
|
public:
|
|
|
|
OnScreenMessagesView(UI::LayoutParams *layoutParams = nullptr) : UI::InertView(layoutParams) {}
|
2021-03-08 23:09:36 +00:00
|
|
|
void Draw(UIContext &dc) override;
|
2023-09-04 09:04:15 +00:00
|
|
|
bool Dismiss(float x, float y); // Not reusing Touch since it's asynchronous.
|
2021-02-22 00:38:02 +00:00
|
|
|
std::string DescribeText() const override;
|
2023-09-04 08:01:07 +00:00
|
|
|
private:
|
2023-09-04 09:04:15 +00:00
|
|
|
struct ClickZone {
|
2023-09-04 08:54:17 +00:00
|
|
|
int index;
|
|
|
|
Bounds bounds;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Argh, would really like to avoid this.
|
2023-09-04 09:04:15 +00:00
|
|
|
std::mutex clickMutex_;
|
|
|
|
std::vector<ClickZone> clickZones_;
|
2014-12-31 15:50:23 +00:00
|
|
|
};
|
|
|
|
|
2023-06-19 13:50:36 +00:00
|
|
|
class OSDOverlayScreen : public UIScreen {
|
|
|
|
public:
|
|
|
|
const char *tag() const override { return "OSDOverlayScreen"; }
|
2023-09-04 09:04:15 +00:00
|
|
|
|
|
|
|
bool UnsyncTouch(const TouchInput &touch) override;
|
|
|
|
|
2023-06-19 13:50:36 +00:00
|
|
|
void CreateViews() override;
|
2023-12-11 11:41:44 +00:00
|
|
|
void DrawForeground(UIContext &ui) override;
|
2023-09-05 14:43:45 +00:00
|
|
|
void update() override;
|
2023-09-04 09:04:15 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
OnScreenMessagesView *osmView_ = nullptr;
|
2023-06-19 13:50:36 +00:00
|
|
|
};
|
2023-07-07 13:23:19 +00:00
|
|
|
|
|
|
|
enum class NoticeLevel {
|
|
|
|
SUCCESS,
|
|
|
|
INFO,
|
|
|
|
WARN,
|
|
|
|
ERROR,
|
|
|
|
};
|
|
|
|
|
|
|
|
class NoticeView : public UI::InertView {
|
|
|
|
public:
|
2023-10-22 17:10:42 +00:00
|
|
|
NoticeView(NoticeLevel level, std::string_view text, std::string_view detailsText, UI::LayoutParams *layoutParams = 0)
|
2023-07-07 13:23:19 +00:00
|
|
|
: InertView(layoutParams), level_(level), text_(text), detailsText_(detailsText), iconName_("") {}
|
|
|
|
|
2023-10-22 17:10:42 +00:00
|
|
|
void SetIconName(std::string_view name) {
|
2023-07-07 13:23:19 +00:00
|
|
|
iconName_ = name;
|
|
|
|
}
|
2023-10-22 17:10:42 +00:00
|
|
|
void SetText(std::string_view text) {
|
|
|
|
text_ = text;
|
|
|
|
}
|
|
|
|
void SetLevel(NoticeLevel level) {
|
|
|
|
level_ = level;
|
|
|
|
}
|
2024-01-31 22:17:51 +00:00
|
|
|
void SetSquishy(bool squishy) {
|
|
|
|
squishy_ = squishy;
|
|
|
|
}
|
2023-07-07 13:23:19 +00:00
|
|
|
|
|
|
|
void GetContentDimensionsBySpec(const UIContext &dc, UI::MeasureSpec horiz, UI::MeasureSpec vert, float &w, float &h) const override;
|
|
|
|
void Draw(UIContext &dc) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string text_;
|
|
|
|
std::string detailsText_;
|
|
|
|
std::string iconName_;
|
|
|
|
NoticeLevel level_;
|
|
|
|
mutable float height1_ = 0.0f;
|
2024-01-31 22:17:51 +00:00
|
|
|
bool squishy_ = false;
|
2023-07-07 13:23:19 +00:00
|
|
|
};
|