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"
|
2014-12-31 15:50:23 +00:00
|
|
|
|
2013-05-22 16:00:06 +00:00
|
|
|
class DrawBuffer;
|
|
|
|
|
|
|
|
class OnScreenMessages {
|
|
|
|
public:
|
2015-09-25 17:08:48 +00:00
|
|
|
void Show(const std::string &message, float duration_s = 1.0f, uint32_t color = 0xFFFFFF, int icon = -1, bool checkUnique = true, const char *id = nullptr);
|
2013-05-22 16:00:06 +00:00
|
|
|
void ShowOnOff(const std::string &message, bool b, float duration_s = 1.0f, uint32_t color = 0xFFFFFF, int icon = -1);
|
|
|
|
bool IsEmpty() const { return messages_.empty(); }
|
|
|
|
|
2014-12-31 15:50:23 +00:00
|
|
|
void Lock() {
|
|
|
|
mutex_.lock();
|
|
|
|
}
|
|
|
|
void Unlock() {
|
|
|
|
mutex_.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Clean();
|
|
|
|
|
2013-05-22 16:00:06 +00:00
|
|
|
struct Message {
|
|
|
|
int icon;
|
|
|
|
uint32_t color;
|
|
|
|
std::string text;
|
2015-09-25 17:08:48 +00:00
|
|
|
const char *id;
|
2013-05-22 16:00:06 +00:00
|
|
|
double endTime;
|
|
|
|
double duration;
|
|
|
|
};
|
2014-12-31 15:50:23 +00:00
|
|
|
const std::list<Message> &Messages() { return messages_; }
|
|
|
|
|
|
|
|
private:
|
2013-05-22 16:00:06 +00:00
|
|
|
std::list<Message> messages_;
|
2017-02-27 20:57:46 +00:00
|
|
|
std::mutex mutex_;
|
2013-05-22 16:00:06 +00:00
|
|
|
};
|
|
|
|
|
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;
|
2021-02-22 00:38:02 +00:00
|
|
|
std::string DescribeText() const override;
|
2014-12-31 15:50:23 +00:00
|
|
|
};
|
|
|
|
|
2013-05-22 16:00:06 +00:00
|
|
|
extern OnScreenMessages osm;
|