Beispiel #1
0
func (p *ProjectAdder) Init(driver gxui.Driver, theme *basic.Theme) {
	p.theme = theme
	p.status = theme.CreateLabel()
	p.path = NewFSLocator(driver, theme)
	p.name = theme.CreateTextBox()
	p.gopath = NewFSLocator(driver, theme)
}
Beispiel #2
0
// New creates and initializes a *Commander, then returns it.
func New(driver gxui.Driver, theme *basic.Theme, controller Controller) *Commander {
	commander := &Commander{
		theme: theme,
	}
	commander.Container.Init(commander, theme)
	commander.BackgroundBorderPainter.Init(commander)
	commander.SetMouseEventTarget(true)
	commander.SetBackgroundBrush(gxui.TransparentBrush)
	commander.SetBorderPen(gxui.TransparentPen)

	mainLayout := theme.CreateLinearLayout()

	mainLayout.SetDirection(gxui.TopToBottom)
	mainLayout.SetSize(math.MaxSize)

	commander.controller = controller
	commander.menuBar = newMenuBar(commander, theme)
	commander.box = newCommandBox(driver, theme, commander.controller)

	mainLayout.AddChild(commander.menuBar)

	subLayout := theme.CreateLinearLayout()
	subLayout.SetDirection(gxui.BottomToTop)
	subLayout.AddChild(commander.box)
	subLayout.AddChild(commander.controller)
	mainLayout.AddChild(subLayout)
	commander.AddChild(mainLayout)
	return commander
}
Beispiel #3
0
func (p *Projects) Init(driver gxui.Driver, theme *basic.Theme) {
	p.driver = driver
	p.theme = theme
	p.button = createIconButton(driver, theme, "projects.png")
	p.projects = theme.CreateList()
	p.projectsAdapter = gxui.CreateDefaultAdapter()

	p.projectsAdapter.SetItems(settings.Projects())
	p.projects.SetAdapter(p.projectsAdapter)
}
Beispiel #4
0
func (b *findBox) Init(driver gxui.Driver, theme *basic.Theme, editor gxui.CodeEditor) {
	b.TextBox.Init(b, driver, theme, theme.DefaultMonospaceFont())
	b.editor = editor

	b.SetTextColor(theme.TextBoxDefaultStyle.FontColor)
	b.SetMargin(math.Spacing{L: 3, T: 3, R: 3, B: 3})
	b.SetPadding(math.Spacing{L: 3, T: 3, R: 3, B: 3})
	b.SetBackgroundBrush(theme.TextBoxDefaultStyle.Brush)
	b.SetDesiredWidth(math.MaxSize.W)
	b.SetMultiline(false)
}
Beispiel #5
0
func newFileBox(driver gxui.Driver, theme *basic.Theme) *fileBox {
	file := new(fileBox)
	file.TextBox.Init(file, driver, theme, theme.DefaultMonospaceFont())
	file.SetTextColor(theme.TextBoxDefaultStyle.FontColor)
	file.SetMargin(math.Spacing{L: 3, T: 3, R: 3, B: 3})
	file.SetPadding(math.Spacing{L: 3, T: 3, R: 3, B: 3})
	file.SetBackgroundBrush(theme.TextBoxDefaultStyle.Brush)
	file.SetDesiredWidth(math.MaxSize.W)
	file.SetMultiline(false)
	return file
}
Beispiel #6
0
func (n *Navigator) Init(driver gxui.Driver, theme *basic.Theme, cmdExecutor func(command commands.Command)) {
	n.LinearLayout.Init(n, theme)
	n.cmdExecutor = cmdExecutor
	n.theme = theme
	n.SetDirection(gxui.LeftToRight)

	n.buttons = theme.CreateLinearLayout()
	n.buttons.SetDirection(gxui.TopToBottom)
	n.AddChild(n.buttons)

	projects := new(Projects)
	projects.Init(driver, theme)
	n.Add(projects)

	dirs := new(ProjectTree)
	dirs.Init(driver, theme)
	n.Add(dirs)
}
Beispiel #7
0
func (d *ProjectTree) Init(driver gxui.Driver, theme *basic.Theme) {
	d.driver = driver
	d.theme = theme

	d.button = createIconButton(driver, theme, "folder.png")
	d.dirs = theme.CreateTree()
	d.dirsAdapter = dirTree(os.Getenv("HOME"))
	d.dirs.SetAdapter(d.dirsAdapter)

	d.files = theme.CreateList()
	d.filesAdapter = fileList(os.Getenv("HOME"))
	d.files.SetAdapter(d.filesAdapter)

	d.layout = newSplitterLayout(d.theme)
	d.layout.SetOrientation(gxui.Vertical)
	d.layout.AddChild(d.dirs)
	d.layout.AddChild(d.files)

	d.dirs.OnSelectionChanged(func(selection gxui.AdapterItem) {
		d.filesAdapter = fileList(selection.(string))
		d.files.SetAdapter(d.filesAdapter)
	})
}
Beispiel #8
0
func createIconButton(driver gxui.Driver, theme *basic.Theme, iconPath string) gxui.Button {
	button := theme.CreateButton()
	button.SetType(gxui.PushButton)

	fileBytes, err := assets.Asset(iconPath)
	if err != nil {
		panic(err)
	}
	f := bytes.NewBuffer(fileBytes)
	src, _, err := image.Decode(f)
	if err != nil {
		panic(err)
	}
	src = resize.Resize(24, 24, src, resize.Bilinear)

	rgba := image.NewRGBA(src.Bounds())
	draw.Draw(rgba, src.Bounds(), src, image.ZP, draw.Src)
	texture := driver.CreateTexture(rgba, 1)

	icon := theme.CreateImage()
	icon.SetTexture(texture)
	button.AddChild(icon)
	return button
}
Beispiel #9
0
func (p *ProjectAdder) Init(driver gxui.Driver, theme *basic.Theme) {
	p.path = NewFSLocator(driver, theme)
	p.name = theme.CreateTextBox()
}
Beispiel #10
0
func (p *ProjectOpener) Init(driver gxui.Driver, theme *basic.Theme) {
	p.name = theme.CreateTextBox()
}
Beispiel #11
0
func newDirLabel(theme *basic.Theme) *dirLabel {
	label := new(dirLabel)
	label.Label.Init(label, theme, theme.DefaultMonospaceFont(), theme.LabelStyle.FontColor)
	label.SetMargin(math.Spacing{L: 3, T: 3, R: 3, B: 3})
	return label
}