1 #include "lua/internal.hpp"
2 #include "fonts/wrapper.hpp"
3 #include "library/framebuffer.hpp"
7 struct render_object_text
: public render_object
9 render_object_text(int32_t _x
, int32_t _y
, const std::string
& _text
, premultiplied_color _fg
,
10 premultiplied_color _bg
, bool _hdbl
= false, bool _vdbl
= false) throw()
11 : x(_x
), y(_y
), text(_text
), fg(_fg
), bg(_bg
), hdbl(_hdbl
), vdbl(_vdbl
) {}
12 ~render_object_text() throw() {}
13 template<bool X
> void op(struct framebuffer
<X
>& scr
) throw()
17 main_font
.render(scr
, x
, y
, text
, fg
, bg
, hdbl
, vdbl
);
19 void operator()(struct framebuffer
<true>& scr
) throw() { op(scr
); }
20 void operator()(struct framebuffer
<false>& scr
) throw() { op(scr
); }
24 premultiplied_color fg
;
25 premultiplied_color bg
;
31 int internal_gui_text(lua_state
& L
, const std::string
& fname
, bool hdbl
, bool vdbl
)
35 int64_t fgc
= 0xFFFFFFU
;
37 int32_t _x
= L
.get_numeric_argument
<int32_t>(1, fname
.c_str());
38 int32_t _y
= L
.get_numeric_argument
<int32_t>(2, fname
.c_str());
39 L
.get_numeric_argument
<int64_t>(4, fgc
, fname
.c_str());
40 L
.get_numeric_argument
<int64_t>(5, bgc
, fname
.c_str());
41 std::string text
= L
.get_string(3, fname
.c_str());
42 premultiplied_color
fg(fgc
);
43 premultiplied_color
bg(bgc
);
44 lua_render_ctx
->queue
->create_add
<render_object_text
>(_x
, _y
, text
, fg
, bg
, hdbl
, vdbl
);
48 function_ptr_luafun
gui_text(LS
, "gui.text", [](lua_state
& L
, const std::string
& fname
) -> int {
49 internal_gui_text(L
, fname
, false, false);
52 function_ptr_luafun
gui_textH(LS
, "gui.textH", [](lua_state
& L
, const std::string
& fname
) -> int {
53 internal_gui_text(L
, fname
, true, false);
56 function_ptr_luafun
gui_textV(LS
, "gui.textV", [](lua_state
& L
, const std::string
& fname
) -> int {
57 internal_gui_text(L
, fname
, false, true);
60 function_ptr_luafun
gui_textHV(LS
, "gui.textHV", [](lua_state
& L
, const std::string
& fname
) -> int {
61 internal_gui_text(L
, fname
, true, true);