diff --git a/Flags.go b/Flags.go index a52decc9..7d2bd8a6 100644 --- a/Flags.go +++ b/Flags.go @@ -310,7 +310,9 @@ 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 @@ -318,7 +320,8 @@ const ( 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 diff --git a/Style.go b/Style.go index fe59cd20..a878cec4 100644 --- a/Style.go +++ b/Style.go @@ -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 } @@ -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 diff --git a/examples/setstyle/setstyle.go b/examples/setstyle/setstyle.go index 8a763f05..5f26c457 100644 --- a/examples/setstyle/setstyle.go +++ b/examples/setstyle/setstyle.go @@ -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"), + ), ) }