From 51d4022b5d7535f325b253a29e653b9b88b5ced7 Mon Sep 17 00:00:00 2001 From: Francisco Garcia Date: Sun, 22 Sep 2024 13:43:05 +0200 Subject: [PATCH] Added draw_r2d() --- Changelog.md | 5 +++-- prj/build.txt | 2 +- src/draw2d/drawg.cpp | 31 +++++++++++++++++++++++++++++++ src/draw2d/drawg.h | 4 ++++ src/draw2d/drawg.hpp | 3 +++ 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/Changelog.md b/Changelog.md index b3bae562..fc61188a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -22,6 +22,7 @@ * OpenGL context ``. * [Documentation](https://nappgui.com/en/ogl3d/ogl3d.html). * [Demo](https://nappgui.com/en/howto/glhello.html). +* `draw_r2df()`, `draw_r2dd()`, `Draw::r2d()`. [Commit](). ### Fixed @@ -29,8 +30,8 @@ * GTK flatbutton padding. [Commit](https://github.com/frang75/nappgui_src/commit/5c41f9697ea7e6664b8b9db6cf16c32229ea8c36). * GTK render listbox checks in Xubuntu. [Commit](https://github.com/frang75/nappgui_src/commit/3c6247159f311195b2871b1fa10492c986b4f42d). * macOS HighSierra and lowers focus ring drawing issue. [Commit](https://github.com/frang75/nappgui_src/commit/a163cb2555101b831414b6deb781a1d1c49ccd42). -* Issue in `dbind_destroy()`. [Commit](). -* Issue in `layout_panel_replace()`. [Commit](). +* Issue in `dbind_destroy()`. [Commit](https://github.com/frang75/nappgui_src/commit/f8e16ad9d7712339400ca55b1a3ab4a426f1da2a). +* Issue in `layout_panel_replace()`. [Commit](https://github.com/frang75/nappgui_src/commit/f8e16ad9d7712339400ca55b1a3ab4a426f1da2a). ### Improved diff --git a/prj/build.txt b/prj/build.txt index 15b7e635..ec296f1c 100644 --- a/prj/build.txt +++ b/prj/build.txt @@ -1 +1 @@ -5456 +5458 diff --git a/src/draw2d/drawg.cpp b/src/draw2d/drawg.cpp index e9daf5d3..98e56805 100644 --- a/src/draw2d/drawg.cpp +++ b/src/draw2d/drawg.cpp @@ -62,6 +62,31 @@ void draw_seg2dd(DCtx *ctx, const Seg2Dd *seg) /*---------------------------------------------------------------------------*/ +template +static void i_r2d(DCtx *ctx, const drawop_t op, const R2D *rect) +{ + cassert_no_null(rect); + draw_rect(ctx, op, (real32_t)rect->pos.x, (real32_t)rect->pos.y, (real32_t)rect->size.width, (real32_t)rect->size.height); +} + +/*---------------------------------------------------------------------------*/ + +void draw_r2df(DCtx *ctx, const drawop_t op, const R2Df *rect) +{ + cassert_no_null(rect); + draw_rect(ctx, op, rect->pos.x, rect->pos.y, rect->size.width, rect->size.height); +} + +/*---------------------------------------------------------------------------*/ + +void draw_r2dd(DCtx *ctx, const drawop_t op, const R2Dd *rect) +{ + cassert_no_null(rect); + draw_rect(ctx, op, (real32_t)rect->pos.x, (real32_t)rect->pos.y, (real32_t)rect->size.width, (real32_t)rect->size.height); +} + +/*---------------------------------------------------------------------------*/ + template static void i_seg2d(DCtx *ctx, const Seg2D *seg) { @@ -261,6 +286,12 @@ void (*Draw::seg2d)(DCtx *, const Seg2D *) = i_seg2d void (*Draw::seg2d)(DCtx *, const Seg2D *) = i_seg2d; +template <> +void (*Draw::r2d)(DCtx *, const drawop_t, const R2D *) = i_r2d; + +template <> +void (*Draw::r2d)(DCtx *, const drawop_t, const R2D *) = i_r2d; + template <> void (*Draw::cir2d)(DCtx *, const drawop_t, const Cir2D *) = i_cir2d; diff --git a/src/draw2d/drawg.h b/src/draw2d/drawg.h index eabe16f6..204f2ca9 100644 --- a/src/draw2d/drawg.h +++ b/src/draw2d/drawg.h @@ -23,6 +23,10 @@ _draw2d_api void draw_seg2df(DCtx *ctx, const Seg2Df *seg); _draw2d_api void draw_seg2dd(DCtx *ctx, const Seg2Dd *seg); +_draw2d_api void draw_r2df(DCtx *ctx, const drawop_t op, const R2Df *rect); + +_draw2d_api void draw_r2dd(DCtx *ctx, const drawop_t op, const R2Dd *rect); + _draw2d_api void draw_cir2df(DCtx *ctx, const drawop_t op, const Cir2Df *cir); _draw2d_api void draw_cir2dd(DCtx *ctx, const drawop_t op, const Cir2Dd *cir); diff --git a/src/draw2d/drawg.hpp b/src/draw2d/drawg.hpp index 04489a30..ab43c827 100644 --- a/src/draw2d/drawg.hpp +++ b/src/draw2d/drawg.hpp @@ -14,6 +14,7 @@ #define __DRAWG_HPP__ #include "draw2d.hxx" +#include #include #include #include @@ -25,6 +26,8 @@ struct Draw _draw2d_api static void (*seg2d)(DCtx *ctx, const Seg2D *seg); + _draw2d_api static void (*r2d)(DCtx *ctx, const drawop_t op, const R2D *r); + _draw2d_api static void (*cir2d)(DCtx *ctx, const drawop_t op, const Cir2D *cir); _draw2d_api static void (*box2d)(DCtx *ctx, const drawop_t op, const Box2D *box);