Пример #1
0
void ConfigureTools::onAirSpeedSliderChange()
{
  ISettings* settings = UIContext::instance()->getSettings();
  Tool* current_tool = settings->getCurrentTool();

  settings->getToolSettings(current_tool)->setSpraySpeed(m_airSpeed->getValue());
}
Пример #2
0
void ConfigureTools::onToleranceSliderChange()
{
  ISettings* settings = UIContext::instance()->getSettings();
  Tool* current_tool = settings->getCurrentTool();

  settings->getToolSettings(current_tool)->setTolerance(m_tolerance->getValue());
}
Пример #3
0
void ConfigureTools::onSprayWidthSliderChange()
{
  ISettings* settings = UIContext::instance()->getSettings();
  Tool* current_tool = settings->getCurrentTool();

  settings->getToolSettings(current_tool)->setSprayWidth(m_sprayWidth->getValue());
}
Пример #4
0
QString CentralServiceReporter::workspaceId() const
{
    QObject parent;
    ISettings *settings = m_proxyConnection->settings(&parent);
    settings->beginGroup("current_workspace");
    return settings->value("id").toString();
}
Пример #5
0
void ConfigureTools::onOpacitySliderChange()
{
  ISettings* settings = UIContext::instance()->getSettings();
  Tool* current_tool = settings->getCurrentTool();

  settings->getToolSettings(current_tool)->setOpacity(m_opacity->getValue());
}
Пример #6
0
  void onExecute(Context* context)
  {
    ISettings* settings = context->getSettings();

    settings->setGridVisible(settings->getGridVisible() ? false: true);
    refresh_all_editors();
  }
Пример #7
0
  void onExecute(Context* context)
  {
    ISettings* settings = context->getSettings();
    char buf[512];

    settings->setSnapToGrid(settings->getSnapToGrid() ? false: true);
    refresh_all_editors();

    usprintf(buf, "Snap to grid: %s",
	     (settings->getSnapToGrid() ? "On": "Off"));

    app_get_statusbar()->setStatusText(250, buf);
  }
Пример #8
0
 std::string get(const std::string& key) const override {
   auto found = settings_.find(key);
   if (found != settings_.end())
     return found->second;
   if (parent_settings_)
     return parent_settings_->get(key);
   return "";
 }
Пример #9
0
/**
 * @brief If is currently a server, reports updates in sync journal to the central services.
 * @return True if success
 */
bool CentralServiceReporter::reportSyncJournal()
{
    QObject parent;
    if (!m_proxyConnection->session(&parent)->isServer())
        return true;

    bool ok;
    QVariantMap serverState = getServerSyncState(&ok);
    if (!ok) {
        m_proxyConnection->message("Central Service Report: Failed to access the service");
        return false;
    }

    SyncServer syncServer(m_proxyConnection);
    QVariantList updates = syncServer.updates(serverState, true, QString());
    if (!updates.count())
        return true;

    ISettings *settings = m_proxyConnection->settings(&parent);
    settings->beginGroup("current_workspace");

    QVariantMap message;
    message.insert("workspace_id", settings->value("id").toString());
    message.insert("workspace_name", settings->value("name").toString());

    bool success = true;
    if (updates.count() < MaxUpdatesInReport) {
        message.insert("updates", updates);
        success = sendUpdates(message);
    } else {
        for (int i = 0; i < updates.count() && success; i += MaxUpdatesInReport) {
            message.insert("updates", updates.mid(i, MaxUpdatesInReport));
            success = sendUpdates(message);
        }
    }
    if (!success)
        m_proxyConnection->message("Central Service Report: Failed to report updates to the service");
    return success;
}
Пример #10
0
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());
}
Пример #11
0
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();
}
Пример #12
0
  bool onChecked(Context* context)
  {
    ISettings* settings = context->getSettings();

    return settings->getSnapToGrid();
  }
Пример #13
0
  bool onChecked(Context* context)
  {
    ISettings* settings = context->getSettings();

    return settings->getGridVisible();
  }