mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-01 03:10:06 +00:00
New class MouseInputSource.
This commit is contained in:
parent
9657241c10
commit
187173da62
2 changed files with 75 additions and 5 deletions
|
|
@ -39,7 +39,7 @@ class MouseInputSourceInternal : public AsyncUpdater
|
|||
{
|
||||
public:
|
||||
MouseInputSourceInternal (MouseInputSource& source_, const int index_, const bool isMouseDevice_)
|
||||
: source (source_), index (index_), isMouseDevice (isMouseDevice_), lastPeer (0), lastTime (0)
|
||||
: index (index_), isMouseDevice (isMouseDevice_), source (source_), lastPeer (0), lastTime (0)
|
||||
{
|
||||
zerostruct (mouseDowns);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,44 +38,114 @@ class MouseInputSourceInternal;
|
|||
|
||||
//==============================================================================
|
||||
/**
|
||||
Represents a linear source of mouse events from a mouse device or individual finger
|
||||
in a multi-touch environment.
|
||||
|
||||
Each MouseEvent object contains a reference to the MouseInputSource that generated
|
||||
it. In an environment with a single mouse for input, all events will come from the
|
||||
same source, but in a multi-touch system, there may be multiple MouseInputSource
|
||||
obects active, each representing a stream of events coming from a particular finger.
|
||||
|
||||
Events coming from a single MouseInputSource are always sent in a fixed and predictable
|
||||
order: a mouseMove will never be called without a mouseEnter having been sent beforehand,
|
||||
the only events that can happen between a mouseDown and its corresponding mouseUp are
|
||||
mouseDrags, etc.
|
||||
When there are multiple touches arriving from multiple MouseInputSources, their
|
||||
event streams may arrive in an interleaved order, so you should use the getIndex()
|
||||
method to find out which finger each event came from.
|
||||
|
||||
@see MouseEvent
|
||||
*/
|
||||
class JUCE_API MouseInputSource
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
/** Creates a MouseInputSource.
|
||||
You should never actually create a MouseInputSource in your own code - the
|
||||
library takes care of managing these objects.
|
||||
*/
|
||||
MouseInputSource (int index, bool isMouseDevice);
|
||||
|
||||
/** Destructor. */
|
||||
~MouseInputSource();
|
||||
|
||||
//==============================================================================
|
||||
/** Returns true if this object represents a normal desk-based mouse device. */
|
||||
bool isMouse() const;
|
||||
|
||||
/** Returns true if this object represents a source of touch events - i.e. a finger or stylus. */
|
||||
bool isTouch() const;
|
||||
|
||||
/** Returns true if this source has an on-screen pointer that can hover over
|
||||
items without clicking them.
|
||||
*/
|
||||
bool canHover() const;
|
||||
|
||||
/** Returns true if this source may have a scroll wheel. */
|
||||
bool hasMouseWheel() const;
|
||||
|
||||
/** Returns this source's index in the global list of possible sources.
|
||||
If the system only has a single mouse, there will only be a single MouseInputSource
|
||||
with an index of 0.
|
||||
|
||||
If the system supports multi-touch input, then the index will represent a finger
|
||||
number, starting from 0. When the first touch event begins, it will have finger
|
||||
number 0, and then if a second touch happens while the first is still down, it
|
||||
will have index 1, etc.
|
||||
*/
|
||||
int getIndex() const;
|
||||
|
||||
/** Returns true if this device is currently being pressed. */
|
||||
bool isDragging() const;
|
||||
|
||||
/** Returns the last-known screen position of this source. */
|
||||
const Point<int> getScreenPosition() const;
|
||||
|
||||
/** Returns a set of modifiers that indicate which buttons are currently
|
||||
held down on this device.
|
||||
*/
|
||||
const ModifierKeys getCurrentModifiers() const;
|
||||
|
||||
/** Returns the component that was last known to be under this device. */
|
||||
Component* getComponentUnderMouse() const;
|
||||
|
||||
/** Tells the device to dispatch a mouse-move event.
|
||||
This is asynchronous - the event will occur on the message thread.
|
||||
*/
|
||||
void triggerFakeMove() const;
|
||||
|
||||
/** Returns the number of clicks that should be counted as belonging to the
|
||||
current mouse event.
|
||||
So the mouse is currently down and it's the second click of a double-click, this
|
||||
will return 2.
|
||||
*/
|
||||
int getNumberOfMultipleClicks() const throw();
|
||||
|
||||
/** Returns the time at which the last mouse-down occurred. */
|
||||
const Time getLastMouseDownTime() const throw();
|
||||
|
||||
/** Returns the screen position at which the last mouse-down occurred. */
|
||||
const Point<int> getLastMouseDownPosition() const throw();
|
||||
|
||||
/** Returns true if this mouse is currently down, and if it has been dragged more
|
||||
than a couple of pixels from the place it was pressed.
|
||||
*/
|
||||
bool hasMouseMovedSignificantlySincePressed() const throw();
|
||||
|
||||
|
||||
//==============================================================================
|
||||
juce_UseDebuggingNewOperator
|
||||
|
||||
/** @internal */
|
||||
void handleEvent (ComponentPeer* peer, const Point<int>& positionWithinPeer, int64 time, const ModifierKeys& mods);
|
||||
/** @internal */
|
||||
void handleWheel (ComponentPeer* peer, const Point<int>& positionWithinPeer, int64 time, float x, float y);
|
||||
|
||||
private:
|
||||
friend class MouseInputSourceInternal;
|
||||
ScopedPointer<MouseInputSourceInternal> pimpl;
|
||||
|
||||
private:
|
||||
friend class Desktop;
|
||||
friend class ComponentPeer;
|
||||
friend class MouseInputSourceInternal;
|
||||
ScopedPointer<MouseInputSourceInternal> pimpl;
|
||||
|
||||
MouseInputSource (const MouseInputSource&);
|
||||
MouseInputSource& operator= (const MouseInputSource&);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue