コード例 #1
0
BEGIN_JUCE_NAMESPACE

//==============================================================================
Joystick::Joystick()
  : Component ("Joystick"),
    current_x (0),
    current_y (0),
    x_min (0),
    x_max (1),
    y_min (0),
    y_max (1),
    backgroundColour (Colours::black),
    sendChangeOnlyOnRelease (false),
    holdOnMouseRelease (false),
    isVelocityBased (false),
    menuEnabled (true),
    menuShown (false),
    mouseWasHidden (false),
    numDecimalPlaces (4)
{
    setOpaque (true);
    setWantsKeyboardFocus (true);

    calculateRatio();
    calculateSnapBack();
}
コード例 #2
0
BEGIN_JUCE_NAMESPACE

#include "jucetice_Joystick.h"
#include "../../text/juce_LocalisedStrings.h"
#include "../../gui/components/menus/juce_PopupMenu.h"


//==============================================================================
Joystick::Joystick()
  : Component (T("Joystick")),
    current_x (0),
    current_y (0),
    x_min (0),
    x_max (1),
    y_min (0),
    y_max (1),
    backgroundColour (Colours::black),
    sendChangeOnlyOnRelease (false),
    holdOnMouseRelease (false),
    isVelocityBased (false),
    menuEnabled (true),
    menuShown (false),
    mouseWasHidden (false),
    numDecimalPlaces (4)
{
    setOpaque (true);
    setWantsKeyboardFocus (true);

    calculateRatio();
    calculateSnapBack();
}
コード例 #3
0
//==============================================================================
void Joystick::setRanges (const double newHorizontalMin,
                          const double newHorizontalMax,
                          const double newVerticalMin,
                          const double newVerticalMax,
                          const double newInt)
{
    bool horizontalChanged = false;
    bool verticalChanged = false;

    if (x_min != newHorizontalMin
        || x_max != newVerticalMax)
    {
        x_min = newHorizontalMin;
        x_max = newHorizontalMax;
        horizontalChanged = true;
    }

    if (y_min != newVerticalMin
        || y_max != newVerticalMax)
    {
        y_min = newVerticalMin;
        y_max = newVerticalMax;
        verticalChanged = true;
    }

    // figure out the number of DPs needed to display all values at this
    // interval setting.
    interval = newInt;
    numDecimalPlaces = 7;
    if (newInt != 0)
    {
        int v = abs ((int) (newInt * 10000000));
        while ((v % 10) == 0)
        {
            --numDecimalPlaces;
            v /= 10;
        }
    }

    if (horizontalChanged || verticalChanged)
        setValues (current_x, current_y, false);

    calculateRatio();
    calculateSnapBack();
    calculateDrawingSpot();
}