Panda3D
 All Classes Functions Variables Enumerations
pgScrollFrame.I
1 // Filename: pgScrollFrame.I
2 // Created by: drose (17Aug05)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: PGScrollFrame::set_virtual_frame
18 // Access: Published
19 // Description: Sets the bounding rectangle of the virtual frame.
20 // This is the size of the large, virtual canvas which
21 // we can see only a portion of at any given time.
22 ////////////////////////////////////////////////////////////////////
23 INLINE void PGScrollFrame::
24 set_virtual_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) {
25  set_virtual_frame(LVecBase4(left, right, bottom, top));
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: PGScrollFrame::set_virtual_frame
30 // Access: Published
31 // Description: Sets the bounding rectangle of the virtual frame.
32 // This is the size of the large, virtual canvas which
33 // we can see only a portion of at any given time.
34 ////////////////////////////////////////////////////////////////////
35 INLINE void PGScrollFrame::
37  LightReMutexHolder holder(_lock);
38  _has_virtual_frame = true;
39  _virtual_frame = frame;
40 
41  if (_auto_hide) {
42  _needs_remanage = true;
43  }
44  _needs_recompute_clip = true;
45 }
46 
47 ////////////////////////////////////////////////////////////////////
48 // Function: PGScrollFrame::get_virtual_frame
49 // Access: Published
50 // Description: Returns the bounding rectangle of the virtual frame.
51 // See set_virtual_frame(). If has_virtual_frame() is
52 // false, this returns the item's clip frame.
53 ////////////////////////////////////////////////////////////////////
54 INLINE const LVecBase4 &PGScrollFrame::
56  LightReMutexHolder holder(_lock);
57  return _has_virtual_frame ? _virtual_frame : get_clip_frame();
58 }
59 
60 ////////////////////////////////////////////////////////////////////
61 // Function: PGScrollFrame::has_virtual_frame
62 // Access: Published
63 // Description: Returns true if the virtual frame has a bounding
64 // rectangle; see set_virtual_frame(). Most
65 // PGScrollFrame objects will have a virtual frame.
66 ////////////////////////////////////////////////////////////////////
67 INLINE bool PGScrollFrame::
69  LightReMutexHolder holder(_lock);
70  return _has_virtual_frame;
71 }
72 
73 ////////////////////////////////////////////////////////////////////
74 // Function: PGScrollFrame::clear_virtual_frame
75 // Access: Published
76 // Description: Removes the virtual frame from the item. This
77 // effectively sets the virtual frame to the same size
78 // as the clip frame. Scrolling will no longer be
79 // possible.
80 ////////////////////////////////////////////////////////////////////
81 INLINE void PGScrollFrame::
83  LightReMutexHolder holder(_lock);
84  _has_virtual_frame = false;
85 }
86 
87 ////////////////////////////////////////////////////////////////////
88 // Function: PGScrollFrame::set_manage_pieces
89 // Access: Published
90 // Description: Sets the manage_pieces flag. When this is true, the
91 // sub-pieces of the scroll frame--that is, the two
92 // scroll bars--are automatically positioned and/or
93 // resized when the scroll frame's overall frame is
94 // changed. They are also automatically resized to fill
95 // in the gap when one or the other is hidden.
96 ////////////////////////////////////////////////////////////////////
97 INLINE void PGScrollFrame::
98 set_manage_pieces(bool manage_pieces) {
99  LightReMutexHolder holder(_lock);
100  _manage_pieces = manage_pieces;
101  _needs_remanage = true;
102  _needs_recompute_clip = true;
103 }
104 
105 ////////////////////////////////////////////////////////////////////
106 // Function: PGScrollFrame::get_manage_pieces
107 // Access: Published
108 // Description: Returns the manage_pieces flag. See
109 // set_manage_pieces().
110 ////////////////////////////////////////////////////////////////////
111 INLINE bool PGScrollFrame::
113  LightReMutexHolder holder(_lock);
114  return _manage_pieces;
115 }
116 
117 ////////////////////////////////////////////////////////////////////
118 // Function: PGScrollFrame::set_auto_hide
119 // Access: Published
120 // Description: Sets the auto_hide flag. When this is true, the
121 // two scroll bars are automatically hidden if they are
122 // not needed (that is, if the virtual frame would fit
123 // within the clip frame without them), and they are
124 // automatically shown when they are needed.
125 //
126 // Setting this flag true forces the manage_pieces flag
127 // to also be set true.
128 ////////////////////////////////////////////////////////////////////
129 INLINE void PGScrollFrame::
130 set_auto_hide(bool auto_hide) {
131  LightReMutexHolder holder(_lock);
132  _auto_hide = auto_hide;
133  if (_auto_hide) {
134  set_manage_pieces(true);
135  _needs_remanage = true;
136  }
137 }
138 
139 ////////////////////////////////////////////////////////////////////
140 // Function: PGScrollFrame::get_auto_hide
141 // Access: Published
142 // Description: Returns the auto_hide flag. See
143 // set_auto_hide().
144 ////////////////////////////////////////////////////////////////////
145 INLINE bool PGScrollFrame::
146 get_auto_hide() const {
147  LightReMutexHolder holder(_lock);
148  return _auto_hide;
149 }
150 
151 ////////////////////////////////////////////////////////////////////
152 // Function: PGScrollFrame::set_horizontal_slider
153 // Access: Published
154 // Description: Sets the PGSliderBar object that will serve as the
155 // horizontal scroll bar for this frame. It is your
156 // responsibility to parent this slider bar to the frame
157 // and move it to the appropriate place.
158 ////////////////////////////////////////////////////////////////////
159 INLINE void PGScrollFrame::
160 set_horizontal_slider(PGSliderBar *horizontal_slider) {
161  LightReMutexHolder holder(_lock);
162  if (_horizontal_slider != (PGSliderBar *)NULL) {
163  _horizontal_slider->set_notify(NULL);
164  }
165  _horizontal_slider = horizontal_slider;
166  if (_horizontal_slider != (PGSliderBar *)NULL) {
167  _horizontal_slider->set_notify(this);
168  }
169  _needs_recompute_clip = true;
170 }
171 
172 ////////////////////////////////////////////////////////////////////
173 // Function: PGScrollFrame::clear_horizontal_slider
174 // Access: Published
175 // Description: Removes the horizontal scroll bar from control of the
176 // frame. It is your responsibility to actually remove
177 // or hide the object itself.
178 ////////////////////////////////////////////////////////////////////
179 INLINE void PGScrollFrame::
181  set_horizontal_slider(NULL);
182 }
183 
184 ////////////////////////////////////////////////////////////////////
185 // Function: PGScrollFrame::get_horizontal_slider
186 // Access: Published
187 // Description: Returns the PGSliderBar that serves as the horizontal
188 // scroll bar for this frame, if any, or NULL if it is
189 // not set.
190 ////////////////////////////////////////////////////////////////////
193  LightReMutexHolder holder(_lock);
194  return _horizontal_slider;
195 }
196 
197 ////////////////////////////////////////////////////////////////////
198 // Function: PGScrollFrame::set_vertical_slider
199 // Access: Published
200 // Description: Sets the PGSliderBar object that will serve as the
201 // vertical scroll bar for this frame. It is your
202 // responsibility to parent this slider bar to the frame
203 // and move it to the appropriate place.
204 ////////////////////////////////////////////////////////////////////
205 INLINE void PGScrollFrame::
206 set_vertical_slider(PGSliderBar *vertical_slider) {
207  LightReMutexHolder holder(_lock);
208  if (_vertical_slider != (PGSliderBar *)NULL) {
209  _vertical_slider->set_notify(NULL);
210  }
211  _vertical_slider = vertical_slider;
212  if (_vertical_slider != (PGSliderBar *)NULL) {
213  _vertical_slider->set_notify(this);
214  }
215  _needs_recompute_clip = true;
216 }
217 
218 ////////////////////////////////////////////////////////////////////
219 // Function: PGScrollFrame::clear_vertical_slider
220 // Access: Published
221 // Description: Removes the vertical scroll bar from control of the
222 // frame. It is your responsibility to actually remove
223 // or hide the object itself.
224 ////////////////////////////////////////////////////////////////////
225 INLINE void PGScrollFrame::
227  set_vertical_slider(NULL);
228 }
229 
230 ////////////////////////////////////////////////////////////////////
231 // Function: PGScrollFrame::get_vertical_slider
232 // Access: Published
233 // Description: Returns the PGSliderBar that serves as the vertical
234 // scroll bar for this frame, if any, or NULL if it is
235 // not set.
236 ////////////////////////////////////////////////////////////////////
239  LightReMutexHolder holder(_lock);
240  return _vertical_slider;
241 }
242 
243 ////////////////////////////////////////////////////////////////////
244 // Function: PGScrollFrame::recompute
245 // Access: Published
246 // Description: Forces the PGScrollFrame to recompute itself right
247 // now. Normally this should not be required.
248 ////////////////////////////////////////////////////////////////////
249 INLINE void PGScrollFrame::
251  LightReMutexHolder holder(_lock);
252  recompute_clip();
253  recompute_canvas();
254 }
void recompute()
Forces the PGScrollFrame to recompute itself right now.
PGSliderBar * get_horizontal_slider() const
Returns the PGSliderBar that serves as the horizontal scroll bar for this frame, if any...
void clear_virtual_frame()
Removes the virtual frame from the item.
Definition: pgScrollFrame.I:82
void clear_vertical_slider()
Removes the vertical scroll bar from control of the frame.
void clear_horizontal_slider()
Removes the horizontal scroll bar from control of the frame.
bool has_virtual_frame() const
Returns true if the virtual frame has a bounding rectangle; see set_virtual_frame().
Definition: pgScrollFrame.I:68
PGSliderBar * get_vertical_slider() const
Returns the PGSliderBar that serves as the vertical scroll bar for this frame, if any...
void set_manage_pieces(bool manage_pieces)
Sets the manage_pieces flag.
Definition: pgScrollFrame.I:98
const LVecBase4 & get_clip_frame() const
Returns the bounding rectangle of the clip frame.
void set_vertical_slider(PGSliderBar *vertical_slider)
Sets the PGSliderBar object that will serve as the vertical scroll bar for this frame.
bool get_manage_pieces() const
Returns the manage_pieces flag.
void set_notify(PGSliderBarNotify *notify)
Sets the object which will be notified when the PGSliderBar changes.
Definition: pgSliderBar.I:26
Similar to MutexHolder, but for a light reentrant mutex.
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
void set_auto_hide(bool auto_hide)
Sets the auto_hide flag.
void set_virtual_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top)
Sets the bounding rectangle of the virtual frame.
Definition: pgScrollFrame.I:24
const LVecBase4 & get_virtual_frame() const
Returns the bounding rectangle of the virtual frame.
Definition: pgScrollFrame.I:55
bool get_auto_hide() const
Returns the auto_hide flag.
void set_horizontal_slider(PGSliderBar *horizontal_slider)
Sets the PGSliderBar object that will serve as the horizontal scroll bar for this frame...
This is a particular kind of PGItem that draws a little bar with a slider that moves from left to rig...
Definition: pgSliderBar.h:34