[gimp] app: use gimp_cairo_rounded_rectangle() in GimpOverlayFrame
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: use gimp_cairo_rounded_rectangle() in GimpOverlayFrame
- Date: Wed, 7 Mar 2018 14:40:39 +0000 (UTC)
commit e4c79cb2d60da824f7c11305df1b73e32ca36dd2
Author: Ell <ell_se yahoo com>
Date: Wed Mar 7 09:21:08 2018 -0500
app: use gimp_cairo_rounded_rectangle() in GimpOverlayFrame
... instead of drawing it the hard way.
app/core/gimp-cairo.c | 7 ++++++
app/widgets/gimpoverlayframe.c | 47 ++++++----------------------------------
2 files changed, 14 insertions(+), 40 deletions(-)
---
diff --git a/app/core/gimp-cairo.c b/app/core/gimp-cairo.c
index 9814235..2cfb3ab 100644
--- a/app/core/gimp-cairo.c
+++ b/app/core/gimp-cairo.c
@@ -151,6 +151,13 @@ gimp_cairo_rounded_rectangle (cairo_t *cr,
corner_radius = CLAMP (corner_radius, 0.0, MIN (width, height) / 2.0);
+ if (corner_radius == 0.0)
+ {
+ cairo_rectangle (cr, x, y, width, height);
+
+ return;
+ }
+
cairo_new_sub_path (cr);
cairo_arc (cr,
diff --git a/app/widgets/gimpoverlayframe.c b/app/widgets/gimpoverlayframe.c
index 039b2b4..ae36f70 100644
--- a/app/widgets/gimpoverlayframe.c
+++ b/app/widgets/gimpoverlayframe.c
@@ -26,6 +26,8 @@
#include "widgets-types.h"
+#include "core/gimp-cairo.h"
+
#include "gimpoverlayframe.h"
#include "gimpwidgets-utils.h"
@@ -134,47 +136,12 @@ gimp_overlay_frame_expose (GtkWidget *widget,
gtk_widget_get_allocation (widget, &allocation);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- if (rgba && border_width > 0)
+ if (rgba)
{
-#define DEG_TO_RAD(deg) ((deg) * (G_PI / 180.0))
-
- cairo_arc (cr,
- border_width,
- border_width,
- border_width,
- DEG_TO_RAD (180),
- DEG_TO_RAD (270));
- cairo_line_to (cr,
- allocation.width - border_width,
- 0);
-
- cairo_arc (cr,
- allocation.width - border_width,
- border_width,
- border_width,
- DEG_TO_RAD (270),
- DEG_TO_RAD (0));
- cairo_line_to (cr,
- allocation.width,
- allocation.height - border_width);
-
- cairo_arc (cr,
- allocation.width - border_width,
- allocation.height - border_width,
- border_width,
- DEG_TO_RAD (0),
- DEG_TO_RAD (90));
- cairo_line_to (cr,
- border_width,
- allocation.height);
-
- cairo_arc (cr,
- border_width,
- allocation.height - border_width,
- border_width,
- DEG_TO_RAD (90),
- DEG_TO_RAD (180));
- cairo_close_path (cr);
+ gimp_cairo_rounded_rectangle (cr,
+ 0.0, 0.0,
+ allocation.width, allocation.height,
+ border_width);
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]