model

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SINGLE = iota
	DOUBLE
)
View Source
const (
	ONE_PAGE = iota
	TWO_PAGE
	LONG_STRIP
)
View Source
const (
	MAX_LOAD = 8
)

Maximum to load into the model Currently confusing because at init the units are pages Later it's spreads (so frequently double the number of pages

Variables

This section is empty.

Functions

This section is empty.

Types

type Bookmark

type Bookmark struct {
	PageIndex    int   `json:"pageIndex"`
	CreationTime int64 `json:"creationTime"`
}

Mark a place in the model by keeping track of an index in the pages slice

type BookmarkList

type BookmarkList struct {
	Model BookmarkListModel
}

Manage a list of bookmarks

func NewBookmarkList

func NewBookmarkList(filePath string) *BookmarkList

func (*BookmarkList) Add

func (l *BookmarkList) Add(b Bookmark)

func (*BookmarkList) Find

func (l *BookmarkList) Find(pageIndex int) *Bookmark

func (*BookmarkList) Load

func (l *BookmarkList) Load(hash string)

func (*BookmarkList) Remove

func (l *BookmarkList) Remove(b Bookmark) *Bookmark

func (*BookmarkList) Store

func (l *BookmarkList) Store() error

type BookmarkListModel

type BookmarkListModel struct {
	FormatVersion string     `json:"formatVersion"`
	Comic         ComicData  `json:"comic"`
	Bookmarks     []Bookmark `json:"bookmarks"`
}

Type used for serialization/deserialization of the BookmarkList

type ComicData

type ComicData struct {
	Hash     string `json:"hash"`
	FilePath string `json:"filePath"`
}

Just a little type for serialization

type Direction

type Direction int

Direction of the model is either Left-To-Right or Right-To-Left

const (
	LTR Direction = iota
	RTL
)

type Layout

type Layout struct {
	FormatVersion string     `json:"formatVersion"`
	Comic         ComicData  `json:"comic"`
	Mode          LayoutMode `json:"mode"`
	Pages         []Page     `json:"pages"`
}

type LayoutMode

type LayoutMode int

Layout mode determines the max pages per spread ONE_PAGE = 1 pg TWO_PAGE = up to 2 pgs LONG_STRIP = n pgs

type Model

type Model struct {
	SendMessage    util.Messenger
	FilePath       string
	TmpDir         string
	Hash           string
	Bookmarks      *BookmarkList
	ImgPaths       []string
	Pages          []Page
	PageIndex      int
	Spreads        []*Spread
	SpreadIndex    int
	Direction      Direction
	LayoutMode     LayoutMode
	SeriesList     []string
	SeriesIndex    int
	BrowseDir      string
	ExportDir      string
	HiddenPages    bool
	Fullscreen     bool
	Loading        bool
	ProgramName    string
	ProgramVersion string
}

Data model of a cbx application Composed of a handful of sub-models, collections and other standard types

func NewModel

func NewModel(md ProgramMetadata, messenger util.Messenger) *Model

func (*Model) CloseCbxFile

func (m *Model) CloseCbxFile()

func (*Model) LoadCbxFile

func (m *Model) LoadCbxFile()

* The second phase of the "loading" process is the actual loading and * its synchronous. We have a lot of stuff to load: * individual pages * page metadata * layout * bookmarks * * It has to be synchronous because the pixbufs that are loaded into the * pages can't be touched on anything but the event dispatch thread or they * leak. * * Errors during this phase are treated as warnings. For two reasons, some of * this stuff is optional and there could be hundreds of errors on a per page * basis. If the program can be useful to the user in spite of that it tries. * * Finally there is the serieslist which is just an exception in that it really * is optional if it can't be calculated the program just does without it, see * loadSeriesList

func (*Model) LoadSeriesList

func (m *Model) LoadSeriesList()

func (*Model) NewPages

func (m *Model) NewPages()

Creates pgs slice and loads it

func (*Model) NewSpreads

func (m *Model) NewSpreads()

Creates spread slice based on pg slice and layout mode

func (*Model) OpenCbxFile added in v0.4.4

func (m *Model) OpenCbxFile()

* When the user fires the "openFile" event a process called "loading" starts. * There are two phases: * * The first phase "Opening" the cbx is asynchronous: * hash created * tmpDir created * cbx file opened * cbx file extracted * Errors during this phase are considered critical, and stop the process * The ui is up and alive, but the user can't navigate until this phase signals * completion either success or failure. If the result is success LoadCbx is invoked, * see below *

func (*Model) PageToSpread

func (m *Model) PageToSpread(n int) int

Returns 0 if spreads are nil or page can't be found Otherwise it guesses fixme: Don't like it, but there's no point in telling a user about any of it because errors detected here are almost certainly the result of a programming error elsewhere in the program

func (*Model) RefreshSpreads added in v0.4.8

func (m *Model) RefreshSpreads()

Iterate over spreads and load/unload pages as needed based on the current spread index

func (*Model) SpreadLoaded added in v0.4.8

func (m *Model) SpreadLoaded(spreadIndex int) bool

Test if a given spread is fully loaded

func (*Model) StoreLayout

func (m *Model) StoreLayout() error

type Page

type Page struct {
	FilePath string    `json:"filePath"`
	Width    int       `json:"width"`
	Height   int       `json:"height"`
	Span     int       `json:"span"`
	Hidden   bool      `json:"hidden"`
	Loaded   bool      `json:"loaded"`
	Image    *util.Img `json:"-"`
}

A page in this case is generally analogous to an image They are grouped on Spreads

func (*Page) Load

func (p *Page) Load()

func (*Page) LoadMeta

func (p *Page) LoadMeta()

type ProgramMetadata

type ProgramMetadata struct {
	Name    string
	Version string
}

type Result added in v0.4.4

type Result struct {
	Code        ResultCode `json:"code"`
	Description string     `json:"description"`
}

type ResultCode added in v0.4.4

type ResultCode int
const (
	OK ResultCode = iota
	ERR
)

type Span

type Span int

How a page is oriented

type Spread

type Spread struct {
	Pages    []*Page
	PageIdxs []int
}

A Spread is an element of a layout It's essentially the pages you can see at a given time

func (*Spread) RectoPage

func (s *Spread) RectoPage() int

func (*Spread) VersoPage

func (s *Spread) VersoPage() int

Jump to

Keyboard shortcuts

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