mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
RichText: Developing Diagram
This commit is contained in:
parent
e5cd5ec924
commit
a9f7667cc6
4 changed files with 18 additions and 15 deletions
|
|
@ -5,7 +5,6 @@ namespace Upp {
|
|||
ColumnPopUp::ColumnPopUp()
|
||||
{
|
||||
SetFrame(BlackFrame());
|
||||
WhenSelect = [=](int i) { code = i; };
|
||||
}
|
||||
|
||||
void ColumnPopUp::Paint(Draw& w)
|
||||
|
|
@ -62,11 +61,10 @@ void ColumnPopUp::PopUp(Point p, Ctrl *owner)
|
|||
int ColumnPopUp::Execute()
|
||||
{
|
||||
PopUp(GetMousePos(), GetActiveCtrl());
|
||||
code = -1;
|
||||
EventLoop(this);
|
||||
if(IsOpen())
|
||||
Close();
|
||||
return code;
|
||||
return cursor;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ struct ColumnPopUp : Ctrl {
|
|||
Size isz = Size(64, 32);
|
||||
int count = 18;
|
||||
int cursor = -1;
|
||||
int code = -1;
|
||||
|
||||
void Paint(Draw& w) override;
|
||||
void MouseMove(Point p, dword keyflags) override;
|
||||
|
|
|
|||
|
|
@ -112,10 +112,6 @@ void DiagramEditor::LeftDown(Point p, dword keyflags)
|
|||
}
|
||||
}
|
||||
|
||||
if((keyflags & K_CTRL) == 0) {
|
||||
sel.Clear();
|
||||
cursor = -1;
|
||||
}
|
||||
int i = FindItem(p);
|
||||
if(i >= 0) {
|
||||
SetCursor(i);
|
||||
|
|
@ -129,6 +125,7 @@ void DiagramEditor::LeftDown(Point p, dword keyflags)
|
|||
}
|
||||
else {
|
||||
sel.Clear();
|
||||
SetCursor(-1);
|
||||
doselection = true;
|
||||
}
|
||||
|
||||
|
|
@ -178,6 +175,7 @@ void DiagramEditor::MouseMove(Point p, dword keyflags)
|
|||
}
|
||||
m.FixPosition();
|
||||
Sync();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -188,9 +186,15 @@ void DiagramEditor::LeftUp(Point p, dword keyflags)
|
|||
Sync();
|
||||
doselection = false;
|
||||
Commit();
|
||||
if(Distance(dragstart, p) < 2 && CursorItem().IsTextClick(p)) {
|
||||
StartText();
|
||||
return;
|
||||
if(Distance(dragstart, p) < 2) {
|
||||
if((keyflags & K_CTRL) == 0) {
|
||||
sel.Clear();
|
||||
SetCursor(cursor);
|
||||
}
|
||||
if(CursorItem().IsTextClick(p)) {
|
||||
StartText();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -162,21 +162,22 @@ void DiagramItem::Paint(Painter& w, dword style) const
|
|||
Pointf a2 = p2;
|
||||
if(d > 20) { // enough length to have caps
|
||||
if(line_start == CAP_ARROW)
|
||||
a1 += v * 8;
|
||||
a1 += v * 4 * width;
|
||||
if(line_end == CAP_ARROW)
|
||||
a2 -= v * 8;
|
||||
a2 -= v * 4 * width;
|
||||
}
|
||||
|
||||
w.Move(a1).Line(a2);
|
||||
DoDash();
|
||||
w.Stroke(width, ink);
|
||||
w.LineCap(LINECAP_ROUND).Stroke(width, ink);
|
||||
|
||||
Pointf o = Orthogonal(v);
|
||||
if(d > 20) {
|
||||
auto PaintCap = [&](int k, Pointf p, Pointf a) {
|
||||
Pointf oo = width * 2 * o;
|
||||
switch(k) {
|
||||
case CAP_ARROW:
|
||||
w.Move(p).Line(a + 4 * o).Line(a - 4 * o).Fill(ink);
|
||||
w.Move(p).Line(a + oo).Line(a - oo).Fill(ink);
|
||||
break;
|
||||
case CAP_CIRCLE:
|
||||
w.Circle(p, 5).Fill(ink);
|
||||
|
|
@ -214,6 +215,7 @@ void DiagramItem::Paint(Painter& w, dword style) const
|
|||
int txt_cy = txt.GetHeight(zoom, GetRect().GetWidth());
|
||||
Rectf r(p1, p2);
|
||||
r.Normalize();
|
||||
r.Deflate(width / 2);
|
||||
Pointf c = r.CenterPoint();
|
||||
int sz = min(r.Width(), r.Height());
|
||||
switch(shape) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue