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 gdk.PaintableIF; 26 27 private import gdk.PaintableIF; 28 private import gdk.Snapshot; 29 private import gdk.c.functions; 30 public import gdk.c.types; 31 private import glib.ConstructionException; 32 private import gobject.ObjectG; 33 private import gobject.Signals; 34 private import std.algorithm; 35 36 37 /** 38 * `GdkPaintable` is a simple interface used by GTK to represent content that 39 * can be painted. 40 * 41 * The content of a `GdkPaintable` can be painted anywhere at any size 42 * without requiring any sort of layout. The interface is inspired by 43 * similar concepts elsewhere, such as 44 * [ClutterContent](https://developer.gnome.org/clutter/stable/ClutterContent.html), 45 * [HTML/CSS Paint Sources](https://www.w3.org/TR/css-images-4/#paint-source), 46 * or [SVG Paint Servers](https://www.w3.org/TR/SVG2/pservers.html). 47 * 48 * A `GdkPaintable` can be snapshot at any time and size using 49 * [method@Gdk.Paintable.snapshot]. How the paintable interprets that size and 50 * if it scales or centers itself into the given rectangle is implementation 51 * defined, though if you are implementing a `GdkPaintable` and don't know what 52 * to do, it is suggested that you scale your paintable ignoring any potential 53 * aspect ratio. 54 * 55 * The contents that a `GdkPaintable` produces may depend on the [class@GdkSnapshot] 56 * passed to it. For example, paintables may decide to use more detailed images 57 * on higher resolution screens or when OpenGL is available. A `GdkPaintable` 58 * will however always produce the same output for the same snapshot. 59 * 60 * A `GdkPaintable` may change its contents, meaning that it will now produce 61 * a different output with the same snapshot. Once that happens, it will call 62 * [method@Gdk.Paintable.invalidate_contents] which will emit the 63 * [signal@GdkPaintable::invalidate-contents] signal. If a paintable is known 64 * to never change its contents, it will set the %GDK_PAINTABLE_STATIC_CONTENTS 65 * flag. If a consumer cannot deal with changing contents, it may call 66 * [method@Gdk.Paintable.get_current_image] which will return a static 67 * paintable and use that. 68 * 69 * A paintable can report an intrinsic (or preferred) size or aspect ratio it 70 * wishes to be rendered at, though it doesn't have to. Consumers of the interface 71 * can use this information to layout thepaintable appropriately. Just like the 72 * contents, the size of a paintable can change. A paintable will indicate this 73 * by calling [method@Gdk.Paintable.invalidate_size] which will emit the 74 * [signal@GdkPaintable::invalidate-size] signal. And just like for contents, 75 * if a paintable is known to never change its size, it will set the 76 * %GDK_PAINTABLE_STATIC_SIZE flag. 77 * 78 * Besides API for applications, there are some functions that are only 79 * useful for implementing subclasses and should not be used by applications: 80 * [method@Gdk.Paintable.invalidate_contents], 81 * [method@Gdk.Paintable.invalidate_size], 82 * [func@Gdk.Paintable.new_empty]. 83 */ 84 public interface PaintableIF{ 85 /** Get the main Gtk struct */ 86 public GdkPaintable* getPaintableStruct(bool transferOwnership = false); 87 88 /** the main Gtk struct as a void* */ 89 protected void* getStruct(); 90 91 92 /** */ 93 public static GType getType() 94 { 95 return gdk_paintable_get_type(); 96 } 97 98 /** 99 * Compute a concrete size for the `GdkPaintable`. 100 * 101 * Applies the sizing algorithm outlined in the 102 * [CSS Image spec](https://drafts.csswg.org/css-images-3/#default-sizing) 103 * to the given @paintable. See that link for more details. 104 * 105 * It is not necessary to call this function when both @specified_width 106 * and @specified_height are known, but it is useful to call this 107 * function in GtkWidget:measure implementations to compute the 108 * other dimension when only one dimension is given. 109 * 110 * Params: 111 * specifiedWidth = the width @paintable could be drawn into or 112 * 0.0 if unknown 113 * specifiedHeight = the height @paintable could be drawn into or 114 * 0.0 if unknown 115 * defaultWidth = the width @paintable would be drawn into if 116 * no other constraints were given 117 * defaultHeight = the height @paintable would be drawn into if 118 * no other constraints were given 119 * concreteWidth = will be set to the concrete width 120 * computed. 121 * concreteHeight = will be set to the concrete height 122 * computed. 123 */ 124 public void computeConcreteSize(double specifiedWidth, double specifiedHeight, double defaultWidth, double defaultHeight, out double concreteWidth, out double concreteHeight); 125 126 /** 127 * Gets an immutable paintable for the current contents displayed by @paintable. 128 * 129 * This is useful when you want to retain the current state of an animation, 130 * for example to take a screenshot of a running animation. 131 * 132 * If the @paintable is already immutable, it will return itself. 133 * 134 * Returns: An immutable paintable for the current 135 * contents of @paintable. 136 */ 137 public PaintableIF getCurrentImage(); 138 139 /** 140 * Get flags for the paintable. 141 * 142 * This is oftentimes useful for optimizations. 143 * 144 * See [flags@Gdk.PaintableFlags] for the flags and what they mean. 145 * 146 * Returns: The `GdkPaintableFlags` for this paintable 147 */ 148 public GdkPaintableFlags getFlags(); 149 150 /** 151 * Gets the preferred aspect ratio the @paintable would like to be displayed at. 152 * 153 * The aspect ratio is the width divided by the height, so a value of 0.5 154 * means that the @paintable prefers to be displayed twice as high as it 155 * is wide. Consumers of this interface can use this to preserve aspect 156 * ratio when displaying the paintable. 157 * 158 * This is a purely informational value and does not in any way limit the 159 * values that may be passed to [method@Gdk.Paintable.snapshot]. 160 * 161 * Usually when a @paintable returns nonzero values from 162 * [method@Gdk.Paintable.get_intrinsic_width] and 163 * [method@Gdk.Paintable.get_intrinsic_height] the aspect ratio 164 * should conform to those values, though that is not required. 165 * 166 * If the @paintable does not have a preferred aspect ratio, 167 * it returns 0. Negative values are never returned. 168 * 169 * Returns: the intrinsic aspect ratio of @paintable or 0 if none. 170 */ 171 public double getIntrinsicAspectRatio(); 172 173 /** 174 * Gets the preferred height the @paintable would like to be displayed at. 175 * 176 * Consumers of this interface can use this to reserve enough space to draw 177 * the paintable. 178 * 179 * This is a purely informational value and does not in any way limit the 180 * values that may be passed to [method@Gdk.Paintable.snapshot]. 181 * 182 * If the @paintable does not have a preferred height, it returns 0. 183 * Negative values are never returned. 184 * 185 * Returns: the intrinsic height of @paintable or 0 if none. 186 */ 187 public int getIntrinsicHeight(); 188 189 /** 190 * Gets the preferred width the @paintable would like to be displayed at. 191 * 192 * Consumers of this interface can use this to reserve enough space to draw 193 * the paintable. 194 * 195 * This is a purely informational value and does not in any way limit the 196 * values that may be passed to [method@Gdk.Paintable.snapshot]. 197 * 198 * If the @paintable does not have a preferred width, it returns 0. 199 * Negative values are never returned. 200 * 201 * Returns: the intrinsic width of @paintable or 0 if none. 202 */ 203 public int getIntrinsicWidth(); 204 205 /** 206 * Called by implementations of `GdkPaintable` to invalidate their contents. 207 * 208 * Unless the contents are invalidated, implementations must guarantee that 209 * multiple calls of [method@Gdk.Paintable.snapshot] produce the same output. 210 * 211 * This function will emit the [signal@Gdk.Paintable::invalidate-contents] 212 * signal. 213 * 214 * If a @paintable reports the %GDK_PAINTABLE_STATIC_CONTENTS flag, 215 * it must not call this function. 216 */ 217 public void invalidateContents(); 218 219 /** 220 * Called by implementations of `GdkPaintable` to invalidate their size. 221 * 222 * As long as the size is not invalidated, @paintable must return the same 223 * values for its intrinsic width, height and aspect ratio. 224 * 225 * This function will emit the [signal@Gdk.Paintable::invalidate-size] 226 * signal. 227 * 228 * If a @paintable reports the %GDK_PAINTABLE_STATIC_SIZE flag, 229 * it must not call this function. 230 */ 231 public void invalidateSize(); 232 233 /** 234 * Snapshots the given paintable with the given @width and @height. 235 * 236 * The paintable is drawn at the current (0,0) offset of the @snapshot. 237 * If @width and @height are not larger than zero, this function will 238 * do nothing. 239 * 240 * Params: 241 * snapshot = a `GdkSnapshot` to snapshot to 242 * width = width to snapshot in 243 * height = height to snapshot in 244 */ 245 public void snapshot(Snapshot snapshot, double width, double height); 246 247 /** 248 * Emitted when the contents of the @paintable change. 249 * 250 * Examples for such an event would be videos changing to the next frame or 251 * the icon theme for an icon changing. 252 */ 253 gulong addOnInvalidateContents(void delegate(PaintableIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 254 255 /** 256 * Emitted when the intrinsic size of the @paintable changes. 257 * 258 * This means the values reported by at least one of 259 * [method@Gdk.Paintable.get_intrinsic_width], 260 * [method@Gdk.Paintable.get_intrinsic_height] or 261 * [method@Gdk.Paintable.get_intrinsic_aspect_ratio] 262 * has changed. 263 * 264 * Examples for such an event would be a paintable displaying 265 * the contents of a toplevel surface being resized. 266 */ 267 gulong addOnInvalidateSize(void delegate(PaintableIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 268 }