Panda3D
|
This is a particular kind of PGItem that draws a little bar with a slider that moves from left to right indicating a value between the ranges. More...
#include "pgSliderBar.h"
Public Member Functions | |
PGSliderBar (const string &name="") | |
virtual void | adjust () |
This is a callback hook function, called whenever the slider value is adjusted by the user or programmatically. | |
void | clear_left_button () |
Removes the left button object from control of the frame. | |
void | clear_right_button () |
Removes the right button object from control of the frame. | |
void | clear_thumb_button () |
Removes the thumb button object from control of the frame. | |
virtual bool | cull_callback (CullTraverser *trav, CullTraverserData &data) |
This function will be called during the cull traversal to perform any additional operations that should be performed at cull time. | |
virtual TypeHandle | force_init_type () |
string | get_adjust_event () const |
Returns the event name that will be thrown when the slider bar value is adjusted by the user or programmatically. | |
const LVector3 & | get_axis () const |
Returns the axis of the slider bar's motion. | |
PGButton * | get_left_button () const |
Returns the PGButton that serves as the left scroll button for this slider, if any, or NULL if it is not set. | |
bool | get_manage_pieces () const |
Returns the manage_pieces flag. | |
PN_stdfloat | get_max_value () const |
Returns the value when the slider is all the way to the right. | |
PN_stdfloat | get_min_value () const |
Returns the value when the slider is all the way to the left. | |
PGSliderBarNotify * | get_notify () const |
Returns the object which will be notified when the PGSliderBar changes, if any. | |
PN_stdfloat | get_page_size () const |
Returns the value last set by set_page_size(). | |
PN_stdfloat | get_ratio () const |
Returns the current value of the slider, expressed in the range 0 . | |
bool | get_resize_thumb () const |
Returns the resize_thumb flag. | |
PGButton * | get_right_button () const |
Returns the PGButton that serves as the right scroll button for this slider, if any, or NULL if it is not set. | |
PN_stdfloat | get_scroll_size () const |
Returns the value last set by set_scroll_size(). | |
PGButton * | get_thumb_button () const |
Returns the PGButton that serves as the thumb for this slider, or NULL if it is not set. | |
virtual TypeHandle | get_type () const |
PN_stdfloat | get_value () const |
Returns the current value of the slider. | |
bool | is_button_down () const |
Returns true if the user is currently holding down the mouse button to manipulate the slider. | |
virtual PandaNode * | make_copy () const |
Returns a newly-allocated Node that is a shallow copy of this one. | |
virtual void | move (const MouseWatcherParameter ¶m) |
This is a callback hook function, called whenever a mouse is moved while within the region. | |
virtual void | press (const MouseWatcherParameter ¶m, bool background) |
This is a callback hook function, called whenever a mouse or keyboard button is depressed while the mouse is within the region. | |
void | recompute () |
Recomputes the position and size of the thumb. | |
virtual void | release (const MouseWatcherParameter ¶m, bool background) |
This is a callback hook function, called whenever a mouse or keyboard button previously depressed with press() is released. | |
void | remanage () |
Manages the position and size of the scroll bars and the thumb. | |
virtual void | set_active (bool active) |
Sets whether the PGItem is active for mouse watching. | |
void | set_axis (const LVector3 &axis) |
Specifies the axis of the slider bar's motion. | |
void | set_left_button (PGButton *left_button) |
Sets the PGButton object that will serve as the left scroll button for this slider. | |
void | set_manage_pieces (bool manage_pieces) |
Sets the manage_pieces flag. | |
void | set_notify (PGSliderBarNotify *notify) |
Sets the object which will be notified when the PGSliderBar changes. | |
void | set_page_size (PN_stdfloat page_size) |
Specifies the amount of data contained in a single page. | |
void | set_range (PN_stdfloat min_value, PN_stdfloat max_value) |
Sets the minimum and maxmimum value for the slider. | |
void | set_ratio (PN_stdfloat ratio) |
Sets the current value of the slider, expressed in the range 0 . | |
void | set_resize_thumb (bool resize_thumb) |
Sets the resize_thumb flag. | |
void | set_right_button (PGButton *right_button) |
Sets the PGButton object that will serve as the right scroll button for this slider. | |
void | set_scroll_size (PN_stdfloat scroll_size) |
Specifies the amount the slider will move when the user clicks on the left or right buttons. | |
void | set_thumb_button (PGButton *thumb_button) |
Sets the PGButton object that will serve as the thumb for this slider. | |
void | set_value (PN_stdfloat value) |
Sets the current value of the slider programmatically. | |
void | setup_scroll_bar (bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdfloat bevel) |
Creates PGSliderBar that represents a vertical or horizontal scroll bar (if vertical is true or false, respectively), with additional buttons for scrolling, and a range of 0 . | |
void | setup_slider (bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdfloat bevel) |
Creates PGSliderBar that represents a slider that the user can use to control an analog quantity. | |
virtual void | xform (const LMatrix4 &mat) |
Transforms the contents of this node by the indicated matrix, if it means anything to do so. | |
Static Public Member Functions | |
static string | get_adjust_prefix () |
Returns the prefix that is used to define the adjust event for all PGSliderBars. | |
static TypeHandle | get_class_type () |
static void | init_type () |
Protected Member Functions | |
PGSliderBar (const PGSliderBar ©) | |
virtual void | frame_changed () |
Called when the user changes the frame size. | |
virtual void | item_draw_mask_changed (PGItem *item) |
Called whenever a watched PGItem's draw_mask has been changed. | |
virtual void | item_frame_changed (PGItem *item) |
Called whenever a watched PGItem's frame has been changed. | |
virtual void | item_move (PGItem *item, const MouseWatcherParameter ¶m) |
Called whenever the "move" event is triggered on a watched PGItem. | |
virtual void | item_press (PGItem *item, const MouseWatcherParameter ¶m) |
Called whenever the "press" event is triggered on a watched PGItem. | |
virtual void | item_release (PGItem *item, const MouseWatcherParameter ¶m) |
Called whenever the "release" event is triggered on a watched PGItem. | |
virtual void | item_transform_changed (PGItem *item) |
Called whenever a watched PGItem's local transform has been changed. | |
Friends | |
class | PGButton |
This is a particular kind of PGItem that draws a little bar with a slider that moves from left to right indicating a value between the ranges.
This is used as an implementation for both DirectSlider and for DirectScrollBar.
Definition at line 34 of file pgSliderBar.h.
void PGSliderBar::adjust | ( | ) | [virtual] |
This is a callback hook function, called whenever the slider value is adjusted by the user or programmatically.
Definition at line 256 of file pgSliderBar.cxx.
References get_adjust_event(), get_notify(), PGItem::has_notify(), PGItem::play_sound(), and PGSliderBarNotify::slider_bar_adjust().
void PGSliderBar::clear_left_button | ( | ) | [inline] |
Removes the left button object from control of the frame.
It is your responsibility to actually remove or hide the button itself.
Definition at line 379 of file pgSliderBar.I.
References set_left_button().
void PGSliderBar::clear_right_button | ( | ) | [inline] |
Removes the right button object from control of the frame.
It is your responsibility to actually remove or hide the button itself.
Definition at line 430 of file pgSliderBar.I.
References set_right_button().
void PGSliderBar::clear_thumb_button | ( | ) | [inline] |
Removes the thumb button object from control of the frame.
It is your responsibility to actually remove or hide the button itself.
Definition at line 329 of file pgSliderBar.I.
References set_thumb_button().
bool PGSliderBar::cull_callback | ( | CullTraverser * | trav, |
CullTraverserData & | data | ||
) | [virtual] |
This function will be called during the cull traversal to perform any additional operations that should be performed at cull time.
This may include additional manipulation of render state or additional visible/invisible decisions, or any other arbitrary operation.
Note that this function will *not* be called unless set_cull_callback() is called in the constructor of the derived class. It is necessary to call set_cull_callback() to indicated that we require cull_callback() to be called.
By the time this function is called, the node has already passed the bounding-volume test for the viewing frustum, and the node's transform and state have already been applied to the indicated CullTraverserData object.
The return value is true if this node should be visible, or false if it should be culled.
Reimplemented from PGItem.
Definition at line 199 of file pgSliderBar.cxx.
References ClockObject::get_global_clock(), recompute(), and remanage().
void PGSliderBar::frame_changed | ( | ) | [protected, virtual] |
Called when the user changes the frame size.
Reimplemented from PGItem.
Definition at line 603 of file pgSliderBar.cxx.
string PGSliderBar::get_adjust_event | ( | ) | const [inline] |
Returns the event name that will be thrown when the slider bar value is adjusted by the user or programmatically.
Definition at line 467 of file pgSliderBar.I.
References get_adjust_prefix(), and PGItem::get_id().
Referenced by adjust().
string PGSliderBar::get_adjust_prefix | ( | ) | [inline, static] |
Returns the prefix that is used to define the adjust event for all PGSliderBars.
The adjust event is the concatenation of this string followed by get_id().
Definition at line 455 of file pgSliderBar.I.
Referenced by get_adjust_event().
const LVector3 & PGSliderBar::get_axis | ( | ) | const [inline] |
Returns the axis of the slider bar's motion.
See set_axis().
Definition at line 76 of file pgSliderBar.I.
PGButton * PGSliderBar::get_left_button | ( | ) | const [inline] |
Returns the PGButton that serves as the left scroll button for this slider, if any, or NULL if it is not set.
Definition at line 391 of file pgSliderBar.I.
bool PGSliderBar::get_manage_pieces | ( | ) | const [inline] |
Returns the manage_pieces flag.
See set_manage_pieces().
Definition at line 290 of file pgSliderBar.I.
PN_stdfloat PGSliderBar::get_max_value | ( | ) | const [inline] |
Returns the value when the slider is all the way to the right.
Definition at line 118 of file pgSliderBar.I.
PN_stdfloat PGSliderBar::get_min_value | ( | ) | const [inline] |
Returns the value when the slider is all the way to the left.
Definition at line 106 of file pgSliderBar.I.
PGSliderBarNotify * PGSliderBar::get_notify | ( | ) | const [inline] |
Returns the object which will be notified when the PGSliderBar changes, if any.
Returns NULL if there is no such object configured.
Reimplemented from PGItem.
Definition at line 38 of file pgSliderBar.I.
Referenced by adjust(), and set_range().
PN_stdfloat PGSliderBar::get_page_size | ( | ) | const [inline] |
Returns the value last set by set_page_size().
Definition at line 169 of file pgSliderBar.I.
PN_stdfloat PGSliderBar::get_ratio | ( | ) | const [inline] |
Returns the current value of the slider, expressed in the range 0 .
. 1.
Definition at line 219 of file pgSliderBar.I.
Referenced by get_value().
bool PGSliderBar::get_resize_thumb | ( | ) | const [inline] |
Returns the resize_thumb flag.
See set_resize_thumb().
Definition at line 261 of file pgSliderBar.I.
PGButton * PGSliderBar::get_right_button | ( | ) | const [inline] |
Returns the PGButton that serves as the right scroll button for this slider, if any, or NULL if it is not set.
Definition at line 442 of file pgSliderBar.I.
PN_stdfloat PGSliderBar::get_scroll_size | ( | ) | const [inline] |
Returns the value last set by set_scroll_size().
Definition at line 142 of file pgSliderBar.I.
PGButton * PGSliderBar::get_thumb_button | ( | ) | const [inline] |
Returns the PGButton that serves as the thumb for this slider, or NULL if it is not set.
Definition at line 340 of file pgSliderBar.I.
PN_stdfloat PGSliderBar::get_value | ( | ) | const [inline] |
Returns the current value of the slider.
Definition at line 193 of file pgSliderBar.I.
References get_ratio().
bool PGSliderBar::is_button_down | ( | ) | const [inline] |
Returns true if the user is currently holding down the mouse button to manipulate the slider.
When true, calls to set_ratio() or set_value() will have no effect.
Definition at line 233 of file pgSliderBar.I.
Referenced by set_ratio().
void PGSliderBar::item_draw_mask_changed | ( | PGItem * | item | ) | [protected, virtual] |
Called whenever a watched PGItem's draw_mask has been changed.
Reimplemented from PGItemNotify.
Definition at line 641 of file pgSliderBar.cxx.
void PGSliderBar::item_frame_changed | ( | PGItem * | item | ) | [protected, virtual] |
Called whenever a watched PGItem's frame has been changed.
Reimplemented from PGItemNotify.
Definition at line 629 of file pgSliderBar.cxx.
void PGSliderBar::item_move | ( | PGItem * | item, |
const MouseWatcherParameter & | param | ||
) | [protected, virtual] |
Called whenever the "move" event is triggered on a watched PGItem.
See PGItem::move().
Reimplemented from PGItemNotify.
Definition at line 698 of file pgSliderBar.cxx.
References MouseWatcherParameter::get_mouse().
void PGSliderBar::item_press | ( | PGItem * | item, |
const MouseWatcherParameter & | param | ||
) | [protected, virtual] |
Called whenever the "press" event is triggered on a watched PGItem.
See PGItem::press().
Reimplemented from PGItemNotify.
Definition at line 653 of file pgSliderBar.cxx.
References ClockObject::get_frame_time(), ClockObject::get_global_clock(), MouseWatcherParameter::get_mouse(), and MouseWatcherParameter::has_mouse().
void PGSliderBar::item_release | ( | PGItem * | item, |
const MouseWatcherParameter & | param | ||
) | [protected, virtual] |
Called whenever the "release" event is triggered on a watched PGItem.
See PGItem::release().
Reimplemented from PGItemNotify.
Definition at line 678 of file pgSliderBar.cxx.
void PGSliderBar::item_transform_changed | ( | PGItem * | item | ) | [protected, virtual] |
Called whenever a watched PGItem's local transform has been changed.
Reimplemented from PGItemNotify.
Definition at line 617 of file pgSliderBar.cxx.
PandaNode * PGSliderBar::make_copy | ( | ) | const [virtual] |
void PGSliderBar::move | ( | const MouseWatcherParameter & | param | ) | [virtual] |
This is a callback hook function, called whenever a mouse is moved while within the region.
Reimplemented from PGItem.
Definition at line 160 of file pgSliderBar.cxx.
References MouseWatcherParameter::get_mouse().
void PGSliderBar::press | ( | const MouseWatcherParameter & | param, |
bool | background | ||
) | [virtual] |
This is a callback hook function, called whenever a mouse or keyboard button is depressed while the mouse is within the region.
Reimplemented from PGItem.
Definition at line 113 of file pgSliderBar.cxx.
References PGItem::get_active(), MouseWatcherParameter::get_button(), ClockObject::get_frame_time(), ClockObject::get_global_clock(), MouseWatcherParameter::get_mouse(), MouseWatcherParameter::has_mouse(), MouseButton::one(), and recompute().
void PGSliderBar::recompute | ( | ) |
Recomputes the position and size of the thumb.
Normally this should not need to be called directly.
Definition at line 486 of file pgSliderBar.cxx.
References PGItem::get_frame(), PGItem::has_frame(), PGItem::reduce_region(), and LVector3f::rfu().
Referenced by cull_callback(), press(), and remanage().
void PGSliderBar::release | ( | const MouseWatcherParameter & | param, |
bool | background | ||
) | [virtual] |
This is a callback hook function, called whenever a mouse or keyboard button previously depressed with press() is released.
Reimplemented from PGItem.
Definition at line 142 of file pgSliderBar.cxx.
References MouseWatcherParameter::get_button(), and MouseButton::is_mouse_button().
void PGSliderBar::remanage | ( | ) |
Manages the position and size of the scroll bars and the thumb.
Normally this should not need to be called directly.
Definition at line 436 of file pgSliderBar.cxx.
References PGItem::get_frame(), recompute(), and LVector3f::rfu().
Referenced by cull_callback().
void PGSliderBar::set_active | ( | bool | active | ) | [virtual] |
Sets whether the PGItem is active for mouse watching.
This is not necessarily related to the active/inactive appearance of the item, which is controlled by set_state(), but it does affect whether it responds to mouse events.
Reimplemented from PGItem.
Definition at line 412 of file pgSliderBar.cxx.
void PGSliderBar::set_axis | ( | const LVector3 & | axis | ) | [inline] |
Specifies the axis of the slider bar's motion.
This should be only one of four vectors: (1, 0, 0), (0, 0, 1), (-1, 0, 0), or (0, 0, -1).
This specifies the vector in which the thumb moves when it is moving from the minimum to the maximum value.
The axis must be parallel to one of the screen axes, and it must be normalized. Hence, it may only be one of the above four possibilities; anything else is an error and will result in indeterminate behavior.
Normally, you should not try to set the axis directly.
Definition at line 62 of file pgSliderBar.I.
void PGSliderBar::set_left_button | ( | PGButton * | left_button | ) | [inline] |
Sets the PGButton object that will serve as the left scroll button for this slider.
This button is optional; if present, the user can click on it to move scroll_size units at a time to the left.
It is the responsibility of the caller to ensure that the button object is parented to the PGSliderBar node.
Definition at line 358 of file pgSliderBar.I.
References PGButton::set_notify().
Referenced by clear_left_button(), setup_scroll_bar(), and setup_slider().
void PGSliderBar::set_manage_pieces | ( | bool | manage_pieces | ) | [inline] |
Sets the manage_pieces flag.
When this is true, the sub-pieces of the slider bar--that is, the thumb, and the left and right scroll buttons--are automatically positioned and/or resized when the slider bar's overall frame is changed.
Definition at line 276 of file pgSliderBar.I.
Referenced by setup_scroll_bar(), and setup_slider().
void PGSliderBar::set_notify | ( | PGSliderBarNotify * | notify | ) | [inline] |
Sets the object which will be notified when the PGSliderBar changes.
Set this to NULL to disable this effect. The PGSliderBar does not retain ownership of the pointer; it is your responsibility to ensure that the notify object does not destruct.
Definition at line 26 of file pgSliderBar.I.
Referenced by PGScrollFrame::set_horizontal_slider(), and PGScrollFrame::set_vertical_slider().
void PGSliderBar::set_page_size | ( | PN_stdfloat | value | ) | [inline] |
Specifies the amount of data contained in a single page.
This indicates how much the thumb will jump when the trough is directly clicked; and if resize_thumb is true, it also controls the visible size of the thumb button.
Definition at line 157 of file pgSliderBar.I.
void PGSliderBar::set_range | ( | PN_stdfloat | min_value, |
PN_stdfloat | max_value | ||
) | [inline] |
Sets the minimum and maxmimum value for the slider.
Definition at line 87 of file pgSliderBar.I.
References get_notify(), PGItem::has_notify(), and PGSliderBarNotify::slider_bar_set_range().
void PGSliderBar::set_ratio | ( | PN_stdfloat | ratio | ) | [inline] |
Sets the current value of the slider, expressed in the range 0 .
. 1.
Definition at line 205 of file pgSliderBar.I.
References is_button_down().
Referenced by set_value().
void PGSliderBar::set_resize_thumb | ( | bool | resize_thumb | ) | [inline] |
Sets the resize_thumb flag.
When this is true, the thumb button's frame will be adjusted so that its width visually represents the page size. When this is false, the thumb button will be left alone.
Definition at line 248 of file pgSliderBar.I.
Referenced by setup_scroll_bar(), and setup_slider().
void PGSliderBar::set_right_button | ( | PGButton * | right_button | ) | [inline] |
Sets the PGButton object that will serve as the right scroll button for this slider.
This button is optional; if present, the user can click on it to move scroll_size units at a time to the right.
It is the responsibility of the caller to ensure that the button object is parented to the PGSliderBar node.
Definition at line 409 of file pgSliderBar.I.
References PGButton::set_notify().
Referenced by clear_right_button(), setup_scroll_bar(), and setup_slider().
void PGSliderBar::set_scroll_size | ( | PN_stdfloat | scroll_size | ) | [inline] |
Specifies the amount the slider will move when the user clicks on the left or right buttons.
Definition at line 130 of file pgSliderBar.I.
void PGSliderBar::set_thumb_button | ( | PGButton * | thumb_button | ) | [inline] |
Sets the PGButton object that will serve as the thumb for this slider.
This button visually represents the position of the slider, and can be dragged left and right by the user.
It is the responsibility of the caller to ensure that the button object is parented to the PGSliderBar node.
Definition at line 308 of file pgSliderBar.I.
References PGButton::set_notify().
Referenced by clear_thumb_button(), setup_scroll_bar(), and setup_slider().
void PGSliderBar::set_value | ( | PN_stdfloat | value | ) | [inline] |
Sets the current value of the slider programmatically.
This should range between get_min_value() and get_max_value().
Definition at line 182 of file pgSliderBar.I.
References set_ratio().
void PGSliderBar::setup_scroll_bar | ( | bool | vertical, |
PN_stdfloat | length, | ||
PN_stdfloat | width, | ||
PN_stdfloat | bevel | ||
) |
Creates PGSliderBar that represents a vertical or horizontal scroll bar (if vertical is true or false, respectively), with additional buttons for scrolling, and a range of 0 .
. 1.
length here is the measurement along the scroll bar, and width is the measurement across the scroll bar, whether it is vertical or horizontal (so for a horizontal scroll bar, the length is actually the x dimension, and the width is the y dimension).
Definition at line 282 of file pgSliderBar.cxx.
References PandaNode::add_child(), PGItem::clear_state_def(), PandaNode::remove_child(), LVector3f::rfu(), PGFrameStyle::set_color(), PGItem::set_frame(), PGItem::set_frame_style(), set_left_button(), set_manage_pieces(), set_resize_thumb(), set_right_button(), PGItem::set_state(), set_thumb_button(), PGFrameStyle::set_type(), and PGFrameStyle::set_width().
void PGSliderBar::setup_slider | ( | bool | vertical, |
PN_stdfloat | length, | ||
PN_stdfloat | width, | ||
PN_stdfloat | bevel | ||
) |
Creates PGSliderBar that represents a slider that the user can use to control an analog quantity.
This is functionally the same as a scroll bar, but it has a distinctive look.
Definition at line 356 of file pgSliderBar.cxx.
References PandaNode::add_child(), PGItem::clear_state_def(), PandaNode::remove_child(), LVector3f::rfu(), PGFrameStyle::set_color(), PGItem::set_frame(), PGItem::set_frame_style(), set_left_button(), set_manage_pieces(), set_resize_thumb(), set_right_button(), PGItem::set_state(), set_thumb_button(), PGFrameStyle::set_type(), PGFrameStyle::set_visible_scale(), and PGFrameStyle::set_width().
void PGSliderBar::xform | ( | const LMatrix4 & | mat | ) | [virtual] |
Transforms the contents of this node by the indicated matrix, if it means anything to do so.
For most kinds of nodes, this does nothing.
Reimplemented from PGItem.
Definition at line 233 of file pgSliderBar.cxx.