doc.go raw

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