doc.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // SPDX-License-Identifier: Unlicense OR MIT
  2. // Package material implements the Material design.
  3. //
  4. // To maximize reusability and visual flexibility, user interface controls are
  5. // split into two parts: the stateful widget and the stateless drawing of it.
  6. //
  7. // For example, widget.Clickable encapsulates the state and event
  8. // handling of all clickable areas, while the Theme is responsible to
  9. // draw a specific area, for example a button.
  10. //
  11. // This snippet defines a button that prints a message when clicked:
  12. //
  13. // var gtx layout.Context
  14. // button := new(widget.Clickable)
  15. //
  16. // for button.Clicked(gtx) {
  17. // fmt.Println("Clicked!")
  18. // }
  19. //
  20. // Use a Theme to draw the button:
  21. //
  22. // theme := material.NewTheme(...)
  23. //
  24. // material.Button(theme, button, "Click me!").Layout(gtx)
  25. //
  26. // # Customization
  27. //
  28. // Quite often, a program needs to customize the theme-provided defaults. Several
  29. // options are available, depending on the nature of the change.
  30. //
  31. // Mandatory parameters: Some parameters are not part of the widget state but
  32. // have no obvious default. In the program above, the button text is a
  33. // parameter to the Theme.Button method.
  34. //
  35. // Theme-global parameters: For changing the look of all widgets drawn with a
  36. // particular theme, adjust the `Theme` fields:
  37. //
  38. // theme.Palette.Fg = color.NRGBA{...}
  39. //
  40. // Widget-local parameters: For changing the look of a particular widget,
  41. // adjust the widget specific theme object:
  42. //
  43. // btn := material.Button(theme, button, "Click me!")
  44. // btn.Font.Style = text.Italic
  45. // btn.Layout(gtx)
  46. //
  47. // Widget variants: A widget can have several distinct representations even
  48. // though the underlying state is the same. A widget.Clickable can be drawn as a
  49. // round icon button:
  50. //
  51. // icon := widget.NewIcon(...)
  52. //
  53. // material.IconButton(theme, button, icon, "Click me!").Layout(gtx)
  54. //
  55. // Specialized widgets: Theme both define a generic Label method
  56. // that takes a text size, and specialized methods for standard text
  57. // sizes such as Theme.H1 and Theme.Body2.
  58. package material