Panda3D
 All Classes Functions Variables Enumerations
pgScrollFrame.h
1 // Filename: pgScrollFrame.h
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 #ifndef PGSCROLLFRAME_H
16 #define PGSCROLLFRAME_H
17 
18 #include "pandabase.h"
19 
20 #include "pgVirtualFrame.h"
21 #include "pgSliderBarNotify.h"
22 #include "pgSliderBar.h"
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : PGScrollFrame
26 // Description : This is a special kind of frame that pretends to be
27 // much larger than it actually is. You can scroll
28 // through the frame, as if you're looking through a
29 // window at the larger frame beneath. All children of
30 // this frame node are scrolled and clipped as if they
31 // were children of the larger, virtual frame.
32 //
33 // This is implemented as a specialization of
34 // PGVirtualFrame, which handles the meat of the virtual
35 // canvas. This class adds automatic support for scroll
36 // bars, and restricts the virtual transform to
37 // translate only (no scale or rotate).
38 ////////////////////////////////////////////////////////////////////
39 class EXPCL_PANDA_PGUI PGScrollFrame : public PGVirtualFrame, public PGSliderBarNotify {
40 PUBLISHED:
41  PGScrollFrame(const string &name = "");
42  virtual ~PGScrollFrame();
43 
44 protected:
45  PGScrollFrame(const PGScrollFrame &copy);
46 
47 public:
48  virtual PandaNode *make_copy() const;
49  virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
50  virtual void xform(const LMatrix4 &mat);
51 
52 PUBLISHED:
53  void setup(PN_stdfloat width, PN_stdfloat height,
54  PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top,
55  PN_stdfloat slider_width, PN_stdfloat bevel);
56 
57  INLINE void set_virtual_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top);
58  INLINE void set_virtual_frame(const LVecBase4 &virtual_frame);
59  INLINE const LVecBase4 &get_virtual_frame() const;
60  INLINE bool has_virtual_frame() const;
61  INLINE void clear_virtual_frame();
62 
63  INLINE void set_manage_pieces(bool manage_pieces);
64  INLINE bool get_manage_pieces() const;
65 
66  INLINE void set_auto_hide(bool auto_hide);
67  INLINE bool get_auto_hide() const;
68 
69  INLINE void set_horizontal_slider(PGSliderBar *horizontal_slider);
70  INLINE void clear_horizontal_slider();
71  INLINE PGSliderBar *get_horizontal_slider() const;
72 
73  INLINE void set_vertical_slider(PGSliderBar *vertical_slider);
74  INLINE void clear_vertical_slider();
75  INLINE PGSliderBar *get_vertical_slider() const;
76 
77  void remanage();
78  INLINE void recompute();
79 
80 protected:
81  virtual void frame_changed();
82 
83  virtual void item_transform_changed(PGItem *item);
84  virtual void item_frame_changed(PGItem *item);
85  virtual void item_draw_mask_changed(PGItem *item);
86  virtual void slider_bar_adjust(PGSliderBar *slider_bar);
87 
88 private:
89  void recompute_clip();
90 
91  void recompute_canvas();
92  PN_stdfloat interpolate_canvas(PN_stdfloat clip_min, PN_stdfloat clip_max,
93  PN_stdfloat canvas_min, PN_stdfloat canvas_max,
94  PGSliderBar *slider_bar);
95 
96 private:
97  bool _needs_remanage;
98  bool _needs_recompute_clip;
99  bool _needs_recompute_canvas;
100 
101  LVecBase4 _orig_clip_frame;
102 
103  bool _has_virtual_frame;
104  LVecBase4 _virtual_frame;
105 
106  bool _manage_pieces;
107  bool _auto_hide;
108 
109  PT(PGSliderBar) _horizontal_slider;
110  PT(PGSliderBar) _vertical_slider;
111 
112 public:
113  static TypeHandle get_class_type() {
114  return _type_handle;
115  }
116  static void init_type() {
117  PGVirtualFrame::init_type();
118  register_type(_type_handle, "PGScrollFrame",
119  PGVirtualFrame::get_class_type());
120  }
121  virtual TypeHandle get_type() const {
122  return get_class_type();
123  }
124  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
125 
126 private:
127  static TypeHandle _type_handle;
128 };
129 
130 #include "pgScrollFrame.I"
131 
132 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this node by the indicated matrix, if it means anything to do so...
Definition: pgItem.cxx:386
This is the base class for all the various kinds of gui widget objects.
Definition: pgItem.h:58
This represents a frame that is rendered as a window onto another (possibly much larger) canvas...
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
void setup(PN_stdfloat width, PN_stdfloat height)
Creates a PGVirtualFrame with the indicated dimensions.
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
Objects that inherit from this class can receive notify messages when a slider bar moves or otherwise...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This is a special kind of frame that pretends to be much larger than it actually is.
Definition: pgScrollFrame.h:39
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
Definition: cullTraverser.h:48
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