diff --git a/uppsrc/Painter/Stroker.cpp b/uppsrc/Painter/Stroker.cpp index 5f5a0f9e7..25d39b8d1 100644 --- a/uppsrc/Painter/Stroker.cpp +++ b/uppsrc/Painter/Stroker.cpp @@ -78,7 +78,7 @@ void Stroker::Line(const Pointf& p3) Pointf v2 = p3 - p2; double l = Length(v2); - if(l < 1e-30) + if(l < 1e-15) return; Pointf o2 = Orthogonal(v2) * w2 / l; Pointf a2 = p2 + o2; diff --git a/uppsrc/RichEdit/Diagram.iml b/uppsrc/RichEdit/Diagram.iml index b1f923cf1..f91227101 100644 --- a/uppsrc/RichEdit/Diagram.iml +++ b/uppsrc/RichEdit/Diagram.iml @@ -2,6 +2,7 @@ PREMULTIPLIED IMAGE_ID(DisplayGrid__UHD) IMAGE_ID(Diagram__UHD) IMAGE_ID(RoundRect__UHD) +IMAGE_ID(RotateCursor__UHD) IMAGE_ID(SelectMode__UHD) IMAGE_ID(Line__UHD) IMAGE_ID(Grid) @@ -34,6 +35,7 @@ IMAGE_ID(Aspect__UHD) IMAGE_ID(DisplayGrid) IMAGE_ID(Diagram) IMAGE_ID(RoundRect) +IMAGE_ID(RotateCursor) IMAGE_ID(SelectMode) IMAGE_ID(Line) IMAGE_ID(HorzCenter) @@ -111,6 +113,32 @@ IMAGE_DATA(119,186,202,116,75,239,183,234,156,41,189,235,106,147,148,222,253,142 IMAGE_DATA(13,179,61,31,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) IMAGE_END_DATA(352, 1) +IMAGE_BEGIN_DATA +IMAGE_DATA(120,156,237,151,65,118,195,32,12,68,125,158,110,122,165,220,255,18,105,183,193,64,64,26,49,194,204,239,99,211,164,32) +IMAGE_DATA(253,1,236,254,188,174,215,245,251,255,99,228,109,253,67,7,111,227,120,34,209,189,89,93,159,146,73,68,47,209,206,159) +IMAGE_DATA(148,5,170,135,97,79,86,102,214,112,244,177,26,111,237,33,174,129,153,100,199,90,55,205,185,49,139,172,204,214,156,206) +IMAGE_DATA(123,137,161,39,38,31,254,174,118,189,169,157,183,104,213,189,74,238,0,55,151,87,127,255,108,225,189,164,209,71,6,170) +IMAGE_DATA(78,175,96,247,189,249,9,107,50,105,246,216,251,12,212,183,107,128,235,97,209,237,167,245,123,150,243,214,216,56,3,214) +IMAGE_DATA(189,98,174,179,55,0,245,174,102,213,29,19,86,119,109,108,148,129,203,255,23,15,203,123,40,199,6,25,160,246,12,251) +IMAGE_DATA(30,189,122,53,37,206,0,177,87,216,222,75,118,202,96,199,59,115,148,29,50,216,249,221,97,148,233,28,42,127,19,94) +IMAGE_DATA(155,133,133,117,122,201,154,129,203,255,97,25,44,169,9,52,178,50,149,65,229,251,225,245,0,71,86,50,101,16,233,127) +IMAGE_DATA(155,12,18,220,67,39,178,242,12,40,187,58,214,12,204,107,32,139,127,8,209,25,236,118,55,51,136,242,191,243,51,114) +IMAGE_DATA(37,81,103,224,99,206,114,157,201,185,158,14,218,127,51,211,242,179,137,57,159,204,208,25,40,191,55,50,31,96,174,83) +IMAGE_DATA(64,158,1,249,159,199,114,6,186,243,0,114,60,13,132,59,237,125,59,136,51,128,56,67,39,227,241,167,187,199,143,199) +IMAGE_DATA(161,238,30,63,158,59,72,119,15,6,249,231,34,255,92,44,30,245,236,197,97,113,169,189,143,197,242,46,35,255,56,228) +IMAGE_DATA(159,139,252,115,145,127,46,242,207,69,254,185,200,63,23,249,231,34,255,92,228,159,139,252,115,129,251,87,6,195,88,93) +IMAGE_DATA(234,12,96,176,122,148,127,12,242,207,101,149,127,101,112,199,243,46,163,103,176,31,175,67,221,65,62,188,254,116,7,217) +IMAGE_DATA(65,252,31,165,59,200,14,202,157,206,192,60,136,189,127,155,75,103,96,24,164,51,75,150,39,103,16,225,75,103,96,156) +IMAGE_DATA(8,87,150,57,79,204,96,104,239,27,247,170,206,192,119,34,29,233,12,244,137,220,251,183,53,148,193,7,43,220,123,214) +IMAGE_DATA(121,114,6,171,157,12,173,117,72,6,195,238,1,123,127,122,205,242,187,206,117,179,113,235,109,225,94,60,61,3,166,251) +IMAGE_DATA(91,13,223,168,213,11,170,129,193,148,251,74,255,33,117,28,146,129,215,61,186,231,147,50,200,230,190,90,215,8,181,94) +IMAGE_DATA(130,106,67,48,237,125,161,251,106,141,142,12,50,229,80,173,47,161,251,106,189,206,12,152,57,52,107,74,236,190,90,251) +IMAGE_DATA(40,189,158,89,181,131,250,96,96,170,125,32,135,136,126,186,235,57,107,103,98,238,99,48,7,107,143,67,243,2,234,205) +IMAGE_DATA(64,68,95,161,3,84,95,38,220,61,70,103,1,174,39,35,208,190,61,153,4,175,153,157,16,31,43,169,245,64,179,105) +IMAGE_DATA(35,108,95,70,210,170,155,228,16,65,232,29,129,160,87,35,197,88,12,233,114,232,213,68,49,180,134,240,231,166,195,249) +IMAGE_DATA(147,189,151,176,222,27,79,247,94,99,250,253,18,52,196,29,57,207,199,99,93,255,1,4,161,216,23,0,0,0,0,0) +IMAGE_END_DATA(736, 1) + IMAGE_BEGIN_DATA IMAGE_DATA(120,156,237,217,81,110,131,48,16,69,209,183,156,46,43,251,223,68,42,71,85,36,192,6,143,25,123,92,124,143,148,79) IMAGE_DATA(248,184,175,184,105,249,121,233,37,0,88,216,251,239,131,24,111,177,65,164,183,216,32,210,190,63,27,140,245,105,158,136) diff --git a/uppsrc/RichEdit/DiagramEditor.h b/uppsrc/RichEdit/DiagramEditor.h index 886618baf..ab716890b 100644 --- a/uppsrc/RichEdit/DiagramEditor.h +++ b/uppsrc/RichEdit/DiagramEditor.h @@ -65,6 +65,7 @@ private: Point dragstart = Point(0, 0); Point dragcurrent = Point(0, 0); Rectf dragfrom = Rect(0, 0, 0, 0); + double base_rotate = 0; Vector sdragfrom; bool doselection = false; // we are doing rect selection bool grid = true; // snap to grid diff --git a/uppsrc/RichEdit/DiagramMouse.cpp b/uppsrc/RichEdit/DiagramMouse.cpp index 15eeea1f5..d409cfff6 100644 --- a/uppsrc/RichEdit/DiagramMouse.cpp +++ b/uppsrc/RichEdit/DiagramMouse.cpp @@ -100,6 +100,10 @@ Image DiagramEditor::CursorImage(Point p, dword keyflags) int m = h.x * h.y; if((h.x || h.y) && i >= 0 && data.item[i].IsLine()) return Image::SizeAll(); + + if(h.x == -1 && h.y == 1) + return DiagramImg::RotateCursor(); + double rot; if(m > 0) rot = - M_PI / 4; @@ -192,6 +196,7 @@ void DiagramEditor::LeftDown(Point p, dword keyflags) FinishText(); dragstart = dragcurrent = p; + base_rotate = CursorItem().rotate; SetCapture(); @@ -296,6 +301,7 @@ void DiagramEditor::MouseMove(Point p, dword keyflags) if(HasCapture() && IsCursor() && (moving || Distance(dragstart, p) >= 8)) { moving = true; DiagramItem& m = CursorItem(); + Pointf p0 = p; Grid(m, p); if(IsNull(draghandle)) { // move selection Rectf to = dragfrom.Offseted(p - dragstart); @@ -319,14 +325,21 @@ void DiagramEditor::MouseMove(Point p, dword keyflags) if(h) (h < 0 ? a1 : a2) = a; }; + Rectf r = m.GetRect(); + Pointf cp = r.CenterPoint(); if(m.IsLine()) { Do(draghandle.x, m.pt[0].x, m.pt[1].x, p.x); Do(draghandle.y, m.pt[0].y, m.pt[1].y, p.y); } + else + if(draghandle.x == -1 && draghandle.y == 1) { + Pointf bl = Xform2D::Rotation(M_2PI * base_rotate / 360).Transform(r.BottomLeft() - cp); + m.rotate = base_rotate + 180.0 * (Bearing((Pointf)p0 - cp) - Bearing(bl)) / M_PI; + if(grid && !GetShift()) + m.rotate = int(m.rotate + 360 + 7) / 15 * 15; + } else { bool rotated = m.rotate && !m.IsLine(); - Rectf r = m.GetRect(); - Pointf cp = r.CenterPoint(); if(rotated) { p -= cp; p = Xform2D::Rotation(-M_2PI * m.rotate / 360).Transform(p); diff --git a/uppsrc/RichText/DiagramShape.cpp b/uppsrc/RichText/DiagramShape.cpp index 9783c1a66..cfc1b5a2a 100644 --- a/uppsrc/RichText/DiagramShape.cpp +++ b/uppsrc/RichText/DiagramShape.cpp @@ -182,6 +182,8 @@ void DiagramItem::Paint(Painter& w, const Diagram& diagram, dword style, const I .Stroke(6, (style & Display::SELECT ? 30 : 200) * sel1); w.RoundedRectangle(-1, -1, w1 + 2, h + 2, 2) .Stroke(2, Gray()); + if(style & Display::CURSOR) + w.Circle(0, h, 6).Stroke(1, Red()); }