Panda3D
 All Classes Functions Variables Enumerations
pgVirtualFrame.h
1 // Filename: pgVirtualFrame.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 PGVIRTUALFRAME_H
16 #define PGVIRTUALFRAME_H
17 
18 #include "pandabase.h"
19 
20 #include "pgItem.h"
21 #include "modelNode.h"
22 
23 class TransformState;
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : PGVirtualFrame
27 // Description : This represents a frame that is rendered as a window
28 // onto another (possibly much larger) canvas. You can
29 // only see the portion of the canvas that is below the
30 // window at any given time.
31 //
32 // This works simply by automatically defining a scissor
33 // effect to be applied to a special child node, called
34 // the canvas_node, of the PGVirtualFrame node. Every
35 // object that is parented to the canvas_node will be
36 // clipped by the scissor effect. Also, you can modify
37 // the canvas_transform through convenience methods
38 // here, which actually modifies the transform on the
39 // canvas_node.
40 //
41 // The net effect is that the virtual canvas is
42 // arbitrarily large, and we can peek at it through the
43 // scissor region, and scroll through different parts of
44 // it by modifying the canvas_transform.
45 //
46 // See PGScrollFrame for a specialization of this class
47 // that handles the traditional scrolling canvas, with
48 // scroll bars.
49 ////////////////////////////////////////////////////////////////////
50 class EXPCL_PANDA_PGUI PGVirtualFrame : public PGItem {
51 PUBLISHED:
52  PGVirtualFrame(const string &name = "");
53  virtual ~PGVirtualFrame();
54 
55 protected:
56  PGVirtualFrame(const PGVirtualFrame &copy);
57  virtual PandaNode *make_copy() const;
58  virtual void r_copy_children(const PandaNode *from, InstanceMap &inst_map,
59  Thread *current_thread);
60 
61 PUBLISHED:
62  void setup(PN_stdfloat width, PN_stdfloat height);
63 
64  INLINE void set_clip_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top);
65  void set_clip_frame(const LVecBase4 &clip_frame);
66  INLINE const LVecBase4 &get_clip_frame() const;
67  INLINE bool has_clip_frame() const;
68  void clear_clip_frame();
69 
70  INLINE void set_canvas_transform(const TransformState *transform);
71  INLINE const TransformState *get_canvas_transform() const;
72 
73  INLINE PandaNode *get_canvas_node() const;
74  INLINE PandaNode *get_canvas_parent() const;
75 
76 protected:
77  virtual void clip_frame_changed();
78 
79 private:
80  void setup_child_nodes();
81 
82 private:
83  bool _has_clip_frame;
84  LVecBase4 _clip_frame;
85 
86  PT(ModelNode) _canvas_node;
87  PT(ModelNode) _canvas_parent;
88 
89 public:
90  static TypeHandle get_class_type() {
91  return _type_handle;
92  }
93  static void init_type() {
94  PGItem::init_type();
95  register_type(_type_handle, "PGVirtualFrame",
96  PGItem::get_class_type());
97  }
98  virtual TypeHandle get_type() const {
99  return get_class_type();
100  }
101  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
102 
103 private:
104  static TypeHandle _type_handle;
105 };
106 
107 #include "pgVirtualFrame.I"
108 
109 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
This is our own Panda specialization on the default STL map.
Definition: pmap.h:52
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 node is placed at key points within the scene graph to indicate the roots of "models": subtrees ...
Definition: modelNode.h:34
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
A thread; that is, a lightweight process.
Definition: thread.h:51
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85