Starting editor

This commit is contained in:
bloeys
2022-02-24 14:25:38 +04:00
parent acb6a8c450
commit 78e822065e
4 changed files with 20 additions and 12 deletions

2
go.mod
View File

@ -3,7 +3,7 @@ module github.com/bloeys/gopad
go 1.17 go 1.17
require ( require (
github.com/bloeys/nmage v0.0.7-0.20220224035035-36ac96d64163 github.com/bloeys/nmage v0.0.7
github.com/inkyblackness/imgui-go/v4 v4.3.0 github.com/inkyblackness/imgui-go/v4 v4.3.0
github.com/veandco/go-sdl2 v0.4.14 github.com/veandco/go-sdl2 v0.4.14
) )

4
go.sum
View File

@ -1,8 +1,8 @@
github.com/bloeys/assimp-go v0.4.2/go.mod h1:my3yRxT7CfOztmvi+0svmwbaqw0KFrxaHxncoyaEIP0= github.com/bloeys/assimp-go v0.4.2/go.mod h1:my3yRxT7CfOztmvi+0svmwbaqw0KFrxaHxncoyaEIP0=
github.com/bloeys/gglm v0.3.1 h1:Sy9upW7SBsBfDXrSmEhid3aQ+7J7itej+upwcxOnPMQ= github.com/bloeys/gglm v0.3.1 h1:Sy9upW7SBsBfDXrSmEhid3aQ+7J7itej+upwcxOnPMQ=
github.com/bloeys/gglm v0.3.1/go.mod h1:qwJQ0WzV191wAMwlGicbfbChbKoSedMk7gFFX6GnyOk= github.com/bloeys/gglm v0.3.1/go.mod h1:qwJQ0WzV191wAMwlGicbfbChbKoSedMk7gFFX6GnyOk=
github.com/bloeys/nmage v0.0.7-0.20220224035035-36ac96d64163 h1:nX0RshsywmSpkK1D2uHrmyUFMbnCDrPYSm5xIYYq8/Y= github.com/bloeys/nmage v0.0.7 h1:MXl/sLWq1e+HLX5X8KbdNb3pbMroQEyuvvltT4HgAt8=
github.com/bloeys/nmage v0.0.7-0.20220224035035-36ac96d64163/go.mod h1:4h2tKtMvk9ab8r/+rem4QonPXEBTho6VWvpCMm0M6iM= github.com/bloeys/nmage v0.0.7/go.mod h1:4h2tKtMvk9ab8r/+rem4QonPXEBTho6VWvpCMm0M6iM=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-gl/gl v0.0.0-20211025173605-bda47ffaa784/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= github.com/go-gl/gl v0.0.0-20211025173605-bda47ffaa784/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw=

View File

@ -10,16 +10,16 @@ Collapsed=0
[Window][sidebar] [Window][sidebar]
Pos=0,0 Pos=0,0
Size=128,720 Size=307,1657
Collapsed=0 Collapsed=0
[Window][editor] [Window][editor]
Pos=128,0 Pos=307,0
Size=1152,38 Size=2764,38
Collapsed=0 Collapsed=0
[Window][editorText] [Window][editorText]
Pos=128,38 Pos=307,38
Size=1152,682 Size=2764,1619
Collapsed=0 Collapsed=0

16
main.go
View File

@ -68,6 +68,7 @@ func main() {
editorToClose: -1, editorToClose: -1,
} }
// engine.SetVSync(true)
engine.Run(&g) engine.Run(&g)
} }
@ -89,6 +90,7 @@ func (g *Gopad) Init() {
w, _ := g.Win.SDLWin.GetSize() w, _ := g.Win.SDLWin.GetSize()
g.sidebarSize = float32(w) * 0.10 g.sidebarSize = float32(w) * 0.10
} }
func (g *Gopad) handleWindowEvents(event sdl.Event) { func (g *Gopad) handleWindowEvents(event sdl.Event) {
@ -150,14 +152,12 @@ func (g *Gopad) Update() {
func (g *Gopad) Render() { func (g *Gopad) Render() {
//Global imgui settings //Global imgui settings
imgui.PushStyleColor(imgui.StyleColorText, imgui.Vec4{X: 1, Y: 1, Z: 1, W: 1})
imgui.PushFont(g.mainFont) imgui.PushFont(g.mainFont)
g.drawSidebar() g.drawSidebar()
g.drawEditors() g.drawEditors()
imgui.PopFont() imgui.PopFont()
imgui.PopStyleColor()
} }
func (g *Gopad) drawSidebar() { func (g *Gopad) drawSidebar() {
@ -232,14 +232,22 @@ func (g *Gopad) drawEditors() {
imgui.End() imgui.End()
//Draw text area //Draw text area
fullWinSize := imgui.Vec2{X: float32(w) - g.sidebarSize, Y: float32(h) - tabsHeight}
imgui.SetNextWindowPos(imgui.Vec2{X: g.sidebarSize, Y: tabsHeight}) imgui.SetNextWindowPos(imgui.Vec2{X: g.sidebarSize, Y: tabsHeight})
imgui.SetNextWindowSize(imgui.Vec2{X: float32(w) - g.sidebarSize, Y: float32(h) - tabsHeight}) imgui.SetNextWindowSize(fullWinSize)
imgui.BeginV("editorText", nil, imgui.WindowFlagsNoCollapse|imgui.WindowFlagsNoDecoration|imgui.WindowFlagsNoMove) imgui.BeginV("editorText", nil, imgui.WindowFlagsNoCollapse|imgui.WindowFlagsNoDecoration|imgui.WindowFlagsNoMove)
imgui.Text(g.getActiveEditor().fileContents) imgui.PushStyleColor(imgui.StyleColorFrameBg, imgui.Vec4{X: 0.1, Y: 0.1, Z: 0.1, W: 1})
fullWinSize.Y -= 18
imgui.InputTextMultilineV("", &g.getActiveEditor().fileContents, fullWinSize, 0, nil)
imgui.PopStyleColor()
imgui.End() imgui.End()
} }
// func (g *Gopad) textEditCB(d imgui.InputTextCallbackData) int32 {
// return 0
// }
func (g *Gopad) getActiveEditor() *Editor { func (g *Gopad) getActiveEditor() *Editor {
return g.getEditor(g.activeEditor) return g.getEditor(g.activeEditor)
} }