()
| 116 | ) |
| 117 | |
| 118 | func (bt *Button) Init() { |
| 119 | bt.Frame.Init() |
| 120 | bt.Styler(func(s *styles.Style) { |
| 121 | s.SetAbilities(true, abilities.Activatable, abilities.Focusable, abilities.Hoverable, abilities.DoubleClickable, abilities.TripleClickable) |
| 122 | if !bt.IsDisabled() { |
| 123 | s.Cursor = cursors.Pointer |
| 124 | } |
| 125 | s.Border.Radius = styles.BorderRadiusFull |
| 126 | s.Padding.Set(units.Dp(10), units.Dp(24)) |
| 127 | if bt.Icon.IsSet() { |
| 128 | s.Padding.Left.Dp(16) |
| 129 | if bt.Text == "" { |
| 130 | s.Padding.Right.Dp(16) |
| 131 | } |
| 132 | } |
| 133 | s.Gap.Zero() |
| 134 | s.CenterAll() |
| 135 | |
| 136 | s.MaxBoxShadow = styles.BoxShadow1() |
| 137 | switch bt.Type { |
| 138 | case ButtonFilled: |
| 139 | s.Background = colors.Scheme.Primary.Base |
| 140 | s.Color = colors.Scheme.Primary.On |
| 141 | s.Border.Offset.Set(units.Dp(2)) |
| 142 | case ButtonTonal: |
| 143 | s.Background = colors.Scheme.Secondary.Container |
| 144 | s.Color = colors.Scheme.Secondary.OnContainer |
| 145 | case ButtonElevated: |
| 146 | s.Background = colors.Scheme.SurfaceContainerLow |
| 147 | s.Color = colors.Scheme.Primary.Base |
| 148 | s.MaxBoxShadow = styles.BoxShadow2() |
| 149 | s.BoxShadow = styles.BoxShadow1() |
| 150 | case ButtonOutlined: |
| 151 | s.Color = colors.Scheme.Primary.Base |
| 152 | s.Border.Style.Set(styles.BorderSolid) |
| 153 | s.Border.Width.Set(units.Dp(1)) |
| 154 | case ButtonText: |
| 155 | s.Color = colors.Scheme.Primary.Base |
| 156 | case ButtonAction: |
| 157 | s.MaxBoxShadow = styles.BoxShadow0() |
| 158 | case ButtonMenu: |
| 159 | s.Grow.Set(1, 0) // need to go to edge of menu |
| 160 | s.Justify.Content = styles.Start |
| 161 | s.Border.Radius.Zero() |
| 162 | s.Padding.Set(units.Dp(6), units.Dp(12)) |
| 163 | s.MaxBoxShadow = styles.BoxShadow0() |
| 164 | } |
| 165 | if s.Is(states.Hovered) { |
| 166 | s.BoxShadow = s.MaxBoxShadow |
| 167 | } |
| 168 | if bt.IsDisabled() { |
| 169 | s.MaxBoxShadow = styles.BoxShadow0() |
| 170 | s.BoxShadow = s.MaxBoxShadow |
| 171 | } |
| 172 | }) |
| 173 | |
| 174 | bt.HandleClickOnEnterSpace() |
| 175 | bt.OnClick(func(e events.Event) { |
nothing calls this directly
no test coverage detected