Skip to content

Commit

Permalink
tried new element creation approach
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoreilly committed Feb 28, 2024
1 parent 11ba26f commit cfd7af2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 27 deletions.
7 changes: 0 additions & 7 deletions vector/prefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,6 @@ func InitPrefs() {
Prefs.Defaults()
Prefs.Open()
// OpenPaths() // todo
// svg.CurIconSet.OpenIconsFromEmbedDir(icons.Icons, ".")
// gi.CustomAppMenuFunc = func(m *gi.Menu, win *gi.Window) {
// m.InsertActionAfter("GoGi Preferences...", gi.ActOpts{Label: "Vector Preferences..."},
// win, func(recv, send ki.Ki, sig int64, data any) {
// PrefsView(&Prefs)
// })
// }
}

// PrefsFileName is the name of the preferences file in GoGi prefs directory
Expand Down
41 changes: 21 additions & 20 deletions vector/svgview.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,24 +178,6 @@ func (sv *SVGView) HandleEvents() {
sv.UpdateSelect()
}
}
if !es.InAction() {
switch es.Tool {
case RectTool:
sv.NewElDrag(svg.RectType, es.DragStartPos, e.Pos())
es.SelBBox.Min.X += 1
es.SelBBox.Min.Y += 1
es.DragSelStartBBox = es.SelBBox
es.DragSelCurBBox = es.SelBBox
es.DragSelEffBBox = es.SelBBox
case EllipseTool:
sv.NewElDrag(svg.EllipseType, es.DragStartPos, e.Pos())
case TextTool:
sv.NewText(es.DragStartPos, e.Pos())
es.NewTextMade = true
case BezierTool:
sv.NewPath(es.DragStartPos, e.Pos())
}
}
}
// if e.MouseButton() == events.Right {
// e.SetHandled()
Expand All @@ -221,10 +203,29 @@ func (sv *SVGView) HandleEvents() {
if es.HasSelected() {
if !es.NewTextMade {
sv.DragMove(e)
return
}
return
}
if es.Action == "BoxSelect" || (!es.InAction() && es.Tool == SelectTool) {
if !es.InAction() {
switch es.Tool {
case SelectTool:
sv.SetRubberBand(e.Pos())
case RectTool:
sv.NewElDrag(svg.RectType, es.DragStartPos, e.Pos())
es.SelBBox.Min.X += 1
es.SelBBox.Min.Y += 1
es.DragSelStartBBox = es.SelBBox
es.DragSelCurBBox = es.SelBBox
es.DragSelEffBBox = es.SelBBox
case EllipseTool:
sv.NewElDrag(svg.EllipseType, es.DragStartPos, e.Pos())
case TextTool:
sv.NewText(es.DragStartPos, e.Pos())
es.NewTextMade = true
case BezierTool:
sv.NewPath(es.DragStartPos, e.Pos())
}
} else if es.Action == "BoxSelect" {
sv.SetRubberBand(e.Pos())
}
})
Expand Down

0 comments on commit cfd7af2

Please sign in to comment.