void NewBrushCommand::onExecute(Context* context) { ASSERT(current_editor); if (!current_editor) return; // If there is no visible mask, the brush must be selected from the // current editor. if (!context->activeDocument()->isMaskVisible()) { EditorStatePtr state = current_editor->getState(); if (dynamic_cast<SelectBoxState*>(state.get())) { // If already are in "SelectBoxState" state, in this way we // avoid creating a stack of several "SelectBoxState" states. return; } current_editor->setState( EditorStatePtr( new SelectBoxState( this, current_editor->sprite()->bounds(), SelectBoxState::DARKOUTSIDE | SelectBoxState::QUICKBOX))); } // Create a brush from the active selection else { createBrush(context->activeDocument()->mask()); selectPencilTool(); // Deselect mask Command* cmd = CommandsModule::instance()->getCommandByName(CommandId::DeselectMask); UIContext::instance()->executeCommand(cmd); } }
void onEntriesChange() { m_rect = getRectFromEntries(); // Redraw new rulers position if (m_editor) { EditorStatePtr state = m_editor->getState(); if (SelectBoxState* boxState = dynamic_cast<SelectBoxState*>(state.get())) { boxState->setBoxBounds(m_rect); m_editor->invalidate(); } } }
void onEntriesChange() { m_rect = getRectFromEntries(); m_padding = getPaddingFromEntries(); // Redraw new rulers position if (m_editor) { EditorStatePtr state = m_editor->getState(); SelectBoxState* boxState = dynamic_cast<SelectBoxState*>(state.get()); boxState->setBoxBounds(m_rect); boxState->setPaddingBounds(m_padding); if (partialTilesValue()) boxState->setFlag(SelectBoxState::Flags::IncludePartialTiles); else boxState->clearFlag(SelectBoxState::Flags::IncludePartialTiles); m_editor->invalidate(); } }