Panda3D
pgTop.h
1 // Filename: pgTop.h
2 // Created by: drose (13Mar02)
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 PGTOP_H
16 #define PGTOP_H
17 
18 #include "pandabase.h"
19 
20 #include "pgMouseWatcherGroup.h"
21 
22 #include "pandaNode.h"
23 #include "mouseWatcher.h"
24 #include "pointerTo.h"
25 
28 
29 ////////////////////////////////////////////////////////////////////
30 // Class : PGTop
31 // Description : The "top" node of the new Panda GUI system. This
32 // node must be parented to the 2-d scene graph, and all
33 // PG objects should be parented to this node or
34 // somewhere below it. PG objects not parented within
35 // this hierarchy will not be clickable.
36 //
37 // This node begins the special traversal of the PG
38 // objects that registers each node within the
39 // MouseWatcher and forces everything to render in a
40 // depth-first, left-to-right order, appropriate for 2-d
41 // objects.
42 ////////////////////////////////////////////////////////////////////
43 class EXPCL_PANDA_PGUI PGTop : public PandaNode {
44 PUBLISHED:
45  PGTop(const string &name);
46  virtual ~PGTop();
47 
48 protected:
49  INLINE PGTop(const PGTop &copy);
50 
51 public:
52  virtual PandaNode *make_copy() const;
53  virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
54  virtual bool is_renderable() const;
55 
56 PUBLISHED:
57  void set_mouse_watcher(MouseWatcher *watcher);
58  INLINE MouseWatcher *get_mouse_watcher() const;
59  INLINE MouseWatcherGroup *get_group() const;
60 
61  INLINE void set_start_sort(int start_sort);
62  INLINE int get_start_sort() const;
63 
64 public:
65  // These methods duplicate the functionality of MouseWatcherGroup.
66  INLINE void add_region(MouseWatcherRegion *region);
67  INLINE void clear_regions();
68 
69 private:
70  PT(MouseWatcher) _watcher;
71  PT(PGMouseWatcherGroup) _watcher_group;
72  int _start_sort;
73 
74 public:
75  static TypeHandle get_class_type() {
76  return _type_handle;
77  }
78  static void init_type() {
79  PandaNode::init_type();
80  register_type(_type_handle, "PGTop",
81  PandaNode::get_class_type());
82  }
83  virtual TypeHandle get_type() const {
84  return get_class_type();
85  }
86  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
87 
88 private:
89  static TypeHandle _type_handle;
90 
91  friend class PGMouseWatcherGroup;
92 };
93 
94 #include "pgTop.I"
95 
96 #endif
The "top" node of the new Panda GUI system.
Definition: pgTop.h:43
This TFormer maintains a list of rectangular regions on the screen that are considered special mouse ...
Definition: mouseWatcher.h:68
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
This represents a collection of MouseWatcherRegions that may be managed as a group.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This is a specialization on MouseWatcherGroup, to associate it with a PGTop.
This is the class that defines a rectangular region on the screen for the MouseWatcher.
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Definition: pandaNode.cxx:604
Encapsulates all the communication with a particular instance of a given rendering backend...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
virtual bool is_renderable() const
Returns true if there is some value to visiting this particular node during the cull traversal for an...
Definition: pandaNode.cxx:578
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
Definition: cullTraverser.h:48