14 changed files with 338 additions and 43 deletions
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
/*=====================================================================
|
||||
|
||||
QGroundControl Open Source Ground Control Station |
||||
|
||||
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||||
|
||||
This file is part of the QGROUNDCONTROL project |
||||
|
||||
QGROUNDCONTROL is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
QGROUNDCONTROL is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
#include "QGCMapPalette.h" |
||||
|
||||
#include <QApplication> |
||||
#include <QPalette> |
||||
|
||||
QColor QGCMapPalette::_thumbJoystick[QGCMapPalette::_cColorGroups] = { QColor("#ffffff"), QColor("#f000000") }; |
||||
|
||||
QGCMapPalette::QGCMapPalette(QObject* parent) : |
||||
QObject(parent) |
||||
{ |
||||
|
||||
} |
||||
|
||||
void QGCMapPalette::setLightColors(bool lightColors) |
||||
{ |
||||
if ( _lightColors != lightColors) { |
||||
_lightColors = lightColors; |
||||
emit paletteChanged(); |
||||
} |
||||
} |
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
/*=====================================================================
|
||||
|
||||
QGroundControl Open Source Ground Control Station |
||||
|
||||
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||||
|
||||
This file is part of the QGROUNDCONTROL project |
||||
|
||||
QGROUNDCONTROL is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
QGROUNDCONTROL is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
/// QGCMapPalette is a variant of QGCPalette which is used to hold colors used for display over
|
||||
/// the map control. Since the coloring of a satellite map differs greatly from the coloring of
|
||||
/// a street map you need to be able to switch between sets of color based on map type.
|
||||
|
||||
#ifndef QGCMapPalette_h |
||||
#define QGCMapPalette_h |
||||
|
||||
#include <QObject> |
||||
#include <QColor> |
||||
|
||||
class QGCMapPalette : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
Q_PROPERTY(bool lightColors READ lightColors WRITE setLightColors NOTIFY paletteChanged) |
||||
|
||||
// The colors are:
|
||||
// thumbJoystick - Thumb joystick indicator
|
||||
|
||||
Q_PROPERTY(QColor thumbJoystick READ thumbJoystick NOTIFY paletteChanged) |
||||
|
||||
public:
|
||||
QGCMapPalette(QObject* parent = NULL); |
||||
|
||||
bool lightColors(void) const { return _lightColors; } |
||||
void setLightColors(bool lightColors); |
||||
|
||||
QColor thumbJoystick(void) const { return _thumbJoystick[_lightColors]; } |
||||
|
||||
signals: |
||||
void paletteChanged(void); |
||||
|
||||
private: |
||||
bool _lightColors; |
||||
|
||||
static const int _cColorGroups = 2; |
||||
|
||||
static QColor _thumbJoystick[_cColorGroups]; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,74 @@
@@ -0,0 +1,74 @@
|
||||
import QtQuick 2.5 |
||||
import QtQuick.Controls 1.2 |
||||
|
||||
import QGroundControl.Palette 1.0 |
||||
import QGroundControl.ScreenTools 1.0 |
||||
|
||||
Rectangle { |
||||
radius: width / 2 |
||||
border.color: mapPal.thumbJoystick |
||||
border.width: 2 |
||||
color: "transparent" |
||||
|
||||
property alias lightColors: mapPal.lightColors /// true: use light colors from QGCMapPalette for drawing |
||||
property var stickPosition: Qt.point(0, 0) |
||||
property real xAxis: 0 /// Value range [-1,1], negative values left stick, positive values right stick |
||||
property real yAxis: 0 /// Value range [-1,1], negative values up stick, positive values down stick |
||||
property bool yAxisThrottle: false /// true: yAxis used for throttle, range [1,0], positive value are stick up |
||||
|
||||
property bool _stickCenteredOnce: false |
||||
|
||||
QGCMapPalette { id: mapPal } |
||||
|
||||
onWidthChanged: { |
||||
if (!_stickCenteredOnce && width != 0) { |
||||
reCenter() |
||||
} |
||||
} |
||||
|
||||
onStickPositionChanged: { |
||||
var xAxisTemp = stickPosition.x / width |
||||
xAxisTemp *= 2.0 |
||||
xAxisTemp -= 1.0 |
||||
xAxis = xAxisTemp |
||||
|
||||
var yAxisTemp = stickPosition.y / width |
||||
yAxisTemp *= 2.0 |
||||
yAxisTemp -= 1.0 |
||||
if (yAxisThrottle) { |
||||
yAxisTemp = ((yAxisTemp * -1.0) / 2.0) + 0.5 |
||||
} |
||||
yAxis = yAxisTemp |
||||
} |
||||
|
||||
function reCenter() |
||||
{ |
||||
stickPosition = Qt.point(width / 2, width / 2) |
||||
} |
||||
|
||||
Column { |
||||
QGCLabel { text: xAxis } |
||||
QGCLabel { text: yAxis } |
||||
} |
||||
|
||||
Rectangle { |
||||
anchors.margins: parent.width / 4 |
||||
anchors.fill: parent |
||||
radius: width / 2 |
||||
border.color: mapPal.thumbJoystick |
||||
border.width: 2 |
||||
color: "transparent" |
||||
} |
||||
|
||||
Rectangle { |
||||
width: hatWidth |
||||
height: hatWidth |
||||
radius: hatWidthHalf |
||||
color: mapPal.thumbJoystick |
||||
x: stickPosition.x - hatWidthHalf |
||||
y: stickPosition.y - hatWidthHalf |
||||
|
||||
readonly property real hatWidth: ScreenTools.defaultFontPixelHeight |
||||
readonly property real hatWidthHalf: ScreenTools.defaultFontPixelHeight / 2 |
||||
} |
||||
} |
@ -1,38 +1,32 @@
@@ -1,38 +1,32 @@
|
||||
Module QGroundControl.Controls |
||||
|
||||
QGCLabel 1.0 QGCLabel.qml |
||||
QGCButton 1.0 QGCButton.qml |
||||
QGCRadioButton 1.0 QGCRadioButton.qml |
||||
QGCCheckBox 1.0 QGCCheckBox.qml |
||||
QGCTextField 1.0 QGCTextField.qml |
||||
QGCComboBox 1.0 QGCComboBox.qml |
||||
QGCColoredImage 1.0 QGCColoredImage.qml |
||||
QGCToolBarButton 1.0 QGCToolBarButton.qml |
||||
QGCMovableItem 1.0 QGCMovableItem.qml |
||||
|
||||
SubMenuButton 1.0 SubMenuButton.qml |
||||
IndicatorButton 1.0 IndicatorButton.qml |
||||
DropButton 1.0 DropButton.qml |
||||
RoundButton 1.0 RoundButton.qml |
||||
VehicleRotationCal 1.0 VehicleRotationCal.qml |
||||
VehicleSummaryRow 1.0 VehicleSummaryRow.qml |
||||
ViewWidget 1.0 ViewWidget.qml |
||||
ExclusiveGroupItem 1.0 ExclusiveGroupItem.qml |
||||
|
||||
ClickableColor 1.0 ClickableColor.qml |
||||
DropButton 1.0 DropButton.qml |
||||
ExclusiveGroupItem 1.0 ExclusiveGroupItem.qml |
||||
IndicatorButton 1.0 IndicatorButton.qml |
||||
JoystickThumbPad 1.0 JoystickThumbPad.qml |
||||
MainToolBar 1.0 MainToolBar.qml |
||||
MissionItemEditor 1.0 MissionItemEditor.qml |
||||
MissionItemIndexLabel 1.0 MissionItemIndexLabel.qml |
||||
ModeSwitchDisplay 1.0 ModeSwitchDisplay.qml |
||||
ParameterEditor 1.0 ParameterEditor.qml |
||||
ParameterEditorDialog 1.0 ParameterEditorDialog.qml |
||||
|
||||
ModeSwitchDisplay 1.0 ModeSwitchDisplay.qml |
||||
|
||||
QGCView 1.0 QGCView.qml |
||||
QGCViewPanel 1.0 QGCViewPanel.qml |
||||
QGCViewDialog 1.0 QGCViewDialog.qml |
||||
QGCViewMessage 1.0 QGCViewMessage.qml |
||||
|
||||
MissionItemIndexLabel 1.0 MissionItemIndexLabel.qml |
||||
MissionItemEditor 1.0 MissionItemEditor.qml |
||||
|
||||
MainToolBar 1.0 MainToolBar.qml |
||||
SignalStrength 1.0 SignalStrength.qml |
||||
|
||||
ClickableColor 1.0 ClickableColor.qml |
||||
QGCButton 1.0 QGCButton.qml |
||||
QGCCheckBox 1.0 QGCCheckBox.qml |
||||
QGCColoredImage 1.0 QGCColoredImage.qml |
||||
QGCComboBox 1.0 QGCComboBox.qml |
||||
QGCLabel 1.0 QGCLabel.qml |
||||
QGCMovableItem 1.0 QGCMovableItem.qml |
||||
QGCRadioButton 1.0 QGCRadioButton.qml |
||||
QGCTextField 1.0 QGCTextField.qml |
||||
QGCToolBarButton 1.0 QGCToolBarButton.qml |
||||
QGCView 1.0 QGCView.qml |
||||
QGCViewDialog 1.0 QGCViewDialog.qml |
||||
QGCViewMessage 1.0 QGCViewMessage.qml |
||||
QGCViewPanel 1.0 QGCViewPanel.qml |
||||
RoundButton 1.0 RoundButton.qml |
||||
SignalStrength 1.0 SignalStrength.qml |
||||
SubMenuButton 1.0 SubMenuButton.qml |
||||
VehicleRotationCal 1.0 VehicleRotationCal.qml |
||||
VehicleSummaryRow 1.0 VehicleSummaryRow.qml |
||||
ViewWidget 1.0 ViewWidget.qml |
||||
|
Loading…
Reference in new issue