screenshot

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package screenshot implements the screenshot edit window.

It's the main part of the application: it may be run after a fork(), if the main program was started as a system tray app.

Index

Constants

View Source
const (
	SaveShortcutDesc  = "ctrl+s"
	CopyShortcutDesc  = "ctrl+c"
	DriveShortcutDesc = "ctrl+g"
)

This file has the default resources for things like menu entries and related stuff, that can be specialized for different platforms.

View Source
const (
	BackgroundColorPreference = "BackgroundColor"
	DrawingColorPreference    = "DrawingColor"
	FontSizePreference        = "FontSize"
	ThicknessPreference       = "Thickness"
)
View Source
const DefaultPathPreference = "DefaultPath"
View Source
const DelayTimePreference = "DelayTime"
View Source
const (
	GoogleDriveTokenPreference = "google_drive_token"
)

Variables

View Source
var (
	Red         = color.RGBA{R: 255, G: 64, B: 64, A: 255}
	Yellow      = color.RGBA{R: 255, G: 255, B: 64, A: 255}
	Transparent = color.RGBA{}
)
View Source
var (
	GoogleDrivePath = []string{"GoShot"}
)

Functions

func Run

func Run()

Types

type GoShot

type GoShot struct {
	// Fyne: Application and Window
	App fyne.App
	Win fyne.Window // Main window.

	// Original screenshot information
	OriginalScreenshot *image.RGBA
	ScreenshotTime     time.Time

	// Edited screenshot
	Screenshot *image.RGBA // The edited/composed screenshot
	CropRect   image.Rectangle
	Filters    []ImageFilter // Configured filters: each filter is one edition to the image.
	// contains filtered or unexported fields
}

func (*GoShot) ApplyFilters

func (gs *GoShot) ApplyFilters(full bool)

ApplyFilters will apply `Filters` to the `CropRect` of the original image and regenerate Screenshot. If full == true, regenerates full Screenshot. If false, regenerates only visible area.

func (*GoShot) BuildEditWindow

func (gs *GoShot) BuildEditWindow()

func (*GoShot) CopyImageToClipboard

func (gs *GoShot) CopyImageToClipboard()

func (*GoShot) DefaultName

func (gs *GoShot) DefaultName() string

DefaultName returns a default name to the screenshot, based on date/time it was made.

func (*GoShot) DelayedScreenshot added in v0.1.2

func (gs *GoShot) DelayedScreenshot(seconds int)

func (*GoShot) DelayedScreenshotForm added in v0.1.2

func (gs *GoShot) DelayedScreenshotForm()

func (*GoShot) GetColorPreference

func (gs *GoShot) GetColorPreference(key string, defaultColor color.RGBA) color.RGBA

GetColorPreference returns the color set for the given key if it has been set. Otherwise it returns `defaultColor`.

func (*GoShot) MakeScreenshot

func (gs *GoShot) MakeScreenshot() error

func (*GoShot) RegisterShortcuts

func (gs *GoShot) RegisterShortcuts()

RegisterShortcuts adds all the shortcuts and keys GoShot listens to. When updating here, please update also the `gs.ShowShortcutsPage()` method to reflect the changes.

func (*GoShot) SaveImage

func (gs *GoShot) SaveImage()

SaveImage opens a file save dialog box to save the currently edited screenshot.

func (*GoShot) SetColorPreference

func (gs *GoShot) SetColorPreference(key string, c color.Color)

SetColorPreference sets the given color in the given preferences key.

func (*GoShot) ShareWithGoogleDrive

func (gs *GoShot) ShareWithGoogleDrive()

func (*GoShot) ShowShortcutsPage

func (gs *GoShot) ShowShortcutsPage()

func (*GoShot) UndoLastFilter

func (gs *GoShot) UndoLastFilter()

UndoLastFilter cancels the last filter applied, and regenerates everything.

type ImageFilter

type ImageFilter interface {
	// Apply filter, shifted (dx, dy) pixels -- e.g. if a filter draws a circle on
	// top of the image, it should add (dx, dy) to the circle center.
	Apply(image image.Image) image.Image
}

type MiniMap

type MiniMap struct {
	widget.BaseWidget
	// contains filtered or unexported fields
}

func NewMiniMap

func NewMiniMap(gs *GoShot, vp *ViewPort) (mm *MiniMap)

func (*MiniMap) BackgroundColor

func (mm *MiniMap) BackgroundColor() color.Color

func (*MiniMap) CreateRenderer

func (mm *MiniMap) CreateRenderer() fyne.WidgetRenderer

func (*MiniMap) Destroy

func (mm *MiniMap) Destroy()

func (*MiniMap) DragEnd

func (mm *MiniMap) DragEnd()

DragEnd implements fyne.Draggable

func (*MiniMap) Dragged

func (mm *MiniMap) Dragged(ev *fyne.DragEvent)

Dragged implements fyne.Draggable

func (*MiniMap) Layout

func (mm *MiniMap) Layout(size fyne.Size)

func (*MiniMap) MinSize

func (mm *MiniMap) MinSize() fyne.Size

func (*MiniMap) Objects

func (mm *MiniMap) Objects() []fyne.CanvasObject

func (*MiniMap) Refresh

func (mm *MiniMap) Refresh()

func (*MiniMap) Resize

func (mm *MiniMap) Resize(size fyne.Size)

func (*MiniMap) SetMinSize

func (mm *MiniMap) SetMinSize(size fyne.Size)

func (*MiniMap) Tapped

func (mm *MiniMap) Tapped(ev *fyne.PointEvent)

type OperationType

type OperationType int
const (
	NoOp OperationType = iota
	CropTopLeft
	CropBottomRight
	DrawCircle
	DrawArrow
	DrawText
)

type ViewPort

type ViewPort struct {
	widget.BaseWidget

	// Geometry of what is being displayed:
	// Log2Zoom is the log2 of the zoom multiplier, it's what we show to the user. It
	// is set by the "zoomEntry" field in the UI
	Log2Zoom float64

	// Thickness of stroke drawing circles and arrows. Set by the corresponding UI element.
	Thickness float64

	// DrawingColor is used on all new drawing operation. BackgroundColor is used
	// for the background of text.
	DrawingColor, BackgroundColor color.Color

	// FontSize is the last used font size.
	FontSize float64

	fyne.ShortcutHandler
	// contains filtered or unexported fields
}

ViewPort is our view port for the image being edited. It's a specialized widget that will display the image according to zoom / window select.

It is both a CanvasObject and a WidgetRenderer -- the abstractions in Fyne are not clear, but when those were implemented it worked (mostly copy&paste code).

Loosely based on github.com/fyne-io/pixeledit

func NewViewPort

func NewViewPort(gs *GoShot) (vp *ViewPort)

func (*ViewPort) CreateRenderer

func (vp *ViewPort) CreateRenderer() fyne.WidgetRenderer

func (*ViewPort) Destroy

func (vp *ViewPort) Destroy()

func (*ViewPort) DragEnd

func (vp *ViewPort) DragEnd()

DragEnd implements fyne.Draggable

func (*ViewPort) Dragged

func (vp *ViewPort) Dragged(ev *fyne.DragEvent)

Dragged implements fyne.Draggable

func (*ViewPort) Layout

func (vp *ViewPort) Layout(size fyne.Size)

func (*ViewPort) MinSize

func (vp *ViewPort) MinSize() fyne.Size

func (*ViewPort) MouseIn

func (vp *ViewPort) MouseIn(ev *desktop.MouseEvent)

MouseIn implements desktop.Hoverable.

func (*ViewPort) MouseMoved

func (vp *ViewPort) MouseMoved(ev *desktop.MouseEvent)

MouseMoved implements desktop.Hoverable.

func (*ViewPort) MouseOut

func (vp *ViewPort) MouseOut()

MouseOut implements desktop.Hoverable.

func (*ViewPort) Objects

func (vp *ViewPort) Objects() []fyne.CanvasObject

func (*ViewPort) PixelSize

func (vp *ViewPort) PixelSize() (x, y int)

PixelSize returns the size in pixels of the this CanvasObject, based on the last request to redraw.

func (*ViewPort) PosToPixel

func (vp *ViewPort) PosToPixel(pos fyne.Position) (x, y int)

PosToPixel converts from the undocumented Fyne screen float dimension to actual number of pixels position in the image.

func (*ViewPort) Refresh

func (vp *ViewPort) Refresh()

func (*ViewPort) Resize

func (vp *ViewPort) Resize(size fyne.Size)

func (*ViewPort) Scrolled

func (vp *ViewPort) Scrolled(ev *fyne.ScrollEvent)

func (*ViewPort) SetMinSize

func (vp *ViewPort) SetMinSize(size fyne.Size)

func (*ViewPort) SetOp

func (vp *ViewPort) SetOp(op OperationType)

SetOp changes the current op on the edit window. It interrupts any dragging event going on.

func (*ViewPort) Tapped

func (vp *ViewPort) Tapped(ev *fyne.PointEvent)

Jump to

Keyboard shortcuts

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