srctree

Robin Linden parent 5fa9256f 04644a99
gfx: Accept fonts from any container in draw_text

inlinesplit
gfx/canvas_command_saver.h added: 15, removed: 15, total 0
@@ -95,7 +95,7 @@ public:
}
void draw_text(geom::Position position,
std::string_view text,
std::vector<Font> const &font_options,
std::span<Font const> font_options,
FontSize size,
FontStyle style,
Color color) override {
 
gfx/canvas_command_saver_test.cpp added: 15, removed: 15, total 0
@@ -101,7 +101,7 @@ int main() {
saver.fill_rect({9, 9, 9, 9}, {0x12, 0x34, 0x56});
saver.draw_rect({9, 9, 9, 9}, {0x10, 0x11, 0x12}, {}, {});
saver.draw_text({10, 10}, "beep beep boop!"sv, {"helvetica"}, {42}, FontStyle::Italic, {3, 2, 1});
saver.draw_text({1, 5}, "hello?"sv, {{"font1"}, {"font2"}}, {42}, FontStyle::Normal, {1, 2, 3});
saver.draw_text({1, 5}, "hello?"sv, {{{"font1"}, {"font2"}}}, {42}, FontStyle::Normal, {1, 2, 3});
auto cmds = saver.take_commands();
 
CanvasCommandSaver replayed;
 
gfx/icanvas.h added: 15, removed: 15, total 0
@@ -9,8 +9,8 @@
#include "gfx/color.h"
#include "gfx/font.h"
 
#include <span>
#include <string_view>
#include <vector>
 
namespace gfx {
 
@@ -48,7 +48,7 @@ public:
virtual void add_translation(int dx, int dy) = 0;
virtual void fill_rect(geom::Rect const &, Color) = 0;
virtual void draw_rect(geom::Rect const &, Color const &, Borders const &, Corners const &) = 0;
virtual void draw_text(geom::Position, std::string_view, std::vector<Font> const &, FontSize, FontStyle, Color) = 0;
virtual void draw_text(geom::Position, std::string_view, std::span<Font const>, FontSize, FontStyle, Color) = 0;
virtual void draw_text(geom::Position, std::string_view, Font, FontSize, FontStyle, Color) = 0;
};
 
 
gfx/opengl_canvas.h added: 15, removed: 15, total 0
@@ -23,7 +23,7 @@ public:
 
void fill_rect(geom::Rect const &, Color) override;
void draw_rect(geom::Rect const &, Color const &, Borders const &, Corners const &) override {}
void draw_text(geom::Position, std::string_view, std::vector<Font> const &, FontSize, FontStyle, Color) override {}
void draw_text(geom::Position, std::string_view, std::span<Font const>, FontSize, FontStyle, Color) override {}
void draw_text(geom::Position, std::string_view, Font, FontSize, FontStyle, Color) override {}
 
private:
 
gfx/painter.h added: 15, removed: 15, total 0
@@ -22,7 +22,7 @@ public:
 
void draw_text(geom::Position p,
std::string_view text,
std::vector<Font> const &font_options,
std::span<Font const> font_options,
FontSize size,
FontStyle style,
Color color) {
 
gfx/sfml_canvas.cpp added: 15, removed: 15, total 0
@@ -152,7 +152,7 @@ void SfmlCanvas::draw_rect(geom::Rect const &rect, Color const &color, Borders c
 
void SfmlCanvas::draw_text(geom::Position p,
std::string_view text,
std::vector<Font> const &font_options,
std::span<Font const> font_options,
FontSize size,
FontStyle style,
Color color) {
 
gfx/sfml_canvas.h added: 15, removed: 15, total 0
@@ -33,7 +33,7 @@ public:
 
void fill_rect(geom::Rect const &, Color) override;
void draw_rect(geom::Rect const &, Color const &, Borders const &, Corners const &) override;
void draw_text(geom::Position, std::string_view, std::vector<Font> const &, FontSize, FontStyle, Color) override;
void draw_text(geom::Position, std::string_view, std::span<Font const>, FontSize, FontStyle, Color) override;
void draw_text(geom::Position, std::string_view, Font, FontSize, FontStyle, Color) override;
 
private: