Gopher2600/gui/sdlimgui/win_coproc_functions.go
JetSetIlly 8b18be888e window searching by title
pressing CTRL+SHIFT allows the user to bring a window to the front by
typing in the window title. as soon as the entered string is unique the
window is selected

a search preview is shown in the menu bar while the CTRL+SHIFT
combination is held down
2023-06-10 12:51:42 +01:00

122 lines
3.2 KiB
Go

// This file is part of Gopher2600.
//
// Gopher2600 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Gopher2600 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Gopher2600. If not, see <https://www.gnu.org/licenses/>.
package sdlimgui
import (
"fmt"
"github.com/inkyblackness/imgui-go/v4"
"github.com/jetsetilly/gopher2600/coprocessor/developer"
)
const winCoProcFunctionsID = "Coprocessor Functions"
const winCoProcFunctionsMenu = "Functions"
type winCoProcFunctions struct {
debuggerWin
img *SdlImgui
showSrcInTooltip bool
optionsHeight float32
}
func newWinCoProcFunctions(img *SdlImgui) (window, error) {
win := &winCoProcFunctions{
img: img,
}
return win, nil
}
func (win *winCoProcFunctions) init() {
}
func (win *winCoProcFunctions) id() string {
return winCoProcFunctionsID
}
func (win *winCoProcFunctions) debuggerDraw() bool {
if !win.debuggerOpen {
return false
}
if !win.img.lz.Cart.HasCoProcBus {
return false
}
imgui.SetNextWindowPosV(imgui.Vec2{775, 102}, imgui.ConditionFirstUseEver, imgui.Vec2{0, 0})
imgui.SetNextWindowSizeV(imgui.Vec2{400, 655}, imgui.ConditionFirstUseEver)
imgui.SetNextWindowSizeConstraints(imgui.Vec2{300, 400}, imgui.Vec2{600, 1000})
title := fmt.Sprintf("%s %s", win.img.lz.Cart.CoProcID, winCoProcFunctionsID)
if imgui.BeginV(win.debuggerID(title), &win.debuggerOpen, imgui.WindowFlagsNone) {
win.draw()
}
win.debuggerGeom.update()
imgui.End()
return true
}
func (win *winCoProcFunctions) draw() {
win.img.dbg.CoProcDev.BorrowSource(func(src *developer.Source) {
if src == nil {
imgui.Text("No source files available")
return
}
if len(src.FunctionNames) == 0 {
imgui.Text("No functions defined")
return
}
const numColumns = 2
flgs := imgui.TableFlagsScrollY
flgs |= imgui.TableFlagsSizingStretchProp
flgs |= imgui.TableFlagsResizable
flgs |= imgui.TableFlagsHideable
imgui.BeginTableV("##coprocFunctionsTable", numColumns, flgs, imgui.Vec2{}, 0.0)
width := imgui.ContentRegionAvail().X
imgui.TableSetupColumnV("Name", imgui.TableColumnFlagsPreferSortDescending|imgui.TableColumnFlagsNoHide, width*0.5, 0)
imgui.TableSetupColumnV("File", imgui.TableColumnFlagsNoSort, width*0.5, 1)
imgui.TableSetupScrollFreeze(0, 1)
imgui.TableHeadersRow()
for _, n := range src.FunctionNames {
fn := src.Functions[n]
if !fn.IsStub() {
imgui.TableNextRow()
imgui.TableNextColumn()
if imgui.SelectableV(n, false, imgui.SelectableFlagsSpanAllColumns, imgui.Vec2{}) {
srcWin := win.img.wm.debuggerWindows[winCoProcSourceID].(*winCoProcSource)
srcWin.gotoSourceLine(fn.DeclLine)
}
imgui.TableNextColumn()
imgui.PushStyleColor(imgui.StyleColorText, win.img.cols.CoProcSourceFilename)
imgui.Text(fn.DeclLine.File.ShortFilename)
imgui.PopStyleColor()
}
}
imgui.EndTable()
})
}