1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gsk.RoundedRect; 26 27 private import gobject.ObjectG; 28 private import graphene.Point; 29 private import graphene.Rect; 30 private import graphene.Size; 31 private import gsk.c.functions; 32 public import gsk.c.types; 33 34 35 /** 36 * A rectangular region with rounded corners. 37 * 38 * Application code should normalize rectangles using 39 * [method@Gsk.RoundedRect.normalize]; this function will ensure that 40 * the bounds of the rectangle are normalized and ensure that the corner 41 * values are positive and the corners do not overlap. 42 * 43 * All functions taking a `GskRoundedRect` as an argument will internally 44 * operate on a normalized copy; all functions returning a `GskRoundedRect` 45 * will always return a normalized one. 46 * 47 * The algorithm used for normalizing corner sizes is described in 48 * [the CSS specification](https://drafts.csswg.org/css-backgrounds-3/#border-radius). 49 */ 50 public class RoundedRect 51 { 52 /** the main Gtk struct */ 53 protected GskRoundedRect* gskRoundedRect; 54 protected bool ownedRef; 55 56 /** Get the main Gtk struct */ 57 public GskRoundedRect* getRoundedRectStruct(bool transferOwnership = false) 58 { 59 if (transferOwnership) 60 ownedRef = false; 61 return gskRoundedRect; 62 } 63 64 /** the main Gtk struct as a void* */ 65 protected void* getStruct() 66 { 67 return cast(void*)gskRoundedRect; 68 } 69 70 /** 71 * Sets our main struct and passes it to the parent class. 72 */ 73 public this (GskRoundedRect* gskRoundedRect, bool ownedRef = false) 74 { 75 this.gskRoundedRect = gskRoundedRect; 76 this.ownedRef = ownedRef; 77 } 78 79 80 /** 81 * Checks if the given @point is inside the rounded rectangle. 82 * 83 * Params: 84 * point = the point to check 85 * 86 * Returns: %TRUE if the @point is inside the rounded rectangle 87 */ 88 public bool containsPoint(Point point) 89 { 90 return gsk_rounded_rect_contains_point(gskRoundedRect, (point is null) ? null : point.getPointStruct()) != 0; 91 } 92 93 /** 94 * Checks if the given @rect is contained inside the rounded rectangle. 95 * 96 * Params: 97 * rect = the rectangle to check 98 * 99 * Returns: %TRUE if the @rect is fully contained inside the rounded rectangle 100 */ 101 public bool containsRect(Rect rect) 102 { 103 return gsk_rounded_rect_contains_rect(gskRoundedRect, (rect is null) ? null : rect.getRectStruct()) != 0; 104 } 105 106 /** 107 * Initializes the given `GskRoundedRect` with the given values. 108 * 109 * This function will implicitly normalize the `GskRoundedRect` 110 * before returning. 111 * 112 * Params: 113 * bounds = a `graphene_rect_t` describing the bounds 114 * topLeft = the rounding radius of the top left corner 115 * topRight = the rounding radius of the top right corner 116 * bottomRight = the rounding radius of the bottom right corner 117 * bottomLeft = the rounding radius of the bottom left corner 118 * 119 * Returns: the initialized rectangle 120 */ 121 public RoundedRect init(Rect bounds, Size topLeft, Size topRight, Size bottomRight, Size bottomLeft) 122 { 123 auto __p = gsk_rounded_rect_init(gskRoundedRect, (bounds is null) ? null : bounds.getRectStruct(), (topLeft is null) ? null : topLeft.getSizeStruct(), (topRight is null) ? null : topRight.getSizeStruct(), (bottomRight is null) ? null : bottomRight.getSizeStruct(), (bottomLeft is null) ? null : bottomLeft.getSizeStruct()); 124 125 if(__p is null) 126 { 127 return null; 128 } 129 130 return ObjectG.getDObject!(RoundedRect)(cast(GskRoundedRect*) __p); 131 } 132 133 /** 134 * Initializes @self using the given @src rectangle. 135 * 136 * This function will not normalize the `GskRoundedRect`, 137 * so make sure the source is normalized. 138 * 139 * Params: 140 * src = a `GskRoundedRect` 141 * 142 * Returns: the initialized rectangle 143 */ 144 public RoundedRect initCopy(RoundedRect src) 145 { 146 auto __p = gsk_rounded_rect_init_copy(gskRoundedRect, (src is null) ? null : src.getRoundedRectStruct()); 147 148 if(__p is null) 149 { 150 return null; 151 } 152 153 return ObjectG.getDObject!(RoundedRect)(cast(GskRoundedRect*) __p); 154 } 155 156 /** 157 * Initializes @self to the given @bounds and sets the radius 158 * of all four corners to @radius. 159 * 160 * Params: 161 * bounds = a `graphene_rect_t` 162 * radius = the border radius 163 * 164 * Returns: the initialized rectangle 165 */ 166 public RoundedRect initFromRect(Rect bounds, float radius) 167 { 168 auto __p = gsk_rounded_rect_init_from_rect(gskRoundedRect, (bounds is null) ? null : bounds.getRectStruct(), radius); 169 170 if(__p is null) 171 { 172 return null; 173 } 174 175 return ObjectG.getDObject!(RoundedRect)(cast(GskRoundedRect*) __p); 176 } 177 178 /** 179 * Checks if part of the given @rect is contained inside the rounded rectangle. 180 * 181 * Params: 182 * rect = the rectangle to check 183 * 184 * Returns: %TRUE if the @rect intersects with the rounded rectangle 185 */ 186 public bool intersectsRect(Rect rect) 187 { 188 return gsk_rounded_rect_intersects_rect(gskRoundedRect, (rect is null) ? null : rect.getRectStruct()) != 0; 189 } 190 191 /** 192 * Checks if all corners of @self are right angles and the 193 * rectangle covers all of its bounds. 194 * 195 * This information can be used to decide if [ctor@Gsk.ClipNode.new] 196 * or [ctor@Gsk.RoundedClipNode.new] should be called. 197 * 198 * Returns: %TRUE if the rectangle is rectilinear 199 */ 200 public bool isRectilinear() 201 { 202 return gsk_rounded_rect_is_rectilinear(gskRoundedRect) != 0; 203 } 204 205 /** 206 * Normalizes the passed rectangle. 207 * 208 * This function will ensure that the bounds of the rectangle 209 * are normalized and ensure that the corner values are positive 210 * and the corners do not overlap. 211 * 212 * Returns: the normalized rectangle 213 */ 214 public RoundedRect normalize() 215 { 216 auto __p = gsk_rounded_rect_normalize(gskRoundedRect); 217 218 if(__p is null) 219 { 220 return null; 221 } 222 223 return ObjectG.getDObject!(RoundedRect)(cast(GskRoundedRect*) __p); 224 } 225 226 /** 227 * Offsets the bound's origin by @dx and @dy. 228 * 229 * The size and corners of the rectangle are unchanged. 230 * 231 * Params: 232 * dx = the horizontal offset 233 * dy = the vertical offset 234 * 235 * Returns: the offset rectangle 236 */ 237 public RoundedRect offset(float dx, float dy) 238 { 239 auto __p = gsk_rounded_rect_offset(gskRoundedRect, dx, dy); 240 241 if(__p is null) 242 { 243 return null; 244 } 245 246 return ObjectG.getDObject!(RoundedRect)(cast(GskRoundedRect*) __p); 247 } 248 249 /** 250 * Shrinks (or grows) the given rectangle by moving the 4 sides 251 * according to the offsets given. 252 * 253 * The corner radii will be changed in a way that tries to keep 254 * the center of the corner circle intact. This emulates CSS behavior. 255 * 256 * This function also works for growing rectangles if you pass 257 * negative values for the @top, @right, @bottom or @left. 258 * 259 * Params: 260 * top = How far to move the top side downwards 261 * right = How far to move the right side to the left 262 * bottom = How far to move the bottom side upwards 263 * left = How far to move the left side to the right 264 * 265 * Returns: the resized `GskRoundedRect` 266 */ 267 public RoundedRect shrink(float top, float right, float bottom, float left) 268 { 269 auto __p = gsk_rounded_rect_shrink(gskRoundedRect, top, right, bottom, left); 270 271 if(__p is null) 272 { 273 return null; 274 } 275 276 return ObjectG.getDObject!(RoundedRect)(cast(GskRoundedRect*) __p); 277 } 278 }