Refactoring
This commit is contained in:
61
ui.go
Normal file
61
ui.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/layout"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
func NewProjectRow(project Project) fyne.CanvasObject {
|
||||
projectName := project.ProjectName
|
||||
iconPath := filepath.Join(project.ProjectPath, projectName+".png")
|
||||
var projectIcon fyne.Resource
|
||||
|
||||
if _, err := os.Stat(iconPath); err == nil {
|
||||
icon, err := fyne.LoadResourceFromPath(iconPath)
|
||||
if err == nil {
|
||||
projectIcon = icon
|
||||
}
|
||||
}
|
||||
if projectIcon == nil {
|
||||
projectIcon = theme.FileIcon()
|
||||
}
|
||||
|
||||
icon := canvas.NewImageFromResource(projectIcon)
|
||||
icon.SetMinSize(fyne.NewSize(48, 48))
|
||||
|
||||
nameLabel := widget.NewLabel(projectName + " / Unreal Engine " + project.Version)
|
||||
nameLabel.Alignment = fyne.TextAlignLeading
|
||||
|
||||
// Crée les boutons masqués par défaut
|
||||
clearButton := widget.NewButton("Clean", func() {
|
||||
CleanUnrealProject(project)
|
||||
})
|
||||
generateBtn := widget.NewButton("Generate", func() {
|
||||
GenerateUnrealSolution(project)
|
||||
})
|
||||
buildBtn := widget.NewButton("Build", func() {
|
||||
BuildUnrealSolution(project)
|
||||
})
|
||||
launchBtn := widget.NewButton("Run", func() {
|
||||
RunUnrealProject(project)
|
||||
})
|
||||
|
||||
buttons := container.NewHBox(clearButton, generateBtn, buildBtn, launchBtn)
|
||||
|
||||
// Conteneur principal
|
||||
row := container.NewHBox(
|
||||
icon,
|
||||
nameLabel,
|
||||
layout.NewSpacer(),
|
||||
buttons,
|
||||
)
|
||||
|
||||
return row
|
||||
}
|
||||
Reference in New Issue
Block a user