Skip to content

Commit

Permalink
hswidget: fix image button hack; readme: add palette and dc6 editor s…
Browse files Browse the repository at this point in the history
…creenshot
  • Loading branch information
gucio321 committed Apr 9, 2021
1 parent e2f7fab commit 8231f15
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 24 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ Feel free to contribute!
## Screenshots

![Screenshot](docs/overview.png)
![Screenshot](docs/palette-and-dc6-editors.png)
Binary file added docs/palette-and-dc6-editors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 11 additions & 18 deletions hswidget/custom_widgets.go
Original file line number Diff line number Diff line change
@@ -1,35 +1,28 @@
package hswidget

import (
"fmt"

"github.com/ianling/giu"
"github.com/ianling/imgui-go"
)

// MakeImageButton is a hack for giu.ImageButton that creates image button
// as a giu.child
func MakeImageButton(id string, w, h int, t *giu.Texture, fn func()) giu.Layout {
const (
childIDSuffix = "child"
padding = 8 // pixels
)

func MakeImageButton(id string, w, h int, t *giu.Texture, fn func()) giu.Widget {
// the image button
btnW, btnH := float32(w), float32(h)
button := giu.Layout{
giu.ImageButton(t).Size(btnW, btnH).OnClick(fn),
}

// the container; needs to be padded to be larger than the button
childW, childH := btnW+padding, btnH+padding
childID := fmt.Sprintf("%s%s", id, childIDSuffix)
con := giu.Child(childID).
Border(false).
Size(childW, childH).
Layout(button).
Flags(giu.WindowFlagsNoDecoration)

return giu.Layout{con}
return giu.Layout{
giu.Custom(func() {
imgui.PushID(id)
}),
button,
giu.Custom(func() {
imgui.PopID()
}),
}
}

// SetByteToInt sets byte given to intager
Expand Down
10 changes: 4 additions & 6 deletions hswidget/fonttablewidget/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,10 @@ func (p *widget) makeGlyphLayout(r rune) *giu.RowWidget {
height32 := int32(h)

row := giu.Row(
giu.Line(
hswidget.MakeImageButton("##"+p.id+"deleteFrame"+string(r),
delSize, delSize,
state.deleteButtonTexture,
func() { p.deleteRow(r) },
),
hswidget.MakeImageButton("##"+p.id+"deleteFrame"+string(r),
delSize, delSize,
state.deleteButtonTexture,
func() { p.deleteRow(r) },
),
giu.Line(
giu.Label(fmt.Sprintf("%d", p.fontTable.Glyphs[r].FrameIndex())),
Expand Down

0 comments on commit 8231f15

Please sign in to comment.