1 /* 2 * This file is part of d-handy. 3 * 4 * d-handy 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 * d-handy 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 d-handy; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 module handy.Squeezer; 20 21 private import glib.ConstructionException; 22 private import gobject.ObjectG; 23 private import gtk.BuildableIF; 24 private import gtk.BuildableT; 25 private import gtk.Container; 26 private import gtk.OrientableIF; 27 private import gtk.OrientableT; 28 private import gtk.Widget; 29 private import handy.c.functions; 30 public import handy.c.types; 31 32 33 /** */ 34 public class Squeezer : Container, OrientableIF 35 { 36 /** the main Gtk struct */ 37 protected HdySqueezer* hdySqueezer; 38 39 /** Get the main Gtk struct */ 40 public HdySqueezer* getSqueezerStruct(bool transferOwnership = false) 41 { 42 if (transferOwnership) 43 ownedRef = false; 44 return hdySqueezer; 45 } 46 47 /** the main Gtk struct as a void* */ 48 protected override void* getStruct() 49 { 50 return cast(void*)hdySqueezer; 51 } 52 53 /** 54 * Sets our main struct and passes it to the parent class. 55 */ 56 public this (HdySqueezer* hdySqueezer, bool ownedRef = false) 57 { 58 this.hdySqueezer = hdySqueezer; 59 super(cast(GtkContainer*)hdySqueezer, ownedRef); 60 } 61 62 // add the Orientable capabilities 63 mixin OrientableT!(HdySqueezer); 64 65 66 /** */ 67 public static GType getType() 68 { 69 return hdy_squeezer_get_type(); 70 } 71 72 /** 73 * Creates a new #HdySqueezer container. 74 * 75 * Returns: a new #HdySqueezer 76 * 77 * Throws: ConstructionException GTK+ fails to create the object. 78 */ 79 public this() 80 { 81 auto __p = hdy_squeezer_new(); 82 83 if(__p is null) 84 { 85 throw new ConstructionException("null returned by new"); 86 } 87 88 this(cast(HdySqueezer*) __p); 89 } 90 91 /** 92 * Gets whether @child is enabled. 93 * 94 * See hdy_squeezer_set_child_enabled(). 95 * 96 * Params: 97 * child = a child of @self 98 * 99 * Returns: %TRUE if @child is enabled, %FALSE otherwise. 100 */ 101 public bool getChildEnabled(Widget child) 102 { 103 return hdy_squeezer_get_child_enabled(hdySqueezer, (child is null) ? null : child.getWidgetStruct()) != 0; 104 } 105 106 /** 107 * Gets whether @self is homogeneous. 108 * 109 * See hdy_squeezer_set_homogeneous(). 110 * 111 * Returns: %TRUE if @self is homogeneous, %FALSE is not 112 * 113 * Since: 0.0.10 114 */ 115 public bool getHomogeneous() 116 { 117 return hdy_squeezer_get_homogeneous(hdySqueezer) != 0; 118 } 119 120 /** 121 * Gets whether @self should interpolate its size on visible child change. 122 * 123 * See hdy_squeezer_set_interpolate_size(). 124 * 125 * Returns: %TRUE if @self interpolates its size on visible child change, %FALSE if not 126 * 127 * Since: 0.0.10 128 */ 129 public bool getInterpolateSize() 130 { 131 return hdy_squeezer_get_interpolate_size(hdySqueezer) != 0; 132 } 133 134 /** 135 * Gets the amount of time (in milliseconds) that transitions between children 136 * in @self will take. 137 * 138 * Returns: the transition duration 139 */ 140 public uint getTransitionDuration() 141 { 142 return hdy_squeezer_get_transition_duration(hdySqueezer); 143 } 144 145 /** 146 * Gets whether @self is currently in a transition from one child to another. 147 * 148 * Returns: %TRUE if the transition is currently running, %FALSE otherwise. 149 */ 150 public bool getTransitionRunning() 151 { 152 return hdy_squeezer_get_transition_running(hdySqueezer) != 0; 153 } 154 155 /** 156 * Gets the type of animation that will be used for transitions between children 157 * in @self. 158 * 159 * Returns: the current transition type of @self 160 */ 161 public HdySqueezerTransitionType getTransitionType() 162 { 163 return hdy_squeezer_get_transition_type(hdySqueezer); 164 } 165 166 /** 167 * Gets the currently visible child of @self, or %NULL if there are no visible 168 * children. 169 * 170 * Returns: the visible child of the #HdySqueezer 171 */ 172 public Widget getVisibleChild() 173 { 174 auto __p = hdy_squeezer_get_visible_child(hdySqueezer); 175 176 if(__p is null) 177 { 178 return null; 179 } 180 181 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p); 182 } 183 184 /** 185 * Gets the #HdySqueezer:xalign property for @self. 186 * 187 * Returns: the xalign property 188 * 189 * Since: 1.0 190 */ 191 public float getXalign() 192 { 193 return hdy_squeezer_get_xalign(hdySqueezer); 194 } 195 196 /** 197 * Gets the #HdySqueezer:yalign property for @self. 198 * 199 * Returns: the yalign property 200 * 201 * Since: 1.0 202 */ 203 public float getYalign() 204 { 205 return hdy_squeezer_get_yalign(hdySqueezer); 206 } 207 208 /** 209 * Make @self enable or disable @child. If a child is disabled, it will be 210 * ignored when looking for the child fitting the available size best. This 211 * allows to programmatically and prematurely hide a child of @self even if it 212 * fits in the available space. 213 * 214 * This can be used e.g. to ensure a certain child is hidden below a certain 215 * window width, or any other constraint you find suitable. 216 * 217 * Params: 218 * child = a child of @self 219 * enabled = %TRUE to enable the child, %FALSE to disable it 220 */ 221 public void setChildEnabled(Widget child, bool enabled) 222 { 223 hdy_squeezer_set_child_enabled(hdySqueezer, (child is null) ? null : child.getWidgetStruct(), enabled); 224 } 225 226 /** 227 * Sets @self to be homogeneous or not. If it is homogeneous, @self will request 228 * the same size for all its children for its opposite orientation, e.g. if 229 * @self is oriented horizontally and is homogeneous, it will request the same 230 * height for all its children. If it isn't, @self may change size when a 231 * different child becomes visible. 232 * 233 * Params: 234 * homogeneous = %TRUE to make @self homogeneous 235 * 236 * Since: 0.0.10 237 */ 238 public void setHomogeneous(bool homogeneous) 239 { 240 hdy_squeezer_set_homogeneous(hdySqueezer, homogeneous); 241 } 242 243 /** 244 * Sets whether or not @self will interpolate the size of its opposing 245 * orientation when changing the visible child. If %TRUE, @self will interpolate 246 * its size between the one of the previous visible child and the one of the new 247 * visible child, according to the set transition duration and the orientation, 248 * e.g. if @self is horizontal, it will interpolate the its height. 249 * 250 * Params: 251 * interpolateSize = %TRUE to interpolate the size 252 * 253 * Since: 0.0.10 254 */ 255 public void setInterpolateSize(bool interpolateSize) 256 { 257 hdy_squeezer_set_interpolate_size(hdySqueezer, interpolateSize); 258 } 259 260 /** 261 * Sets the duration that transitions between children in @self will take. 262 * 263 * Params: 264 * duration = the new duration, in milliseconds 265 */ 266 public void setTransitionDuration(uint duration) 267 { 268 hdy_squeezer_set_transition_duration(hdySqueezer, duration); 269 } 270 271 /** 272 * Sets the type of animation that will be used for transitions between children 273 * in @self. Available types include various kinds of fades and slides. 274 * 275 * The transition type can be changed without problems at runtime, so it is 276 * possible to change the animation based on the child that is about to become 277 * current. 278 * 279 * Params: 280 * transition = the new transition type 281 */ 282 public void setTransitionType(HdySqueezerTransitionType transition) 283 { 284 hdy_squeezer_set_transition_type(hdySqueezer, transition); 285 } 286 287 /** 288 * Sets the #HdySqueezer:xalign property for @self. 289 * 290 * Params: 291 * xalign = the new xalign value, between 0 and 1 292 * 293 * Since: 1.0 294 */ 295 public void setXalign(float xalign) 296 { 297 hdy_squeezer_set_xalign(hdySqueezer, xalign); 298 } 299 300 /** 301 * Sets the #HdySqueezer:yalign property for @self. 302 * 303 * Params: 304 * yalign = the new yalign value, between 0 and 1 305 * 306 * Since: 1.0 307 */ 308 public void setYalign(float yalign) 309 { 310 hdy_squeezer_set_yalign(hdySqueezer, yalign); 311 } 312 }