Panda3D

Loading...
Searching...
No Matches
pgScrollFrame.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 pgScrollFrame.h
10 * @author drose
11 * @date 2005-08-17
12 */
13
14#ifndef PGSCROLLFRAME_H
15#define PGSCROLLFRAME_H
16
17#include "pandabase.h"
18
19#include "pgVirtualFrame.h"
20#include "pgSliderBarNotify.h"
21#include "pgSliderBar.h"
22
23#ifdef PHAVE_ATOMIC
24#include <atomic>
25#endif
26
27/**
28 * This is a special kind of frame that pretends to be much larger than it
29 * actually is. You can scroll through the frame, as if you're looking
30 * through a window at the larger frame beneath. All children of this frame
31 * node are scrolled and clipped as if they were children of the larger,
32 * virtual frame.
33 *
34 * This is implemented as a specialization of PGVirtualFrame, which handles
35 * the meat of the virtual canvas. This class adds automatic support for
36 * scroll bars, and restricts the virtual transform to translate only (no
37 * scale or rotate).
38 */
39 class EXPCL_PANDA_PGUI PGScrollFrame : public PGVirtualFrame, public PGSliderBarNotify {
40PUBLISHED:
41 explicit PGScrollFrame(const std::string &name = "");
42 virtual ~PGScrollFrame();
43
44 protected:
45 PGScrollFrame(const PGScrollFrame &copy);
46
47 public:
48 virtual PandaNode *make_copy() const;
49 virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
50 virtual void xform(const LMatrix4 &mat);
51
52PUBLISHED:
53 void setup(PN_stdfloat width, PN_stdfloat height,
54 PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top,
55 PN_stdfloat slider_width, PN_stdfloat bevel);
56
57 INLINE void set_virtual_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top);
58 INLINE void set_virtual_frame(const LVecBase4 &virtual_frame);
59 INLINE const LVecBase4 &get_virtual_frame() const;
60 INLINE bool has_virtual_frame() const;
61 INLINE void clear_virtual_frame();
62
63 INLINE void set_manage_pieces(bool manage_pieces);
64 INLINE bool get_manage_pieces() const;
65
66 INLINE void set_auto_hide(bool auto_hide);
67 INLINE bool get_auto_hide() const;
68
69 INLINE void set_horizontal_slider(PGSliderBar *horizontal_slider);
70 INLINE void clear_horizontal_slider();
71 INLINE PGSliderBar *get_horizontal_slider() const;
72
73 INLINE void set_vertical_slider(PGSliderBar *vertical_slider);
74 INLINE void clear_vertical_slider();
75 INLINE PGSliderBar *get_vertical_slider() const;
76
77 void remanage();
78 INLINE void recompute();
79
80 protected:
81 virtual void frame_changed();
82
83 virtual void item_transform_changed(PGItem *item);
84 virtual void item_frame_changed(PGItem *item);
85 virtual void item_draw_mask_changed(PGItem *item);
86 virtual void slider_bar_adjust(PGSliderBar *slider_bar);
87
88 private:
89 void recompute_clip();
90
91 void recompute_canvas();
92 PN_stdfloat interpolate_canvas(PN_stdfloat clip_min, PN_stdfloat clip_max,
93 PN_stdfloat canvas_min, PN_stdfloat canvas_max,
94 PGSliderBar *slider_bar);
95
96 private:
97 bool _needs_remanage;
98 bool _needs_recompute_clip;
99 std::atomic_flag _canvas_computed;
100
101 bool _has_virtual_frame;
102 LVecBase4 _virtual_frame;
103
104 bool _manage_pieces;
105 bool _auto_hide;
106
107 PT(PGSliderBar) _horizontal_slider;
108 PT(PGSliderBar) _vertical_slider;
109
110 public:
111 static TypeHandle get_class_type() {
112 return _type_handle;
113 }
114 static void init_type() {
115 PGVirtualFrame::init_type();
116 register_type(_type_handle, "PGScrollFrame",
117 PGVirtualFrame::get_class_type());
118 }
119 virtual TypeHandle get_type() const {
120 return get_class_type();
121 }
122 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
123
124 private:
125 static TypeHandle _type_handle;
126};
127
128#include "pgScrollFrame.I"
129
130#endif
CullTraverser
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
Definition cullTraverser.h:45
PGScrollFrame::set_manage_pieces
void set_manage_pieces(bool manage_pieces)
Sets the manage_pieces flag.
Definition pgScrollFrame.I:79
PGScrollFrame::make_copy
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
Definition pgScrollFrame.cxx:67
PGScrollFrame::xform
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this node by the indicated matrix, if it means anything to do so.
Definition pgScrollFrame.cxx:110
PGScrollFrame::set_virtual_frame
void set_virtual_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top)
Sets the bounding rectangle of the virtual frame.
Definition pgScrollFrame.I:19
PGScrollFrame::has_virtual_frame
bool has_virtual_frame() const
Returns true if the virtual frame has a bounding rectangle; see set_virtual_frame().
Definition pgScrollFrame.I:55
PGScrollFrame::get_virtual_frame
const LVecBase4 & get_virtual_frame() const
Returns the bounding rectangle of the virtual frame.
Definition pgScrollFrame.I:45
PGScrollFrame::get_vertical_slider
PGSliderBar * get_vertical_slider() const
Returns the PGSliderBar that serves as the vertical scroll bar for this frame, if any,...
Definition pgScrollFrame.I:191
PGScrollFrame::set_auto_hide
void set_auto_hide(bool auto_hide)
Sets the auto_hide flag.
Definition pgScrollFrame.I:104
PGScrollFrame::clear_horizontal_slider
void clear_horizontal_slider()
Removes the horizontal scroll bar from control of the frame.
Definition pgScrollFrame.I:145
PGScrollFrame::set_horizontal_slider
void set_horizontal_slider(PGSliderBar *horizontal_slider)
Sets the PGSliderBar object that will serve as the horizontal scroll bar for this frame.
Definition pgScrollFrame.I:128
PGScrollFrame::remanage
void remanage()
Manages the position and size of the scroll bars.
Definition pgScrollFrame.cxx:176
PGScrollFrame::recompute
void recompute()
Forces the PGScrollFrame to recompute itself right now.
Definition pgScrollFrame.I:201
PGScrollFrame::clear_virtual_frame
void clear_virtual_frame()
Removes the virtual frame from the item.
Definition pgScrollFrame.I:66
PGScrollFrame::cull_callback
virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data)
This function will be called during the cull traversal to perform any additional operations that shou...
Definition pgScrollFrame.cxx:91
PGScrollFrame::get_auto_hide
bool get_auto_hide() const
Returns the auto_hide flag.
Definition pgScrollFrame.I:117
PGScrollFrame::get_horizontal_slider
PGSliderBar * get_horizontal_slider() const
Returns the PGSliderBar that serves as the horizontal scroll bar for this frame, if any,...
Definition pgScrollFrame.I:154
PGScrollFrame::clear_vertical_slider
void clear_vertical_slider()
Removes the vertical scroll bar from control of the frame.
Definition pgScrollFrame.I:182
PGScrollFrame::set_vertical_slider
void set_vertical_slider(PGSliderBar *vertical_slider)
Sets the PGSliderBar object that will serve as the vertical scroll bar for this frame.
Definition pgScrollFrame.I:165
PGScrollFrame::get_manage_pieces
bool get_manage_pieces() const
Returns the manage_pieces flag.
Definition pgScrollFrame.I:90
PGVirtualFrame::setup
void setup(PN_stdfloat width, PN_stdfloat height)
Creates a PGVirtualFrame with the indicated dimensions.
Definition pgVirtualFrame.cxx:115
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pgScrollFrame.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pgSliderBarNotify.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pgSliderBar.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pgVirtualFrame.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
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