1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

MixerCurve, Commands on/off button.

This commit is contained in:
Mike LaBranche 2012-07-12 12:40:51 -07:00
parent a5e117101b
commit 2be7721a0f
3 changed files with 45 additions and 10 deletions

View File

@ -57,7 +57,9 @@ public:
void commandText(QString text);
int getCommandIndex() { return index; }
void setCommandIndex(int idx) { index = idx; }
void setActive(bool enable) { cmdActive = enable; }
bool getCommandActive() { return cmdActive; }
void setCommandActive(bool enable) { cmdActive = enable; }
void setToggle(bool enable) { cmdToggle = enable; }
bool getToggle() { return cmdToggle; }

View File

@ -187,6 +187,15 @@ MixerCurveWidget::MixerCurveWidget(QWidget *parent) : QGraphicsView(parent)
node->setNegativeColor("#0000aa", "#0000aa");
scene->addItem(node);
// commands toggle
node = getCommandNode(13);
node->setName("Commands");
node->setToolTip("Toggle Command Buttons On/Off");
node->setToggle(true);
node->setPositiveColor("#00aa00", "#00aa00"); //greenish
node->setNegativeColor("#000000", "#000000");
scene->addItem(node);
resizeCommands();
initNodes(MixerCurveWidget::NODE_NUMELEM);
@ -420,10 +429,13 @@ void MixerCurveWidget::resizeCommands()
QRectF rect = plot->boundingRect();
Node* node;
//reset
node = getCommandNode(0);
node->setPos((rect.left() + rect.width() / 2) - 10, rect.height() + 10);
//centered under widget
node->setPos((rect.left() + rect.width() / 2) - 5, rect.height() + 10);
//commands on/off
node = getCommandNode(13);
node->setPos((rect.left() + rect.width() / 2) + 10, rect.height() + 10);
for (int i = 1; i<6; i++) {
node = getCommandNode(i);
@ -527,23 +539,42 @@ void MixerCurveWidget::setCommandText(const QString& name, const QString& text)
}
void MixerCurveWidget::activateCommand(const QString& name)
{
for (int i=0; i<cmdNodePool.count(); i++) {
for (int i=1; i<cmdNodePool.count()-1; i++) {
Node* node = cmdNodePool.at(i);
node->setActive(node->getName() == name);
node->setCommandActive(node->getName() == name);
node->update();
}
}
void MixerCurveWidget::showCommands(bool show)
{
for (int i=1; i<cmdNodePool.count()-1; i++) {
Node* node = cmdNodePool.at(i);
if (show)
node->show();
else
node->hide();
node->update();
}
}
void MixerCurveWidget::cmdActivated(Node* node)
{
if (node->getToggle()) {
for (int i=0; i<cmdNodePool.count(); i++) {
Node* n = cmdNodePool.at(i);
n->setActive(false);
n->update();
if (node->getName() == "Commands") {
node->setCommandActive(!node->getCommandActive());
showCommands(node->getCommandActive());
}
else {
for (int i=1; i<cmdNodePool.count()-1; i++) {
Node* n = cmdNodePool.at(i);
n->setCommandActive(false);
n->update();
}
node->setCommandActive(true);
}
node->setActive(true);
}
node->update();
emit commandActivated(node);

View File

@ -58,8 +58,10 @@ public:
double getMax();
double setRange(double min, double max);
void cmdActivated(Node* node);
void activateCommand(const QString& name);
void showCommands(bool show);
Node* getCmdNode(const QString& name);
void setCommandText(const QString& name, const QString& text);