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