Panda3D
 All Classes Functions Variables Enumerations
mouseWatcherBase.h
1 // Filename: mouseWatcherBase.h
2 // Created by: rdb (13Jan14)
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 MOUSEWATCHERBASE_H
16 #define MOUSEWATCHERBASE_H
17 
18 #include "pandabase.h"
19 #include "mouseWatcherRegion.h"
20 
21 #include "pointerTo.h"
22 #include "pvector.h"
23 #include "nodePath.h"
24 #include "lightMutex.h"
25 
26 ////////////////////////////////////////////////////////////////////
27 // Class : MouseWatcherBase
28 // Description : This represents a collection of MouseWatcherRegions
29 // that may be managed as a group. This is the base
30 // class for both MouseWatcherGroup and MouseWatcher,
31 // and exists so that we don't have to make MouseWatcher
32 // inherit from ReferenceCount more than once.
33 ////////////////////////////////////////////////////////////////////
34 class EXPCL_PANDA_TFORM MouseWatcherBase {
35 public:
37  virtual ~MouseWatcherBase();
38 
39 PUBLISHED:
40  void add_region(MouseWatcherRegion *region);
41  bool has_region(MouseWatcherRegion *region) const;
42  bool remove_region(MouseWatcherRegion *region);
43  MouseWatcherRegion *find_region(const string &name) const;
44  void clear_regions();
45 
46  void sort_regions();
47  bool is_sorted() const;
48 
49  int get_num_regions() const;
50  MouseWatcherRegion *get_region(int n) const;
51  MAKE_SEQ(get_regions, get_num_regions, get_region);
52 
53  void output(ostream &out) const;
54  void write(ostream &out, int indent_level = 0) const;
55 
56 #ifndef NDEBUG
57  void show_regions(const NodePath &render2d,
58  const string &bin_name, int draw_order);
59  void set_color(const LColor &color);
60  void hide_regions();
61 
62  void update_regions();
63 #endif // NDEBUG
64 
65 protected:
66  void do_sort_regions();
67  bool do_remove_region(MouseWatcherRegion *region);
68 
69 #ifndef NDEBUG
70  virtual void do_show_regions(const NodePath &render2d,
71  const string &bin_name, int draw_order);
72  virtual void do_hide_regions();
73  void do_update_regions();
74 #endif // NDEBUG
75 
76 protected:
78  Regions _regions;
79  bool _sorted;
80 
81  // This mutex protects the above list of regions, as well as the
82  // below list of vizzes. It is also referenced directly by
83  // MouseWatcher, a derived class.
84  LightMutex _lock;
85 
86 private:
87 #ifndef NDEBUG
88  PandaNode *make_viz_region(MouseWatcherRegion *region);
89 
91  Vizzes _vizzes;
92 
93  bool _show_regions;
94  NodePath _show_regions_root;
95  LColor _color;
96 #endif // NDEBUG
97 
98 public:
99  static TypeHandle get_class_type() {
100  return _type_handle;
101  }
102  static void init_type() {
103  register_type(_type_handle, "MouseWatcherBase");
104  }
105 
106 private:
107  static TypeHandle _type_handle;
108 
109  friend class MouseWatcher;
110  friend class BlobWatcher;
111 };
112 
113 #endif
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 is the class that defines a rectangular region on the screen for the MouseWatcher.
This represents a collection of MouseWatcherRegions that may be managed as a group.
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This is a standard, non-reentrant mutex, similar to the Mutex class.
Definition: lightMutex.h:45
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165