github.com/gop9/olt@v0.0.0-20200202132135-d956aad50b08/gio/widget/material/doc.go (about)

     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.Button encapsulates the state and event
     9  // handling of all buttons, while the Theme can draw a single Button
    10  // in various styles.
    11  //
    12  // This snippet defines a button that prints a message when clicked:
    13  //
    14  //     var gtx *layout.Context
    15  //     button := new(widget.Button)
    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  //     th.Button("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.RGBA{...}
    40  //
    41  // Widget-local parameters: For changing the look of a particular widget,
    42  // adjust the widget specific theme object:
    43  //
    44  //     btn := th.Button("Click me!")
    45  //     btn.Font.Style = text.Italic
    46  //     btn.Layout(gtx)
    47  //
    48  // Widget variants: A widget can have several distinct representations even
    49  // though the underlying state is the same. A widget.Button can be drawn as a
    50  // round icon button:
    51  //
    52  //     icon := material.NewIcon(...)
    53  //
    54  //     th.IconButton(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