2022-03-09 03:46:27 +02:00
|
|
|
#pragma once
|
|
|
|
|
2022-03-09 20:02:18 +02:00
|
|
|
#include "Box.hpp"
|
2022-03-18 02:49:16 +02:00
|
|
|
#include "Point.hpp"
|
2022-03-18 03:22:30 +02:00
|
|
|
#include "RGB.hpp"
|
2022-03-26 02:57:41 +02:00
|
|
|
#include "cairomm/xlib_surface.h"
|
2022-03-09 03:46:27 +02:00
|
|
|
#include <cairomm/cairomm.h>
|
2022-03-18 02:49:16 +02:00
|
|
|
#include <pango/pangocairo.h>
|
2022-03-09 03:46:27 +02:00
|
|
|
|
2022-03-08 02:25:22 +02:00
|
|
|
namespace Raven {
|
|
|
|
|
2022-03-18 02:49:16 +02:00
|
|
|
enum class PaintTextAlign {
|
|
|
|
Center = 0,
|
|
|
|
Left
|
|
|
|
};
|
|
|
|
|
2022-03-08 02:25:22 +02:00
|
|
|
class Painter {
|
2022-03-09 03:46:27 +02:00
|
|
|
private:
|
2022-03-26 02:57:41 +02:00
|
|
|
Cairo::RefPtr<Cairo::Context> m_cairo { nullptr };
|
2022-03-09 03:46:27 +02:00
|
|
|
public:
|
|
|
|
Painter() {}
|
2022-03-08 02:25:22 +02:00
|
|
|
|
2022-04-30 09:40:09 +03:00
|
|
|
Cairo::RefPtr<Cairo::Context> cairo() { return m_cairo; }
|
2022-03-09 03:46:27 +02:00
|
|
|
void set_cairo(Cairo::RefPtr<Cairo::Context> cairo) { m_cairo = cairo; }
|
2022-03-09 20:02:18 +02:00
|
|
|
|
|
|
|
void rounded_rectangle(Box &geometry, double border_radius);
|
2022-06-11 16:19:02 +03:00
|
|
|
Point compute_text_size(Box &widget_geometry, std::string &text, PangoFontDescription *pango_font_description);
|
2022-06-15 18:26:07 +03:00
|
|
|
void text(Box &geometry, std::string &text, PaintTextAlign align, PangoEllipsizeMode ellipsize, PangoFontDescription *pango_font_description);
|
2022-03-18 02:49:16 +02:00
|
|
|
|
2022-04-24 02:59:47 +03:00
|
|
|
bool can_paint() { if (m_cairo) return true; else return false; }
|
|
|
|
|
2022-06-11 15:52:23 +03:00
|
|
|
void source_rgb(RGB source_rgb);
|
2022-03-18 02:49:16 +02:00
|
|
|
void fill();
|
2022-03-26 02:57:41 +02:00
|
|
|
|
|
|
|
void begin_paint_group();
|
|
|
|
void end_paint_group();
|
2022-05-13 17:33:53 +03:00
|
|
|
void flush_paint_group();
|
2022-03-08 02:25:22 +02:00
|
|
|
};
|
|
|
|
|
2022-03-09 03:46:27 +02:00
|
|
|
}
|