void ColorPicker::processMouse(const scv::MouseEvent &evt) { static Kernel *kernel = Kernel::getInstance(); static Cursor * cursor = Cursor::getInstance(); if (!_receivingCallbacks) { Component::processMouse(evt); } else { Panel::processMouse(evt); } if (!_receivingCallbacks) return; if (_pickerWaitingColor) { kernel->lockMouseUse(this); cursor->forceCursor(kernel->glfwWindow, GLFW_CROSSHAIR_CURSOR); glReadPixels(evt.getPosition().x, evt.getInversePosition().y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &_currentColor); setSpinsColor(); onColorChange(); if (evt.getState() == MouseEvent::CLICK && evt.getButton() == MouseEvent::LEFT) { _btPicker->setState(false); _pickerWaitingColor = false; _currentColorPosition = foundHSL(); createTexture(); } } else { if (isInside(evt.getPosition()) && kernel->requestMouseUse(this)) { if (isFocused()) { Point relativeMouse = evt.getPosition()-getAbsolutePosition(); if (relativeMouse.x < MatrixTemplate<ColorRGBA>::getWidth() && relativeMouse.y < MatrixTemplate<ColorRGBA>::getHeight()) { cursor->forceCursor(kernel->glfwWindow, GLFW_CROSSHAIR_CURSOR); if (evt.getState() == MouseEvent::CLICK && evt.getButton() == MouseEvent::LEFT) { _isDragging = false; _currentColorPosition = relativeMouse; _currentColor = ColorRGBA(MatrixTemplate<ColorRGBA>::get(_currentColorPosition.y,_currentColorPosition.x)); setSpinsColor(); onColorChange(); onMouseClick(evt); } else if (evt.getState() == MouseEvent::HOLD && evt.getButton() == MouseEvent::LEFT) { kernel->lockMouseUse(this); _isDragging = false; _currentColorPosition = relativeMouse; _currentColor = ColorRGBA(MatrixTemplate<ColorRGBA>::get(_currentColorPosition.y,_currentColorPosition.x)); setSpinsColor(); onColorChange(); onMouseDrag(evt); } else if (evt.getState() == MouseEvent::UP) { kernel->unlockMouseUse(this); } } } } else if (evt.getState() == MouseEvent::UP) { kernel->unlockMouseUse(this); } } }
void ColorPicker::refreshColor(void) { _currentPickerColor = ColorRGBA((unsigned char)_rgbs[0]->getValue(), (unsigned char)_rgbs[1]->getValue(), (unsigned char)_rgbs[2]->getValue()); if (_saturation != _rgbs[3]->getValue()) { _saturation = _rgbs[3]->getValue(); createTexture(); _currentColor = ColorRGBA(MatrixTemplate<ColorRGBA>::get(_currentColorPosition.y, _currentColorPosition.x)); setSpinsColor(); onColorChange(); } else if (_currentPickerColor != _currentColor) { _currentColor = _currentPickerColor; onColorChange(); } }
void ColorPicker::setColor(const ColorRGBA &color) { if (_currentColor == color) return; _currentColor = color; setSpinsColor(); refreshColor(); onColorChange(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), baseUrl_("http://192.168.43.177/"), ui(new Ui::MainWindow) { ui->setupUi(this); connect(&accessManager_, SIGNAL(finished(QNetworkReply*)), this, SLOT(enableGui())); connect(ui->hsRed, SIGNAL(valueChanged(int)), this, SLOT(onColorChange())); connect(ui->hsGreen, SIGNAL(valueChanged(int)), this, SLOT(onColorChange())); connect(ui->hsBlue, SIGNAL(valueChanged(int)), this, SLOT(onColorChange())); onColorChange(); }
void Drawable::setColor(const Color &color) { this->color = color; onColorChange(); }
void Drawable::setAlpha(float alpha) { color.a = static_cast<uint8_t>(255 * alpha); onColorChange(); }