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