1 /* 2 * This file is part of d-dazzle. 3 * 4 * d-dazzle 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-dazzle 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-dazzle; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 module dazzle.DockRevealer; 20 21 private import dazzle.Bin; 22 private import dazzle.c.functions; 23 public import dazzle.c.types; 24 private import glib.ConstructionException; 25 private import gobject.ObjectG; 26 private import gtk.Widget; 27 28 29 /** 30 * This widget is a bit like #GtkRevealer with a couple of important 31 * differences. First, it only supports a couple transition types 32 * (the direction to slide reveal). Additionally, the size of the 33 * child allocation will not change during the animation. This is not 34 * as generally useful as an upstream GTK+ widget, but is extremely 35 * important for the panel case to avoid things looking strange while 36 * animating into and out of view. 37 */ 38 public class DockRevealer : Bin 39 { 40 /** the main Gtk struct */ 41 protected DzlDockRevealer* dzlDockRevealer; 42 43 /** Get the main Gtk struct */ 44 public DzlDockRevealer* getDockRevealerStruct(bool transferOwnership = false) 45 { 46 if (transferOwnership) 47 ownedRef = false; 48 return dzlDockRevealer; 49 } 50 51 /** the main Gtk struct as a void* */ 52 protected override void* getStruct() 53 { 54 return cast(void*)dzlDockRevealer; 55 } 56 57 /** 58 * Sets our main struct and passes it to the parent class. 59 */ 60 public this (DzlDockRevealer* dzlDockRevealer, bool ownedRef = false) 61 { 62 this.dzlDockRevealer = dzlDockRevealer; 63 super(cast(DzlBin*)dzlDockRevealer, ownedRef); 64 } 65 66 67 /** */ 68 public static GType getType() 69 { 70 return dzl_dock_revealer_get_type(); 71 } 72 73 /** */ 74 public this() 75 { 76 auto p = dzl_dock_revealer_new(); 77 78 if(p is null) 79 { 80 throw new ConstructionException("null returned by new"); 81 } 82 83 this(cast(DzlDockRevealer*) p); 84 } 85 86 /** */ 87 public void animateToPosition(int position, uint transitionDuration) 88 { 89 dzl_dock_revealer_animate_to_position(dzlDockRevealer, position, transitionDuration); 90 } 91 92 /** */ 93 public bool getChildRevealed() 94 { 95 return dzl_dock_revealer_get_child_revealed(dzlDockRevealer) != 0; 96 } 97 98 /** */ 99 public int getPosition() 100 { 101 return dzl_dock_revealer_get_position(dzlDockRevealer); 102 } 103 104 /** */ 105 public bool getPositionSet() 106 { 107 return dzl_dock_revealer_get_position_set(dzlDockRevealer) != 0; 108 } 109 110 /** */ 111 public bool getRevealChild() 112 { 113 return dzl_dock_revealer_get_reveal_child(dzlDockRevealer) != 0; 114 } 115 116 /** */ 117 public uint getTransitionDuration() 118 { 119 return dzl_dock_revealer_get_transition_duration(dzlDockRevealer); 120 } 121 122 /** */ 123 public DzlDockRevealerTransitionType getTransitionType() 124 { 125 return dzl_dock_revealer_get_transition_type(dzlDockRevealer); 126 } 127 128 /** 129 * This is a helper to check if the revealer is animating. You probably don't 130 * want to poll this function. Connect to notify::child-revealed or 131 * notify::reveal-child instead. 132 * 133 * Returns: %TRUE if an animation is in progress. 134 */ 135 public bool isAnimating() 136 { 137 return dzl_dock_revealer_is_animating(dzlDockRevealer) != 0; 138 } 139 140 /** */ 141 public void setPosition(int position) 142 { 143 dzl_dock_revealer_set_position(dzlDockRevealer, position); 144 } 145 146 /** */ 147 public void setPositionSet(bool positionSet) 148 { 149 dzl_dock_revealer_set_position_set(dzlDockRevealer, positionSet); 150 } 151 152 /** */ 153 public void setRevealChild(bool revealChild) 154 { 155 dzl_dock_revealer_set_reveal_child(dzlDockRevealer, revealChild); 156 } 157 158 /** */ 159 public void setTransitionDuration(uint transitionDuration) 160 { 161 dzl_dock_revealer_set_transition_duration(dzlDockRevealer, transitionDuration); 162 } 163 164 /** */ 165 public void setTransitionType(DzlDockRevealerTransitionType transitionType) 166 { 167 dzl_dock_revealer_set_transition_type(dzlDockRevealer, transitionType); 168 } 169 }