Documentation
¶
Index ¶
- Variables
- type ImgGrid
- func (ig *ImgGrid) BitmapAtIdx(idx int) *gi.Bitmap
- func (ig *ImgGrid) Config(reset bool)
- func (ig *ImgGrid) ConnectEvents2D()
- func (ig *ImgGrid) Copy(reset bool)
- func (ig *ImgGrid) CopyIdxs(reset bool)
- func (ig *ImgGrid) CopySelToMime() mimedata.Mimes
- func (ig *ImgGrid) Cut()
- func (ig *ImgGrid) CutIdxs()
- func (ig *ImgGrid) DeleteIdxs()
- func (ig *ImgGrid) DragNDropFinalize(mod dnd.DropMods)
- func (ig *ImgGrid) DragNDropSource(de *dnd.Event)
- func (ig *ImgGrid) DragNDropStart()
- func (ig *ImgGrid) DragNDropTarget(de *dnd.Event)
- func (ig *ImgGrid) Drop(md mimedata.Mimes, mod dnd.DropMods)
- func (ig *ImgGrid) DropAfter(md mimedata.Mimes, mod dnd.DropMods, idx int)
- func (ig *ImgGrid) DropAssign(md mimedata.Mimes, idx int)
- func (ig *ImgGrid) DropBefore(md mimedata.Mimes, mod dnd.DropMods, idx int)
- func (ig *ImgGrid) DropCancel()
- func (ig *ImgGrid) Duplicate() int
- func (ig *ImgGrid) FromMimeData(md mimedata.Mimes) []string
- func (ig *ImgGrid) Grid() *gi.Layout
- func (ig *ImgGrid) IdxFromPos(pos image.Point) (int, bool)
- func (ig *ImgGrid) IdxGrabFocus(idx int)
- func (ig *ImgGrid) IdxIsSelected(idx int) bool
- func (ig *ImgGrid) IdxPos(idx int) image.Point
- func (ig *ImgGrid) ImageDeleteAt(idx int)
- func (ig *ImgGrid) ImageInsertAt(idx int, files []string)
- func (ig *ImgGrid) ImgGridEvents()
- func (ig *ImgGrid) IsIdxVisible(idx int) bool
- func (ig *ImgGrid) ItemCtxtMenu(idx int)
- func (ig *ImgGrid) KeyInputActive(kt *key.ChordEvent)
- func (ig *ImgGrid) Layout2D(parBBox image.Rectangle, iter int) bool
- func (ig *ImgGrid) LayoutGrid(iter int) bool
- func (ig *ImgGrid) MakeDropMenu(m *gi.Menu, data any, mod dnd.DropMods, idx int)
- func (ig *ImgGrid) MakePasteMenu(m *gi.Menu, data any, idx int)
- func (ig *ImgGrid) MimeDataIdx(md *mimedata.Mimes, idx int)
- func (ig *ImgGrid) MoveDown(selMode mouse.SelectModes) int
- func (ig *ImgGrid) MoveDownAction(selMode mouse.SelectModes) int
- func (ig *ImgGrid) MoveNext(selMode mouse.SelectModes) int
- func (ig *ImgGrid) MoveNextAction(selMode mouse.SelectModes) int
- func (ig *ImgGrid) MovePageDown(selMode mouse.SelectModes) int
- func (ig *ImgGrid) MovePageDownAction(selMode mouse.SelectModes) int
- func (ig *ImgGrid) MovePageUp(selMode mouse.SelectModes) int
- func (ig *ImgGrid) MovePageUpAction(selMode mouse.SelectModes) int
- func (ig *ImgGrid) MovePrev(selMode mouse.SelectModes) int
- func (ig *ImgGrid) MovePrevAction(selMode mouse.SelectModes) int
- func (ig *ImgGrid) MoveUp(selMode mouse.SelectModes) int
- func (ig *ImgGrid) MoveUpAction(selMode mouse.SelectModes) int
- func (ig *ImgGrid) NumImages() int
- func (ig *ImgGrid) Paste()
- func (ig *ImgGrid) PasteAssign(md mimedata.Mimes, idx int)
- func (ig *ImgGrid) PasteAtIdx(md mimedata.Mimes, idx int)
- func (ig *ImgGrid) PasteIdx(idx int)
- func (ig *ImgGrid) PasteMenu(md mimedata.Mimes, idx int)
- func (ig *ImgGrid) Render2D()
- func (ig *ImgGrid) RenderSelected()
- func (ig *ImgGrid) ResetSelectedIdxs()
- func (ig *ImgGrid) SaveDraggedIdxs(idx int)
- func (ig *ImgGrid) ScrollBar() *gi.ScrollBar
- func (ig *ImgGrid) ScrollToIdx(idx int) bool
- func (ig *ImgGrid) SelectAllIdxs()
- func (ig *ImgGrid) SelectIdx(idx int)
- func (ig *ImgGrid) SelectIdxAction(idx int, mode mouse.SelectModes)
- func (ig *ImgGrid) SelectIdxWidgets(idx int, sel bool) bool
- func (ig *ImgGrid) SelectedIdxsList(descendingSort bool) []int
- func (ig *ImgGrid) SetImages(files []string, reset bool)
- func (ig *ImgGrid) SetScrollMax() int
- func (ig *ImgGrid) StartIdx() int
- func (ig *ImgGrid) StdCtxtMenu(m *gi.Menu, idx int)
- func (ig *ImgGrid) UnselectAllIdxs()
- func (ig *ImgGrid) UnselectIdx(idx int)
- func (ig *ImgGrid) UnselectIdxAction(idx int)
- func (ig *ImgGrid) Update()
- func (ig *ImgGrid) UpdateSelectIdx(idx int, sel bool)
- type ImgGridSignals
Constants ¶
This section is empty.
Variables ¶
var ImgGridProps = ki.Props{ "EnumType:Flag": gi.KiT_NodeFlags, "background-color": &gi.Prefs.Colors.Background, "color": &gi.Prefs.Colors.Font, "border-color": &gi.Prefs.Colors.Border, "border-width": units.NewPx(4), "max-width": -1, "max-height": -1, }
var KiT_ImgGrid = kit.Types.AddType(&ImgGrid{}, ImgGridProps)
Functions ¶
This section is empty.
Types ¶
type ImgGrid ¶
type ImgGrid struct { gi.Frame // maximum size for images -- geom set to square of this size ImageMax float32 `desc:"maximum size for images -- geom set to square of this size"` // list of image files to display Images []string `desc:"list of image files to display"` // function for displaying context menu for item at given index -- if not set then a basic standard one is used CtxtMenuFunc func(m *gi.Menu, idx int) `desc:"function for displaying context menu for item at given index -- if not set then a basic standard one is used"` // if true, drag-n-drop and paste actions actually result in insertion -- otherwise they just drive signals to be managed externally InsertOk bool `` /* 136-byte string literal not displayed */ // last selected item SelectedIdx int `desc:"last selected item"` // editing-mode select rows mode SelectMode bool `copy:"-" desc:"editing-mode select rows mode"` // list of currently-selected file indexes SelectedIdxs map[int]struct{} `copy:"-" desc:"list of currently-selected file indexes"` // list of currently-dragged indexes DraggedIdxs []int `copy:"-" desc:"list of currently-dragged indexes"` // signal for image events -- selection events occur via WidgetSig ImageSig ki.Signal `copy:"-" json:"-" xml:"-" desc:"signal for image events -- selection events occur via WidgetSig"` // number of columns and rows to display -- computed from avail room Size image.Point `desc:"number of columns and rows to display -- computed from avail room"` // current copy / paste idx CurIdx int `copy:"-" json:"-" xml:"-" desc:"current copy / paste idx"` }
ImgGrid shows a list of images in a grid. The outer layout contains the inner grid and a scrollbar
func AddNewImgGrid ¶
AddNewImgGrid adds a new imggrid to given parent node, with given name.
func (*ImgGrid) BitmapAtIdx ¶
BitmapAtIdx returns the gi.Bitmap at given index
func (*ImgGrid) ConnectEvents2D ¶
func (ig *ImgGrid) ConnectEvents2D()
func (*ImgGrid) Copy ¶
Copy copies selected rows to clip.Board, optionally resetting the selection satisfies gi.Clipper interface and can be overridden by subtypes
func (*ImgGrid) CopyIdxs ¶
CopyIdxs copies selected idxs to clip.Board, optionally resetting the selection
func (*ImgGrid) CopySelToMime ¶
CopySelToMime copies selected rows to mime data
func (*ImgGrid) Cut ¶
func (ig *ImgGrid) Cut()
Cut copies selected indexes to clip.Board and deletes selected indexes satisfies gi.Clipper interface and can be overridden by subtypes
func (*ImgGrid) CutIdxs ¶
func (ig *ImgGrid) CutIdxs()
CutIdxs copies selected indexes to clip.Board and deletes selected indexes
func (*ImgGrid) DeleteIdxs ¶
func (ig *ImgGrid) DeleteIdxs()
DeleteIdxs deletes all selected indexes
func (*ImgGrid) DragNDropFinalize ¶
DragNDropFinalize is called to finalize actions on the Source node prior to performing target actions -- mod must indicate actual action taken by the target, including ignore -- ends up calling DragNDropSource if us..
func (*ImgGrid) DragNDropSource ¶
DragNDropSource is called after target accepts the drop -- we just remove elements that were moved
func (*ImgGrid) DragNDropStart ¶
func (ig *ImgGrid) DragNDropStart()
DragNDropStart starts a drag-n-drop
func (*ImgGrid) DragNDropTarget ¶
DragNDropTarget handles a drag-n-drop drop
func (*ImgGrid) Drop ¶
Drop pops up a menu to determine what specifically to do with dropped items this satisfies gi.DragNDropper interface, and can be overwritten in subtypes
func (*ImgGrid) DropAssign ¶
DropAssign assigns mime data (only the first one!) to this node
func (*ImgGrid) DropBefore ¶
DropBefore inserts object(s) from mime data before this node
func (*ImgGrid) DropCancel ¶
func (ig *ImgGrid) DropCancel()
DropCancel cancels the drop action e.g., preventing deleting of source items in a Move case
func (*ImgGrid) Duplicate ¶
Duplicate copies selected items and inserts them after current selection -- return idx of start of duplicates if successful, else -1
func (*ImgGrid) FromMimeData ¶
FromMimeData creates a slice of file names from mime data
func (*ImgGrid) IdxFromPos ¶
IdxFromPos returns the widget grid idx that contains given position, false if not found add StartIdx to get actual index
func (*ImgGrid) IdxGrabFocus ¶
IdxGrabFocus grabs the focus for the first focusable widget in given idx
func (*ImgGrid) IdxIsSelected ¶
IdxIsSelected returns the selected status of given slice index
func (*ImgGrid) IdxPos ¶
IdxPos returns center of window position of index label for idx (ContextMenuPos)
func (*ImgGrid) ImageDeleteAt ¶
ImageDeleteAt deletes image at given index
func (*ImgGrid) ImageInsertAt ¶
ImageInsertAt inserts image(s) at given index
func (*ImgGrid) ImgGridEvents ¶
func (ig *ImgGrid) ImgGridEvents()
func (*ImgGrid) IsIdxVisible ¶
IsIdxVisible returns true if image index is currently visible
func (*ImgGrid) ItemCtxtMenu ¶
func (*ImgGrid) KeyInputActive ¶
func (ig *ImgGrid) KeyInputActive(kt *key.ChordEvent)
func (*ImgGrid) LayoutGrid ¶
LayoutGrid updates the grid size based on allocated size if returns true, then needs a new iteration
func (*ImgGrid) MakeDropMenu ¶
MakeDropMenu makes the menu of options for dropping on a target
func (*ImgGrid) MakePasteMenu ¶
MakePasteMenu makes the menu of options for paste events
func (*ImgGrid) MimeDataIdx ¶
MimeDataIdx adds mimedata for given idx: an application/json of the struct
func (*ImgGrid) MoveDown ¶
func (ig *ImgGrid) MoveDown(selMode mouse.SelectModes) int
MoveDown moves the selection down to next row, using given select mode (from keyboard modifiers) -- returns newly selected row or -1 if failed
func (*ImgGrid) MoveDownAction ¶
func (ig *ImgGrid) MoveDownAction(selMode mouse.SelectModes) int
MoveDownAction moves the selection down to next row, using given select mode (from keyboard modifiers) -- and emits select event for newly selected row
func (*ImgGrid) MoveNext ¶
func (ig *ImgGrid) MoveNext(selMode mouse.SelectModes) int
MoveNext moves the selection to next item, using given select mode (from keyboard modifiers) -- returns newly selected row or -1 if failed
func (*ImgGrid) MoveNextAction ¶
func (ig *ImgGrid) MoveNextAction(selMode mouse.SelectModes) int
MoveNextAction moves the selection to next item, using given select mode (from keyboard modifiers) -- and emits select event for newly selected row
func (*ImgGrid) MovePageDown ¶
func (ig *ImgGrid) MovePageDown(selMode mouse.SelectModes) int
MovePageDown moves the selection down to next page, using given select mode (from keyboard modifiers) -- returns newly selected idx or -1 if failed
func (*ImgGrid) MovePageDownAction ¶
func (ig *ImgGrid) MovePageDownAction(selMode mouse.SelectModes) int
MovePageDownAction moves the selection down to next page, using given select mode (from keyboard modifiers) -- and emits select event for newly selected idx
func (*ImgGrid) MovePageUp ¶
func (ig *ImgGrid) MovePageUp(selMode mouse.SelectModes) int
MovePageUp moves the selection up to previous page, using given select mode (from keyboard modifiers) -- returns newly selected idx or -1 if failed
func (*ImgGrid) MovePageUpAction ¶
func (ig *ImgGrid) MovePageUpAction(selMode mouse.SelectModes) int
MovePageUpAction moves the selection up to previous page, using given select mode (from keyboard modifiers) -- and emits select event for newly selected idx
func (*ImgGrid) MovePrev ¶
func (ig *ImgGrid) MovePrev(selMode mouse.SelectModes) int
MovePrev moves the selection to previous idx, using given select mode (from keyboard modifiers) -- returns newly selected idx or -1 if failed
func (*ImgGrid) MovePrevAction ¶
func (ig *ImgGrid) MovePrevAction(selMode mouse.SelectModes) int
MovePrevAction moves the selection to previous idx, using given select mode (from keyboard modifiers) -- and emits select event for newly selected idx
func (*ImgGrid) MoveUp ¶
func (ig *ImgGrid) MoveUp(selMode mouse.SelectModes) int
MoveUp moves the selection up to previous idx, using given select mode (from keyboard modifiers) -- returns newly selected idx or -1 if failed
func (*ImgGrid) MoveUpAction ¶
func (ig *ImgGrid) MoveUpAction(selMode mouse.SelectModes) int
MoveUpAction moves the selection up to previous idx, using given select mode (from keyboard modifiers) -- and emits select event for newly selected idx
func (*ImgGrid) Paste ¶
func (ig *ImgGrid) Paste()
Paste pastes clipboard at CurIdx satisfies gi.Clipper interface and can be overridden by subtypes
func (*ImgGrid) PasteAssign ¶
PasteAssign assigns mime data (only the first one!) to this idx
func (*ImgGrid) PasteAtIdx ¶
PasteAtIdx inserts object(s) from mime data at (before) given slice index
func (*ImgGrid) PasteMenu ¶
PasteMenu performs a paste from the clipboard using given data -- pops up a menu to determine what specifically to do
func (*ImgGrid) RenderSelected ¶
func (ig *ImgGrid) RenderSelected()
func (*ImgGrid) ResetSelectedIdxs ¶
func (ig *ImgGrid) ResetSelectedIdxs()
func (*ImgGrid) SaveDraggedIdxs ¶
SaveDraggedIdxs saves selectedindexes into dragged indexes taking into account insertion at idx
func (*ImgGrid) ScrollToIdx ¶
ScrollToIdx ensures that given slice idx is visible by scrolling display as needed
func (*ImgGrid) SelectIdx ¶
SelectIdx selects given idx (if not already selected) -- updates select status of index label
func (*ImgGrid) SelectIdxAction ¶
func (ig *ImgGrid) SelectIdxAction(idx int, mode mouse.SelectModes)
SelectIdxAction is called when a select action has been received (e.g., a mouse click) -- translates into selection updates -- gets selection mode from mouse event (ExtendContinuous, ExtendOne)
func (*ImgGrid) SelectIdxWidgets ¶
SelectIdxWidgets sets the selection state of given slice index returns false if index is not visible
func (*ImgGrid) SelectedIdxsList ¶
SelectedIdxsList returns list of selected indexes, sorted either ascending or descending
func (*ImgGrid) SetImages ¶
SetImages sets the current image files to view (makes a copy of slice), and does a config rebuild. If reset, then reset selections, else not
func (*ImgGrid) SetScrollMax ¶
func (*ImgGrid) UnselectAllIdxs ¶
func (ig *ImgGrid) UnselectAllIdxs()
UnselectAllIdxs unselects all selected idxs
func (*ImgGrid) UnselectIdx ¶
UnselectIdx unselects given idx (if selected)
func (*ImgGrid) UnselectIdxAction ¶
UnselectIdxAction unselects this idx (if selected) -- and emits a signal
func (*ImgGrid) Update ¶
func (ig *ImgGrid) Update()
Update updates the display for current scrollbar position, rendering the images
func (*ImgGrid) UpdateSelectIdx ¶
UpdateSelectIdx updates the selection for the given index
type ImgGridSignals ¶
type ImgGridSignals int
ImgGridSignals are signals that sliceview can send, mostly for editing mode. Selection events are sent on WidgetSig WidgetSelected signals in both modes.
const ( // ImgGridDoubleClicked emitted during inactive mode when item // double-clicked -- can be used for accepting dialog. ImgGridDoubleClicked ImgGridSignals = iota // ImgGridInserted emitted when a new item is inserted -- data is index of new item ImgGridInserted // ImgGridDeleted emitted when an item is deleted -- data is index of item deleted ImgGridDeleted ImgGridSignalsN )
func (*ImgGridSignals) FromString ¶
func (i *ImgGridSignals) FromString(s string) error
func (ImgGridSignals) String ¶
func (i ImgGridSignals) String() string