gocvui

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2022 License: MIT Imports: 10 Imported by: 0

README

gocvui

A (very) simple UI lib built on top of OpenCV drawing primitives

Documentation

Index

Constants

View Source
const CLICK int = 3
View Source
const COLUMN int = 1
View Source
const CVUI_ANTIALISED int = int(gocv.LineAA) // cv2.LINE_AA

Internal things

View Source
const CVUI_FILLED int = -1
View Source
const DOWN int = 2
View Source
const EVENT_FLAG_ALTKEY int = 32 //!< indicates that ALT Key is pressed.
View Source
const EVENT_FLAG_CTRLKEY int = 8 //!< indicates that CTRL Key is pressed.
View Source
const EVENT_FLAG_LBUTTON int = 1 //!< indicates that the left mouse button is down.

! Mouse Event Flags see cv::MouseCallback

View Source
const EVENT_FLAG_MBUTTON int = 4 //!< indicates that the middle mouse button is down.
View Source
const EVENT_FLAG_RBUTTON int = 2 //!< indicates that the right mouse button is down.
View Source
const EVENT_FLAG_SHIFTKEY int = 16 //!< indicates that SHIFT Key is pressed.
View Source
const EVENT_LBUTTONDBLCLK int = 7 //!< indicates that left mouse button is double clicked.
View Source
const EVENT_LBUTTONDOWN int = 1 //!< indicates that the left mouse button is pressed.
View Source
const EVENT_LBUTTONUP int = 4 //!< indicates that left mouse button is released.
View Source
const EVENT_MBUTTONDBLCLK int = 9 //!< indicates that middle mouse button is double clicked.
View Source
const EVENT_MBUTTONDOWN int = 3 //!< indicates that the middle mouse button is pressed.
View Source
const EVENT_MBUTTONUP int = 6 //!< indicates that middle mouse button is released.
View Source
const EVENT_MOUSEHWHEEL int = 11 //!< positive and negative values mean right and left scrolling, respectively.
View Source
const EVENT_MOUSEMOVE int = 0 //!< indicates that the mouse pointer has moved over the window.

! Mouse Events see cv::MouseCallback MouseEventTypes

View Source
const EVENT_MOUSEWHEEL int = 10 //!< positive and negative values mean forward and backward scrolling, respectively.
View Source
const EVENT_RBUTTONDBLCLK int = 8 //!< indicates that right mouse button is double clicked.
View Source
const EVENT_RBUTTONDOWN int = 2 //!< indicates that the right mouse button is pressed.
View Source
const EVENT_RBUTTONUP int = 5 //!< indicates that right mouse button is released.
View Source
const IS_DOWN int = 7
View Source
const LEFT_BUTTON int = 0

Constants regarding mouse buttons

View Source
const MIDDLE_BUTTON int = 1
View Source
const OUT int = 5
View Source
const OVER int = 4
View Source
const RIGHT_BUTTON int = 2
View Source
const ROW int = 0

Constants regarding component interactions

View Source
const TRACKBAR_DISCRETE int = 4
View Source
const TRACKBAR_HIDE_LABELS int = 32
View Source
const TRACKBAR_HIDE_MIN_MAX_LABELS int = 8
View Source
const TRACKBAR_HIDE_SEGMENT_LABELS int = 1

Constants regarding components

View Source
const TRACKBAR_HIDE_STEP_SCALE int = 2
View Source
const TRACKBAR_HIDE_VALUE_LABEL int = 16
View Source
const UP int = 6
View Source
const VERSION string = "2.7"

Lib version

Variables

This section is empty.

Functions

func BeginColumn

func BeginColumn(theArgs ...interface{})

func BeginRow

func BeginRow(theArgs ...interface{})

func Button

func Button(theArgs ...interface{}) (bool, error)

func Checkbox

func Checkbox(theArgs ...interface{}) bool

func Image

func Image(theArgs ...interface{})

func Imshow

func Imshow(theWindowName string, theFrame gocv.Mat)

See Also ---------- update() context() watch()

func Init

func Init(theArgs ...interface{})

func Sparkline

func Sparkline(theArgs ...interface{})

func Text

func Text(theArgs ...interface{})

func Update

func Update(theArgs ...interface{})

See Also ---------- init() watch() context()

func Watch

func Watch(theWindowName string, theCreateNamedWindow bool)

See Also ---------- init() context()

Types

type Block

type Block struct {
	Where   gocv.Mat
	Rect    Rect
	Fill    Rect
	Anchor  Point
	Padding int
	Type    int
}

Describe a block structure used by gocvui to handle `begin*()` and `end*()` calls.

func NewBlock

func NewBlock() Block

func (*Block) Reset

func (b *Block) Reset()

type Context

type Context struct {
	Window *gocv.Window
	Mouse  Mouse
}

Describe a (window) context.

func NewContext

func NewContext() Context

type Internal

type Internal struct {
	DefaultContext  string
	CurrentContext  string
	Contexts        map[string]Context // indexed by the window name.
	Buffer          []interface{}
	LastKeyPressed  int // TODO: collect it per window
	DelayWaitKey    int
	Screen          Block
	Stack           []Block // TODO: make it dynamic
	StackCount      int
	TrackbarMarginX int
	// contains filtered or unexported fields
}

This class contains all stuff that gocvui uses internally to render and control interaction with components.

func NewInternal

func NewInternal() Internal

func (*Internal) Begin

func (in *Internal) Begin(theType int, theWhere *gocv.Mat, theX, theY, theWidth, theHeight int, thePadding int)

func (*Internal) BitsetHas

func (in *Internal) BitsetHas(theBitset int, theValue int) bool

func (*Internal) BlockStackEmpty

func (in *Internal) BlockStackEmpty() bool

func (*Internal) Button

func (in *Internal) Button(theBlock *Block, theX, theY int, theLabel string) bool

func (*Internal) ButtonI

func (in *Internal) ButtonI(theBlock *Block, theX, theY int, theIdle, theOver, theDown *gocv.Mat, theUpdateLayout bool) bool

func (*Internal) ButtonWH

func (in *Internal) ButtonWH(theBlock *Block, theX, theY, theWidth, theHeight int, theLabel string, theUpdateLayout bool) bool

func (*Internal) Checkbox

func (in *Internal) Checkbox(theBlock *Block, theX, theY int, theLabel string, theState []bool, theColor uint32) bool

func (*Internal) Clamp01

func (in *Internal) Clamp01(theValue float64) float64

func (*Internal) Counter

func (in *Internal) Counter(theBlock *Block, theX, theY int, theValue []int, theStep int, theFormat string) int

func (*Internal) CreateLabel

func (in *Internal) CreateLabel(theLabel string) Label

func (*Internal) End

func (in *Internal) End(theType int)

func (*Internal) Error

func (in *Internal) Error(theId int, theMessage string)

func (*Internal) FindMinMax

func (in *Internal) FindMinMax(theValues []float64) (float64, float64)

Find the min and max values of a vector

func (*Internal) GetContext

func (in *Internal) GetContext(theWindowName string) Context

func (*Internal) HexToScalar

func (in *Internal) HexToScalar(theColor uint32) color.RGBA

func (*Internal) IArea

func (in *Internal) IArea(theX, theY, theWidth, theHeight int) int

func (*Internal) Image

func (in *Internal) Image(theBlock *Block, theX, theY int, theImage *gocv.Mat)

func (*Internal) Init

func (in *Internal) Init(theWindowName string, theDelayWaitKey int)

func (*Internal) IsMouseButton

func (in *Internal) IsMouseButton(theButton *MouseButton, theQuery int) bool

func (*Internal) IsString

func (in *Internal) IsString(theObj interface{}) bool

func (*Internal) MouseQ

func (in *Internal) MouseQ(theQuery int) bool

Mouse(const cv::String&) Mouse(const cv::String&, int) Mouse(const cv::String&, int, int) Mouse(int, int)

func (*Internal) MouseW

func (in *Internal) MouseW(theWindowName string) Point

Return the last position of the mouse. param theWindowName name of the window whose mouse cursor will be used. If nothing is informed (default), the function will return the position of the mouse cursor for the default window (the one informed in `gocvui::Init()`). return a point containing the position of the mouse cursor in the speficied window.

func (*Internal) MouseWBQ

func (in *Internal) MouseWBQ(theWindowName string, theButton int, theQuery int) bool

\param theWindowName name of the window that will be queried. \param theButton an integer describing the mouse button to be queried. Possible values are `gocvui::LEFT_BUTTON`, `gocvui::MIDDLE_BUTTON` and `gocvui::LEFT_BUTTON`. \param theQuery an integer describing the intended mouse query. Available queries are `gocvui::DOWN`, `gocvui::UP`, `gocvui::CLICK`, and `gocvui::IS_DOWN`.

func (*Internal) MouseWQ

func (in *Internal) MouseWQ(theWindowName string, theQuery int) bool

Mouse(const cv::String&) Mouse(const cv::String&, int, int) Mouse(int, int) Mouse(int)

func (*Internal) PopBlock

func (in *Internal) PopBlock() Block

func (*Internal) PushBlock

func (in *Internal) PushBlock() Block

func (*Internal) Sparkline

func (in *Internal) Sparkline(theBlock *Block, theValues []float64, theX, theY, theWidth, theHeight int, theColor uint32)

func (*Internal) Text

func (in *Internal) Text(theBlock *Block, theX, theY int, theText string, theFontScale float64, theColor uint32, theUpdateLayout bool)

func (*Internal) TopBlock

func (in *Internal) TopBlock() *Block

func (*Internal) TrackbarForceValuesAsMultiplesOfSmallStep

func (in *Internal) TrackbarForceValuesAsMultiplesOfSmallStep(theParams TrackbarParams, theValue []float64)

func (*Internal) TrackbarValueToXPixel

func (in *Internal) TrackbarValueToXPixel(theParams TrackbarParams, theBounding Rect, theValue float64) int

func (*Internal) TrackbarXPixelToValue

func (in *Internal) TrackbarXPixelToValue(theParams TrackbarParams, theBounding Rect, thePixelX int) float64

func (*Internal) UpdateLayoutFlow

func (in *Internal) UpdateLayoutFlow(theBlock *Block, theSize Size)

type Label

type Label struct {
	HasShortcut        bool
	Shortcut           byte
	TextBeforeShortcut string
	TextAfterShortcut  string
}

Describe a component label, including info about a shortcut. If a label contains "Re&start", then: - hasShortcut will be true - shortcut will be "s" - textBeforeShortcut will be "Re" - textAfterShortcut will be "tart"

func NewLabel

func NewLabel() Label

type Mouse

type Mouse struct {
	Buttons   map[int]*MouseButton
	AnyButton *MouseButton
	Position  Point
}

Describe the information of the mouse cursor

func NewMouse

func NewMouse() Mouse

type MouseButton

type MouseButton struct {
	JustReleased bool
	JustPressed  bool
	Pressed      bool
}

Describe a mouse button

func NewMouseButton

func NewMouseButton() *MouseButton

func (*MouseButton) Reset

func (b *MouseButton) Reset()

type Point

type Point struct {
	X int
	Y int
}

Represent a 2D point.

func NewPoint

func NewPoint(theX int, theY int) Point

func (*Point) Inside

func (p *Point) Inside(theRect Rect) bool

type Rect

type Rect struct {
	X      int
	Y      int
	Width  int
	Height int
}

Represent a rectangle.

func NewRect

func NewRect(theX, theY, theWidth, theHeight int) Rect

func (*Rect) Area

func (r *Rect) Area() int

func (*Rect) Contains

func (r *Rect) Contains(thePoint Point) bool

type Render

type Render struct {
	// contains filtered or unexported fields
}

Class that contains all rendering methods.

func (*Render) Button

func (r *Render) Button(theBlock *Block, theState int, theShape Rect, theLabel string)

func (*Render) ButtonLabel

func (r *Render) ButtonLabel(theBlock *Block, theState int, theRect Rect, theLabel string, theTextSize Rect)

func (*Render) Checkbox

func (r *Render) Checkbox(theBlock *Block, theState int, theShape Rect)

func (*Render) CheckboxCheck

func (r *Render) CheckboxCheck(theBlock *Block, theShape Rect)

func (*Render) CheckboxLabel

func (r *Render) CheckboxLabel(theBlock *Block, theRect Rect, theLabel string, theTextSize Rect, theColor uint32)

// Inside theShape.x += 1 theShape.y += 1 theShape.width -= 2 theShape.height -= 2 in.rectangle(theBlock.where, theShape, (0x29, 0x29, 0x29), CVUI_FILLED)

func (*Render) Counter

func (r *Render) Counter(theBlock *Block, theShape Rect, theValue string)

func (*Render) Image

func (r *Render) Image(theBlock *Block, theRect Rect, theImage *gocv.Mat)

func (*Render) PutText

func (r *Render) PutText(theBlock *Block, theState int, theColor color.RGBA, theText string, thePosition Point) int

func (*Render) Rectangle

func (r *Render) Rectangle(theWhere *gocv.Mat, theShape Rect, theColor color.RGBA, theThickness int)

func (*Render) Sparkline

func (r *Render) Sparkline(theBlock *Block, theValues []float64, theRect Rect, theMin, theMax float64, theColor uint32)

func (*Render) Text

func (r *Render) Text(theBlock *Block, theText string, thePos Point, theFontScale float64, theColor uint32)

func (*Render) Window

func (r *Render) Window(theBlock *Block, theTitleBar Rect, theContent Rect, theTitle string)

type Size

type Size struct {
	X      int
	Y      int
	Width  int
	Height int
}

Represent the size of something, i.e. width and height. It is essentially a simplified version of Rect where x and y are zero.

func NewSize

func NewSize(theWidth, theHeight int) Size

type TrackbarParams

type TrackbarParams struct {
	Min         float64
	Max         float64
	Step        float64
	Segments    int
	Options     int
	LabelFormat string
}

Describe the inner parts of the trackbar component.

func NewTrackbarParams

func NewTrackbarParams(theMin, theMax, theStep float64, theSegments int, theLabelFormat string, theOptions int) TrackbarParams

type Window

type Window struct {
	*gocv.Window
	Name         string
	OnMouse      func(theEvent int, theX, theY int, theFlags int, theContext *Context)
	OnMouseParam interface{}
}

func (*Window) SetMouseCallback

func (w *Window) SetMouseCallback(callbackFunc func(theEvent int, theX, theY int, theFlags int, theContext *Context), context Context)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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