A component that acts as a rectangular selection region, which you drag with the mouse to select groups of objects (in conjunction with a SelectedItemSet). More...
Inherits Component.
Public Types | |
| enum | ColourIds { lassoFillColourId = 0x1000440, lassoOutlineColourId = 0x1000441 } |
A set of colour IDs to use to change the colour of various aspects of the label. More... | |
Public Member Functions | |
| LassoComponent (const int outlineThickness_=1) | |
| Creates a Lasso component. | |
| ~LassoComponent () | |
| Destructor. | |
| void | beginLasso (const MouseEvent &e, LassoSource< SelectableItemType > *const lassoSource) |
| Call this in your mouseDown event, to initialise a drag. | |
| void | dragLasso (const MouseEvent &e) |
| Call this in your mouseDrag event, to update the lasso's position. | |
| void | endLasso () |
| Call this in your mouseUp event, after the lasso has been dragged. | |
| void | paint (Graphics &g) |
| Components can override this method to draw their content. | |
| bool | hitTest (int, int) |
| Tests whether a given point inside the component. | |
A component that acts as a rectangular selection region, which you drag with the mouse to select groups of objects (in conjunction with a SelectedItemSet).
To use one of these:
The class takes into account the modifier keys that are being held down while the lasso is being dragged, so if shift is pressed, then any lassoed items will be added to the original selection; if ctrl or command is pressed, they will be xor'ed with any previously selected items.
| enum LassoComponent::ColourIds |
A set of colour IDs to use to change the colour of various aspects of the label.
These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() methods.
Note that you can also use the constants from TextEditor::ColourIds to change the colour of the text editor that is opened when a label is editable.
| LassoComponent< SelectableItemType >::LassoComponent | ( | const int | outlineThickness_ = 1 ) |
[explicit] |
Creates a Lasso component.
The fill colour is used to fill the lasso'ed rectangle, and the outline colour is used to draw a line around its edge.
| LassoComponent< SelectableItemType >::~LassoComponent | ( | ) |
Destructor.
| void LassoComponent< SelectableItemType >::beginLasso | ( | const MouseEvent & | e, |
| LassoSource< SelectableItemType > *const | lassoSource | ||
| ) |
Call this in your mouseDown event, to initialise a drag.
Pass in a suitable LassoSource object which the lasso will use to find the items and change the selection.
After using this method to initialise the lasso, repeatedly call dragLasso() in your component's mouseDrag callback.
References LassoSource< SelectableItemType >::getLassoSelection(), MouseEvent::getMouseDownPosition(), Component::getParentComponent(), jassert, and Component::setSize().
| void LassoComponent< SelectableItemType >::dragLasso | ( | const MouseEvent & | e ) |
Call this in your mouseDrag event, to update the lasso's position.
This must be repeatedly calling when the mouse is dragged, after you've first initialised the lasso with beginLasso().
This method takes into account the modifier keys that are being held down, so if shift is pressed, then the lassoed items will be added to any that were previously selected; if ctrl or command is pressed, then they will be xor'ed with previously selected items.
References Array< ElementType, TypeOfCriticalSectionToUse >::addArray(), Component::getBounds(), MouseEvent::getPosition(), ModifierKeys::isAltDown(), ModifierKeys::isCommandDown(), ModifierKeys::isShiftDown(), MouseEvent::mods, Array< ElementType, TypeOfCriticalSectionToUse >::removeValuesIn(), Component::setBounds(), and Component::setVisible().
| void LassoComponent< SelectableItemType >::endLasso | ( | ) |
Call this in your mouseUp event, after the lasso has been dragged.
References Array< ElementType, TypeOfCriticalSectionToUse >::clear(), and Component::setVisible().
| void LassoComponent< SelectableItemType >::paint | ( | Graphics & | g ) | [virtual] |
Components can override this method to draw their content.
The paint() method gets called when a region of a component needs redrawing, either because the component's repaint() method has been called, or because something has happened on the screen that means a section of a window needs to be redrawn.
Any child components will draw themselves over whatever this method draws. If you need to paint over the top of your child components, you can also implement the paintOverChildren() method to do this.
If you want to cause a component to redraw itself, this is done asynchronously - calling the repaint() method marks a region of the component as "dirty", and the paint() method will automatically be called sometime later, by the message thread, to paint any bits that need refreshing. In Juce (and almost all modern UI frameworks), you never redraw something synchronously.
You should never need to call this method directly - to take a snapshot of the component you could use createComponentSnapshot() or paintEntireComponent().
| g | the graphics context that must be used to do the drawing operations. |
Reimplemented from Component.
References Graphics::drawRect(), Graphics::fillAll(), Component::findColour(), Component::getHeight(), Component::getWidth(), Component::isMouseButtonDownAnywhere(), jassert, LassoComponent< SelectableItemType >::lassoFillColourId, LassoComponent< SelectableItemType >::lassoOutlineColourId, and Graphics::setColour().
| bool LassoComponent< SelectableItemType >::hitTest | ( | int | x, |
| int | y | ||
| ) | [virtual] |
Tests whether a given point inside the component.
Overriding this method allows you to create components which only intercept mouse-clicks within a user-defined area.
This is called to find out whether a particular x, y coordinate is considered to be inside the component or not, and is used by methods such as contains() and getComponentAt() to work out which component the mouse is clicked on.
Components with custom shapes will probably want to override it to perform some more complex hit-testing.
The default implementation of this method returns either true or false, depending on the value that was set by calling setInterceptsMouseClicks() (true is the default return value).
Note that the hit-test region is not related to the opacity with which areas of a component are painted.
Applications should never call hitTest() directly - instead use the contains() method, because this will also test for occlusion by the component's parent.
Note that for components on the desktop, this method will be ignored, because it's not always possible to implement this behaviour on all platforms.
| x | the x coordinate to test, relative to the left hand edge of this component. This value is guaranteed to be greater than or equal to zero, and less than the component's width |
| y | the y coordinate to test, relative to the top edge of this component. This value is guaranteed to be greater than or equal to zero, and less than the component's height |
Reimplemented from Component.