36 lines
682 B
C++
36 lines
682 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "imgui.h"
|
|
#include "imgui_internal.h"
|
|
|
|
|
|
struct TipLine {
|
|
bool has_marker = false;
|
|
ImU32 marker = 0;
|
|
std::string name;
|
|
std::string bold;
|
|
std::string rest;
|
|
};
|
|
|
|
class TipLabel {
|
|
public:
|
|
void showText(const ImVec2 &pt, const std::vector<TipLine> &text, const ImRect &rect);
|
|
void hide() { visible_ = false; }
|
|
bool isVisible() const { return visible_; }
|
|
void draw();
|
|
|
|
private:
|
|
|
|
ImVec2 layoutLines(ImDrawList *p, const ImVec2 &origin, ImU32 fg) const;
|
|
ImVec2 sizeHint() const;
|
|
|
|
static constexpr float MARGIN = 2.0f;
|
|
std::vector<TipLine> text_;
|
|
ImVec2 pos_;
|
|
ImVec2 size_;
|
|
bool visible_ = false;
|
|
};
|