Documentation
¶
Overview ¶
Package graph provides a scene-graph editing framework.
It implements a model for interactive graphical editing with items, scenes, tools, selections, undo/redo, and coordinate transformations.
Key types:
- Item/IItem: base graph item with bounds, parent-child hierarchy
- SceneItem: root container for graph items
- GraphView: scrollable, zoomable view of a scene
- Selection: multi-item selection with decoration handles
- Tool/Part: input handling chain (select, move, resize, marquee)
- UndoStack: command-based undo/redo
Index ¶
- Constants
- func AddMoveSubtree(cmd *MoveCommand, item IItem, dx, dy float64)
- func HandleIcon(shape int, active bool) paint.Icon
- func KeepAspect(x0, y0, x1, y1 float64, x2, y2 *float64)
- func LoadIcon(s string) paint.Icon
- func ParentOrigin(parent IItem) (ox, oy float64)
- func ShiftSubtree(item IItem, dx, dy float64)
- func TranslateBetweenParents(from, to IItem, x, y float64) (x1, y1 float64)
- func TraversalCond_Selectable(p IItem) (self, descendants bool)
- func TraversalCond_SelectableAndMoveable(p IItem) (self, descendants bool)
- type AddCommand
- type ArrowTool
- type DbgTreeModel
- func (m *DbgTreeModel) ColCount() int
- func (m *DbgTreeModel) Data(idx gui.ModelIndex, role gui.ItemDataRole) interface{}
- func (m *DbgTreeModel) Flags(idx gui.ModelIndex) gui.ItemFlags
- func (m *DbgTreeModel) HeaderData(section int, vertical bool, role gui.ItemDataRole) interface{}
- func (m *DbgTreeModel) Index(row, col int, parent gui.ModelIndex) gui.ModelIndex
- func (m *DbgTreeModel) Parent(idx gui.ModelIndex) gui.ModelIndex
- func (m *DbgTreeModel) RowCount(parent gui.ModelIndex) int
- func (m *DbgTreeModel) SetRootItems(items []IItem)
- type DbgTreeView
- type Decor
- func (this *Decor) ActiveHandle() int
- func (this *Decor) DrawDefaultHandle(g paint.Painter, x, y float64, shape int, active bool)
- func (this *Decor) HandleAt(x, y float64) int
- func (this *Decor) HandleCursor(handle int) *gui.Cursor
- func (this *Decor) HandleSize() float64
- func (this *Decor) HoverHandle() int
- func (this *Decor) Init(self IDecor)
- func (this *Decor) IsHitCircleHandle(xc, yc, x, y float64) bool
- func (this *Decor) IsHitCircleHandle1(xc, yc, r, x, y float64) bool
- func (this *Decor) IsHitDiamonHandle(xc, yc, x, y float64) bool
- func (this *Decor) IsHitDiamonHandle1(xc, yc, r, x, y float64) bool
- func (this *Decor) IsHitRectHandle(xc, yc, x, y float64) bool
- func (this *Decor) IsHitRectHandle1(xc, yc, r, x, y float64) bool
- func (this *Decor) IsMovingHandle() bool
- func (this *Decor) Item() IItem
- func (this *Decor) NakedDecor() *Decor
- func (this *Decor) OnBeginMoveHandle(handle int, x, y float64)
- func (this *Decor) OnClickHandle(handle int, x, y float64)
- func (this *Decor) OnDraw(g paint.Painter)
- func (this *Decor) OnEndMoveHandle(handle int, x, y float64)
- func (this *Decor) OnMoveHandle(handle int, x, y float64)
- func (this *Decor) Scene() IScene
- func (this *Decor) SetActiveHandle(n int)
- func (this *Decor) SetMovingHandle(b bool)
- func (this *Decor) Update()
- func (this *Decor) View() IView
- type DecorPart
- func (this *DecorPart) HandleSize() float64
- func (this *DecorPart) MapToDecor(x, y float64) (x1, y1 float64)
- func (this *DecorPart) OnLeftDown(x, y float64)
- func (this *DecorPart) OnLeftDragStart(x, y float64)
- func (this *DecorPart) OnLeftUp(x, y float64)
- func (this *DecorPart) OnMouseMove(x, y float64)
- type DeleteCommand
- type GraphView
- func (this *GraphView) Actions() (ret []gui.IAction)
- func (this *GraphView) ActiveTool() ITool
- func (this *GraphView) AddAction(a gui.IAction)
- func (this *GraphView) AddStandardTools()
- func (this *GraphView) AddTool(tool ...ITool)
- func (this *GraphView) DefaultTool() ITool
- func (this *GraphView) DirtyList() []string
- func (this *GraphView) Draw(g paint.Painter)
- func (this *GraphView) FindHandleAt(xMm, yMm float64) (decor IDecor, handle int)
- func (this *GraphView) GetPropertyView() prop.IPropertyView
- func (this *GraphView) Icon() paint.Icon
- func (this *GraphView) Init(iw gui.IWidget)
- func (this *GraphView) IsItemSelected(a IItem) bool
- func (this *GraphView) IsPageMarginVisible() bool
- func (this *GraphView) Layout()
- func (this *GraphView) MapFromScene(x, y float64) (x1, y1 float64)
- func (this *GraphView) MapRectFromScene(x, y, w, h float64) (x1, y1, w1, h1 float64)
- func (this *GraphView) MapRectFromScene1(rect geom.Rect) geom.Rect
- func (this *GraphView) MapRectToScene(x, y, w, h float64) (x1, y1, w1, h1 float64)
- func (this *GraphView) MapRectToScene1(rect geom.Rect) geom.Rect
- func (this *GraphView) MapToScene(x, y float64) (x1, y1 float64)
- func (this *GraphView) OnHorzScroll(sender gui.IWidget)
- func (this *GraphView) OnIdle()
- func (this *GraphView) OnLeftDown(x, y float64)
- func (this *GraphView) OnLeftUp(x, y float64)
- func (this *GraphView) OnMouseMove(x, y float64)
- func (this *GraphView) OnMouseWheel(x, y, z float64)
- func (this *GraphView) OnVertScroll(sender gui.IWidget)
- func (this *GraphView) PaddingPx() (left, right, top, bottom float64)
- func (this *GraphView) PageLayout() PageLayout
- func (this *GraphView) PageOriginPx() (x0, y0 float64)
- func (this *GraphView) PageSizeMm(includeMargin bool) (width, height float64)
- func (this *GraphView) PageSizePx(includeMargin bool, zoom float64) (width, height float64)
- func (this *GraphView) PropertyConfigName() (cfgName string)
- func (this *GraphView) Save() bool
- func (this *GraphView) Scene() IScene
- func (this *GraphView) SceneOriginPx() (x0, y0 float64)
- func (this *GraphView) SceneSizeMm() (width, height float64)
- func (this *GraphView) ScrollSizePx() (width, height float64)
- func (this *GraphView) Selection() *Selection
- func (this *GraphView) SetActiveTool(tool ITool)
- func (this *GraphView) SetDefaultTool(tool ITool)
- func (this *GraphView) SetPaddingMm(left, right, top, bottom float64)
- func (this *GraphView) SetPaddingPx(left, right, top, bottom float64)
- func (this *GraphView) SetPageLayout(mode PageLayout)
- func (this *GraphView) SetPageMarginVisible(b bool)
- func (this *GraphView) SetPropertyConfigName(cfgName string)
- func (this *GraphView) SetPropertyView(propView prop.IPropertyView)
- func (this *GraphView) SetScene(scene IScene)
- func (this *GraphView) SetZoomFactor(z float64)
- func (this *GraphView) SigGenDecors(fn func(s interface{}, item IItem) []IDecor)
- func (this *GraphView) SigItemAttached(fn func(s interface{}, item, parent IItem))
- func (this *GraphView) SigItemDeselected(fn func(s interface{}, item IItem))
- func (this *GraphView) SigItemDetached(fn func(s interface{}, item, parent IItem))
- func (this *GraphView) SigItemSelected(fn func(s interface{}, item IItem))
- func (this *GraphView) SigSelectionChanged(fn func(s interface{}, selection *Selection))
- func (this *GraphView) SigZoomChanged(fn func(s interface{}, zoom float64))
- func (this *GraphView) Title() string
- func (this *GraphView) Tools() []ITool
- func (this *GraphView) ZoomFactor() float64
- type IDecor
- type IItem
- type IPart
- type IScene
- type ITool
- type IView
- type Item
- func (this *Item) Bounds() (x, y, width, height float64)
- func (this *Item) Bounds1() geom.Rect
- func (this *Item) BringToFront()
- func (this *Item) Children() []IItem
- func (this *Item) CoordOffset() (dx, dy float64)
- func (this *Item) DebugFlagsString() (ret string)
- func (this *Item) DebugLabel() string
- func (this *Item) DebugPathString(ancestor IItem) string
- func (this *Item) Detach()
- func (this *Item) DrawAll(g paint.Painter)
- func (this *Item) DrawChildren(g paint.Painter)
- func (this *Item) DrawOutline(g paint.Painter)
- func (this *Item) DrawSelf(g paint.Painter)
- func (this *Item) EaveBounds() (x, y, width, height float64)
- func (this *Item) EaveBounds1() geom.Rect
- func (this *Item) EnumProperties(list prop.IPropertyList)
- func (this *Item) FindItemAt(x, y float64, cond TraversalCond) IItem
- func (this *Item) FindItemsAt(x, y float64, cond TraversalCond) []IItem
- func (this *Item) FindItemsInRect(bounds geom.Rect, cond TraversalCond) []IItem
- func (this *Item) FindItemsInRectF(cx, cy, cw, ch float64, cond TraversalCond) []IItem
- func (this *Item) GenDecors() []IDecor
- func (this *Item) HasChildren() bool
- func (this *Item) HasLocalCoord() bool
- func (this *Item) Height() float64
- func (this *Item) Hide()
- func (this *Item) Icon() paint.Icon
- func (this *Item) IndexInParent() int
- func (this *Item) Init(ig IItem)
- func (this *Item) IsHitBody(x, y float64) bool
- func (this *Item) IsLockPos() bool
- func (this *Item) IsLockSize() bool
- func (this *Item) IsSelectable() bool
- func (this *Item) IsVisible() bool
- func (this *Item) Layout()
- func (this *Item) Lower()
- func (this *Item) MapFromChild(x, y float64) (x1, y1 float64)
- func (this *Item) MapFromItem(a IItem, x, y float64) (x1, y1 float64)
- func (this *Item) MapFromScene(x, y float64) (x1, y1 float64)
- func (this *Item) MapRectFromChild(x, y, width, height float64) (x1, y1, width1, height1 float64)
- func (this *Item) MapRectFromChild1(rect geom.Rect) geom.Rect
- func (this *Item) MapRectFromItem(a IItem, x, y, width, height float64) (x1, y1, width1, height1 float64)
- func (this *Item) MapRectFromItem1(a IItem, rect geom.Rect) geom.Rect
- func (this *Item) MapRectFromScene(x, y, width, height float64) (x1, y1, width1, height1 float64)
- func (this *Item) MapRectFromScene1(rect geom.Rect) geom.Rect
- func (this *Item) MapRectToChild(x, y, width, height float64) (x1, y1, width1, height1 float64)
- func (this *Item) MapRectToChild1(rect geom.Rect) geom.Rect
- func (this *Item) MapRectToItem(a IItem, x, y, width, height float64) (x1, y1, width1, height1 float64)
- func (this *Item) MapRectToItem1(a IItem, rect geom.Rect) geom.Rect
- func (this *Item) MapRectToScene(x, y, width, height float64) (x1, y1, width1, height1 float64)
- func (this *Item) MapRectToScene1(rect geom.Rect) geom.Rect
- func (this *Item) MapToChild(x, y float64) (x1, y1 float64)
- func (this *Item) MapToItem(a IItem, x, y float64) (x1, y1 float64)
- func (this *Item) MapToScene(x, y float64) (x1, y1 float64)
- func (this *Item) MaybeHitBody(x, y float64) bool
- func (this *Item) NakedItem() *Item
- func (this *Item) OnMove()
- func (this *Item) OnResize()
- func (this *Item) Parent() IItem
- func (this *Item) Path(ancestor IItem) []IItem
- func (this *Item) Pos() (x, y float64)
- func (this *Item) Raise()
- func (this *Item) Root() IItem
- func (this *Item) Scene() IScene
- func (this *Item) Self() IItem
- func (this *Item) SendToBack()
- func (this *Item) SetBounds(x, y, width, height float64)
- func (this *Item) SetBounds1(bounds geom.Rect)
- func (this *Item) SetHeight(h float64)
- func (this *Item) SetLocalCoord(b bool)
- func (this *Item) SetLockPos(b bool)
- func (this *Item) SetLockSize(b bool)
- func (this *Item) SetParent(newParent IItem)
- func (this *Item) SetParentAt(newParent IItem, index int)
- func (this *Item) SetPos(x, y float64)
- func (this *Item) SetSelectable(b bool)
- func (this *Item) SetSize(width, height float64)
- func (this *Item) SetVisible(b bool)
- func (this *Item) SetWidth(w float64)
- func (this *Item) SetX(x float64)
- func (this *Item) SetY(y float64)
- func (this *Item) Show()
- func (this *Item) Size() (width, height float64)
- func (this *Item) SizeHints() gui.SizeHints
- func (this *Item) String() string
- func (this *Item) Title() string
- func (this *Item) TreeItems() []IItem
- func (this *Item) Update()
- func (this *Item) Width() float64
- func (this *Item) X() float64
- func (this *Item) Y() float64
- type MarqueePart
- type MoveCommand
- func (cmd *MoveCommand) AddItem(item IItem, toX, toY float64)
- func (cmd *MoveCommand) Count() int
- func (cmd *MoveCommand) MergeWidth(next gui.ICommand) bool
- func (cmd *MoveCommand) Redo()
- func (cmd *MoveCommand) SetMergeToken(token uint64)
- func (cmd *MoveCommand) Text() string
- func (cmd *MoveCommand) Undo()
- type MovePart
- type PageLayout
- type Part
- func (this *Part) Activate() bool
- func (this *Part) CurrentPos() (x, y float64)
- func (this *Part) DownPos() (x, y float64)
- func (this *Part) Init(self IPart)
- func (this *Part) IsActive() bool
- func (this *Part) IsDraging() bool
- func (this *Part) Scene() IScene
- func (this *Part) Self() IPart
- func (this *Part) Tool() ITool
- func (this *Part) TrackRect() geom.Rect
- func (this *Part) View() IView
- type RectItem
- type RectPart
- type RectTool
- type ReparentCommand
- type ResizeCommand
- func (cmd *ResizeCommand) AddItem(item IItem, rect geom.Rect)
- func (cmd *ResizeCommand) Count() int
- func (cmd *ResizeCommand) MergeWidth(next gui.ICommand) bool
- func (cmd *ResizeCommand) Redo()
- func (cmd *ResizeCommand) SetMergeToken(token uint64)
- func (cmd *ResizeCommand) Text() string
- func (cmd *ResizeCommand) Undo()
- type ResizeDecor
- func (this *ResizeDecor) HandleAt(x, y float64) int
- func (this *ResizeDecor) HandleCursor(handle int) *gui.Cursor
- func (this *ResizeDecor) Init(self IDecor)
- func (this *ResizeDecor) OnBeginMoveHandle(handle int, x, y float64)
- func (this *ResizeDecor) OnDraw(g paint.Painter)
- func (this *ResizeDecor) OnEndMoveHandle(handle int, x, y float64)
- func (this *ResizeDecor) OnMoveHandle(handle int, x, y float64)
- type SameSizeMode
- type SceneItem
- func (this *SceneItem) DirtyList() []string
- func (this *SceneItem) Init(i IItem)
- func (this *SceneItem) IsClean() bool
- func (this *SceneItem) NakedScene() *SceneItem
- func (this *SceneItem) OnMove()
- func (this *SceneItem) OnResize()
- func (this *SceneItem) PropertyConfigName() (cfgName string)
- func (this *SceneItem) PushCommand(cmd gui.ICommand)
- func (this *SceneItem) Save() bool
- func (this *SceneItem) SetPropertyConfigName(cfgName string)
- func (this *SceneItem) SetTitle(t string)
- func (this *SceneItem) SigItemAttached(fn func(s interface{}, item, parent IItem))
- func (this *SceneItem) SigItemDetached(fn func(s interface{}, item, parent IItem))
- func (this *SceneItem) Title() string
- func (this *SceneItem) UndoStack() gui.IUndoStack
- func (this *SceneItem) Update()
- func (this *SceneItem) View() IView
- type SelectNode
- type SelectPart
- type Selection
- func (s *Selection) Add(a IItem)
- func (s *Selection) AddMulti(v []IItem)
- func (s *Selection) Clear()
- func (s *Selection) Contains(a IItem) bool
- func (s *Selection) Count() int
- func (s *Selection) DebugDump()
- func (s *Selection) FindHandleAt(xMm, yMm float64) (decor IDecor, handle int)
- func (s *Selection) GenerateMoveCommand(dx, dy float64) *MoveCommand
- func (s *Selection) GenerateReparentCommand(newParent IItem) *ReparentCommand
- func (s *Selection) GenerateResizeCommand(dw, dh, minSize float64) *ResizeCommand
- func (s *Selection) GenerateSameSizeCommand(mode SameSizeMode, minSize float64) *ResizeCommand
- func (s *Selection) Invert(a IItem)
- func (s *Selection) InvertMulti(v []IItem)
- func (s *Selection) IsEmpty() bool
- func (s *Selection) IsSingle() bool
- func (s *Selection) ItemList() (ret []IItem)
- func (s *Selection) OnDraw(g paint.Painter)
- func (s *Selection) Remove(a IItem)
- func (s *Selection) RemoveMulti(v []IItem)
- type Tool
- func (this *Tool) Action() gui.IAction
- func (this *Tool) Activate()
- func (this *Tool) ActivePart() IPart
- func (this *Tool) AddPart(part ...IPart)
- func (this *Tool) CurrentPos() (x, y float64)
- func (this *Tool) DownPos() (x, y float64)
- func (this *Tool) GraphView() IView
- func (this *Tool) Icon() paint.Icon
- func (this *Tool) Init(self ITool)
- func (this *Tool) IsActive() bool
- func (this *Tool) IsEnabled() bool
- func (this *Tool) Name() string
- func (this *Tool) OnDraw(g paint.Painter)
- func (this *Tool) OnLeftClick(x, y float64)
- func (this *Tool) OnLeftDown(x, y float64)
- func (this *Tool) OnLeftDragStart(x, y float64)
- func (this *Tool) OnLeftUp(x, y float64)
- func (this *Tool) OnMouseMove(x, y float64)
- func (this *Tool) Scene() IScene
- func (this *Tool) Self() ITool
- func (this *Tool) SetEnabled(b bool)
- func (this *Tool) SetIcon(icon paint.Icon)
- func (this *Tool) SetIcon1(s string)
- func (this *Tool) SetName(name string)
- func (this *Tool) SetText(text string)
- func (this *Tool) Text() string
- type TraversalCond
Constants ¶
const HANDLE_SIZE = 3.2
Variables ¶
This section is empty.
Functions ¶
func AddMoveSubtree ¶
func AddMoveSubtree(cmd *MoveCommand, item IItem, dx, dy float64)
AddMoveSubtree records item at its shifted position, plus every descendant that keeps its own scene coordinates. A container does not carry its children on its own — SetPos moves the one item and OnMove only re-lays it out — so a tree whose coordinates are absolute (ged never turns on local coords) would leave the children sitting where they were.
HasLocalCoord is the boundary: below such an item the children are stored relative to it and already ride along, so descending past it would move them a second time.
A descendant rides along whatever its own IsLockPos says: the lock pins a widget inside its container, and moving the container is not a request to rearrange what is in it. Only the selected item's own lock, tested by the caller, keeps a move out.
Exported for the callers that build their own MoveCommand because each item has its own target rather than one shared delta — ged's multi-item align.
func KeepAspect ¶
func ParentOrigin ¶
ParentOrigin returns, in scene coordinates, the origin of the coordinate space `parent` gives its children — i.e. exactly what CoordOffset() reports for every child of `parent`. A nil parent means the scene origin.
It mirrors the recurrence in Item.CoordOffset: only a parent that opts into local coordinates (HasLocalCoord) shifts its children by its own position; a parent without them hands its children the space it lives in, unchanged.
func ShiftSubtree ¶
ShiftSubtree moves item by (dx, dy) right now, carrying exactly the descendants AddMoveSubtree would have recorded. It is for the corrections that are applied outside the undo stack — ged's post-drag grid snap tidies the resting place of a move that is already committed — which still have to take the subtree with them.
func TranslateBetweenParents ¶
TranslateBetweenParents maps (x, y) — a position expressed in `from`'s child coordinate space — into `to`'s child coordinate space so the point keeps its scene position. It is the whole coordinate rule of a re-parent: changing an item's owner must not move it on screen.
The delta is zero whenever both parents hand their children the same space, which is the case for every parent that does not set HasLocalCoord.
Types ¶
type AddCommand ¶
type AddCommand struct {
// contains filtered or unexported fields
}
func NewAddCommand ¶
func NewAddCommand() *AddCommand
func (*AddCommand) AddItem ¶
func (cmd *AddCommand) AddItem(item, parent IItem)
func (*AddCommand) Count ¶
func (cmd *AddCommand) Count() int
func (*AddCommand) Redo ¶
func (cmd *AddCommand) Redo()
func (*AddCommand) Text ¶
func (cmd *AddCommand) Text() string
func (*AddCommand) Undo ¶
func (cmd *AddCommand) Undo()
type DbgTreeModel ¶
/////////////////////////////////////////////////////////
func NewDbgTreeModel ¶
func NewDbgTreeModel() *DbgTreeModel
func (*DbgTreeModel) Data ¶
func (m *DbgTreeModel) Data(idx gui.ModelIndex, role gui.ItemDataRole) interface{}
获取单元格数据
func (*DbgTreeModel) Flags ¶
func (m *DbgTreeModel) Flags(idx gui.ModelIndex) gui.ItemFlags
子节点的属性标记, 例如是否可选
func (*DbgTreeModel) HeaderData ¶
func (m *DbgTreeModel) HeaderData(section int, vertical bool, role gui.ItemDataRole) interface{}
func (*DbgTreeModel) Index ¶
func (m *DbgTreeModel) Index(row, col int, parent gui.ModelIndex) gui.ModelIndex
获取parent下第row行col列的索引
func (*DbgTreeModel) Parent ¶
func (m *DbgTreeModel) Parent(idx gui.ModelIndex) gui.ModelIndex
获取父节点的索引
func (*DbgTreeModel) RowCount ¶
func (m *DbgTreeModel) RowCount(parent gui.ModelIndex) int
指定节点下子结点的行数
func (*DbgTreeModel) SetRootItems ¶
func (m *DbgTreeModel) SetRootItems(items []IItem)
type DbgTreeView ¶
func NewDbgTreeView ¶
func NewDbgTreeView() *DbgTreeView
func (*DbgTreeView) DbgTreeModel ¶
func (this *DbgTreeView) DbgTreeModel() *DbgTreeModel
func (*DbgTreeView) Init ¶
func (this *DbgTreeView) Init(iw gui.IWidget)
func (*DbgTreeView) SetRootItems ¶
func (this *DbgTreeView) SetRootItems(items []IItem)
type Decor ¶
type Decor struct {
// contains filtered or unexported fields
}
func (*Decor) ActiveHandle ¶
func (*Decor) DrawDefaultHandle ¶
func (*Decor) HandleSize ¶
func (*Decor) HoverHandle ¶
func (*Decor) IsHitCircleHandle ¶
func (*Decor) IsHitCircleHandle1 ¶
func (*Decor) IsHitDiamonHandle ¶
func (*Decor) IsHitDiamonHandle1 ¶
func (*Decor) IsHitRectHandle ¶
func (*Decor) IsHitRectHandle1 ¶
func (*Decor) IsMovingHandle ¶
func (*Decor) NakedDecor ¶
func (*Decor) OnBeginMoveHandle ¶
func (*Decor) OnClickHandle ¶
func (*Decor) OnEndMoveHandle ¶
func (*Decor) OnMoveHandle ¶
func (*Decor) SetActiveHandle ¶
func (*Decor) SetMovingHandle ¶
type DecorPart ¶
type DecorPart struct {
Part
// contains filtered or unexported fields
}
func NewDecorPart ¶
func NewDecorPart() *DecorPart
func (*DecorPart) HandleSize ¶
func (*DecorPart) MapToDecor ¶
func (*DecorPart) OnLeftDown ¶
func (*DecorPart) OnLeftDragStart ¶
func (*DecorPart) OnMouseMove ¶
type DeleteCommand ¶
type DeleteCommand struct {
// contains filtered or unexported fields
}
DeleteCommand is the undoable mirror image of AddCommand: where AddCommand attaches items on Redo and detaches them on Undo, DeleteCommand detaches on Redo and re-attaches on Undo. It exists so the designer's "Delete" drops a selection without data loss — Ctrl+Z brings every removed widget back at its original parent and z-order slot instead of losing it.
Add() records only the item; the parent and index are snapshotted in Redo() (the pre-applied → applied transition PushCommand's Push() drives), exactly like ged's zorderCommand snapshots oldIdx there. Capturing at detach time — not in Add() — is what makes the reverse-order restore in Undo() correct for a multi-item batch: detaching at live indices i0,i1,… and re-inserting at those same indices in reverse inverts the whole sequence (the undo of a;b;c is c⁻¹;b⁻¹;a⁻¹), so even deleting every child of a parent restores their order. Like AddCommand it is built in the pre-applied state and Push() calls Redo() to apply it; the isUndo guard panics on out-of-order calls.
func NewDeleteCommand ¶
func NewDeleteCommand(label string) *DeleteCommand
NewDeleteCommand returns an empty command. label is shown by Text().
func (*DeleteCommand) Add ¶
func (cmd *DeleteCommand) Add(item IItem)
Add records that item is to be deleted. Call it before the command is applied (the pre-applied state PushCommand expects); the item's parent and index are captured later, in Redo(), against the live tree.
func (*DeleteCommand) Count ¶
func (cmd *DeleteCommand) Count() int
Count returns the number of items the command deletes.
func (*DeleteCommand) Redo ¶
func (cmd *DeleteCommand) Redo()
func (*DeleteCommand) Text ¶
func (cmd *DeleteCommand) Text() string
func (*DeleteCommand) Undo ¶
func (cmd *DeleteCommand) Undo()
type GraphView ¶
type GraphView struct {
gui.ScrollArea
// contains filtered or unexported fields
}
func (*GraphView) ActiveTool ¶
func (*GraphView) AddStandardTools ¶
func (this *GraphView) AddStandardTools()
func (*GraphView) DefaultTool ¶
func (*GraphView) FindHandleAt ¶
func (*GraphView) GetPropertyView ¶
func (this *GraphView) GetPropertyView() prop.IPropertyView
func (*GraphView) IsItemSelected ¶
func (*GraphView) IsPageMarginVisible ¶
IsPageMarginVisible reports whether the page margin is part of the page. Subclasses that paint their own page-sized overlay need it to size that overlay exactly like Draw sizes the page.
func (*GraphView) MapFromScene ¶
从场景坐标转到视图坐标 注: 视图坐标等同于Widget坐标, 不随滚动条变化
func (*GraphView) MapRectFromScene ¶
从场景坐标转到视图坐标 注: 视图坐标等同于Widget坐标, 不随滚动条变化
func (*GraphView) MapRectFromScene1 ¶
func (*GraphView) MapRectToScene ¶
注: 视图坐标等同于Widget坐标, 不随滚动条变化
func (*GraphView) MapRectToScene1 ¶
func (*GraphView) MapToScene ¶
从视图坐标转到场景坐标. 注: 视图坐标等同于Widget坐标, 不随滚动条变化
func (*GraphView) OnHorzScroll ¶
func (*GraphView) OnLeftDown ¶
func (*GraphView) OnMouseMove ¶
func (*GraphView) OnMouseWheel ¶
func (*GraphView) OnVertScroll ¶
func (*GraphView) PageLayout ¶
func (this *GraphView) PageLayout() PageLayout
func (*GraphView) PageOriginPx ¶
获取页面左上角相对于像素原点的偏移量 注: 页面通常不紧贴着视图边界, 这个值可能随着视图的缩放而变化
func (*GraphView) PageSizeMm ¶
func (*GraphView) PageSizePx ¶
func (*GraphView) PropertyConfigName ¶
func (*GraphView) SceneOriginPx ¶
获取场景左上角相对于像素原点的偏移量
func (*GraphView) SceneSizeMm ¶
func (*GraphView) ScrollSizePx ¶
func (*GraphView) SetActiveTool ¶
func (*GraphView) SetDefaultTool ¶
func (*GraphView) SetPaddingMm ¶
func (*GraphView) SetPaddingPx ¶
设置页面和窗口边界之间的最小填充距离, 像素坐标, 不足1像素按1像素计算.
func (*GraphView) SetPageLayout ¶
func (this *GraphView) SetPageLayout(mode PageLayout)
func (*GraphView) SetPageMarginVisible ¶
func (*GraphView) SetPropertyConfigName ¶
func (*GraphView) SetPropertyView ¶
func (this *GraphView) SetPropertyView(propView prop.IPropertyView)
func (*GraphView) SetZoomFactor ¶
func (*GraphView) SigGenDecors ¶
func (*GraphView) SigItemAttached ¶
func (*GraphView) SigItemDeselected ¶
func (*GraphView) SigItemDetached ¶
func (*GraphView) SigItemSelected ¶
func (*GraphView) SigSelectionChanged ¶
func (*GraphView) SigZoomChanged ¶
SigZoomChanged registers a callback fired whenever the view's zoom factor moves to a new value. Fires after Layout, so observers see the new zoom AND a re-laid-out viewport. Used by silkide to keep the status-bar zoom % cell synced with Ctrl+wheel zoom — without the signal, only the keyboard shortcuts would update the cell and wheel-driven zoom would silently desync the indicator.
func (*GraphView) ZoomFactor ¶
type IItem ¶
type IItem interface {
Self() IItem
NakedItem() *Item
Parent() IItem
SetParent(a IItem)
// SetParentAt re-parents this item and inserts it at a specific index
// among the new parent's children (Children() order). It lets undo/redo
// restore an item to the exact slot it held before a move; plain
// SetParent always tail-inserts and so loses that position. index == -1
// appends (identical to SetParent).
SetParentAt(a IItem, index int)
Root() IItem
Scene() IScene
DrawAll(g paint.Painter)
DrawSelf(g paint.Painter)
DrawOutline(g paint.Painter)
DrawChildren(g paint.Painter)
X() float64
Y() float64
Width() float64
Height() float64
SetX(x float64)
SetY(y float64)
SetWidth(w float64)
SetHeight(h float64)
Pos() (x, y float64)
SetPos(x, y float64)
Size() (width, height float64)
SetSize(width, height float64)
Bounds() (x, y, width, height float64)
Bounds1() geom.Rect
SetBounds1(geom.Rect)
SetBounds(x, y, width, height float64)
EaveBounds() (x, y, width, height float64)
EaveBounds1() geom.Rect
IsVisible() bool
SetVisible(bool)
IsSelectable() bool
SetSelectable(b bool)
IsLockPos() bool
SetLockPos(b bool)
IsLockSize() bool
SetLockSize(b bool)
Show()
Hide()
HasLocalCoord() bool
SetLocalCoord(bool)
HasChildren() bool
Children() []IItem
// slow
IndexInParent() int
IsHitBody(x, y float64) bool
MaybeHitBody(x, y float64) bool
// 从子树中查找指定坐标处第一个满足指定条件的图元.
// 如果未指定条件, 则默认使用 TraversalCond_Selectable.
// 如果有多个图元满足要求, 则上层图元优先.
// 此方法通常用来实现点选/拖放等鼠标操作
FindItemAt(x, y float64, cond TraversalCond) IItem
// 从子树中查找指定坐标处所有满足指定条件的图元.
// 如果未指定条件, 则默认使用 TraversalCond_Selectable.
// 返回结果中上层图元排在前面, 和绘图顺序相反
FindItemsAt(x, y float64, cond TraversalCond) []IItem
// 从子树中查找指定矩形内所有满足指定条件的图元.
// 如果未指定条件, 则默认使用 TraversalCond_Selectable.
// 如果allIntersected为true, 则返回结果中也包含部分相交的图元
// 返回结果中上层图元排在前面, 和绘图顺序相反
// 相交/包含检测仅考虑图元的边框, 不考虑内部形状.
FindItemsInRectF(x, y, width, height float64, cond TraversalCond) []IItem
FindItemsInRect(bounds geom.Rect, cond TraversalCond) []IItem
// 获取从ancestor到当前结点的路径中的全部结点,
// 如果路径存在, 则返回值不为空, 且ancestor在最前, 当前节点在最后.
// 如果路径不存在, 则返回值为nil
Path(ancestor IItem) []IItem
Update()
// 获取以当前节点为根的整棵子树的全部结点.
// 返回的结点的排列顺序和绘图顺序相同(Pre-Order遍历)
TreeItems() []IItem
MapToChild(x, y float64) (x1, y1 float64)
MapFromChild(x, y float64) (x1, y1 float64)
MapToScene(x, y float64) (x1, y1 float64)
MapFromScene(x, y float64) (x1, y1 float64)
MapToItem(a IItem, x, y float64) (x1, y1 float64)
MapFromItem(a IItem, x, y float64) (x1, y1 float64)
MapRectToChild(x, y, width, height float64) (x1, y1, width1, height1 float64)
MapRectFromChild(x, y, width, height float64) (x1, y1, width1, height1 float64)
MapRectToScene(x, y, width, height float64) (x1, y1, width1, height1 float64)
MapRectFromScene(x, y, width, height float64) (x1, y1, width1, height1 float64)
MapRectToItem(a IItem, x, y, width, height float64) (x1, y1, width1, height1 float64)
MapRectFromItem(a IItem, x, y, width, height float64) (x1, y1, width1, height1 float64)
MapRectToChild1(rect geom.Rect) geom.Rect
MapRectFromChild1(rect geom.Rect) geom.Rect
MapRectToScene1(rect geom.Rect) geom.Rect
MapRectFromScene1(rect geom.Rect) geom.Rect
MapRectToItem1(a IItem, rect geom.Rect) geom.Rect
MapRectFromItem1(a IItem, rect geom.Rect) geom.Rect
CoordOffset() (dx, dy float64)
GenDecors() []IDecor
Icon() paint.Icon
String() string
Title() string
// 获取字符串形式表示的从ancestor到当前结点的路径,
// 此函数返回的值只用作调试信息
DebugPathString(ancestor IItem) string
DebugLabel() string
DebugFlagsString() (ret string)
//OnResize()
Layout()
SizeHints() gui.SizeHints
Detach()
// 调整此图元在兄弟图元中的堆叠顺序. 队首图元最先绘制(在最底层),
// 队尾图元最后绘制(在最上层).
Raise()
Lower()
BringToFront()
SendToBack()
}
type IScene ¶
type IScene interface {
IItem
NakedScene() *SceneItem
View() IView
UndoStack() gui.IUndoStack
SigItemAttached(func(s interface{}, item, parent IItem))
SigItemDetached(func(s interface{}, item, parent IItem))
SetPropertyConfigName(cfgName string)
PropertyConfigName() (cfgName string)
DirtyList() []string
Save() bool
PushCommand(cmd gui.ICommand)
SetTitle(s string)
IsClean() bool
}
type ITool ¶
type ITool interface {
Self() ITool
Action() gui.IAction
Text() string
SetText(text string)
Icon() paint.Icon
SetIcon(icon paint.Icon)
Name() string
SetName(name string)
IsEnabled() bool
SetEnabled(b bool)
IsActive() bool
Activate()
OnDraw(g paint.Painter)
OnLeftDown(x, y float64)
OnLeftUp(x, y float64)
OnMouseMove(x, y float64)
OnLeftClick(x, y float64)
OnLeftDragStart(x, y float64)
// contains filtered or unexported methods
}
func NewArrowTool ¶
func NewArrowTool() ITool
func NewRectTool ¶
func NewRectTool() ITool
type IView ¶
type IView interface {
gui.IWidget
Scene() IScene
Selection() *Selection
AddTool(tool ...ITool)
Tools() []ITool
SetActiveTool(tool ITool)
SetDefaultTool(tool ITool)
DefaultTool() ITool
ActiveTool() ITool
SetScene(IScene)
// 判断图元是否在当前视图中被选中
IsItemSelected(IItem) bool
// 从视图坐标转到场景坐标.
// 注: 视图坐标等同于Widget坐标, 不随滚动条变化
MapToScene(x, y float64) (x1, y1 float64)
// 从场景坐标转到视图坐标
// 注: 视图坐标等同于Widget坐标, 不随滚动条变化
MapFromScene(x, y float64) (x1, y1 float64)
// 从视图坐标转到场景坐标.
// 注: 视图坐标等同于Widget坐标, 不随滚动条变化
MapRectToScene(x, y, w, h float64) (x1, y1, w1, h1 float64)
// 从场景坐标转到视图坐标
// 注: 视图坐标等同于Widget坐标, 不随滚动条变化
MapRectFromScene(x, y, w, h float64) (x1, y1, w1, h1 float64)
MapRectToScene1(rect geom.Rect) geom.Rect
MapRectFromScene1(rect geom.Rect) geom.Rect
ZoomFactor() float64
SigItemSelected(func(s interface{}, item IItem))
SigItemDeselected(func(s interface{}, item IItem))
SigItemAttached(func(s interface{}, item, parent IItem))
SigItemDetached(func(s interface{}, item, parent IItem))
SigGenDecors(func(s interface{}, item IItem) []IDecor)
SigSelectionChanged(func(s interface{}, selection *Selection))
FindHandleAt(xMm, yMm float64) (decor IDecor, handle int)
SetPropertyView(prop.IPropertyView)
SetPropertyConfigName(cfgName string)
PropertyConfigName() (cfgName string)
// 布局, 一般由内部调用
Layout()
// contains filtered or unexported methods
}
type Item ¶
type Item struct {
// contains filtered or unexported fields
}
func (*Item) BringToFront ¶
func (this *Item) BringToFront()
BringToFront moves this item in front of all its siblings.
func (*Item) CoordOffset ¶
func (*Item) DebugFlagsString ¶
func (*Item) DebugLabel ¶
func (*Item) DebugPathString ¶
func (*Item) DrawChildren ¶
func (*Item) DrawOutline ¶
func (*Item) EaveBounds ¶
func (*Item) EaveBounds1 ¶
func (*Item) EnumProperties ¶
func (this *Item) EnumProperties(list prop.IPropertyList)
func (*Item) FindItemAt ¶
func (this *Item) FindItemAt(x, y float64, cond TraversalCond) IItem
func (*Item) FindItemsAt ¶
func (this *Item) FindItemsAt(x, y float64, cond TraversalCond) []IItem
func (*Item) FindItemsInRect ¶
func (this *Item) FindItemsInRect(bounds geom.Rect, cond TraversalCond) []IItem
func (*Item) FindItemsInRectF ¶
func (this *Item) FindItemsInRectF(cx, cy, cw, ch float64, cond TraversalCond) []IItem
func (*Item) HasChildren ¶
func (*Item) HasLocalCoord ¶
func (*Item) IndexInParent ¶
func (*Item) IsLockSize ¶
func (*Item) IsSelectable ¶
func (*Item) Lower ¶
func (this *Item) Lower()
Lower moves this item one step toward the back (drawn earlier).
func (*Item) MapFromChild ¶
func (*Item) MapFromScene ¶
func (*Item) MapRectFromChild ¶
func (*Item) MapRectFromItem ¶
func (*Item) MapRectFromItem1 ¶
func (*Item) MapRectFromScene ¶
func (*Item) MapRectToChild ¶
func (*Item) MapRectToItem ¶
func (*Item) MapRectToScene ¶
func (*Item) MapToChild ¶
func (*Item) MapToScene ¶
func (*Item) MaybeHitBody ¶
func (*Item) Raise ¶
func (this *Item) Raise()
Raise moves this item one step toward the front (drawn later).
func (*Item) SendToBack ¶
func (this *Item) SendToBack()
SendToBack moves this item behind all its siblings.
func (*Item) SetBounds1 ¶
func (*Item) SetLocalCoord ¶
func (*Item) SetLockPos ¶
func (*Item) SetLockSize ¶
func (*Item) SetParentAt ¶
SetParentAt re-parents this item and inserts it at the given 0-based position among newParent's children, in the same head-first order that Children() and IndexInParent() use (head == index 0 == back / drawn first; tail == front). It exists so an undo can put an item back in the exact sibling slot it occupied before a move — plain SetParent always appends at the tail and so loses the original position.
index == -1 is the "append" sentinel and reproduces SetParent's tail insert; any other out-of-range value is clamped into [0, n] (n == current child count), so index >= n also appends and index < -1 inserts at the head. A nil newParent detaches (index ignored). Re-parenting to the current parent is a no-op — use Raise/Lower/BringToFront/SendToBack to reorder within a single parent.
func (*Item) SetSelectable ¶
func (*Item) SetVisible ¶
type MarqueePart ¶
type MarqueePart struct {
Part
// contains filtered or unexported fields
}
func NewMarqueePart ¶
func NewMarqueePart() *MarqueePart
func (*MarqueePart) OnDraw ¶
func (this *MarqueePart) OnDraw(g paint.Painter)
func (*MarqueePart) OnLeftDragStart ¶
func (this *MarqueePart) OnLeftDragStart(x, y float64)
func (*MarqueePart) OnLeftUp ¶
func (this *MarqueePart) OnLeftUp(x, y float64)
func (*MarqueePart) OnMouseMove ¶
func (this *MarqueePart) OnMouseMove(x, y float64)
type MoveCommand ¶
type MoveCommand struct {
// contains filtered or unexported fields
}
func NewMoveCommand ¶
func NewMoveCommand() *MoveCommand
func (*MoveCommand) AddItem ¶
func (cmd *MoveCommand) AddItem(item IItem, toX, toY float64)
func (*MoveCommand) Count ¶
func (cmd *MoveCommand) Count() int
func (*MoveCommand) MergeWidth ¶
func (cmd *MoveCommand) MergeWidth(next gui.ICommand) bool
MergeWidth folds next into cmd so a held arrow key leaves one undo step instead of one per key repeat. gui.UndoStack.Push probes the command below the stack top for this exact — misspelled — method name and, when it returns true, redoes next without growing the stack.
cmd has already been redone, so its records hold the positions from before the gesture started, which is precisely what a later Undo must restore. Absorbing next is therefore a no-op on cmd's records. That only holds while cmd records every item next touches: an item moved by next but absent from cmd would keep no undo record at all, so such a list refuses the merge and lets the stack start a fresh step instead.
The test is containment, not equality. A later step in the same gesture may legitimately drive fewer items — ResizeCommand's generator drops an item once it reaches the size floor — and cmd still holds that item's pre-gesture state, so the burst stays one undo step. Both lists are built by walking the selection in order, so one pass over cmd's records decides it.
func (*MoveCommand) Redo ¶
func (cmd *MoveCommand) Redo()
func (*MoveCommand) SetMergeToken ¶
func (cmd *MoveCommand) SetMergeToken(token uint64)
SetMergeToken tags cmd as belonging to one continuous gesture, such as the burst of auto-repeat events a held arrow key produces. Commands sharing a non-zero token collapse into a single undo step; the zero default means "never merge", so a caller that does not opt in keeps one command per push.
func (*MoveCommand) Text ¶
func (cmd *MoveCommand) Text() string
func (*MoveCommand) Undo ¶
func (cmd *MoveCommand) Undo()
type MovePart ¶
type MovePart struct {
Part
// contains filtered or unexported fields
}
func NewMovePart ¶
func NewMovePart() *MovePart
func (*MovePart) OnLeftDragStart ¶
func (*MovePart) OnMouseMove ¶
type PageLayout ¶
type PageLayout int
const ( PL_FIT_WIDTH PageLayout = iota PL_FIT_HEIGHT PL_FIT_VIEW PL_FREE_ZOOM )
func ParsePageLayout ¶
func ParsePageLayout(s string) PageLayout
func (PageLayout) String ¶
func (v PageLayout) String() string
type Part ¶
type Part struct {
// contains filtered or unexported fields
}
func (*Part) CurrentPos ¶
type RectPart ¶
type RectPart struct {
Part
// contains filtered or unexported fields
}
func NewRectPart ¶
func NewRectPart() *RectPart
func (*RectPart) OnLeftDragStart ¶
func (*RectPart) OnMouseMove ¶
type ReparentCommand ¶
type ReparentCommand struct {
// contains filtered or unexported fields
}
ReparentCommand is an undoable structural edit that moves a set of items between parents — the basis for the designer's "Lay Out" (wrap a selection in a new container) and "Break Layout" (dissolve a container) operations, both of which are pure reparenting once the container item exists.
Redo replays the moves in insertion order, tail-appending each item into its target (the operations' natural behaviour). Undo restores every item to its original parent AT ITS ORIGINAL INDEX (reparentRecord.fromIndex), so a Redo followed by an Undo returns the tree to byte-identical sibling order.
Undo does NOT simply walk the records in reverse: SetParentAt inserts at an absolute index, so items returning to the SAME parent must be reinserted in increasing fromIndex order (a lower slot must be filled before a higher one). Undo therefore stable-sorts the records by fromIndex before applying them. The relative order between DIFFERENT parents does not matter — inserting a child into a parent that has not been reattached yet is fine, because the child is carried along when that parent is itself restored — so a single global sort by fromIndex is enough and is robust to whatever order the caller recorded the moves in ("Lay Out" records in canvas-position order, not child order).
Like AddCommand, the command is built in the pre-applied state and PushCommand's Push() calls Redo() to apply it.
func NewReparentCommand ¶
func NewReparentCommand(label string) *ReparentCommand
NewReparentCommand returns an empty command. label is shown by Text().
func (*ReparentCommand) Add ¶
func (cmd *ReparentCommand) Add(item, from, to IItem)
Add records that `item` moves from `from` to `to` when the command is applied. Pass to=nil to detach, from=nil if the item had no parent before the command.
Add must be called before the command is applied (the pre-applied state, as PushCommand expects): it snapshots the item's current index via IndexInParent(), which at this point is its position inside `from`, so Undo can later restore that exact slot.
func (*ReparentCommand) AddMoved ¶
func (cmd *ReparentCommand) AddMoved(item, from, to IItem, toX, toY float64)
AddMoved records a re-parent that also repositions the item: like Add, plus the item lands at (toX, toY) in `to`'s child coordinate space. Callers get (toX, toY) from TranslateBetweenParents so the item keeps its scene position across the move.
Undo restores the original position along with the original slot, so a re-parent that had to shift coordinates does not leave the item at the shifted position once it is back inside its old parent.
func (*ReparentCommand) Count ¶
func (cmd *ReparentCommand) Count() int
Count returns the number of reparent records.
func (*ReparentCommand) Redo ¶
func (cmd *ReparentCommand) Redo()
func (*ReparentCommand) Text ¶
func (cmd *ReparentCommand) Text() string
func (*ReparentCommand) Undo ¶
func (cmd *ReparentCommand) Undo()
type ResizeCommand ¶
type ResizeCommand struct {
// contains filtered or unexported fields
}
func NewResizeCommand ¶
func NewResizeCommand() *ResizeCommand
func (*ResizeCommand) Count ¶
func (cmd *ResizeCommand) Count() int
func (*ResizeCommand) MergeWidth ¶
func (cmd *ResizeCommand) MergeWidth(next gui.ICommand) bool
MergeWidth folds next into cmd so a held Ctrl+arrow leaves one undo step instead of one per key repeat. Same contract and same reasoning as MoveCommand.MergeWidth — keep the two in step; only the record type differs.
func (*ResizeCommand) Redo ¶
func (cmd *ResizeCommand) Redo()
func (*ResizeCommand) SetMergeToken ¶
func (cmd *ResizeCommand) SetMergeToken(token uint64)
SetMergeToken tags cmd as belonging to one continuous gesture; see MoveCommand.SetMergeToken for the contract.
func (*ResizeCommand) Text ¶
func (cmd *ResizeCommand) Text() string
func (*ResizeCommand) Undo ¶
func (cmd *ResizeCommand) Undo()
type ResizeDecor ¶
type ResizeDecor struct {
Decor
// contains filtered or unexported fields
}
func NewResizeDecor ¶
func NewResizeDecor() *ResizeDecor
func (*ResizeDecor) HandleAt ¶
func (this *ResizeDecor) HandleAt(x, y float64) int
func (*ResizeDecor) HandleCursor ¶
func (this *ResizeDecor) HandleCursor(handle int) *gui.Cursor
func (*ResizeDecor) Init ¶
func (this *ResizeDecor) Init(self IDecor)
func (*ResizeDecor) OnBeginMoveHandle ¶
func (this *ResizeDecor) OnBeginMoveHandle(handle int, x, y float64)
func (*ResizeDecor) OnDraw ¶
func (this *ResizeDecor) OnDraw(g paint.Painter)
func (*ResizeDecor) OnEndMoveHandle ¶
func (this *ResizeDecor) OnEndMoveHandle(handle int, x, y float64)
func (*ResizeDecor) OnMoveHandle ¶
func (this *ResizeDecor) OnMoveHandle(handle int, x, y float64)
type SameSizeMode ¶
type SameSizeMode int
SameSizeMode selects which extents a same-size command copies from its reference item.
const ( SameSizeWidth SameSizeMode = iota SameSizeHeight SameSizeBoth )
type SceneItem ¶
type SceneItem struct {
Item
// contains filtered or unexported fields
}
func (*SceneItem) NakedScene ¶
func (*SceneItem) PropertyConfigName ¶
func (*SceneItem) PushCommand ¶
PushCommand is the one door every design mutation goes through: it is the only place in the tree allowed to touch UndoStack().Push, so a scene that overrides it (ged.GedScene, which announces the change) sees every command. Pushing onto the stack directly from a tool or a view compiles and undoes correctly while leaving every listener showing the pre-edit design.
func (*SceneItem) SetPropertyConfigName ¶
func (*SceneItem) SigItemAttached ¶
func (*SceneItem) SigItemDetached ¶
func (*SceneItem) UndoStack ¶
func (this *SceneItem) UndoStack() gui.IUndoStack
type SelectNode ¶
type SelectNode struct {
// contains filtered or unexported fields
}
func (*SelectNode) OnDraw ¶
func (p *SelectNode) OnDraw(g paint.Painter)
type SelectPart ¶
type SelectPart struct {
Part
// contains filtered or unexported fields
}
func NewSelectPart ¶
func NewSelectPart() *SelectPart
func (*SelectPart) OnLeftClick ¶
func (this *SelectPart) OnLeftClick(x, y float64)
type Selection ¶
type Selection struct {
// contains filtered or unexported fields
}
func (*Selection) FindHandleAt ¶
func (*Selection) GenerateMoveCommand ¶
func (s *Selection) GenerateMoveCommand(dx, dy float64) *MoveCommand
func (*Selection) GenerateReparentCommand ¶
func (s *Selection) GenerateReparentCommand(newParent IItem) *ReparentCommand
GenerateReparentCommand hands every selected item to newParent, keeping each item where it is on screen (TranslateBetweenParents), and returns one command whose Undo restores the original parent, sibling index and position. Returns nil when nothing would actually change, so a caller can forward that as a quiet no-op instead of pushing an empty command — same contract as GenerateMoveCommand.
Skipped, and why:
- an item whose ancestor is also selected: the ancestor carries it along, exactly as GenerateMoveCommand skips it;
- an IsLockPos item: a drag leaves it behind (GenerateMoveCommand skips it too), so handing it a new owner would split one gesture in two;
- an item already parented to newParent: SetParentAt is a documented no-op for it, and recording no-ops would make Count() claim work that is not there;
- a newParent inside the item's own subtree: SetParentAt has no cycle guard, and a cyclic child ring hangs every later traversal.
func (*Selection) GenerateResizeCommand ¶
func (s *Selection) GenerateResizeCommand(dw, dh, minSize float64) *ResizeCommand
GenerateResizeCommand grows every selected item by (dw, dh) millimetres, anchored at each item's top-left corner and floored at minSize by resizeRectBy. Returns nil when nothing would actually change, so a caller can forward that as a quiet no-op instead of pushing an empty command.
Unlike the drag-handle path in ResizeDecor, an IsLockPos item is kept here: the top-left anchor means resizing never moves it, so a position lock has nothing to violate. Only IsLockSize opts an item out.
func (*Selection) GenerateSameSizeCommand ¶
func (s *Selection) GenerateSameSizeCommand(mode SameSizeMode, minSize float64) *ResizeCommand
GenerateSameSizeCommand resizes every selected item onto the width and/or height of the LAST selected item, each item keeping its own X/Y. Add appends, so the last item is the one the designer picked most recently — the reference convention every form designer uses for "make same size".
Same exclusions and same nil contract as GenerateResizeCommand: a size-locked or ancestor-selected item is left out, and nothing left to do returns nil so the caller forwards a quiet no-op instead of pushing an empty command. The reference needs no special case — resizing it onto its own size is not a change, so the unchanged-rect filter drops it.
func (*Selection) InvertMulti ¶
func (*Selection) RemoveMulti ¶
type Tool ¶
type Tool struct {
// contains filtered or unexported fields
}
func (*Tool) ActivePart ¶
func (*Tool) CurrentPos ¶
func (*Tool) OnLeftClick ¶
func (*Tool) OnLeftDown ¶
func (*Tool) OnLeftDragStart ¶
func (*Tool) OnMouseMove ¶
func (*Tool) SetEnabled ¶
type TraversalCond ¶
图元树的遍历条件. 在绘图系统中, 查找/绘制/单选/框选等操作都涉及到图元的遍历, 相关的方法都接受一个TraversalCond参数, 用来筛选出满足条件的图元. TraversalCond需要提供两个返回值:
self : 当前结点是否满足要求 descendants : 是否需要遍历当前结点的子孙结点