void ConfigureTools::onAirSpeedSliderChange() { ISettings* settings = UIContext::instance()->getSettings(); Tool* current_tool = settings->getCurrentTool(); settings->getToolSettings(current_tool)->setSpraySpeed(m_airSpeed->getValue()); }
void ConfigureTools::onSprayWidthSliderChange() { ISettings* settings = UIContext::instance()->getSettings(); Tool* current_tool = settings->getCurrentTool(); settings->getToolSettings(current_tool)->setSprayWidth(m_sprayWidth->getValue()); }
void ConfigureTools::onToleranceSliderChange() { ISettings* settings = UIContext::instance()->getSettings(); Tool* current_tool = settings->getCurrentTool(); settings->getToolSettings(current_tool)->setTolerance(m_tolerance->getValue()); }
void ConfigureTools::onOpacitySliderChange() { ISettings* settings = UIContext::instance()->getSettings(); Tool* current_tool = settings->getCurrentTool(); settings->getToolSettings(current_tool)->setOpacity(m_opacity->getValue()); }
void EyedropperCommand::onExecute(Context* context) { Widget* widget = ui::Manager::getDefault()->getMouse(); if (!widget || widget->type != editor_type()) return; Editor* editor = static_cast<Editor*>(widget); Sprite* sprite = editor->sprite(); if (!sprite) return; // pixel position to get gfx::Point pixelPos = editor->screenToEditor(ui::get_mouse_position()); // Check if we've to grab alpha channel or the merged color. ISettings* settings = UIContext::instance()->settings(); bool grabAlpha = settings->getGrabAlpha(); ColorPicker picker; picker.pickColor(editor->getSite(), pixelPos, grabAlpha ? ColorPicker::FromActiveLayer: ColorPicker::FromComposition); if (grabAlpha) { tools::ToolBox* toolBox = App::instance()->getToolBox(); for (tools::ToolIterator it=toolBox->begin(), end=toolBox->end(); it!=end; ++it) { settings->getToolSettings(*it)->setOpacity(picker.alpha()); } } if (m_background) settings->setBgColor(picker.color()); else settings->setFgColor(picker.color()); }
void ConfigureTools::onExecute(Context* context) { Button* set_grid; Widget* brush_preview_box; Widget* brush_type_box; bool first_time = false; if (!window) { window = app::load_widget<Window>("tools_configuration.xml", "configure_tool"); first_time = true; } /* if the window is opened, close it */ else if (window->isVisible()) { window->closeWindow(NULL); return; } try { m_tiled = app::find_widget<CheckBox>(window, "tiled"); m_tiledX = app::find_widget<CheckBox>(window, "tiled_x"); m_tiledY = app::find_widget<CheckBox>(window, "tiled_y"); m_snapToGrid = app::find_widget<CheckBox>(window, "snap_to_grid"); m_viewGrid = app::find_widget<CheckBox>(window, "view_grid"); m_pixelGrid = app::find_widget<CheckBox>(window, "pixel_grid"); set_grid = app::find_widget<Button>(window, "set_grid"); m_brushSize = app::find_widget<Slider>(window, "brush_size"); m_brushAngle = app::find_widget<Slider>(window, "brush_angle"); m_opacity = app::find_widget<Slider>(window, "opacity"); m_tolerance = app::find_widget<Slider>(window, "tolerance"); m_sprayWidth = app::find_widget<Slider>(window, "spray_width"); m_airSpeed = app::find_widget<Slider>(window, "air_speed"); brush_preview_box = app::find_widget<Widget>(window, "brush_preview_box"); brush_type_box = app::find_widget<Widget>(window, "brush_type_box"); m_onionSkin = app::find_widget<CheckBox>(window, "onionskin"); } catch (...) { delete window; window = NULL; throw; } /* brush-preview */ if (first_time) { m_brushPreview = new BrushPreview(); m_brushPreview->min_w = 32 + 4; m_brushPreview->min_h = 32 + 4; m_brushPreview->setId("brush_preview"); } else { m_brushPreview = window->findChild("brush_preview"); } // Current settings ISettings* settings = UIContext::instance()->getSettings(); Tool* current_tool = settings->getCurrentTool(); IToolSettings* tool_settings = settings->getToolSettings(current_tool); /* brush-type */ if (first_time) { PenType type = tool_settings->getPen()->getType(); m_brushType = new ButtonSet(3, 1, type, PART_BRUSH_CIRCLE, PART_BRUSH_SQUARE, PART_BRUSH_LINE); m_brushType->setId("brush_type"); } else { m_brushType = window->findChildT<ButtonSet>("brush_type"); } if (settings->getTiledMode() != TILED_NONE) { m_tiled->setSelected(true); if (settings->getTiledMode() & TILED_X_AXIS) m_tiledX->setSelected(true); if (settings->getTiledMode() & TILED_Y_AXIS) m_tiledY->setSelected(true); } if (settings->getSnapToGrid()) m_snapToGrid->setSelected(true); if (settings->getGridVisible()) m_viewGrid->setSelected(true); if (settings->getPixelGridVisible()) m_pixelGrid->setSelected(true); if (settings->getUseOnionskin()) m_onionSkin->setSelected(true); if (first_time) { // Append children brush_preview_box->addChild(m_brushPreview); brush_type_box->addChild(m_brushType); // Slots window->Close.connect(Bind<void>(&ConfigureTools::onWindowClose, this)); m_tiled->Click.connect(Bind<void>(&ConfigureTools::onTiledClick, this)); m_tiledX->Click.connect(Bind<void>(&ConfigureTools::onTiledXYClick, this, TILED_X_AXIS, m_tiledX)); m_tiledY->Click.connect(Bind<void>(&ConfigureTools::onTiledXYClick, this, TILED_Y_AXIS, m_tiledY)); m_viewGrid->Click.connect(Bind<void>(&ConfigureTools::onViewGridClick, this)); m_pixelGrid->Click.connect(Bind<void>(&ConfigureTools::onPixelGridClick, this)); set_grid->Click.connect(Bind<void>(&ConfigureTools::onSetGridClick, this)); m_snapToGrid->Click.connect(Bind<void>(&ConfigureTools::onSnapToGridClick, this)); m_onionSkin->Click.connect(Bind<void>(&ConfigureTools::onOnionSkinClick, this)); App::instance()->Exit.connect(&on_exit_delete_this_widget); App::instance()->PenSizeAfterChange.connect(&on_pen_size_after_change); App::instance()->CurrentToolChange.connect(&on_current_tool_change); // Append hooks m_brushSize->Change.connect(Bind<void>(&ConfigureTools::onBrushSizeSliderChange, this)); m_brushAngle->Change.connect(Bind<void>(&ConfigureTools::onBrushAngleSliderChange, this)); m_opacity->Change.connect(&ConfigureTools::onOpacitySliderChange, this); m_tolerance->Change.connect(&ConfigureTools::onToleranceSliderChange, this); m_airSpeed->Change.connect(&ConfigureTools::onAirSpeedSliderChange, this); m_sprayWidth->Change.connect(&ConfigureTools::onSprayWidthSliderChange, this); m_brushType->ItemChange.connect(&ConfigureTools::onBrushTypeChange, this); } // Update current pen properties on_current_tool_change(); // Default position window->remap_window(); window->center_window(); // Load window configuration load_window_pos(window, "ConfigureTool"); window->openWindow(); }