Start of small refactor for better workflow
This commit is contained in:
parent
d4bf27e110
commit
724f2c87c6
|
@ -0,0 +1,5 @@
|
|||
package ui
|
||||
|
||||
type Editor interface {
|
||||
Representationer
|
||||
}
|
|
@ -12,11 +12,39 @@ import (
|
|||
"gitea.mmo.to/ProtocolPacketForger/ppf/protocolctl"
|
||||
)
|
||||
|
||||
type Representationer interface {
|
||||
Representation() *fyne.Container
|
||||
}
|
||||
|
||||
type FileHandler interface {
|
||||
Name() string
|
||||
Path() string
|
||||
Open(path string) error
|
||||
Save() error
|
||||
SaveAs(path string) error
|
||||
Close() error
|
||||
|
||||
Changed()
|
||||
HasChanged() bool
|
||||
}
|
||||
|
||||
type ppfApp struct {
|
||||
App fyne.App
|
||||
Window fyne.Window
|
||||
// Container for the borderlayout
|
||||
// Container for the main layout, toolbar at top, in Center the doctabs.
|
||||
MainContainer *fyne.Container
|
||||
// toolbar
|
||||
Toolbar fyne.CanvasObject
|
||||
// left optional the local/remote library
|
||||
// tbd
|
||||
// center opened objects
|
||||
OpenTabs *container.DocTabs // DocTabs
|
||||
OpenObjects []*FileHandler // actual files
|
||||
|
||||
// Global important stuff
|
||||
Settings map[string]interface{}
|
||||
|
||||
/*/ will be part of the Editor
|
||||
Metadata *Metadata
|
||||
Extensions *fyne.Container
|
||||
ContextBar *fyne.Container
|
||||
|
@ -25,14 +53,11 @@ type ppfApp struct {
|
|||
// Once initialized metadata containers for swapping
|
||||
ProtocolMeta *ProtocolMetadata
|
||||
PacketMeta *PacketMetadata
|
||||
// Global important stuff
|
||||
Settings map[string]string
|
||||
ProtocolForging bool
|
||||
// Once initialized instances of the editor views
|
||||
EditorPacket *PacketEditor
|
||||
EditorProtocol *ProtocolEditor
|
||||
// workspace handling
|
||||
OpenProtocolFiles []*ProtocolFileHandler
|
||||
OpenProtocolFiles []*ProtocolFileHandler//*/
|
||||
}
|
||||
|
||||
var PPF ppfApp
|
||||
|
@ -41,21 +66,21 @@ func NewPPF(fyneApp fyne.App, w fyne.Window) ppfApp {
|
|||
PPF.App = fyneApp
|
||||
PPF.Window = w
|
||||
PPF.Toolbar = CreateToolbar(fyneApp)
|
||||
PPF.Workarea = CreateWorkarea()
|
||||
/*PPF.Workarea = CreateWorkarea()
|
||||
PPF.Extensions = container.NewCenter()
|
||||
PPF.ProtocolMeta = NewMetadataProtocol()
|
||||
PPF.Metadata = &PPF.ProtocolMeta.Metadata
|
||||
PPF.ContextBar = container.NewCenter()
|
||||
PPF.ContextBar = container.NewCenter() //*/
|
||||
return PPF
|
||||
}
|
||||
|
||||
func (ppf *ppfApp) GetContainer() *fyne.Container {
|
||||
return container.NewBorder(
|
||||
PPF.Toolbar,
|
||||
PPF.ContextBar,
|
||||
PPF.Metadata.Representation,
|
||||
PPF.Extensions,
|
||||
PPF.Workarea,
|
||||
nil, //PPF.ContextBar,
|
||||
nil, //PPF.Metadata.Representation,
|
||||
nil, //PPF.Extensions,
|
||||
PPF.OpenTabs,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -66,6 +91,13 @@ func (ppf *ppfApp) OpenFile(path string) {
|
|||
}
|
||||
|
||||
func (ppf *ppfApp) NewFile() {
|
||||
//TODO: show entry screen with choosable ways of:
|
||||
// PROTOCOL editor
|
||||
// create a new protocol
|
||||
// edit an existing protocol
|
||||
// PACKET editor
|
||||
// create a binary packet
|
||||
// edit an existing binary packet
|
||||
pfh := NewProtocolFileHandler()
|
||||
PPF.OpenProtocolFiles = append(PPF.OpenProtocolFiles, pfh)
|
||||
ppf.Workarea.Append(container.NewTabItem(pfh.Filename, pfh.GetWorkarea()))
|
||||
|
@ -93,11 +125,6 @@ func (ppf *ppfApp) GetReferenceForFile(s string) *protocol.ProtocolStructure {
|
|||
|
||||
func CreateToolbar(fyneApp fyne.App) fyne.CanvasObject {
|
||||
toolbar := widget.NewToolbar()
|
||||
toolbar.Append(widget.NewToolbarAction(theme.MenuIcon(), func() {
|
||||
PPF.ProtocolForging = !PPF.ProtocolForging
|
||||
//TODO: implement the switch
|
||||
}))
|
||||
toolbar.Append(widget.NewToolbarSeparator())
|
||||
toolbar.Append(widget.NewToolbarAction(theme.ContentAddIcon(), func() {
|
||||
PPF.NewFile()
|
||||
}))
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
type NewObjectDialog struct {
|
||||
representation *fyne.Container
|
||||
// views
|
||||
selection *fyne.Container // 4buttons grid
|
||||
protocolChooser *fyne.Container
|
||||
packetChooser *fyne.Container
|
||||
}
|
||||
|
||||
var pnod *NewObjectDialog
|
||||
|
||||
func CreateNewObjectDialog() *NewObjectDialog {
|
||||
if pnod == nil {
|
||||
pnod = &NewObjectDialog{}
|
||||
|
||||
pnod.representation = container.NewMax(nil)
|
||||
// representation
|
||||
// grid layout 100x100px elements in a center layout, 4 buttons, new Protocol, edit protocol, new Packet, edit Packet
|
||||
buttons := []widget.Button{}
|
||||
buttons = append(buttons, *widget.NewButton("New protocol", func() {
|
||||
|
||||
}))
|
||||
buttons = append(buttons, *widget.NewButton("Edit protocol", func() {
|
||||
|
||||
}))
|
||||
buttons = append(buttons, *widget.NewButton("New packet", func() {
|
||||
|
||||
}))
|
||||
buttons = append(buttons, *widget.NewButton("Edit packet", func() {
|
||||
|
||||
}))
|
||||
selectgrid := container.NewGridWithColumns(2, nil)
|
||||
for _, v := range buttons {
|
||||
selectgrid.Add(&v)
|
||||
}
|
||||
pnod.selection = container.NewMax(selectgrid)
|
||||
|
||||
pnod.representation.Add(pnod.selection)
|
||||
// data
|
||||
}
|
||||
return pnod
|
||||
}
|
||||
|
||||
func (nod *NewObjectDialog) Representation() *fyne.Container {
|
||||
return nod.representation
|
||||
}
|
||||
|
||||
func (nod *NewObjectDialog) Refresh() {
|
||||
|
||||
}
|
Loading…
Reference in New Issue