15 #include "pgVirtualFrame.h"
16 #include "scissorEffect.h"
17 #include "sceneGraphReducer.h"
27 PGVirtualFrame(
const string &name) :
PGItem(name)
29 _has_clip_frame =
false;
30 _clip_frame.set(0.0f, 0.0f, 0.0f, 0.0f);
52 _has_clip_frame(copy._has_clip_frame),
53 _clip_frame(copy._clip_frame)
58 if (_has_clip_frame) {
59 set_clip_frame(_clip_frame);
98 PandaNode::r_copy_children(from, inst_map, current_thread);
105 InstanceMap::const_iterator ci;
106 ci = inst_map.find(from_canvas_node);
107 if (ci != inst_map.end()) {
109 _canvas_node = DCAST(
ModelNode, (*ci).second);
112 ci = inst_map.find(from_canvas_parent);
113 if (ci != inst_map.end()) {
115 _canvas_parent = DCAST(
ModelNode, (*ci).second);
119 if (_has_clip_frame) {
133 setup(PN_stdfloat width, PN_stdfloat height) {
140 PN_stdfloat bevel = 0.05f;
146 style.
set_type(PGFrameStyle::T_bevel_out);
150 bevel, height - 2 * bevel);
166 if (!_has_clip_frame || _clip_frame != frame) {
167 _has_clip_frame =
true;
170 CPT(
RenderEffect) scissor_effect = ScissorEffect::make_node
171 (
LPoint3(_clip_frame[0], _clip_frame[2], _clip_frame[2]),
172 LPoint3(_clip_frame[1], _clip_frame[2], _clip_frame[2]),
173 LPoint3(_clip_frame[1], _clip_frame[3], _clip_frame[3]),
174 LPoint3(_clip_frame[0], _clip_frame[3], _clip_frame[3]));
176 _canvas_parent->set_effect(scissor_effect);
177 clip_frame_changed();
190 if (_has_clip_frame) {
191 _has_clip_frame =
false;
193 _canvas_parent->clear_effect(ScissorEffect::get_class_type());
194 clip_frame_changed();
203 void PGVirtualFrame::
204 clip_frame_changed() {
213 void PGVirtualFrame::
214 setup_child_nodes() {
215 _canvas_parent =
new ModelNode(
"canvas_parent");
216 _canvas_parent->set_preserve_transform(ModelNode::PT_local);
220 _canvas_node->set_preserve_transform(ModelNode::PT_local);
221 _canvas_parent->add_child(_canvas_node);
A basic node of the scene graph or data graph.
void set_width(PN_stdfloat x, PN_stdfloat y)
Sets the width parameter, which has meaning only for certain frame types.
void remove_child(int child_index, Thread *current_thread=Thread::get_current_thread())
Removes the nth child from the node.
This is our own Panda specialization on the default STL map.
This is the base class for all the various kinds of gui widget objects.
This represents a frame that is rendered as a window onto another (possibly much larger) canvas...
void set_clip_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top)
Sets the bounding rectangle of the clip frame.
void set_type(Type type)
Sets the basic type of frame.
void set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top)
Sets the bounding rectangle of the item, in local coordinates.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
This is the base class for a number of special render effects that may be set on scene graph nodes to...
PandaNode * get_canvas_parent() const
Returns the parent node of the canvas_node.
void set_frame_style(int state, const PGFrameStyle &style)
Changes the kind of frame that will be drawn behind the item when it is in the indicated state...
This node is placed at key points within the scene graph to indicate the roots of "models": subtrees ...
void clear_clip_frame()
Removes the clip frame from the item.
void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a)
Sets the dominant color of the frame.
void setup(PN_stdfloat width, PN_stdfloat height)
Creates a PGVirtualFrame with the indicated dimensions.
Similar to MutexHolder, but for a light reentrant mutex.
This is the base class for all three-component vectors and points.
void set_state(int state)
Sets the "state" of this particular PGItem.
PandaNode * get_canvas_node() const
Returns the special node that holds all of the children that appear in the virtual canvas...
A thread; that is, a lightweight process.
void clear_state_def(int state)
Resets the NodePath assigned to the indicated state to its initial default, with only a frame represe...
TypeHandle is the identifier used to differentiate C++ class types.
void add_child(PandaNode *child_node, int sort=0, Thread *current_thread=Thread::get_current_thread())
Adds a new child to the node.