~eliasnaur/gio-patches

2 2

Make checkbox icon modifiable

Pham Song
Details
Message ID
<43DE2453-E9E2-421C-A235-263350AB4CEE@icloud.com>
DKIM signature
pass
Download raw message
Hello, 

if in checkbox.go, add method to modifiable the icons, it would be useful when user want to custom the icon rather than default


func (c *CheckBoxStyle) SetIcons(checked *widget.Icon, unchecked *widget.Icon) {
	if checked != nil {
		c.checkedStateIcon = checked
	}

	if unchecked != nil {
		c.uncheckedStateIcon = unchecked
	}
}



Thanks
Details
Message ID
<C4CHTBJHRBC7.0JM86M0T9DCZ@themachine>
In-Reply-To
<43DE2453-E9E2-421C-A235-263350AB4CEE@icloud.com> (view parent)
DKIM signature
pass
Download raw message
On Tue Jul 21, 2020 at 20:26, Pham Song wrote:
> Hello, 
>
> if in checkbox.go, add method to modifiable the icons, it would be useful when user want to custom the icon rather than default
>
>
> func (c *CheckBoxStyle) SetIcons(checked *widget.Icon, unchecked *widget.Icon) {
> 	if checked != nil {
> 		c.checkedStateIcon = checked
> 	}
>
> 	if unchecked != nil {
> 		c.uncheckedStateIcon = unchecked
> 	}
> }
>

Sure. I think a better fix is to export the icon fields on Theme:

https://git.sr.ht/~eliasnaur/gio/tree/master/widget/material/theme.go#L26

and add similar exported fields to CheckBoxStyle.

Elias
Details
Message ID
<CAE_4BPD4qz3k4R3XZNPjpTYaqjCz9rHNOad4=o2CB+vGeN1a_w@mail.gmail.com>
In-Reply-To
<C4CHTBJHRBC7.0JM86M0T9DCZ@themachine> (view parent)
DKIM signature
missing
Download raw message
Could you also just in general make a policy that all Theme fields
should be exported?  It seems to me that it shouldn't ever be
impossible to create your own completely custom theme.

Either that, or instead of a concrete struct, use an interface (or set
of interfaces, of course).

Or conceivably both, where the api uses interfaces but the struct
implements all the appropriate interfaces.

Just my thoughts.

-- Larry

On Tue, Jul 21, 2020 at 1:54 PM Elias Naur <mail@eliasnaur.com> wrote:
>
> On Tue Jul 21, 2020 at 20:26, Pham Song wrote:
> > Hello,
> >
> > if in checkbox.go, add method to modifiable the icons, it would be useful when user want to custom the icon rather than default
> >
> >
> > func (c *CheckBoxStyle) SetIcons(checked *widget.Icon, unchecked *widget.Icon) {
> >       if checked != nil {
> >               c.checkedStateIcon = checked
> >       }
> >
> >       if unchecked != nil {
> >               c.uncheckedStateIcon = unchecked
> >       }
> > }
> >
>
> Sure. I think a better fix is to export the icon fields on Theme:
>
> https://git.sr.ht/~eliasnaur/gio/tree/master/widget/material/theme.go#L26
>
> and add similar exported fields to CheckBoxStyle.
>
> Elias
Export thread (mbox)