Panda3D

pgVirtualFrame.h

00001 // Filename: pgVirtualFrame.h
00002 // Created by:  drose (17Aug05)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef PGVIRTUALFRAME_H
00016 #define PGVIRTUALFRAME_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "pgItem.h"
00021 #include "modelNode.h"
00022 
00023 class TransformState;
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : PGVirtualFrame
00027 // Description : This represents a frame that is rendered as a window
00028 //               onto another (possibly much larger) canvas.  You can
00029 //               only see the portion of the canvas that is below the
00030 //               window at any given time.
00031 //
00032 //               This works simply by automatically defining a scissor
00033 //               effect to be applied to a special child node, called
00034 //               the canvas_node, of the PGVirtualFrame node.  Every
00035 //               object that is parented to the canvas_node will be
00036 //               clipped by the scissor effect.  Also, you can modify
00037 //               the canvas_transform through convenience methods
00038 //               here, which actually modifies the transform on the
00039 //               canvas_node.
00040 //
00041 //               The net effect is that the virtual canvas is
00042 //               arbitrarily large, and we can peek at it through the
00043 //               scissor region, and scroll through different parts of
00044 //               it by modifying the canvas_transform.
00045 //
00046 //               See PGScrollFrame for a specialization of this class
00047 //               that handles the traditional scrolling canvas, with
00048 //               scroll bars.
00049 ////////////////////////////////////////////////////////////////////
00050 class EXPCL_PANDA_PGUI PGVirtualFrame : public PGItem {
00051 PUBLISHED:
00052   PGVirtualFrame(const string &name = "");
00053   virtual ~PGVirtualFrame();
00054 
00055 protected:
00056   PGVirtualFrame(const PGVirtualFrame &copy);
00057   virtual PandaNode *make_copy() const;
00058   virtual void r_copy_children(const PandaNode *from, InstanceMap &inst_map,
00059                                Thread *current_thread);
00060 
00061 PUBLISHED:
00062   void setup(PN_stdfloat width, PN_stdfloat height);
00063 
00064   INLINE void set_clip_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top);
00065   void set_clip_frame(const LVecBase4 &clip_frame);
00066   INLINE const LVecBase4 &get_clip_frame() const;
00067   INLINE bool has_clip_frame() const;
00068   void clear_clip_frame();
00069 
00070   INLINE void set_canvas_transform(const TransformState *transform);
00071   INLINE const TransformState *get_canvas_transform() const;
00072 
00073   INLINE PandaNode *get_canvas_node() const;
00074   INLINE PandaNode *get_canvas_parent() const;
00075 
00076 protected:
00077   virtual void clip_frame_changed();
00078 
00079 private:
00080   void setup_child_nodes();
00081 
00082 private:
00083   bool _has_clip_frame;
00084   LVecBase4 _clip_frame;
00085 
00086   PT(ModelNode) _canvas_node;
00087   PT(ModelNode) _canvas_parent;
00088 
00089 public:
00090   static TypeHandle get_class_type() {
00091     return _type_handle;
00092   }
00093   static void init_type() {
00094     PGItem::init_type();
00095     register_type(_type_handle, "PGVirtualFrame",
00096                   PGItem::get_class_type());
00097   }
00098   virtual TypeHandle get_type() const {
00099     return get_class_type();
00100   }
00101   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00102 
00103 private:
00104   static TypeHandle _type_handle;
00105 };
00106 
00107 #include "pgVirtualFrame.I"
00108 
00109 #endif
 All Classes Functions Variables Enumerations