2013-06-06 08:05:31 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <list>
|
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
2014-02-10 11:38:23 +00:00
|
|
|
#include "math/geom2d.h"
|
2013-06-06 08:05:31 +00:00
|
|
|
#include "Common/StdMutex.h"
|
2013-05-22 16:00:06 +00:00
|
|
|
|
2014-12-31 15:50:23 +00:00
|
|
|
#include "ui/view.h"
|
|
|
|
|
2013-05-22 16:00:06 +00:00
|
|
|
class DrawBuffer;
|
|
|
|
|
|
|
|
class OnScreenMessages {
|
|
|
|
public:
|
2013-12-05 15:15:33 +00:00
|
|
|
void Show(const std::string &message, float duration_s = 1.0f, uint32_t color = 0xFFFFFF, int icon = -1, bool checkUnique = true);
|
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;
|
|
|
|
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_;
|
|
|
|
std::recursive_mutex mutex_;
|
|
|
|
};
|
|
|
|
|
2014-12-31 15:50:23 +00:00
|
|
|
class OnScreenMessagesView : public UI::InertView {
|
|
|
|
public:
|
|
|
|
OnScreenMessagesView(UI::LayoutParams *layoutParams = nullptr) : UI::InertView(layoutParams) {}
|
|
|
|
void Draw(UIContext &dc);
|
|
|
|
};
|
|
|
|
|
2013-05-22 16:00:06 +00:00
|
|
|
extern OnScreenMessages osm;
|