void StandbyState::Decorator::postRenderDecorator(EditorPostRender* render) { Editor* editor = render->getEditor(); // Draw transformation handles (if the mask is visible and isn't frozen). if (editor->isActive() && editor->editorFlags() & Editor::kShowMask && editor->document()->isMaskVisible() && !editor->document()->mask()->isFrozen()) { // And draw only when the user has a selection tool as active tool. tools::Ink* ink = editor->getCurrentEditorInk(); if (ink->isSelection()) getTransformHandles(editor)->drawHandles(editor, m_standbyState->getTransformation(editor)); } // Draw transformation handles (if the mask is visible and isn't frozen). gfx::Rect box1, box2; if (StandbyState::Decorator::getSymmetryHandles(editor, box1, box2)) { skin::SkinTheme* theme = static_cast<skin::SkinTheme*>(CurrentTheme::get()); she::Surface* part = theme->parts.transformationHandle()->bitmap(0); ScreenGraphics g; g.drawRgbaSurface(part, box1.x, box1.y); g.drawRgbaSurface(part, box2.x, box2.y); } }
void StandbyState::Decorator::postRenderDecorator(EditorPostRender* render) { Editor* editor = render->getEditor(); // Draw transformation handles (if the mask is visible and isn't frozen). if (editor->editorFlags() & Editor::kShowMask && editor->document()->isMaskVisible() && !editor->document()->mask()->isFrozen()) { // And draw only when the user has a selection tool as active tool. tools::Ink* ink = editor->getCurrentEditorInk(); if (ink->isSelection()) getTransformHandles(editor)->drawHandles(editor, m_standbyState->getTransformation(editor)); } }
bool StandbyState::Decorator::onSetCursor(Editor* editor) { if (!editor->document()->isMaskVisible()) return false; const gfx::Transformation transformation(m_standbyState->getTransformation(editor)); TransformHandles* tr = getTransformHandles(editor); HandleType handle = tr->getHandleAtPoint(editor, ui::get_mouse_position(), transformation); CursorType newCursor = kArrowCursor; switch (handle) { case ScaleNWHandle: newCursor = kSizeNWCursor; break; case ScaleNHandle: newCursor = kSizeNCursor; break; case ScaleNEHandle: newCursor = kSizeNECursor; break; case ScaleWHandle: newCursor = kSizeWCursor; break; case ScaleEHandle: newCursor = kSizeECursor; break; case ScaleSWHandle: newCursor = kSizeSWCursor; break; case ScaleSHandle: newCursor = kSizeSCursor; break; case ScaleSEHandle: newCursor = kSizeSECursor; break; case RotateNWHandle: newCursor = kRotateNWCursor; break; case RotateNHandle: newCursor = kRotateNCursor; break; case RotateNEHandle: newCursor = kRotateNECursor; break; case RotateWHandle: newCursor = kRotateWCursor; break; case RotateEHandle: newCursor = kRotateECursor; break; case RotateSWHandle: newCursor = kRotateSWCursor; break; case RotateSHandle: newCursor = kRotateSCursor; break; case RotateSEHandle: newCursor = kRotateSECursor; break; case PivotHandle: newCursor = kHandCursor; break; default: return false; } // Adjust the cursor depending the current transformation angle. fixmath::fixed angle = fixmath::ftofix(128.0 * transformation.angle() / PI); angle = fixmath::fixadd(angle, fixmath::itofix(16)); angle &= (255<<16); angle >>= 16; angle /= 32; if (newCursor >= kSizeNCursor && newCursor <= kSizeNWCursor) { size_t num = sizeof(rotated_size_cursors) / sizeof(rotated_size_cursors[0]); size_t c; for (c=num-1; c>0; --c) if (rotated_size_cursors[c] == newCursor) break; newCursor = rotated_size_cursors[(c+angle) % num]; } else if (newCursor >= kRotateNCursor && newCursor <= kRotateNWCursor) { size_t num = sizeof(rotated_rotate_cursors) / sizeof(rotated_rotate_cursors[0]); size_t c; for (c=num-1; c>0; --c) if (rotated_rotate_cursors[c] == newCursor) break; newCursor = rotated_rotate_cursors[(c+angle) % num]; } // Hide the drawing cursor (just in case) and show the new system cursor. editor->hideDrawingCursor(); ui::set_mouse_cursor(newCursor); return true; }
bool StandbyState::Decorator::onSetCursor(tools::Ink* ink, Editor* editor, const gfx::Point& mouseScreenPos) { if (!editor->isActive()) return false; if (ink && ink->isSelection() && editor->document()->isMaskVisible()) { const gfx::Transformation transformation(m_standbyState->getTransformation(editor)); TransformHandles* tr = getTransformHandles(editor); HandleType handle = tr->getHandleAtPoint( editor, mouseScreenPos, transformation); CursorType newCursor = kArrowCursor; switch (handle) { case ScaleNWHandle: newCursor = kSizeNWCursor; break; case ScaleNHandle: newCursor = kSizeNCursor; break; case ScaleNEHandle: newCursor = kSizeNECursor; break; case ScaleWHandle: newCursor = kSizeWCursor; break; case ScaleEHandle: newCursor = kSizeECursor; break; case ScaleSWHandle: newCursor = kSizeSWCursor; break; case ScaleSHandle: newCursor = kSizeSCursor; break; case ScaleSEHandle: newCursor = kSizeSECursor; break; case RotateNWHandle: newCursor = kRotateNWCursor; break; case RotateNHandle: newCursor = kRotateNCursor; break; case RotateNEHandle: newCursor = kRotateNECursor; break; case RotateWHandle: newCursor = kRotateWCursor; break; case RotateEHandle: newCursor = kRotateECursor; break; case RotateSWHandle: newCursor = kRotateSWCursor; break; case RotateSHandle: newCursor = kRotateSCursor; break; case RotateSEHandle: newCursor = kRotateSECursor; break; case PivotHandle: newCursor = kHandCursor; break; default: return false; } // Adjust the cursor depending the current transformation angle. fixmath::fixed angle = fixmath::ftofix(128.0 * transformation.angle() / PI); angle = fixmath::fixadd(angle, fixmath::itofix(16)); angle &= (255<<16); angle >>= 16; angle /= 32; if (newCursor >= kSizeNCursor && newCursor <= kSizeNWCursor) { size_t num = sizeof(rotated_size_cursors) / sizeof(rotated_size_cursors[0]); size_t c; for (c=num-1; c>0; --c) if (rotated_size_cursors[c] == newCursor) break; newCursor = rotated_size_cursors[(c+angle) % num]; } else if (newCursor >= kRotateNCursor && newCursor <= kRotateNWCursor) { size_t num = sizeof(rotated_rotate_cursors) / sizeof(rotated_rotate_cursors[0]); size_t c; for (c=num-1; c>0; --c) if (rotated_rotate_cursors[c] == newCursor) break; newCursor = rotated_rotate_cursors[(c+angle) % num]; } editor->showMouseCursor(newCursor); return true; } gfx::Rect box1, box2; if (getSymmetryHandles(editor, box1, box2) && (box1.contains(mouseScreenPos) || box2.contains(mouseScreenPos))) { switch (Preferences::instance().document(editor->document()).symmetry.mode()) { case app::gen::SymmetryMode::HORIZONTAL: editor->showMouseCursor(kSizeWECursor); break; case app::gen::SymmetryMode::VERTICAL: editor->showMouseCursor(kSizeNSCursor); break; } return true; } return false; }