Пример #1
0
void RadioMMI::readInput()
{
  long newPos;
  newPos = mEncoder->read();
  if (newPos != mEncoderPosition) {
    if (0 == newPos % 4) {
      if (newPos > mEncoderPosition) {
        mEncoderPosition = newPos;
        onRotateRight();
      } else if(newPos < mEncoderPosition) {
        mEncoderPosition = newPos;
        onRotateLeft();
      }
    }
  }

  if (!buttonPressed()) {
    mButtonState = NOT_PRESSED;
  } else if (buttonPressed()
      && mButtonState == NOT_PRESSED) {
    mButtonState = PRESSED;
    mButtonDownSince = millis();
    onPressed();
  } else if (buttonPressed()
      && mButtonState == PRESSED
      && ((millis() - mButtonDownSince) > 1000)) {
    mButtonState = LONG_PRESSED;
    onLongPressed();
  }
}
void KeyboardManager::onKeyPressed(const EventKeyboard::KeyCode keyCode, const Event* event) {
  auto key = findKey(keyCode);
  _pressedKeys |= static_cast<Keys>(key);

  if (onPressed != nullptr) {
    onPressed(key);
  }
}
Пример #3
0
FadePedal::FadePedal(QWidget *parent)
	: FadeButton(parent)
	, m_State(STATE_IDLE)
	, m_Elapsed(0)
	, m_UpDuration(250)
	, m_DownDuration(1000)
{
	connect(this, SIGNAL(pressed()), this, SLOT(onPressed()));
	connect(this, SIGNAL(released()), this, SLOT(onReleased()));
}
Пример #4
0
BlePixmapItem::BlePixmapItem(QWidget *parent) :
    QPushButton(parent),
    ui(new Ui::BlePixmapItem)
  , m_enter(false)
  , m_selected(false)
{
    ui->setupUi(this);

    connect(this, SIGNAL(clicked()), this, SLOT(onPressed()));
    g_items << this;
}
Пример #5
0
ToyButtonWidget::ToyButtonWidget(QWidget *parent)
	: ToyWidget(parent)
{
	m_HelpText = tr("Min = Button Down\nMax = Button Up\n\nOSC Trigger:\nNo Arguments = Click\nArgument(1) = Press\nArgument(0) = Release");

	m_Widget = new FadeButton(this);
	connect(m_Widget, SIGNAL(pressed()), this, SLOT(onPressed()));
	connect(m_Widget, SIGNAL(released()), this, SLOT(onReleased()));
	
	QPalette pal( m_Widget->palette() );
	m_Color = pal.color(QPalette::Button);
	m_TextColor = pal.color(QPalette::ButtonText);
}
Пример #6
0
/// Constructor
TUIFileBrowserButton::TUIFileBrowserButton(int id, int type, QWidget *w, int parent, QString name)
    : TUIElement(id, type, w, parent, name)
{
    QPushButton *b = new QPushButton(w);
    if (name.contains("."))
    {
        QPixmap pm(name);
        if (pm.isNull())
        {
            QString covisedir = QString(getenv("COVISEDIR"));
            QPixmap pm(covisedir + "/" + name);
            if (pm.isNull())
            {
                b->setText(name);
            }
            else
            {
                b->setIcon(pm);
            }
        }
        else
        {
            b->setIcon(pm);
        }
    }
    else
        b->setText(name);

    //b->setFixedSize(b->sizeHint());
    //std::cerr << "Creating new Filebrowser instance!" << std::endl;
    this->mFileBrowser = new FileBrowser(this, 0, id);
    connect(this, SIGNAL(dirUpdate(QStringList)), this->mFileBrowser, SLOT(handleDirUpdate(QStringList)));
    connect(this, SIGNAL(fileUpdate(QStringList)), this->mFileBrowser, SLOT(handleFileUpdate(QStringList)));
    connect(this, SIGNAL(clientUpdate(QStringList)), this->mFileBrowser, SLOT(handleClientUpdate(QStringList)));
    /*connect(this,SIGNAL(filterUpdate(QStringList)),this->mFileBrowser, SLOT(handleFilterUpdate(QStringList)));*/
    connect(this, SIGNAL(curDirUpdate(QString)), this->mFileBrowser, SLOT(handleCurDirUpdate(QString)));
    connect(this, SIGNAL(driveUpdate(QStringList)), this->mFileBrowser, SLOT(handleDriveUpdate(QStringList)));
    connect(this, SIGNAL(updateMode(int)), this->mFileBrowser, SLOT(handleUpdateMode(int)));
    connect(this, SIGNAL(updateFilterList(char *)), this->mFileBrowser, SLOT(handleUpdateFilterList(char *)));
    connect(this, SIGNAL(locationUpdate(QString)), this->mFileBrowser, SLOT(handleLocationUpdate(QString)));
    connect(this, SIGNAL(updateRemoteButtonState(int)), this->mFileBrowser, SLOT(handleupdateRemoteButtonState(int)));
    connect(this, SIGNAL(updateLoadCheckBox(bool)), this->mFileBrowser, SLOT(handleUpdateLoadCheckBox(bool)));

    mFileBrowser->setWindowTitle("TabletUI VRML - Remote File Browser");

    widget = b;

    connect(b, SIGNAL(pressed()), this, SLOT(onPressed()));
}
Пример #7
0
ParameterSlider::ParameterSlider(QWidget *parent, ParameterObject *parameterobject, DescLoD descriptionLoD)
	: ParameterVirtualWidget(parent, parameterobject, descriptionLoD)
{
	this->pressed = true;
	this->suppressUpdate=false;

	setValue();
	connect(slider, SIGNAL(sliderPressed()), this, SLOT(onPressed()));
	connect(slider, SIGNAL(sliderReleased()), this, SLOT(onReleased()));
	connect(slider, SIGNAL(valueChanged(int)), this, SLOT(onSliderChanged(int)));
	connect(doubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(onSpinBoxChanged(double)));
	connect(doubleSpinBox, SIGNAL(editingFinished()), this, SLOT(onEditingFinished()));

	IgnoreWheelWhenNotFocused *ignoreWheelWhenNotFocused = new IgnoreWheelWhenNotFocused(this);
	slider->installEventFilter(ignoreWheelWhenNotFocused);
	doubleSpinBox->installEventFilter(ignoreWheelWhenNotFocused);
}
int MoodBox::ContactListButton::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QToolButton::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: update((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: updateImage(); break;
        case 2: onPressed(); break;
        case 3: onReleased(); break;
        default: ;
        }
        _id -= 4;
    }
    return _id;
}
Пример #9
0
ObjectBrowser::ObjectBrowser(QWidget *parent) : QWidget(parent)
{
    //WidgetUtils::setBackgroundColor(this, Qt::blue);

    listView_ = new QListView;
    listView_->setModel(LevelObjectsModel::sharedInstance());
    listView_->setSpacing(5);
    listView_->setViewMode(QListView::IconMode);
    listView_->setAlternatingRowColors(false);
    listView_->setSelectionMode(QAbstractItemView::SingleSelection);
    listView_->setMovement(QListView::Static);
    listView_->setResizeMode(QListView::Adjust);
    listView_->setUniformItemSizes(false);
    listView_->setDragDropMode(QAbstractItemView::DragOnly);
    listView_->setDragEnabled(true);
    connect(listView_, SIGNAL(pressed(QModelIndex)),
            this, SLOT(onPressed(QModelIndex)));

    QVBoxLayout *layout = new QVBoxLayout;
    layout->setContentsMargins(0, 0, 0, 0);
    layout->addWidget(listView_);
    setLayout(layout);
}
Пример #10
0
int
SDL2TestApplication::run()
{
    m_window = SDL_CreateWindow("SDL2TestApplication",
            SDL_WINDOWPOS_CENTERED,
            SDL_WINDOWPOS_CENTERED, 
            0, 0,
            SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN);

    if (m_window == NULL) {
        printf("Could not create window: %s\n", SDL_GetError());
        return 1;
    }

    int w, h;
    SDL_GetWindowSize(m_window, &w, &h);
    printf("Window size after create: (%d, %d)\n", w, h);

#if 0
    SDL_SetWindowFullscreen(window, SDL_FALSE);
    SDL_GetWindowSize(window, &w, &h);
    printf("Window size after fullscreen off: (%d, %d)\n", w, h);

    SDL_SetWindowSize(window, 200, 200);
    SDL_GetWindowSize(window, &w, &h);
    printf("Window size after resize: (%d, %d)\n", w, h);

    SDL_SetWindowFullscreen(window, SDL_TRUE);
    SDL_GetWindowSize(window, &w, &h);
    printf("Window size after fullscreen on: (%d, %d)\n", w, h);
#endif

    if (m_major != 0 && m_minor != 0) {
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, m_major);
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, m_minor);
    }

    m_gl_context = SDL_GL_CreateContext(m_window);

    initGL();
    resizeGL(w, h);

    std::list<TouchPoint*>::iterator it;
    TouchPoint *touch;

    SDL_Event event;
    int quit = 0;
    while (!quit) {
        while (SDL_PollEvent(&event)) {
            switch (event.type) {
                case SDL_QUIT:
                    quit = 1;
                    break;
                case SDL_WINDOWEVENT:
                    printf("Window event: %d (%d, %d)\n", event.window.event,
                            event.window.data1, event.window.data2);
                    break;
                case SDL_FINGERDOWN:
                    touch = new TouchPoint(event.tfinger.fingerId,
                            event.tfinger.x, event.tfinger.y);
                    m_touches.push_back(touch);
                    onPressed(touch);
                    printf("Finger down: (%.2f, %.2f)\n", touch->x, touch->y);
                    break;
                case SDL_FINGERUP:
                case SDL_FINGERMOTION:
                    for (it=m_touches.begin(); it != m_touches.end(); ++it) {
                        touch = *it;
                        if (touch->id == event.tfinger.fingerId) {
                            if (event.type == SDL_FINGERMOTION) {
                                touch->x = event.tfinger.x;
                                touch->y = event.tfinger.y;
                                printf("finger move: (%.2f, %.2f)\n", touch->x, touch->y);
                            } else {
                                printf("Finger up: (%.2f, %.2f)\n", touch->x, touch->y);
                                m_touches.erase(it);
                            }
                            break;
                        }
                    }
                    break;
                default:
                    printf("SDL Event: %d\n", event.type);
                    break;
            }
        }

        if (quit) {
            /* Application has to quit - don't render anymore */
            break;
        }

        renderGL();

        SDL_GL_SwapWindow(m_window);
        SDL_Delay(10);
    }

    SDL_GL_DeleteContext(m_gl_context);
    SDL_DestroyWindow(m_window);
    SDL_Quit();

    return 0;
}