Browse Source

move rect to new file

master
Alexandros Theodotou 3 years ago
parent
commit
aa8515852a
Signed by: alex
GPG Key ID: 022EAE42313D70F3
  1. 29
      inc/ztoolkit/math.h
  2. 44
      inc/ztoolkit/rect.h
  3. 11
      inc/ztoolkit/types.h
  4. 4
      inc/ztoolkit/ztk.h
  5. 2
      inc/ztoolkit/ztk_widget.h
  6. 1
      src/meson.build
  7. 48
      src/rect.c

29
inc/ztoolkit/math.h

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
/*
* Copyright (C) 2020 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of ZToolkit
*
* ZToolkit is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* ZToolkit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Affero Public License
* along with ZToolkit. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __ZTOOLKIT_MATH_H__
#define __ZTOOLKIT_MATH_H__
#include <float.h>
#include <math.h>
#define math_doubles_equal(a,b) \
(a > b ? a - b < DBL_EPSILON : b - a < DBL_EPSILON)
#endif

44
inc/ztoolkit/rect.h

@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
/*
* Copyright (C) 2020 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of ZToolkit
*
* ZToolkit is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* ZToolkit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Affero Public License
* along with ZToolkit. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __ZTOOLKIT_RECT_H__
#define __ZTOOLKIT_RECT_H__
/**
* Wrapper over PuglRect.
*/
typedef struct ZtkRect
{
double x;
double y;
double width;
double height;
} ZtkRect;
int
ztk_rect_is_equal (
ZtkRect * src,
ZtkRect * dest);
void
ztk_rect_copy (
ZtkRect * dest,
ZtkRect * src);
#endif

11
inc/ztoolkit/types.h

@ -20,15 +20,4 @@ @@ -20,15 +20,4 @@
#ifndef __ZTOOLKIT_TYPES_H__
#define __ZTOOLKIT_TYPES_H__
/**
* Wrapper over PuglRect.
*/
typedef struct ZtkRect
{
double x;
double y;
double width;
double height;
} ZtkRect;
#endif

4
inc/ztoolkit/ztk.h

@ -21,9 +21,11 @@ @@ -21,9 +21,11 @@
#define __Z_TOOLKIT_ZTK_H__
#include "ztoolkit_config.h"
#include "math.h"
#include "log.h"
#include "types.h"
#include "rect.h"
#include "rsvg.h"
#include "types.h"
#include "ztk_widget.h"
#include "ztk_app.h"
#include "ztk_button.h"

2
inc/ztoolkit/ztk_widget.h

@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
#ifndef __Z_TOOLKIT_ZTK_WIDGET_H__
#define __Z_TOOLKIT_ZTK_WIDGET_H__
#include <ztoolkit/types.h>
#include "rect.h"
#include <cairo.h>
#include <pugl/pugl.h>

1
src/meson.build

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
ztoolkit_srcs = files([
'log.c',
'rect.c',
'rsvg.c',
'ztk_app.c',
'ztk_button.c',

48
src/rect.c

@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
/*
* Copyright (C) 2020 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of ZToolkit
*
* ZToolkit is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* ZToolkit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Affero Public License
* along with ZToolkit. If not, see <https://www.gnu.org/licenses/>.
*/
#include "ztoolkit/math.h"
#include "ztoolkit/rect.h"
int
ztk_rect_is_equal (
ZtkRect * src,
ZtkRect * dest)
{
return
math_doubles_equal (
src->x, dest->x) &&
math_doubles_equal (
src->y, dest->y) &&
math_doubles_equal (
src->width, dest->width) &&
math_doubles_equal (
src->height, dest->height);
}
void
ztk_rect_copy (
ZtkRect * dest,
ZtkRect * src)
{
dest->x = src->x;
dest->y = src->y;
dest->width = src->width;
dest->height = src->height;
}
Loading…
Cancel
Save