void SubToolBar::initColorLabel() { m_colorLabel = new QLabel(this); m_colorLabel->setStyleSheet(getFileContent(":/resources/qss/colorbtn.qss")); QList<ColorButton*> colorBtnList; QButtonGroup* colorBtnGroup = new QButtonGroup(m_colorLabel); colorBtnGroup->setExclusive(true); for(int i = 0; i < COLOR_NUM; i ++) { ColorButton* colorBtn = new ColorButton(colorIndexOf(i)); colorBtn->setObjectName(QString("ColorBtn%1").arg(i+1)); colorBtnList.append(colorBtn); colorBtnGroup->addButton(colorBtn); } QHBoxLayout* colorLayout = new QHBoxLayout(); colorLayout->setMargin(0); colorLayout->setSpacing(0); colorLayout->addSpacing(3); for(int i = 0; i < colorBtnList.length(); i++) { colorLayout->addWidget(colorBtnList[i]); colorLayout->addSpacing(1); connect(colorBtnList[i], &ColorButton::updatePaintColor, this, &SubToolBar::updateColor); } colorLayout->addStretch(); m_colorLabel->setLayout(colorLayout); addWidget(m_colorLabel); connect(this, &SubToolBar::defaultColorIndexChanged, this, [=](int index){ colorBtnList[index]->setChecked(true); }); }
platform_display_type insert<color_button_t>(display_t& display, platform_display_type& parent, color_button_t& element) { if (element.using_label_m) insert(display, parent, element.name_m); assert(!element.control_m); ColorButton* button = new ColorButton(GG::X(element.width_m), GG::Y(element.height_m), element.border_color_m, 2, element.dialog_color_m, element.dialog_border_color_m, element.dialog_text_color_m); element.original_size_m = GG::Pt(button->Width(), button->Height()); element.control_m = button; GG::Connect(button->ColorChanged, boost::bind(&color_changed, boost::ref(element))); if (!element.alt_text_m.empty()) adobe::implementation::set_control_alt_text(element.control_m, element.alt_text_m); return display.insert(parent, element.control_m); }
void OptionsCommand::onResetCheckedBg() { // Default values m_checked_bg->setSelectedItem((int)RenderEngine::CHECKED_BG_16X16); m_checked_bg_zoom->setSelected(true); m_checked_bg_color1->setColor(app::Color::fromRgb(128, 128, 128)); m_checked_bg_color2->setColor(app::Color::fromRgb(192, 192, 192)); }
void GroupOptionsPanel::OnHighlightColorClick(wxCommandEvent& event) { ColorButton* origin = (ColorButton*)event.GetEventObject(); wxColour c = GetColourFromUser(this, origin->GetColor()); if (c.IsOk()) { origin->SetColor(c); useractions().SetGroupColor(m_current_group, c); } }
void CustomColorsWidget::addColor(QColor color) { ColorButton *currentButton = 0; for (std::vector<ColorButton*>::iterator it=buttons.begin(); it != buttons.end(); ++it) { currentButton = *it; if (currentButton && !currentButton->isEnabled()) { currentButton->SetBackgroundColor(color); currentButton->setEnabled(true); break; } } }
void ConditionList::buttonClicked(Button *btn) { ColorButton *cbtn = (ColorButton *)btn; // also inform trial circular buffer about visibility change. if (btn == titleButton) { int x = 5; } else if (btn == noneButton) { if (processor->trialCircularBuffer != nullptr) { //processor->trialCircularBuffer->lockConditions(); const ScopedLock myScopedLock(processor->trialCircularBuffer->psthMutex); for (int k = 0; k<processor->trialCircularBuffer->getNumConditions(); k++) { processor->trialCircularBuffer->modifyConditionVisibility(k, false); conditionButtons[k]->setEnabledState(false); } //processor->trialCircularBuffer->unlockConditions(); } } else if (btn == allButton) { if (processor->trialCircularBuffer != nullptr) { const ScopedLock myScopedLock(processor->trialCircularBuffer->psthMutex); //processor->trialCircularBuffer->lockConditions(); for (int k = 0; k<processor->trialCircularBuffer->getNumConditions(); k++) { processor->trialCircularBuffer->modifyConditionVisibility(k, true); conditionButtons[k]->setEnabledState(true); } //processor->trialCircularBuffer->unlockConditions(); } } else { // probably a condition button int conditionID = cbtn->getUserDefinedData(); cbtn->setEnabledState(!cbtn->getEnabledState()); processor->trialCircularBuffer->modifyConditionVisibilityusingConditionID(conditionID, cbtn->getEnabledState()); } repaint(); }
void ConditionList::updateConditionButtons() { if (processor->trialCircularBuffer != nullptr) { const ScopedLock myScopedLock(processor->trialCircularBuffer->psthMutex); //processor->trialCircularBuffer->lockConditions(); conditionButtons.clear(); for (int k = 0; k<processor->trialCircularBuffer->getNumConditions(); k++) { Condition cond = processor->trialCircularBuffer->getCondition(k); ColorButton* conditionButton = new ColorButton(cond.name, Font("Default", 20, Font::plain)); conditionButton->setBounds(0, 50 + k * 20, 200, 20); conditionButton->setColors(Colours::white, juce::Colour::fromRGB(cond.colorRGB[0], cond.colorRGB[1], cond.colorRGB[2])); conditionButton->setEnabledState(cond.visible); conditionButton->setUserDefinedData(cond.conditionID); conditionButton->setShowEnabled(true); conditionButton->addListener(this); addAndMakeVisible(conditionButton); conditionButtons.add(conditionButton); } //processor->trialCircularBuffer->unlockConditions(); } }
void ChooseColorDialog::updateColorGroup() { // cannot use dataSourceList.fileNames() as it contains datasources that // are not used by any curves or vectors DataVectorList vcList = _store->getObjects<DataVector>(); QStringList fileNameList; for (DataVectorList::Iterator vc_iter = vcList.begin(); vc_iter != vcList.end(); ++vc_iter) { if (fileNameList.contains((*vc_iter)->dp()->filename()) == 0) fileNameList.push_back((*vc_iter)->dp()->filename()); } cleanColorGroup(); grid = new QGridLayout(colorFrame); grid->setSpacing(8); grid->setColumnStretch(1,0); int i = fileNameList.count(); for (QStringList::Iterator it = fileNameList.begin(); it != fileNameList.end(); ++it) { QLineEdit* dataSourceName = new QLineEdit(colorFrame); dataSourceName->setReadOnly(true); dataSourceName->setText(*it); grid->addWidget(dataSourceName,i,0); lineEdits.push_back(dataSourceName); dataSourceName->show(); ColorButton* dataSourceColor = new ColorButton(colorFrame); dataSourceColor->setColor(ColorSequence::next()); grid->addWidget(dataSourceColor,i,1); colorButtons.push_back(dataSourceColor); dataSourceColor->show(); i++; } adjustSize(); resize(QSize(500, minimumSizeHint().height())); setFixedHeight(height()); }
void ChooseColorDialog::updateColorGroup() { // cannot use dataSourceList.fileNames() as it contains datasources that // are not used by any curves or vectors DataVectorList vcList = _store->getObjects<DataVector>(); _dataSourceColors.clear(); for (DataVectorList::Iterator vc_iter = vcList.begin(); vc_iter != vcList.end(); ++vc_iter) { if (! (_dataSourceColors.contains((*vc_iter)->dataSource()))) _dataSourceColors[(*vc_iter)->dataSource()] = (*vc_iter)->dataSource()->color(); } cleanColorGroup(); _grid = new QGridLayout(colorFrame); _grid->setSpacing(8); _grid->setColumnStretch(0,1); _grid->setColumnMinimumWidth(0,450); int i=0; QMapIterator<DataSourcePtr, QColor> it(_dataSourceColors); while (it.hasNext()) { it.next(); QLineEdit* dataSourceName = new QLineEdit(colorFrame); dataSourceName->setReadOnly(true); dataSourceName->setText(it.key()->fileName()); _grid->addWidget(dataSourceName,i,0); _lineEdits.push_back(dataSourceName); dataSourceName->show(); ColorButton* dataSourceColor = new ColorButton(colorFrame); dataSourceColor->setColor(it.value()); _grid->addWidget(dataSourceColor,i,1); _colorButtons.push_back(dataSourceColor); dataSourceColor->show(); i++; } adjustSize(); }
QWidget *CustomColor::settingsWidget() { if (!m_settingsWidget) { m_settingsWidget = new QWidget(); QHBoxLayout *layout = new QHBoxLayout(m_settingsWidget); QLabel *label = new QLabel(tr("Custom Color:"), m_settingsWidget); ColorButton *button = new ColorButton(m_settingsWidget); layout->addWidget(label); layout->addWidget(button); button->setColor(Color::color()); connect(button, SIGNAL(colorChanged(QColor)), this, SLOT(colorChanged(QColor))); connect(m_settingsWidget, SIGNAL(destroyed()), this, SLOT(settingsWidgetDestroyed())); } return m_settingsWidget; }
void CustomColorsWidget::CreateButtons() { int titleRow = 1 ? includeTitleRow : 0; for (int row=0; row<buttonsHigh; ++row) { for (int col=0; col<buttonsWide; ++col) { ColorButton *newButton = new ColorButton(); newButton->setEnabled(false); newButton->SetRow(row); newButton->SetColumn(col); newButton->setCheckable(true); connect(newButton, SIGNAL(clicked(QColor)), this, SIGNAL(colorClicked(QColor))); connect(newButton, SIGNAL(clicked(QColor,int,int)), this, SLOT(setCurrentColor(QColor,int,int))); newButton->SetBackgroundColor(QColor::fromRgb(255, 255, 255)); gridLayout->addWidget(newButton, row+titleRow, col); buttons.push_back(newButton); buttonGroup->addButton(newButton); } } if (includeTitleRow) { QLabel *titleLabel = new QLabel("Custom Colors:"); titleLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); gridLayout->addWidget(titleLabel, 0, 0, 1, gridLayout->columnCount()); } QPushButton *removeColorButton = new QPushButton(); removeColorButton->setText("Remove From Custom Colors"); removeColorButton->setFixedHeight(27); connect(removeColorButton, SIGNAL(clicked()), this, SLOT(removeColor())); gridLayout->addWidget(removeColorButton, gridLayout->rowCount(), 0, 1, gridLayout->columnCount()); }
Mask* MaskByColorCommand::generateMask(const Sprite* sprite, const Image* image, int xpos, int ypos) { int color, tolerance; color = color_utils::color_for_image(m_buttonColor->getColor(), sprite->pixelFormat()); tolerance = m_sliderTolerance->getValue(); base::UniquePtr<Mask> mask(new Mask()); mask->byColor(image, color, tolerance); mask->offsetOrigin(xpos, ypos); return mask.release(); }
ColorButton* HelloWorld::createRect(Color4B color4B1,Color4B color4B2,int horizontal,int vertical) { Size rect = VisibleRect::getVisibleRect().size; ColorButton * layer = ColorButton::createWithColor(color4B1, color4B1); layer->setTag(horizontal+vertical*2); layer->setAnchorPoint(Point(0.0f,1.0f)); layer->ignoreAnchorPointForPosition(false); layer->setContentSize(rect/2); layer->setPosition(VisibleRect::leftTop()+Point(rect.width/2*horizontal,-rect.height/2*vertical)); addChild(layer); return layer; }
void CustomColorsWidget::removeColor() { ColorButton *currentButton = 0; for (std::vector<ColorButton*>::iterator it=buttons.begin(); it != buttons.end(); ++it) { currentButton = *it; if (currentButton && currentButton->GetRow() == selectedRow && currentButton->GetColumn() == selectedCol) { currentButton->SetBackgroundColor(QColor::fromRgb(255, 255, 255)); currentButton->setEnabled(false); break; } } currentButton = *buttons.begin(); if (currentButton) currentButton->setChecked(true); }
void ColorPicker::onColorSelected(QAbstractButton *b) { ColorButton * cbt = static_cast<ColorButton*>(b); ColorButton * fbbt = static_cast<ColorButton*>(fbframe->buttons->checkedButton()); fbbt->setColor(cbt->CurrentColor); }
//========================================================================================================== CFrame::CFrame(QWidget *parent, CPStyles style): QFrame(parent){ //................................................ this->setObjectName(QStringLiteral("CFrame")); this->setFrameShape(QFrame::StyledPanel); this->setLineWidth(1); //................................................ int cbcount; if ((style == maxvertical)||(style == maxhorizontal)){ cbcount = MAX_CBUTTONS; } else if ((style == vertical)||(style == horizontal)){ cbcount = STD_CBUTTONS; } else{ cbcount = MIN_CBUTTONS; } for (int i=0; i<cbcount; i++){ ColorButton *cb = new ColorButton(this); cb->setMaximumSize(CBUTTON_SIZE); cb->setObjectName(QString("colButton").append(QString::number(i))); colButtons.push_back(cb); } //................................................... buttons = new QButtonGroup(this); gridLayout = new QGridLayout(this); gridLayout->setSpacing(2); gridLayout->setObjectName(QStringLiteral("gridLayout")); gridLayout->setContentsMargins(0, 0, 0, 0); int columns; switch(style){ case maxvertical:{ columns = MAX_VERTICAL_COLUMNS; break; } case vertical:{ columns = VERTICAL_COLUMNS; break; } case maxhorizontal:{ columns = MAX_HORIZONTAL_COLUMNS; break; } case horizontal:{ columns = HORIZONTAL_COLUMNS; break; } case minvertical:{ columns = MIN_VERTICAL_COLUMNS; break; } case minhorizontal:{ columns = MIN_HORIZONTAL_COLUMNS; break; } }; int r = 0; int c = 0; for (ColorButton *cb : colButtons){ gridLayout->addWidget(cb, r, c, 1, 1); buttons->addButton(cb); c++; if (c==columns){ c = 0; r++; } } }
void OptionsCommand::onExecute(Context* context) { // Load the window widget UniquePtr<Window> window(app::load_widget<Window>("options.xml", "options")); Widget* check_smooth = app::find_widget<Widget>(window, "smooth"); Widget* move_click2 = app::find_widget<Widget>(window, "move_click2"); Widget* draw_click2 = app::find_widget<Widget>(window, "draw_click2"); Widget* cursor_color_box = app::find_widget<Widget>(window, "cursor_color_box"); Widget* grid_color_box = app::find_widget<Widget>(window, "grid_color_box"); Widget* pixel_grid_color_box = app::find_widget<Widget>(window, "pixel_grid_color_box"); m_checked_bg = app::find_widget<ComboBox>(window, "checked_bg_size"); m_checked_bg_zoom = app::find_widget<Widget>(window, "checked_bg_zoom"); Widget* checked_bg_color1_box = app::find_widget<Widget>(window, "checked_bg_color1_box"); Widget* checked_bg_color2_box = app::find_widget<Widget>(window, "checked_bg_color2_box"); Button* checked_bg_reset = app::find_widget<Button>(window, "checked_bg_reset"); Widget* undo_size_limit = app::find_widget<Widget>(window, "undo_size_limit"); Widget* undo_goto_modified = app::find_widget<Widget>(window, "undo_goto_modified"); Widget* button_ok = app::find_widget<Widget>(window, "button_ok"); // Cursor color ColorButton* cursor_color = new ColorButton(Editor::get_cursor_color(), IMAGE_RGB); cursor_color->setId("cursor_color"); cursor_color_box->addChild(cursor_color); // Get global settings for documents IDocumentSettings* docSettings = context->getSettings()->getDocumentSettings(NULL); // Grid color ColorButton* grid_color = new ColorButton(docSettings->getGridColor(), IMAGE_RGB); grid_color->setId("grid_color"); grid_color_box->addChild(grid_color); // Pixel grid color ColorButton* pixel_grid_color = new ColorButton(docSettings->getPixelGridColor(), IMAGE_RGB); pixel_grid_color->setId("pixel_grid_color"); pixel_grid_color_box->addChild(pixel_grid_color); // Others if (get_config_bool("Options", "MoveClick2", false)) move_click2->setSelected(true); if (get_config_bool("Options", "DrawClick2", false)) draw_click2->setSelected(true); if (get_config_bool("Options", "MoveSmooth", true)) check_smooth->setSelected(true); // Checked background size m_checked_bg->addItem("16x16"); m_checked_bg->addItem("8x8"); m_checked_bg->addItem("4x4"); m_checked_bg->addItem("2x2"); m_checked_bg->setSelectedItem((int)RenderEngine::getCheckedBgType()); // Zoom checked background if (RenderEngine::getCheckedBgZoom()) m_checked_bg_zoom->setSelected(true); // Checked background colors m_checked_bg_color1 = new ColorButton(RenderEngine::getCheckedBgColor1(), IMAGE_RGB); m_checked_bg_color2 = new ColorButton(RenderEngine::getCheckedBgColor2(), IMAGE_RGB); checked_bg_color1_box->addChild(m_checked_bg_color1); checked_bg_color2_box->addChild(m_checked_bg_color2); // Reset button checked_bg_reset->Click.connect(Bind<void>(&OptionsCommand::onResetCheckedBg, this)); // Undo limit undo_size_limit->setTextf("%d", get_config_int("Options", "UndoSizeLimit", 8)); // Goto modified frame/layer on undo/redo if (get_config_bool("Options", "UndoGotoModified", true)) undo_goto_modified->setSelected(true); // Show the window and wait the user to close it window->openWindowInForeground(); if (window->getKiller() == button_ok) { int undo_size_limit_value; Editor::set_cursor_color(cursor_color->getColor()); docSettings->setGridColor(grid_color->getColor()); docSettings->setPixelGridColor(pixel_grid_color->getColor()); set_config_bool("Options", "MoveSmooth", check_smooth->isSelected()); set_config_bool("Options", "MoveClick2", move_click2->isSelected()); set_config_bool("Options", "DrawClick2", draw_click2->isSelected()); RenderEngine::setCheckedBgType((RenderEngine::CheckedBgType)m_checked_bg->getSelectedItem()); RenderEngine::setCheckedBgZoom(m_checked_bg_zoom->isSelected()); RenderEngine::setCheckedBgColor1(m_checked_bg_color1->getColor()); RenderEngine::setCheckedBgColor2(m_checked_bg_color2->getColor()); undo_size_limit_value = undo_size_limit->getTextInt(); undo_size_limit_value = MID(1, undo_size_limit_value, 9999); set_config_int("Options", "UndoSizeLimit", undo_size_limit_value); set_config_bool("Options", "UndoGotoModified", undo_goto_modified->isSelected()); // Save configuration flush_config_file(); } }
void MaskByColorCommand::onExecute(Context* context) { const ContextReader reader(context); const Sprite* sprite = reader.sprite(); Box* box1, *box2, *box3, *box4; Widget* label_color; Widget* label_tolerance; Button* button_ok; Button* button_cancel; if (!App::instance()->isGui() || !sprite) return; int xpos, ypos; const Image* image = reader.image(&xpos, &ypos); if (!image) return; base::UniquePtr<Window> window(new Window(Window::WithTitleBar, "Mask by Color")); box1 = new Box(JI_VERTICAL); box2 = new Box(JI_HORIZONTAL); box3 = new Box(JI_HORIZONTAL); box4 = new Box(JI_HORIZONTAL | JI_HOMOGENEOUS); label_color = new Label("Color:"); m_buttonColor = new ColorButton (get_config_color("MaskColor", "Color", ColorBar::instance()->getFgColor()), sprite->pixelFormat()); label_tolerance = new Label("Tolerance:"); m_sliderTolerance = new Slider(0, 255, get_config_int("MaskColor", "Tolerance", 0)); m_checkPreview = new CheckBox("&Preview"); button_ok = new Button("&OK"); button_cancel = new Button("&Cancel"); if (get_config_bool("MaskColor", "Preview", true)) m_checkPreview->setSelected(true); button_ok->Click.connect(Bind<void>(&Window::closeWindow, window.get(), button_ok)); button_cancel->Click.connect(Bind<void>(&Window::closeWindow, window.get(), button_cancel)); m_buttonColor->Change.connect(Bind<void>(&MaskByColorCommand::maskPreview, this, Ref(reader))); m_sliderTolerance->Change.connect(Bind<void>(&MaskByColorCommand::maskPreview, this, Ref(reader))); m_checkPreview->Click.connect(Bind<void>(&MaskByColorCommand::maskPreview, this, Ref(reader))); button_ok->setFocusMagnet(true); m_buttonColor->setExpansive(true); m_sliderTolerance->setExpansive(true); box2->setExpansive(true); window->addChild(box1); box1->addChild(box2); box1->addChild(box3); box1->addChild(m_checkPreview); box1->addChild(box4); box2->addChild(label_color); box2->addChild(m_buttonColor); box3->addChild(label_tolerance); box3->addChild(m_sliderTolerance); box4->addChild(button_ok); box4->addChild(button_cancel); // Default position window->remapWindow(); window->centerWindow(); // Mask first preview maskPreview(reader); // Load window configuration load_window_pos(window, "MaskColor"); // Open the window window->openWindowInForeground(); bool apply = (window->getKiller() == button_ok); ContextWriter writer(reader); Document* document(writer.document()); if (apply) { Transaction transaction(writer.context(), "Mask by Color", DoesntModifyDocument); base::UniquePtr<Mask> mask(generateMask(sprite, image, xpos, ypos)); transaction.execute(new cmd::SetMask(document, mask)); transaction.commit(); set_config_color("MaskColor", "Color", m_buttonColor->getColor()); set_config_int("MaskColor", "Tolerance", m_sliderTolerance->getValue()); set_config_bool("MaskColor", "Preview", m_checkPreview->isSelected()); } // Update boundaries and editors. document->generateMaskBoundaries(); update_screen_for_document(document); // Save window configuration. save_window_pos(window, "MaskColor"); }