imgrid

package
v0.9.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2021 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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,
}
View Source
var KiT_ImgGrid = kit.Types.AddType(&ImgGrid{}, ImgGridProps)

Functions

This section is empty.

Types

type ImgGrid

type ImgGrid struct {
	gi.Frame
	ImageMax     float32                   `desc:"maximum size for images -- geom set to square of this size"`
	Images       []string                  `desc:"list of image files to display"`
	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"`
	InsertOk     bool                      `` /* 136-byte string literal not displayed */
	SelectedIdx  int                       `desc:"last selected item"`
	SelectMode   bool                      `copy:"-" desc:"editing-mode select rows mode"`
	SelectedIdxs map[int]struct{}          `copy:"-" desc:"list of currently-selected file indexes"`
	DraggedIdxs  []int                     `copy:"-" desc:"list of currently-dragged indexes"`
	ImageSig     ki.Signal                 `copy:"-" json:"-" xml:"-" desc:"signal for image events -- selection events occur via WidgetSig"`
	Size         image.Point               `desc:"number of columns and rows to display -- computed from avail room"`
	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

func AddNewImgGrid(parent ki.Ki, name string) *ImgGrid

AddNewImgGrid adds a new imggrid to given parent node, with given name.

func (*ImgGrid) BitmapAtIdx

func (ig *ImgGrid) BitmapAtIdx(idx int) *gi.Bitmap

BitmapAtIdx returns the gi.Bitmap at given index

func (*ImgGrid) Config

func (ig *ImgGrid) Config(reset bool)

Config configures the grid

func (*ImgGrid) ConnectEvents2D

func (ig *ImgGrid) ConnectEvents2D()

func (*ImgGrid) Copy

func (ig *ImgGrid) Copy(reset bool)

Copy copies selected rows to clip.Board, optionally resetting the selection satisfies gi.Clipper interface and can be overridden by subtypes

func (*ImgGrid) CopyIdxs

func (ig *ImgGrid) CopyIdxs(reset bool)

CopyIdxs copies selected idxs to clip.Board, optionally resetting the selection

func (*ImgGrid) CopySelToMime

func (ig *ImgGrid) CopySelToMime() mimedata.Mimes

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

func (ig *ImgGrid) DragNDropFinalize(mod dnd.DropMods)

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

func (ig *ImgGrid) DragNDropSource(de *dnd.Event)

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

func (ig *ImgGrid) DragNDropTarget(de *dnd.Event)

DragNDropTarget handles a drag-n-drop drop

func (*ImgGrid) Drop

func (ig *ImgGrid) Drop(md mimedata.Mimes, mod dnd.DropMods)

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) DropAfter

func (ig *ImgGrid) DropAfter(md mimedata.Mimes, mod dnd.DropMods, idx int)

DropAfter inserts object(s) from mime data after this node

func (*ImgGrid) DropAssign

func (ig *ImgGrid) DropAssign(md mimedata.Mimes, idx int)

DropAssign assigns mime data (only the first one!) to this node

func (*ImgGrid) DropBefore

func (ig *ImgGrid) DropBefore(md mimedata.Mimes, mod dnd.DropMods, idx int)

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

func (ig *ImgGrid) Duplicate() int

Duplicate copies selected items and inserts them after current selection -- return idx of start of duplicates if successful, else -1

func (*ImgGrid) FromMimeData

func (ig *ImgGrid) FromMimeData(md mimedata.Mimes) []string

FromMimeData creates a slice of file names from mime data

func (*ImgGrid) Grid

func (ig *ImgGrid) Grid() *gi.Layout

Grid returns the actual grid layout

func (*ImgGrid) IdxFromPos

func (ig *ImgGrid) IdxFromPos(pos image.Point) (int, bool)

IdxFromPos returns the widget grid idx that contains given position, false if not found add StartIdx to get actual index

func (*ImgGrid) IdxGrabFocus

func (ig *ImgGrid) IdxGrabFocus(idx int)

IdxGrabFocus grabs the focus for the first focusable widget in given idx

func (*ImgGrid) IdxIsSelected

func (ig *ImgGrid) IdxIsSelected(idx int) bool

IdxIsSelected returns the selected status of given slice index

func (*ImgGrid) IdxPos

func (ig *ImgGrid) IdxPos(idx int) image.Point

IdxPos returns center of window position of index label for idx (ContextMenuPos)

func (*ImgGrid) ImageDeleteAt

func (ig *ImgGrid) ImageDeleteAt(idx int)

ImageDeleteAt deletes image at given index

func (*ImgGrid) ImageInsertAt

func (ig *ImgGrid) ImageInsertAt(idx int, files []string)

ImageInsertAt inserts image(s) at given index

func (*ImgGrid) ImgGridEvents

func (ig *ImgGrid) ImgGridEvents()

func (*ImgGrid) IsIdxVisible

func (ig *ImgGrid) IsIdxVisible(idx int) bool

IsIdxVisible returns true if image index is currently visible

func (*ImgGrid) ItemCtxtMenu

func (ig *ImgGrid) ItemCtxtMenu(idx int)

func (*ImgGrid) KeyInputActive

func (ig *ImgGrid) KeyInputActive(kt *key.ChordEvent)

func (*ImgGrid) Layout2D

func (ig *ImgGrid) Layout2D(parBBox image.Rectangle, iter int) bool

func (*ImgGrid) LayoutGrid

func (ig *ImgGrid) LayoutGrid(iter int) bool

LayoutGrid updates the grid size based on allocated size if returns true, then needs a new iteration

func (*ImgGrid) MakeDropMenu

func (ig *ImgGrid) MakeDropMenu(m *gi.Menu, data interface{}, mod dnd.DropMods, idx int)

MakeDropMenu makes the menu of options for dropping on a target

func (*ImgGrid) MakePasteMenu

func (ig *ImgGrid) MakePasteMenu(m *gi.Menu, data interface{}, idx int)

MakePasteMenu makes the menu of options for paste events

func (*ImgGrid) MimeDataIdx

func (ig *ImgGrid) MimeDataIdx(md *mimedata.Mimes, idx int)

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) NumImages

func (ig *ImgGrid) NumImages() int

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

func (ig *ImgGrid) PasteAssign(md mimedata.Mimes, idx int)

PasteAssign assigns mime data (only the first one!) to this idx

func (*ImgGrid) PasteAtIdx

func (ig *ImgGrid) PasteAtIdx(md mimedata.Mimes, idx int)

PasteAtIdx inserts object(s) from mime data at (before) given slice index

func (*ImgGrid) PasteIdx

func (ig *ImgGrid) PasteIdx(idx int)

PasteIdx pastes clipboard at given idx

func (*ImgGrid) PasteMenu

func (ig *ImgGrid) PasteMenu(md mimedata.Mimes, idx int)

PasteMenu performs a paste from the clipboard using given data -- pops up a menu to determine what specifically to do

func (*ImgGrid) Render2D

func (ig *ImgGrid) Render2D()

func (*ImgGrid) RenderSelected

func (ig *ImgGrid) RenderSelected()

func (*ImgGrid) ResetSelectedIdxs

func (ig *ImgGrid) ResetSelectedIdxs()

func (*ImgGrid) SaveDraggedIdxs

func (ig *ImgGrid) SaveDraggedIdxs(idx int)

SaveDraggedIdxs saves selectedindexes into dragged indexes taking into account insertion at idx

func (*ImgGrid) ScrollBar

func (ig *ImgGrid) ScrollBar() *gi.ScrollBar

ScrollBar returns the scrollbar

func (*ImgGrid) ScrollToIdx

func (ig *ImgGrid) ScrollToIdx(idx int) bool

ScrollToIdx ensures that given slice idx is visible by scrolling display as needed

func (*ImgGrid) SelectAllIdxs

func (ig *ImgGrid) SelectAllIdxs()

SelectAllIdxs selects all idxs

func (*ImgGrid) SelectIdx

func (ig *ImgGrid) SelectIdx(idx int)

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

func (ig *ImgGrid) SelectIdxWidgets(idx int, sel bool) bool

SelectIdxWidgets sets the selection state of given slice index returns false if index is not visible

func (*ImgGrid) SelectedIdxsList

func (ig *ImgGrid) SelectedIdxsList(descendingSort bool) []int

SelectedIdxsList returns list of selected indexes, sorted either ascending or descending

func (*ImgGrid) SetImages

func (ig *ImgGrid) SetImages(files []string, reset bool)

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 (ig *ImgGrid) SetScrollMax() int

func (*ImgGrid) StartIdx

func (ig *ImgGrid) StartIdx() int

StartIdx returns the index of first image visible

func (*ImgGrid) StdCtxtMenu

func (ig *ImgGrid) StdCtxtMenu(m *gi.Menu, idx int)

func (*ImgGrid) UnselectAllIdxs

func (ig *ImgGrid) UnselectAllIdxs()

UnselectAllIdxs unselects all selected idxs

func (*ImgGrid) UnselectIdx

func (ig *ImgGrid) UnselectIdx(idx int)

UnselectIdx unselects given idx (if selected)

func (*ImgGrid) UnselectIdxAction

func (ig *ImgGrid) UnselectIdxAction(idx int)

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

func (ig *ImgGrid) UpdateSelectIdx(idx int, sel bool)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL