github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/protocol/gui-page-state.go (about)

     1  /* For license and copyright information please see LEGAL file in repository */
     2  
     3  package protocol
     4  
     5  // GUIPageState is like window in browsers and each page state has its own window
     6  type GUIPageState interface {
     7  	Page() GUIPage
     8  	Title() string
     9  	Description() string
    10  
    11  	URL() string // Path + Parameters + Fragments
    12  	Conditions() map[string]any
    13  	Fragment() string
    14  
    15  	// DOM as Document-Object-Model will render to user screen
    16  	// Same as Document interface of the Web declare in browsers in many ways but split not related concern to other interfaces
    17  	// like Document.URI that not belong to this interface and relate to GUIPageState because we develope multi page app not web page
    18  	DOM() DOM // GUIElement
    19  	SOM() SOM
    20  	Thumbnail() Image // The picture of the page in current state, use in social linking and SwitcherPage()
    21  
    22  	ActiveDates() []Time // first is CreateDate and last is EndDate(When Close() called)
    23  	State() ScreenMode
    24  	Type() WindowType
    25  
    26  	// Activate() or Show() Called call to render page in this state (brings to front).
    27  	// Also can call to move the page state to other screen
    28  	Activate(options PageStateActivateOptions)
    29  	// Deactivate() or Minimize() Called before this state wants to remove from the render tree (brings to back)
    30  	Deactivate() (res PageStateDeactivateResult)
    31  	Refresh() Error // force to refresh
    32  
    33  	SafeToSilentClose() bool
    34  	// Remove render tree from screen and close DOM and SOM and archive it.
    35  	// But do clean logic after some time e.g. 10sec maybe user close by mistake click action
    36  	Close() Error
    37  
    38  	// DynamicElements struct {}
    39  }
    40  
    41  type PageStateActivateOptions struct {
    42  	Screen GUIScreen
    43  	// It will effect just on this app and this page state only, not OS level.
    44  	Orientation ScreenOrientation
    45  	WindowType  WindowType
    46  	PopUp       bool // force to bring to front immediately
    47  }
    48  
    49  type PageStateDeactivateResult struct {
    50  	// let the caller know user of the GUI app let page in this state bring to back.
    51  	ApproveLeave bool
    52  	// or hadActiveOverlay help navigator works in better way.
    53  	// e.g. for some keyboard event like back button in android OS to close dialog not pop previous page state to front
    54  	HadActiveDialog bool
    55  }
    56  
    57  type WindowType uint8
    58  
    59  const (
    60  	WindowType_Unset      WindowType = 0
    61  	WindowType_Resizeable WindowType = (1 << iota) // has resizeable frame
    62  	WindowType_GLASSY                              // glassy window
    63  	WindowType_ALPHA                               // transparent window
    64  )