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
- Variables
- func Run()
- type GoShot
- func (gs *GoShot) ApplyFilters(full bool)
- func (gs *GoShot) BuildEditWindow()
- func (gs *GoShot) CopyImageToClipboard()
- func (gs *GoShot) DefaultName() string
- func (gs *GoShot) DelayedScreenshot(seconds int)
- func (gs *GoShot) DelayedScreenshotForm()
- func (gs *GoShot) GetColorPreference(key string, defaultColor color.RGBA) color.RGBA
- func (gs *GoShot) MakeScreenshot() error
- func (gs *GoShot) RegisterShortcuts()
- func (gs *GoShot) SaveImage()
- func (gs *GoShot) SetColorPreference(key string, c color.Color)
- func (gs *GoShot) ShareWithGoogleDrive()
- func (gs *GoShot) ShowShortcutsPage()
- func (gs *GoShot) UndoLastFilter()
- type ImageFilter
- type MiniMap
- func (mm *MiniMap) BackgroundColor() color.Color
- func (mm *MiniMap) CreateRenderer() fyne.WidgetRenderer
- func (mm *MiniMap) Destroy()
- func (mm *MiniMap) DragEnd()
- func (mm *MiniMap) Dragged(ev *fyne.DragEvent)
- func (mm *MiniMap) Layout(size fyne.Size)
- func (mm *MiniMap) MinSize() fyne.Size
- func (mm *MiniMap) Objects() []fyne.CanvasObject
- func (mm *MiniMap) Refresh()
- func (mm *MiniMap) Resize(size fyne.Size)
- func (mm *MiniMap) SetMinSize(size fyne.Size)
- func (mm *MiniMap) Tapped(ev *fyne.PointEvent)
- type OperationType
- type ViewPort
- func (vp *ViewPort) CreateRenderer() fyne.WidgetRenderer
- func (vp *ViewPort) Destroy()
- func (vp *ViewPort) DragEnd()
- func (vp *ViewPort) Dragged(ev *fyne.DragEvent)
- func (vp *ViewPort) Layout(size fyne.Size)
- func (vp *ViewPort) MinSize() fyne.Size
- func (vp *ViewPort) MouseIn(ev *desktop.MouseEvent)
- func (vp *ViewPort) MouseMoved(ev *desktop.MouseEvent)
- func (vp *ViewPort) MouseOut()
- func (vp *ViewPort) Objects() []fyne.CanvasObject
- func (vp *ViewPort) PixelSize() (x, y int)
- func (vp *ViewPort) PosToPixel(pos fyne.Position) (x, y int)
- func (vp *ViewPort) Refresh()
- func (vp *ViewPort) Resize(size fyne.Size)
- func (vp *ViewPort) Scrolled(ev *fyne.ScrollEvent)
- func (vp *ViewPort) SetMinSize(size fyne.Size)
- func (vp *ViewPort) SetOp(op OperationType)
- func (vp *ViewPort) Tapped(ev *fyne.PointEvent)
Constants ¶
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.
const ( BackgroundColorPreference = "BackgroundColor" DrawingColorPreference = "DrawingColor" FontSizePreference = "FontSize" ThicknessPreference = "Thickness" )
const DefaultPathPreference = "DefaultPath"
const DelayTimePreference = "DelayTime"
const (
GoogleDriveTokenPreference = "google_drive_token"
)
Variables ¶
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{} )
var (
GoogleDrivePath = []string{"GoShot"}
)
Functions ¶
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 ¶
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 ¶
DefaultName returns a default name to the screenshot, based on date/time it was made.
func (*GoShot) DelayedScreenshot ¶ added in v0.1.2
func (*GoShot) DelayedScreenshotForm ¶ added in v0.1.2
func (gs *GoShot) DelayedScreenshotForm()
func (*GoShot) GetColorPreference ¶
GetColorPreference returns the color set for the given key if it has been set. Otherwise it returns `defaultColor`.
func (*GoShot) MakeScreenshot ¶
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 ¶
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 MiniMap ¶
type MiniMap struct { widget.BaseWidget // contains filtered or unexported fields }
func NewMiniMap ¶
func (*MiniMap) BackgroundColor ¶
func (*MiniMap) CreateRenderer ¶
func (mm *MiniMap) CreateRenderer() fyne.WidgetRenderer
func (*MiniMap) Dragged ¶
func (mm *MiniMap) Dragged(ev *fyne.DragEvent)
Dragged implements fyne.Draggable
func (*MiniMap) SetMinSize ¶
func (mm *MiniMap) SetMinSize(size fyne.Size)
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 (*ViewPort) CreateRenderer ¶
func (vp *ViewPort) CreateRenderer() fyne.WidgetRenderer
func (*ViewPort) Dragged ¶
func (vp *ViewPort) Dragged(ev *fyne.DragEvent)
Dragged implements fyne.Draggable
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) PixelSize ¶
PixelSize returns the size in pixels of the this CanvasObject, based on the last request to redraw.
func (*ViewPort) PosToPixel ¶
PosToPixel converts from the undocumented Fyne screen float dimension to actual number of pixels position in the image.
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.