Skip to content

Commit

Permalink
Added draw_r2d()
Browse files Browse the repository at this point in the history
  • Loading branch information
frang75 committed Sep 22, 2024
1 parent f8e16ad commit 51d4022
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
* OpenGL context `<ogl3d/ogl3d.h>`.
* [Documentation](https://nappgui.com/en/ogl3d/ogl3d.html).
* [Demo](https://nappgui.com/en/howto/glhello.html).
* `draw_r2df()`, `draw_r2dd()`, `Draw::r2d()`. [Commit]().

### Fixed

* GTK scrollbars position. [Commit](https://github.com/frang75/nappgui_src/commit/5c41f9697ea7e6664b8b9db6cf16c32229ea8c36).
* 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

Expand Down
2 changes: 1 addition & 1 deletion prj/build.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5456
5458
31 changes: 31 additions & 0 deletions src/draw2d/drawg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,31 @@ void draw_seg2dd(DCtx *ctx, const Seg2Dd *seg)

/*---------------------------------------------------------------------------*/

template <typename real>
static void i_r2d(DCtx *ctx, const drawop_t op, const R2D<real> *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 <typename real>
static void i_seg2d(DCtx *ctx, const Seg2D<real> *seg)
{
Expand Down Expand Up @@ -261,6 +286,12 @@ void (*Draw<real32_t>::seg2d)(DCtx *, const Seg2D<real32_t> *) = i_seg2d<real32_
template <>
void (*Draw<real64_t>::seg2d)(DCtx *, const Seg2D<real64_t> *) = i_seg2d<real64_t>;

template <>
void (*Draw<real32_t>::r2d)(DCtx *, const drawop_t, const R2D<real32_t> *) = i_r2d<real32_t>;

template <>
void (*Draw<real64_t>::r2d)(DCtx *, const drawop_t, const R2D<real64_t> *) = i_r2d<real64_t>;

template <>
void (*Draw<real32_t>::cir2d)(DCtx *, const drawop_t, const Cir2D<real32_t> *) = i_cir2d<real32_t>;

Expand Down
4 changes: 4 additions & 0 deletions src/draw2d/drawg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/draw2d/drawg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define __DRAWG_HPP__

#include "draw2d.hxx"
#include <geom2d/r2d.hpp>
#include <geom2d/cir2d.hpp>
#include <geom2d/obb2d.hpp>
#include <geom2d/pol2d.hpp>
Expand All @@ -25,6 +26,8 @@ struct Draw

_draw2d_api static void (*seg2d)(DCtx *ctx, const Seg2D<real> *seg);

_draw2d_api static void (*r2d)(DCtx *ctx, const drawop_t op, const R2D<real> *r);

_draw2d_api static void (*cir2d)(DCtx *ctx, const drawop_t op, const Cir2D<real> *cir);

_draw2d_api static void (*box2d)(DCtx *ctx, const drawop_t op, const Box2D<real> *box);
Expand Down

0 comments on commit 51d4022

Please sign in to comment.