Skip to content

Commit

Permalink
Merge branch 'master' of github.com:AllenDang/giu
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenDang committed Sep 29, 2021
2 parents 4cce647 + 8e33d03 commit 50bb713
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,18 @@ const (
// ColorEditFlagsNoDragDrop disables drag and drop target. ColorButton: disable drag and drop source.
ColorEditFlagsNoDragDrop ColorEditFlags = imgui.ColorEditFlagsNoDragDrop

// User Options (right-click on widget to change some of them). You can set application defaults using SetColorEditOptions(). The idea is that you probably don't want to override them in most of your calls, let the user choose and/or call SetColorEditOptions() during startup.
// User Options (right-click on widget to change some of them). You can set application defaults using SetColorEditOptions().
// The idea is that you probably don't want to override them in most of your calls, let the user choose and/or call SetColorEditOptions()
// during startup.

// ColorEditFlagsAlphaBar shows vertical alpha bar/gradient in picker.
ColorEditFlagsAlphaBar ColorEditFlags = imgui.ColorEditFlagsAlphaBar
// ColorEditFlagsAlphaPreview displays preview as a transparent color over a checkerboard, instead of opaque.
ColorEditFlagsAlphaPreview ColorEditFlags = imgui.ColorEditFlagsAlphaPreview
// ColorEditFlagsAlphaPreviewHalf displays half opaque / half checkerboard, instead of opaque.
ColorEditFlagsAlphaPreviewHalf ColorEditFlags = imgui.ColorEditFlagsAlphaPreviewHalf
// ColorEditFlagsHDR = (WIP) surrently only disable 0.0f..1.0f limits in RGBA edition (note: you probably want to use ImGuiColorEditFlags_Float flag as well).
// ColorEditFlagsHDR = (WIP) surrently only disable 0.0f..1.0f limits in RGBA edition (note: you probably want to use
// ImGuiColorEditFlags_Float flag as well).
ColorEditFlagsHDR ColorEditFlags = imgui.ColorEditFlagsHDR
// ColorEditFlagsRGB sets the format as RGB
ColorEditFlagsRGB ColorEditFlags = imgui.ColorEditFlagsRGB
Expand Down
22 changes: 22 additions & 0 deletions Style.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ import (
// NOTE: PopFont has to be called
// NOTE: Don't use PushFont. use StyleSetter instead
func PushFont(font *FontInfo) bool {
if font == nil {
return false
}

if f, ok := extraFontMap[font.String()]; ok {
imgui.PushFont(*f)
return true
}

return false
}

Expand Down Expand Up @@ -358,6 +363,23 @@ func (ss *StyleSetter) SetFont(font *FontInfo) *StyleSetter {
return ss
}

func (ss *StyleSetter) SetFontSize(size float32) *StyleSetter {
var font FontInfo
if ss.font != nil {
font = *ss.font
} else {
font = defaultFonts[0]
}

font.size = size

extraFonts = append(extraFonts, font)

ss.font = &font

return ss
}

// SetDisabled sets if items are disabled
func (ss *StyleSetter) SetDisabled(d bool) *StyleSetter {
ss.disabled = d
Expand Down
4 changes: 4 additions & 0 deletions examples/setstyle/setstyle.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ func loop() {
g.Button("I'm a styled button"),
),
g.Button("I'm a normal button"),
g.Style().
SetFontSize(60).To(
g.Label("large label"),
),
)
}

Expand Down

0 comments on commit 50bb713

Please sign in to comment.