screenshot

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2021 License: Apache-2.0 Imports: 28 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 (
	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"
)
View Source
const SelectScreenIndex = "SelectScreen"

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{"FireShotGO"}
)

Functions

func Run

func Run()

Run 截图的主程序

Types

type FireShotGO

type FireShotGO 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 (*FireShotGO) ApplyFilters

func (gs *FireShotGO) 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 (*FireShotGO) BuildEditWindow

func (gs *FireShotGO) BuildEditWindow()

func (*FireShotGO) CopyImageToClipboard

func (gs *FireShotGO) CopyImageToClipboard()

func (*FireShotGO) DefaultName

func (gs *FireShotGO) DefaultName() string

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

func (*FireShotGO) DelayedScreenshot

func (gs *FireShotGO) DelayedScreenshot(seconds int)

func (*FireShotGO) DelayedScreenshotForm

func (gs *FireShotGO) DelayedScreenshotForm()

func (*FireShotGO) GetColorPreference

func (gs *FireShotGO) 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 (*FireShotGO) MakeScreenshot

func (gs *FireShotGO) MakeScreenshot() error

MakeScreenshot 开始截屏

func (*FireShotGO) RegisterShortcuts

func (gs *FireShotGO) RegisterShortcuts()

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

func (*FireShotGO) SaveImage

func (gs *FireShotGO) SaveImage()

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

func (*FireShotGO) SetColorPreference

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

SetColorPreference sets the given color in the given preferences key.

func (*FireShotGO) ShareWithGoogleDrive

func (gs *FireShotGO) ShareWithGoogleDrive()

func (*FireShotGO) ShowShortcutsPage

func (gs *FireShotGO) ShowShortcutsPage()

func (*FireShotGO) UndoLastFilter

func (gs *FireShotGO) 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 *FireShotGO, 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 裁剪点 - 左上角
	CropTopLeft
	// CropBottomRight 裁剪点 - 右下角
	CropBottomRight
	// DrawCircle 绘制圆 包括椭圆和圆
	DrawCircle
	// DrawArrow 绘制剪头
	DrawArrow
	// DrawText 绘制文本
	DrawText
	// DrawStraightLine 绘制直线
	DrawStraightLine
)

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 存储绘制直线等元素的宽度元素.
	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 *FireShotGO) (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