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