mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-02 12:32:03 +01:00
RenderNotice and MeasureNotice take padding (added inside the background) and the corners to round. The drop shadow moves out of RenderNotice to the floating OSD notices, since views don't have one. Without layout params, a NoticeView is FILL_PARENT wide like a Choice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
1.9 KiB
C++
63 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
#include "Common/Render/DrawEnum.h"
|
|
#include "Common/UI/View.h"
|
|
#include "Common/System/OSD.h"
|
|
|
|
#undef ERROR
|
|
|
|
enum class NoticeLevel {
|
|
SUCCESS,
|
|
INFO,
|
|
WARN,
|
|
ERROR,
|
|
};
|
|
|
|
class NoticeView : public UI::InertView {
|
|
public:
|
|
NoticeView(NoticeLevel level, std::string_view text, std::string_view detailsText, UI::LayoutParams *layoutParams = nullptr);
|
|
|
|
void SetIconName(std::string_view name) {
|
|
iconName_ = name;
|
|
}
|
|
void SetText(std::string_view text) {
|
|
text_ = text;
|
|
}
|
|
void SetLevel(NoticeLevel level) {
|
|
level_ = level;
|
|
}
|
|
void SetLevelAndText(NoticeLevel level, std::string_view text) {
|
|
level_ = level;
|
|
text_ = text;
|
|
}
|
|
void SetWrapText(bool wrapText) {
|
|
wrapText_ = wrapText;
|
|
}
|
|
void SetDetailsText(std::string_view detailsText) {
|
|
detailsText_ = detailsText;
|
|
}
|
|
|
|
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;
|
|
bool wrapText_ = true;
|
|
};
|
|
|
|
ImageID GetOSDIcon(NoticeLevel level);
|
|
NoticeLevel GetNoticeLevel(OSDType type);
|
|
uint32_t GetNoticeBackgroundColor(NoticeLevel type);
|
|
// padding is added around the contents, inside the background. Pass the same to both.
|
|
void MeasureNotice(const UIContext &dc, NoticeLevel level, std::string_view text, std::string_view details, std::string_view iconName, int align, float maxWidth, float *width, float *height, float *height1, float padding = 0.0f);
|
|
// Doesn't draw a drop shadow, floating notices draw their own.
|
|
void RenderNotice(UIContext &dc, Bounds bounds, float height1, NoticeLevel level, std::string_view text, std::string_view details, std::string_view iconName, int align, float alpha, OSDMessageFlags flags, float timeVal, float padding = 0.0f, RoundCorners corners = RoundCorners::None);
|