Panda3D

pgScrollFrame.I

00001 // Filename: pgScrollFrame.I
00002 // Created by:  drose (17Aug05)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: PGScrollFrame::set_virtual_frame
00018 //       Access: Published
00019 //  Description: Sets the bounding rectangle of the virtual frame.
00020 //               This is the size of the large, virtual canvas which
00021 //               we can see only a portion of at any given time.
00022 ////////////////////////////////////////////////////////////////////
00023 INLINE void PGScrollFrame::
00024 set_virtual_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) {
00025   set_virtual_frame(LVecBase4(left, right, bottom, top));
00026 }
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //     Function: PGScrollFrame::set_virtual_frame
00030 //       Access: Published
00031 //  Description: Sets the bounding rectangle of the virtual frame.
00032 //               This is the size of the large, virtual canvas which
00033 //               we can see only a portion of at any given time.
00034 ////////////////////////////////////////////////////////////////////
00035 INLINE void PGScrollFrame::
00036 set_virtual_frame(const LVecBase4 &frame) {
00037   LightReMutexHolder holder(_lock);
00038   _has_virtual_frame = true;
00039   _virtual_frame = frame;
00040 
00041   if (_auto_hide) {
00042     _needs_remanage = true;
00043   }
00044   _needs_recompute_clip = true;
00045 }
00046 
00047 ////////////////////////////////////////////////////////////////////
00048 //     Function: PGScrollFrame::get_virtual_frame
00049 //       Access: Published
00050 //  Description: Returns the bounding rectangle of the virtual frame.
00051 //               See set_virtual_frame().  If has_virtual_frame() is
00052 //               false, this returns the item's clip frame.
00053 ////////////////////////////////////////////////////////////////////
00054 INLINE const LVecBase4 &PGScrollFrame::
00055 get_virtual_frame() const {
00056   LightReMutexHolder holder(_lock);
00057   return _has_virtual_frame ? _virtual_frame : get_clip_frame();
00058 }
00059 
00060 ////////////////////////////////////////////////////////////////////
00061 //     Function: PGScrollFrame::has_virtual_frame
00062 //       Access: Published
00063 //  Description: Returns true if the virtual frame has a bounding
00064 //               rectangle; see set_virtual_frame().  Most
00065 //               PGScrollFrame objects will have a virtual frame.
00066 ////////////////////////////////////////////////////////////////////
00067 INLINE bool PGScrollFrame::
00068 has_virtual_frame() const {
00069   LightReMutexHolder holder(_lock);
00070   return _has_virtual_frame;
00071 }
00072 
00073 ////////////////////////////////////////////////////////////////////
00074 //     Function: PGScrollFrame::clear_virtual_frame
00075 //       Access: Published
00076 //  Description: Removes the virtual frame from the item.  This
00077 //               effectively sets the virtual frame to the same size
00078 //               as the clip frame.  Scrolling will no longer be
00079 //               possible.
00080 ////////////////////////////////////////////////////////////////////
00081 INLINE void PGScrollFrame::
00082 clear_virtual_frame() {
00083   LightReMutexHolder holder(_lock);
00084   _has_virtual_frame = false;
00085 }
00086 
00087 ////////////////////////////////////////////////////////////////////
00088 //     Function: PGScrollFrame::set_manage_pieces
00089 //       Access: Published
00090 //  Description: Sets the manage_pieces flag.  When this is true, the
00091 //               sub-pieces of the scroll frame--that is, the two
00092 //               scroll bars--are automatically positioned and/or
00093 //               resized when the scroll frame's overall frame is
00094 //               changed.  They are also automatically resized to fill
00095 //               in the gap when one or the other is hidden.
00096 ////////////////////////////////////////////////////////////////////
00097 INLINE void PGScrollFrame:: 
00098 set_manage_pieces(bool manage_pieces) {
00099   LightReMutexHolder holder(_lock);
00100   _manage_pieces = manage_pieces;
00101   _needs_remanage = true;
00102   _needs_recompute_clip = true;
00103 }
00104 
00105 ////////////////////////////////////////////////////////////////////
00106 //     Function: PGScrollFrame::get_manage_pieces
00107 //       Access: Published
00108 //  Description: Returns the manage_pieces flag.  See
00109 //               set_manage_pieces().
00110 ////////////////////////////////////////////////////////////////////
00111 INLINE bool PGScrollFrame:: 
00112 get_manage_pieces() const {
00113   LightReMutexHolder holder(_lock);
00114   return _manage_pieces;
00115 }
00116 
00117 ////////////////////////////////////////////////////////////////////
00118 //     Function: PGScrollFrame::set_auto_hide
00119 //       Access: Published
00120 //  Description: Sets the auto_hide flag.  When this is true, the
00121 //               two scroll bars are automatically hidden if they are
00122 //               not needed (that is, if the virtual frame would fit
00123 //               within the clip frame without them), and they are
00124 //               automatically shown when they are needed.
00125 //
00126 //               Setting this flag true forces the manage_pieces flag
00127 //               to also be set true.
00128 ////////////////////////////////////////////////////////////////////
00129 INLINE void PGScrollFrame:: 
00130 set_auto_hide(bool auto_hide) {
00131   LightReMutexHolder holder(_lock);
00132   _auto_hide = auto_hide;
00133   if (_auto_hide) {
00134     set_manage_pieces(true);
00135     _needs_remanage = true;
00136   }
00137 }
00138 
00139 ////////////////////////////////////////////////////////////////////
00140 //     Function: PGScrollFrame::get_auto_hide
00141 //       Access: Published
00142 //  Description: Returns the auto_hide flag.  See
00143 //               set_auto_hide().
00144 ////////////////////////////////////////////////////////////////////
00145 INLINE bool PGScrollFrame:: 
00146 get_auto_hide() const {
00147   LightReMutexHolder holder(_lock);
00148   return _auto_hide;
00149 }
00150 
00151 ////////////////////////////////////////////////////////////////////
00152 //     Function: PGScrollFrame::set_horizontal_slider
00153 //       Access: Published
00154 //  Description: Sets the PGSliderBar object that will serve as the
00155 //               horizontal scroll bar for this frame.  It is your
00156 //               responsibility to parent this slider bar to the frame
00157 //               and move it to the appropriate place.
00158 ////////////////////////////////////////////////////////////////////
00159 INLINE void PGScrollFrame::
00160 set_horizontal_slider(PGSliderBar *horizontal_slider) {
00161   LightReMutexHolder holder(_lock);
00162   if (_horizontal_slider != (PGSliderBar *)NULL) {
00163     _horizontal_slider->set_notify(NULL);
00164   }
00165   _horizontal_slider = horizontal_slider;
00166   if (_horizontal_slider != (PGSliderBar *)NULL) {
00167     _horizontal_slider->set_notify(this);
00168   }
00169   _needs_recompute_clip = true;
00170 }
00171 
00172 ////////////////////////////////////////////////////////////////////
00173 //     Function: PGScrollFrame::clear_horizontal_slider
00174 //       Access: Published
00175 //  Description: Removes the horizontal scroll bar from control of the
00176 //               frame.  It is your responsibility to actually remove
00177 //               or hide the object itself.
00178 ////////////////////////////////////////////////////////////////////
00179 INLINE void PGScrollFrame::
00180 clear_horizontal_slider() {
00181   set_horizontal_slider(NULL);
00182 }
00183 
00184 ////////////////////////////////////////////////////////////////////
00185 //     Function: PGScrollFrame::get_horizontal_slider
00186 //       Access: Published
00187 //  Description: Returns the PGSliderBar that serves as the horizontal
00188 //               scroll bar for this frame, if any, or NULL if it is
00189 //               not set.
00190 ////////////////////////////////////////////////////////////////////
00191 INLINE PGSliderBar *PGScrollFrame::
00192 get_horizontal_slider() const {
00193   LightReMutexHolder holder(_lock);
00194   return _horizontal_slider;
00195 }
00196 
00197 ////////////////////////////////////////////////////////////////////
00198 //     Function: PGScrollFrame::set_vertical_slider
00199 //       Access: Published
00200 //  Description: Sets the PGSliderBar object that will serve as the
00201 //               vertical scroll bar for this frame.  It is your
00202 //               responsibility to parent this slider bar to the frame
00203 //               and move it to the appropriate place.
00204 ////////////////////////////////////////////////////////////////////
00205 INLINE void PGScrollFrame::
00206 set_vertical_slider(PGSliderBar *vertical_slider) {
00207   LightReMutexHolder holder(_lock);
00208   if (_vertical_slider != (PGSliderBar *)NULL) {
00209     _vertical_slider->set_notify(NULL);
00210   }
00211   _vertical_slider = vertical_slider;
00212   if (_vertical_slider != (PGSliderBar *)NULL) {
00213     _vertical_slider->set_notify(this);
00214   }
00215   _needs_recompute_clip = true;
00216 }
00217 
00218 ////////////////////////////////////////////////////////////////////
00219 //     Function: PGScrollFrame::clear_vertical_slider
00220 //       Access: Published
00221 //  Description: Removes the vertical scroll bar from control of the
00222 //               frame.  It is your responsibility to actually remove
00223 //               or hide the object itself.
00224 ////////////////////////////////////////////////////////////////////
00225 INLINE void PGScrollFrame::
00226 clear_vertical_slider() {
00227   set_vertical_slider(NULL);
00228 }
00229 
00230 ////////////////////////////////////////////////////////////////////
00231 //     Function: PGScrollFrame::get_vertical_slider
00232 //       Access: Published
00233 //  Description: Returns the PGSliderBar that serves as the vertical
00234 //               scroll bar for this frame, if any, or NULL if it is
00235 //               not set.
00236 ////////////////////////////////////////////////////////////////////
00237 INLINE PGSliderBar *PGScrollFrame::
00238 get_vertical_slider() const {
00239   LightReMutexHolder holder(_lock);
00240   return _vertical_slider;
00241 }
00242 
00243 ////////////////////////////////////////////////////////////////////
00244 //     Function: PGScrollFrame::recompute
00245 //       Access: Published
00246 //  Description: Forces the PGScrollFrame to recompute itself right
00247 //               now.  Normally this should not be required.
00248 ////////////////////////////////////////////////////////////////////
00249 INLINE void PGScrollFrame::
00250 recompute() {
00251   LightReMutexHolder holder(_lock);
00252   recompute_clip();
00253   recompute_canvas();
00254 }
 All Classes Functions Variables Enumerations