| 53 | }; |
| 54 | |
| 55 | HandleType TransformHandles::getHandleAtPoint(Editor* editor, const gfx::Point& pt, const Transformation& transform) |
| 56 | { |
| 57 | SkinTheme* theme = static_cast<SkinTheme*>(CurrentTheme::get()); |
| 58 | she::Surface* gfx = theme->parts.transformationHandle()->bitmap(0); |
| 59 | fixmath::fixed angle = fixmath::ftofix(128.0 * transform.angle() / PI); |
| 60 | |
| 61 | Transformation::Corners corners; |
| 62 | transform.transformBox(corners); |
| 63 | |
| 64 | std::vector<gfx::Point> screenPoints(corners.size()); |
| 65 | for (size_t c=0; c<corners.size(); ++c) |
| 66 | screenPoints[c] = editor->editorToScreen( |
| 67 | gfx::Point((int)corners[c].x, (int)corners[c].y)); |
| 68 | |
| 69 | int handle_rs[2] = { gfx->width()*2, gfx->width()*3 }; |
| 70 | for (int i=0; i<2; ++i) { |
| 71 | int handle_r = handle_rs[i]; |
| 72 | for (size_t c=0; c<HANDLES; ++c) { |
| 73 | if (inHandle(pt, |
| 74 | (screenPoints[handles_info[c].i1].x+screenPoints[handles_info[c].i2].x)/2, |
| 75 | (screenPoints[handles_info[c].i1].y+screenPoints[handles_info[c].i2].y)/2, |
| 76 | handle_r, handle_r, |
| 77 | angle + handles_info[c].angle)) { |
| 78 | return handles_info[c].handle[i]; |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // Check if the cursor is in the pivot |
| 84 | if (visiblePivot(angle) && getPivotHandleBounds(editor, transform, corners).contains(pt)) |
| 85 | return PivotHandle; |
| 86 | |
| 87 | return NoHandle; |
| 88 | } |
| 89 | |
| 90 | void TransformHandles::drawHandles(Editor* editor, const Transformation& transform) |
| 91 | { |
no test coverage detected