github.com/gop9/olt@v0.0.0-20200202132135-d956aad50b08/framework/style/style.go (about)

     1  package style
     2  
     3  import (
     4  	"image"
     5  	"image/color"
     6  
     7  	"github.com/gop9/olt/framework/command"
     8  	"github.com/gop9/olt/framework/font"
     9  	"github.com/gop9/olt/framework/label"
    10  )
    11  
    12  type WidgetStates int
    13  
    14  const (
    15  	WidgetStateInactive WidgetStates = iota
    16  	WidgetStateHovered
    17  	WidgetStateActive
    18  )
    19  
    20  type Style struct {
    21  	Scaling          float64
    22  	unscaled         *Style
    23  	defaultFont      font.Face
    24  	Font             font.Face
    25  	Text             Text
    26  	Button           Button
    27  	ContextualButton Button
    28  	MenuButton       Button
    29  	Option           Toggle
    30  	Checkbox         Toggle
    31  	Selectable       Selectable
    32  	Slider           Slider
    33  	Progress         Progress
    34  	Property         Property
    35  	Edit             Edit
    36  	Scrollh          Scrollbar
    37  	Scrollv          Scrollbar
    38  	Tab              Tab
    39  	Combo            Combo
    40  	NormalWindow     Window
    41  	MenuWindow       Window
    42  	TooltipWindow    Window
    43  	ComboWindow      Window
    44  	ContextualWindow Window
    45  	GroupWindow      Window
    46  }
    47  
    48  type ColorTable struct {
    49  	ColorText                  color.RGBA
    50  	ColorWindow                color.RGBA
    51  	ColorHeader                color.RGBA
    52  	ColorHeaderFocused         color.RGBA
    53  	ColorBorder                color.RGBA
    54  	ColorButton                color.RGBA
    55  	ColorButtonHover           color.RGBA
    56  	ColorButtonActive          color.RGBA
    57  	ColorToggle                color.RGBA
    58  	ColorToggleHover           color.RGBA
    59  	ColorToggleCursor          color.RGBA
    60  	ColorSelect                color.RGBA
    61  	ColorSelectActive          color.RGBA
    62  	ColorSlider                color.RGBA
    63  	ColorSliderCursor          color.RGBA
    64  	ColorSliderCursorHover     color.RGBA
    65  	ColorSliderCursorActive    color.RGBA
    66  	ColorProperty              color.RGBA
    67  	ColorEdit                  color.RGBA
    68  	ColorEditCursor            color.RGBA
    69  	ColorCombo                 color.RGBA
    70  	ColorChart                 color.RGBA
    71  	ColorChartColor            color.RGBA
    72  	ColorChartColorHighlight   color.RGBA
    73  	ColorScrollbar             color.RGBA
    74  	ColorScrollbarCursor       color.RGBA
    75  	ColorScrollbarCursorHover  color.RGBA
    76  	ColorScrollbarCursorActive color.RGBA
    77  	ColorTabHeader             color.RGBA
    78  }
    79  
    80  type ItemType int
    81  
    82  const (
    83  	ItemColor ItemType = iota
    84  	ItemImage
    85  )
    86  
    87  type ItemData struct {
    88  	Image *image.RGBA
    89  	Color color.RGBA
    90  }
    91  
    92  type Item struct {
    93  	Type ItemType
    94  	Data ItemData
    95  }
    96  
    97  type Text struct {
    98  	Color   color.RGBA
    99  	Padding image.Point
   100  }
   101  
   102  type Button struct {
   103  	Normal            Item
   104  	Hover             Item
   105  	Active            Item
   106  	BorderColor       color.RGBA
   107  	TextBackground    color.RGBA
   108  	TextNormal        color.RGBA
   109  	TextHover         color.RGBA
   110  	TextActive        color.RGBA
   111  	Border            int
   112  	Rounding          uint16
   113  	Padding           image.Point
   114  	ImagePadding      image.Point
   115  	TouchPadding      image.Point
   116  	DrawBegin         func(*command.Buffer)
   117  	Draw              CustomButtonDrawing
   118  	DrawEnd           func(*command.Buffer)
   119  	SymbolBorderWidth int
   120  }
   121  
   122  type CustomButtonDrawing struct {
   123  	ButtonText       func(*command.Buffer, image.Rectangle, image.Rectangle, WidgetStates, *Button, string, label.Align, font.Face)
   124  	ButtonSymbol     func(*command.Buffer, image.Rectangle, image.Rectangle, WidgetStates, *Button, label.SymbolType, font.Face)
   125  	ButtonImage      func(*command.Buffer, image.Rectangle, image.Rectangle, WidgetStates, *Button, *image.RGBA)
   126  	ButtonTextSymbol func(*command.Buffer, image.Rectangle, image.Rectangle, image.Rectangle, WidgetStates, *Button, string, label.SymbolType, font.Face)
   127  	ButtonTextImage  func(*command.Buffer, image.Rectangle, image.Rectangle, image.Rectangle, WidgetStates, *Button, string, font.Face, *image.RGBA)
   128  }
   129  
   130  type Toggle struct {
   131  	Normal         Item
   132  	Hover          Item
   133  	Active         Item
   134  	CursorNormal   Item
   135  	CursorHover    Item
   136  	TextNormal     color.RGBA
   137  	TextHover      color.RGBA
   138  	TextActive     color.RGBA
   139  	TextBackground color.RGBA
   140  	Padding        image.Point
   141  	TouchPadding   image.Point
   142  	DrawBegin      func(*command.Buffer)
   143  	Draw           CustomToggleDrawing
   144  	DrawEnd        func(*command.Buffer)
   145  }
   146  
   147  type CustomToggleDrawing struct {
   148  	Radio    func(*command.Buffer, WidgetStates, *Toggle, bool, image.Rectangle, image.Rectangle, image.Rectangle, string, font.Face)
   149  	Checkbox func(*command.Buffer, WidgetStates, *Toggle, bool, image.Rectangle, image.Rectangle, image.Rectangle, string, font.Face)
   150  }
   151  
   152  type Selectable struct {
   153  	Normal            Item
   154  	Hover             Item
   155  	Pressed           Item
   156  	NormalActive      Item
   157  	HoverActive       Item
   158  	PressedActive     Item
   159  	TextNormal        color.RGBA
   160  	TextHover         color.RGBA
   161  	TextPressed       color.RGBA
   162  	TextNormalActive  color.RGBA
   163  	TextHoverActive   color.RGBA
   164  	TextPressedActive color.RGBA
   165  	TextBackground    color.RGBA
   166  	TextAlignment     uint32
   167  	Rounding          uint16
   168  	Padding           image.Point
   169  	TouchPadding      image.Point
   170  	DrawBegin         func(*command.Buffer)
   171  	Draw              func(*command.Buffer, WidgetStates, *Selectable, bool, image.Rectangle, string, label.Align, font.Face)
   172  	DrawEnd           func(*command.Buffer)
   173  }
   174  
   175  type Slider struct {
   176  	Normal       Item
   177  	Hover        Item
   178  	Active       Item
   179  	BorderColor  color.RGBA
   180  	BarNormal    color.RGBA
   181  	BarHover     color.RGBA
   182  	BarActive    color.RGBA
   183  	BarFilled    color.RGBA
   184  	CursorNormal Item
   185  	CursorHover  Item
   186  	CursorActive Item
   187  	Border       int
   188  	Rounding     uint16
   189  	BarHeight    int
   190  	Padding      image.Point
   191  	Spacing      image.Point
   192  	CursorSize   image.Point
   193  	ShowButtons  bool
   194  	IncButton    Button
   195  	DecButton    Button
   196  	IncSymbol    label.SymbolType
   197  	DecSymbol    label.SymbolType
   198  	DrawBegin    func(*command.Buffer)
   199  	Draw         func(*command.Buffer, WidgetStates, *Slider, image.Rectangle, image.Rectangle, float64, float64, float64)
   200  	DrawEnd      func(*command.Buffer)
   201  }
   202  
   203  type Progress struct {
   204  	Normal       Item
   205  	Hover        Item
   206  	Active       Item
   207  	CursorNormal Item
   208  	CursorHover  Item
   209  	CursorActive Item
   210  	Rounding     uint16
   211  	Padding      image.Point
   212  	DrawBegin    func(*command.Buffer)
   213  	Draw         func(*command.Buffer, WidgetStates, *Progress, image.Rectangle, image.Rectangle, int, int)
   214  	DrawEnd      func(*command.Buffer)
   215  }
   216  
   217  type Scrollbar struct {
   218  	Normal       Item
   219  	Hover        Item
   220  	Active       Item
   221  	BorderColor  color.RGBA
   222  	CursorNormal Item
   223  	CursorHover  Item
   224  	CursorActive Item
   225  	Border       int
   226  	Rounding     uint16
   227  	Padding      image.Point
   228  	ShowButtons  bool
   229  	IncButton    Button
   230  	DecButton    Button
   231  	IncSymbol    label.SymbolType
   232  	DecSymbol    label.SymbolType
   233  	DrawBegin    func(*command.Buffer)
   234  	Draw         func(*command.Buffer, WidgetStates, *Scrollbar, image.Rectangle, image.Rectangle)
   235  	DrawEnd      func(*command.Buffer)
   236  }
   237  
   238  type Edit struct {
   239  	Normal             Item
   240  	Hover              Item
   241  	Active             Item
   242  	BorderColor        color.RGBA
   243  	Scrollbar          Scrollbar
   244  	CursorNormal       color.RGBA
   245  	CursorHover        color.RGBA
   246  	CursorTextNormal   color.RGBA
   247  	CursorTextHover    color.RGBA
   248  	TextNormal         color.RGBA
   249  	TextHover          color.RGBA
   250  	TextActive         color.RGBA
   251  	SelectedNormal     color.RGBA
   252  	SelectedHover      color.RGBA
   253  	SelectedTextNormal color.RGBA
   254  	SelectedTextHover  color.RGBA
   255  	Border             int
   256  	Rounding           uint16
   257  	ScrollbarSize      image.Point
   258  	Padding            image.Point
   259  	RowPadding         int
   260  }
   261  
   262  type Property struct {
   263  	Normal      Item
   264  	Hover       Item
   265  	Active      Item
   266  	BorderColor color.RGBA
   267  	LabelNormal color.RGBA
   268  	LabelHover  color.RGBA
   269  	LabelActive color.RGBA
   270  	SymLeft     label.SymbolType
   271  	SymRight    label.SymbolType
   272  	Border      int
   273  	Rounding    uint16
   274  	Padding     image.Point
   275  	Edit        Edit
   276  	IncButton   Button
   277  	DecButton   Button
   278  	DrawBegin   func(*command.Buffer)
   279  	Draw        func(*command.Buffer, *Property, image.Rectangle, image.Rectangle, WidgetStates, string, font.Face)
   280  	DrawEnd     func(*command.Buffer)
   281  }
   282  
   283  type Chart struct {
   284  	Background    Item
   285  	BorderColor   color.RGBA
   286  	SelectedColor color.RGBA
   287  	Color         color.RGBA
   288  	Border        int
   289  	Rounding      uint16
   290  	Padding       image.Point
   291  }
   292  
   293  type Combo struct {
   294  	Normal         Item
   295  	Hover          Item
   296  	Active         Item
   297  	BorderColor    color.RGBA
   298  	LabelNormal    color.RGBA
   299  	LabelHover     color.RGBA
   300  	LabelActive    color.RGBA
   301  	SymbolNormal   color.RGBA
   302  	SymbolHover    color.RGBA
   303  	SymbolActive   color.RGBA
   304  	Button         Button
   305  	SymNormal      label.SymbolType
   306  	SymHover       label.SymbolType
   307  	SymActive      label.SymbolType
   308  	Border         int
   309  	Rounding       uint16
   310  	ContentPadding image.Point
   311  	ButtonPadding  image.Point
   312  	Spacing        image.Point
   313  }
   314  
   315  type Tab struct {
   316  	Background  Item
   317  	BorderColor color.RGBA
   318  	Text        color.RGBA
   319  	TabButton   Button
   320  	NodeButton  Button
   321  	SymMinimize label.SymbolType
   322  	SymMaximize label.SymbolType
   323  	Border      int
   324  	Rounding    uint16
   325  	Padding     image.Point
   326  	Spacing     image.Point
   327  	Indent      int
   328  }
   329  
   330  type HeaderAlign int
   331  
   332  const (
   333  	HeaderLeft HeaderAlign = iota
   334  	HeaderRight
   335  )
   336  
   337  type WindowHeader struct {
   338  	Normal         Item
   339  	Hover          Item
   340  	Active         Item
   341  	CloseButton    Button
   342  	MinimizeButton Button
   343  	CloseSymbol    label.SymbolType
   344  	MinimizeSymbol label.SymbolType
   345  	MaximizeSymbol label.SymbolType
   346  	LabelNormal    color.RGBA
   347  	LabelHover     color.RGBA
   348  	LabelActive    color.RGBA
   349  	Align          HeaderAlign
   350  	Padding        image.Point
   351  	LabelPadding   image.Point
   352  	Spacing        image.Point
   353  }
   354  
   355  type Window struct {
   356  	Header          WindowHeader
   357  	FixedBackground Item
   358  	Background      color.RGBA
   359  	BorderColor     color.RGBA
   360  	Scaler          Item
   361  	FooterPadding   image.Point
   362  	Border          int
   363  	Rounding        uint16
   364  	ScalerSize      image.Point
   365  	Padding         image.Point
   366  	Spacing         image.Point
   367  	ScrollbarSize   image.Point
   368  	MinSize         image.Point
   369  }
   370  
   371  //var defaultThemeTable = ColorTable{
   372  // color.RGBA{207, 207, 207, 255}, color.RGBA{45, 45, 45, 255}, color.RGBA{40, 40, 40, 255}, color.RGBA{40, 40, 40, 255}, color.RGBA{65, 65, 65, 255},
   373  // color.RGBA{50, 50, 50, 255}, color.RGBA{40, 40, 40, 255}, color.RGBA{35, 35, 35, 255}, color.RGBA{100, 100, 100, 255}, color.RGBA{120, 120, 120, 255}, color.RGBA{45, 45, 45, 255},
   374  // color.RGBA{45, 45, 45, 255}, color.RGBA{35, 35, 35, 255}, color.RGBA{38, 38, 38, 255}, color.RGBA{100, 100, 100, 255}, color.RGBA{120, 120, 120, 255}, color.RGBA{150, 150, 150, 255},
   375  // color.RGBA{38, 38, 38, 255}, color.RGBA{38, 38, 38, 255}, color.RGBA{207, 207, 207, 255}, color.RGBA{45, 45, 45, 255}, color.RGBA{120, 120, 120, 255}, color.RGBA{45, 45, 45, 255},
   376  // color.RGBA{255, 0, 0, 255}, color.RGBA{40, 40, 40, 255}, color.RGBA{100, 100, 100, 255}, color.RGBA{120, 120, 120, 255}, color.RGBA{150, 150, 150, 255}, color.RGBA{40, 40, 40, 255}}
   377  
   378  var defaultThemeTable = ColorTable{
   379  	ColorText:                  color.RGBA{48, 48, 48, 255},
   380  	ColorWindow:                color.RGBA{207, 207, 207, 255},
   381  	ColorHeader:                color.RGBA{207, 207, 207, 255},
   382  	ColorHeaderFocused:         color.RGBA{0xc3, 0x9a, 0x9a, 255},
   383  	ColorBorder:                color.RGBA{0, 0, 0, 255},
   384  	ColorButton:                color.RGBA{48, 128, 207, 255},
   385  	ColorButtonHover:           color.RGBA{127, 168, 207, 255},
   386  	ColorButtonActive:          color.RGBA{160, 160, 160, 255},
   387  	ColorToggle:                color.RGBA{150, 150, 150, 255},
   388  	ColorToggleHover:           color.RGBA{120, 120, 120, 255},
   389  	ColorToggleCursor:          color.RGBA{207, 207, 207, 255},
   390  	ColorSelect:                color.RGBA{207, 207, 207, 255},
   391  	ColorSelectActive:          color.RGBA{190, 190, 190, 255},
   392  	ColorSlider:                color.RGBA{190, 190, 190, 255},
   393  	ColorSliderCursor:          color.RGBA{80, 80, 80, 255},
   394  	ColorSliderCursorHover:     color.RGBA{48, 48, 48, 255},
   395  	ColorSliderCursorActive:    color.RGBA{60, 60, 60, 255},
   396  	ColorProperty:              color.RGBA{207, 207, 207, 255},
   397  	ColorEdit:                  color.RGBA{150, 150, 150, 255},
   398  	ColorEditCursor:            color.RGBA{0, 0, 0, 255},
   399  	ColorCombo:                 color.RGBA{207, 207, 207, 255},
   400  	ColorChart:                 color.RGBA{160, 160, 160, 255},
   401  	ColorChartColor:            color.RGBA{45, 45, 45, 255},
   402  	ColorChartColorHighlight:   color.RGBA{255, 0, 0, 255},
   403  	ColorScrollbar:             color.RGBA{180, 180, 180, 255},
   404  	ColorScrollbarCursor:       color.RGBA{140, 140, 140, 255},
   405  	ColorScrollbarCursorHover:  color.RGBA{150, 150, 150, 255},
   406  	ColorScrollbarCursorActive: color.RGBA{160, 160, 160, 255},
   407  	ColorTabHeader:             color.RGBA{180, 180, 180, 255},
   408  }
   409  
   410  func FromTable(table ColorTable, scaling float64) *Style {
   411  	var text *Text
   412  	var button *Button
   413  	var toggle *Toggle
   414  	var select_ *Selectable
   415  	var slider *Slider
   416  	var prog *Progress
   417  	var scroll *Scrollbar
   418  	var edit *Edit
   419  	var property *Property
   420  	var combo *Combo
   421  	var tab *Tab
   422  	var win *Window
   423  
   424  	style := &Style{Scaling: 1.0}
   425  
   426  	/* default text */
   427  	text = &style.Text
   428  
   429  	text.Color = table.ColorText
   430  	text.Padding = image.Point{4, 4}
   431  
   432  	/* default button */
   433  	button = &style.Button
   434  
   435  	*button = Button{}
   436  	button.Normal = MakeItemColor(table.ColorButton)
   437  	button.Hover = MakeItemColor(table.ColorButtonHover)
   438  	button.Active = MakeItemColor(table.ColorButtonActive)
   439  	button.BorderColor = table.ColorBorder
   440  	button.TextBackground = table.ColorButton
   441  	button.TextNormal = table.ColorText
   442  	button.TextHover = table.ColorText
   443  	button.TextActive = table.ColorText
   444  	button.Padding = image.Point{4.0, 4.0}
   445  	button.ImagePadding = image.Point{0.0, 0.0}
   446  	button.TouchPadding = image.Point{0.0, 0.0}
   447  	button.Border = 1
   448  	button.SymbolBorderWidth = 1
   449  	button.Rounding = 1
   450  	button.DrawBegin = nil
   451  	button.DrawEnd = nil
   452  
   453  	/* contextual button */
   454  	button = &style.ContextualButton
   455  
   456  	*button = Button{}
   457  	button.Normal = MakeItemColor(table.ColorWindow)
   458  	button.Hover = MakeItemColor(table.ColorButtonHover)
   459  	button.Active = MakeItemColor(table.ColorButtonActive)
   460  	button.BorderColor = table.ColorWindow
   461  	button.TextBackground = table.ColorWindow
   462  	button.TextNormal = table.ColorText
   463  	button.TextHover = table.ColorText
   464  	button.TextActive = table.ColorText
   465  	button.Padding = image.Point{4.0, 4.0}
   466  	button.TouchPadding = image.Point{0.0, 0.0}
   467  	button.Border = 0
   468  	button.SymbolBorderWidth = 1
   469  	button.Rounding = 0
   470  	button.DrawBegin = nil
   471  	button.DrawEnd = nil
   472  
   473  	/* menu button */
   474  	button = &style.MenuButton
   475  
   476  	*button = Button{}
   477  	button.Normal = MakeItemColor(table.ColorWindow)
   478  	button.Hover = MakeItemColor(table.ColorWindow)
   479  	button.Active = MakeItemColor(table.ColorWindow)
   480  	button.BorderColor = table.ColorWindow
   481  	button.TextBackground = table.ColorWindow
   482  	button.TextNormal = table.ColorText
   483  	button.TextHover = table.ColorText
   484  	button.TextActive = table.ColorText
   485  	button.Padding = image.Point{4.0, 4.0}
   486  	button.TouchPadding = image.Point{0.0, 0.0}
   487  	button.Border = 0
   488  	button.SymbolBorderWidth = 1
   489  	button.Rounding = 1
   490  	button.DrawBegin = nil
   491  	button.DrawEnd = nil
   492  
   493  	/* checkbox toggle */
   494  	toggle = &style.Checkbox
   495  
   496  	*toggle = Toggle{}
   497  	toggle.Normal = MakeItemColor(table.ColorToggle)
   498  	toggle.Hover = MakeItemColor(table.ColorToggleHover)
   499  	toggle.Active = MakeItemColor(table.ColorToggleHover)
   500  	toggle.CursorNormal = MakeItemColor(table.ColorToggleCursor)
   501  	toggle.CursorHover = MakeItemColor(table.ColorToggleCursor)
   502  	toggle.TextBackground = table.ColorWindow
   503  	toggle.TextNormal = table.ColorText
   504  	toggle.TextHover = table.ColorText
   505  	toggle.TextActive = table.ColorText
   506  	toggle.Padding = image.Point{4.0, 4.0}
   507  	toggle.TouchPadding = image.Point{0, 0}
   508  
   509  	/* option toggle */
   510  	toggle = &style.Option
   511  
   512  	*toggle = Toggle{}
   513  	toggle.Normal = MakeItemColor(table.ColorToggle)
   514  	toggle.Hover = MakeItemColor(table.ColorToggleHover)
   515  	toggle.Active = MakeItemColor(table.ColorToggleHover)
   516  	toggle.CursorNormal = MakeItemColor(table.ColorToggleCursor)
   517  	toggle.CursorHover = MakeItemColor(table.ColorToggleCursor)
   518  	toggle.TextBackground = table.ColorWindow
   519  	toggle.TextNormal = table.ColorText
   520  	toggle.TextHover = table.ColorText
   521  	toggle.TextActive = table.ColorText
   522  	toggle.Padding = image.Point{4.0, 4.0}
   523  	toggle.TouchPadding = image.Point{0, 0}
   524  
   525  	/* selectable */
   526  	select_ = &style.Selectable
   527  
   528  	*select_ = Selectable{}
   529  	select_.Normal = MakeItemColor(table.ColorSelect)
   530  	select_.Hover = MakeItemColor(table.ColorSelect)
   531  	select_.Pressed = MakeItemColor(table.ColorSelect)
   532  	select_.NormalActive = MakeItemColor(table.ColorSelectActive)
   533  	select_.HoverActive = MakeItemColor(table.ColorSelectActive)
   534  	select_.PressedActive = MakeItemColor(table.ColorSelectActive)
   535  	select_.TextNormal = table.ColorText
   536  	select_.TextHover = table.ColorText
   537  	select_.TextPressed = table.ColorText
   538  	select_.TextNormalActive = table.ColorText
   539  	select_.TextHoverActive = table.ColorText
   540  	select_.TextPressedActive = table.ColorText
   541  	select_.Padding = image.Point{4.0, 4.0}
   542  	select_.TouchPadding = image.Point{0, 0}
   543  	select_.Rounding = 0.0
   544  	select_.DrawBegin = nil
   545  	select_.Draw = nil
   546  	select_.DrawEnd = nil
   547  
   548  	/* slider */
   549  	slider = &style.Slider
   550  
   551  	*slider = Slider{}
   552  	slider.Normal = ItemHide()
   553  	slider.Hover = ItemHide()
   554  	slider.Active = ItemHide()
   555  	slider.BarNormal = table.ColorSlider
   556  	slider.BarHover = table.ColorSlider
   557  	slider.BarActive = table.ColorSlider
   558  	slider.BarFilled = table.ColorSliderCursor
   559  	slider.CursorNormal = MakeItemColor(table.ColorSliderCursor)
   560  	slider.CursorHover = MakeItemColor(table.ColorSliderCursorHover)
   561  	slider.CursorActive = MakeItemColor(table.ColorSliderCursorActive)
   562  	slider.IncSymbol = label.SymbolTriangleRight
   563  	slider.DecSymbol = label.SymbolTriangleLeft
   564  	slider.CursorSize = image.Point{16, 16}
   565  	slider.Padding = image.Point{4, 4}
   566  	slider.Spacing = image.Point{4, 4}
   567  	slider.ShowButtons = false
   568  	slider.BarHeight = 8
   569  	slider.Rounding = 0
   570  	slider.DrawBegin = nil
   571  	slider.Draw = nil
   572  	slider.DrawEnd = nil
   573  
   574  	/* slider buttons */
   575  	button = &style.Slider.IncButton
   576  
   577  	button.Normal = MakeItemColor(color.RGBA{40, 40, 40, 0xff})
   578  	button.Hover = MakeItemColor(color.RGBA{42, 42, 42, 0xff})
   579  	button.Active = MakeItemColor(color.RGBA{44, 44, 44, 0xff})
   580  	button.BorderColor = color.RGBA{65, 65, 65, 0xff}
   581  	button.TextBackground = color.RGBA{40, 40, 40, 0xff}
   582  	button.TextNormal = color.RGBA{207, 207, 207, 0xff}
   583  	button.TextHover = color.RGBA{207, 207, 207, 0xff}
   584  	button.TextActive = color.RGBA{207, 207, 207, 0xff}
   585  	button.Padding = image.Point{8.0, 8.0}
   586  	button.TouchPadding = image.Point{0.0, 0.0}
   587  	button.Border = 1.0
   588  	button.Rounding = 0.0
   589  	button.DrawBegin = nil
   590  	button.DrawEnd = nil
   591  	style.Slider.DecButton = style.Slider.IncButton
   592  
   593  	/* progressbar */
   594  	prog = &style.Progress
   595  
   596  	*prog = Progress{}
   597  	prog.Normal = MakeItemColor(table.ColorSlider)
   598  	prog.Hover = MakeItemColor(table.ColorSlider)
   599  	prog.Active = MakeItemColor(table.ColorSlider)
   600  	prog.CursorNormal = MakeItemColor(table.ColorSliderCursor)
   601  	prog.CursorHover = MakeItemColor(table.ColorSliderCursorHover)
   602  	prog.CursorActive = MakeItemColor(table.ColorSliderCursorActive)
   603  	prog.Padding = image.Point{4, 4}
   604  	prog.Rounding = 0
   605  	prog.DrawBegin = nil
   606  	prog.Draw = nil
   607  	prog.DrawEnd = nil
   608  
   609  	/* scrollbars */
   610  	scroll = &style.Scrollh
   611  
   612  	*scroll = Scrollbar{}
   613  	scroll.Normal = MakeItemColor(table.ColorScrollbar)
   614  	scroll.Hover = MakeItemColor(table.ColorScrollbar)
   615  	scroll.Active = MakeItemColor(table.ColorScrollbar)
   616  	scroll.CursorNormal = MakeItemColor(table.ColorScrollbarCursor)
   617  	scroll.CursorHover = MakeItemColor(table.ColorScrollbarCursorHover)
   618  	scroll.CursorActive = MakeItemColor(table.ColorScrollbarCursorActive)
   619  	scroll.DecSymbol = label.SymbolCircleFilled
   620  	scroll.IncSymbol = label.SymbolCircleFilled
   621  	scroll.BorderColor = color.RGBA{65, 65, 65, 0xff}
   622  	scroll.Padding = image.Point{4, 4}
   623  	scroll.ShowButtons = false
   624  	scroll.Border = 0
   625  	scroll.Rounding = 0
   626  	scroll.DrawBegin = nil
   627  	scroll.Draw = nil
   628  	scroll.DrawEnd = nil
   629  	style.Scrollv = style.Scrollh
   630  
   631  	/* scrollbars buttons */
   632  	button = &style.Scrollh.IncButton
   633  
   634  	button.Normal = MakeItemColor(color.RGBA{40, 40, 40, 0xff})
   635  	button.Hover = MakeItemColor(color.RGBA{42, 42, 42, 0xff})
   636  	button.Active = MakeItemColor(color.RGBA{44, 44, 44, 0xff})
   637  	button.BorderColor = color.RGBA{65, 65, 65, 0xff}
   638  	button.TextBackground = color.RGBA{40, 40, 40, 0xff}
   639  	button.TextNormal = color.RGBA{207, 207, 207, 0xff}
   640  	button.TextHover = color.RGBA{207, 207, 207, 0xff}
   641  	button.TextActive = color.RGBA{207, 207, 207, 0xff}
   642  	button.Padding = image.Point{4.0, 4.0}
   643  	button.TouchPadding = image.Point{0.0, 0.0}
   644  	button.Border = 1.0
   645  	button.Rounding = 0.0
   646  	button.DrawBegin = nil
   647  	button.DrawEnd = nil
   648  	style.Scrollh.DecButton = style.Scrollh.IncButton
   649  	style.Scrollv.IncButton = style.Scrollh.IncButton
   650  	style.Scrollv.DecButton = style.Scrollh.IncButton
   651  
   652  	/* edit */
   653  	edit = &style.Edit
   654  
   655  	*edit = Edit{}
   656  	edit.Normal = MakeItemColor(table.ColorEdit)
   657  	edit.Hover = MakeItemColor(table.ColorEdit)
   658  	edit.Active = MakeItemColor(table.ColorEdit)
   659  	edit.Scrollbar = *scroll
   660  	edit.CursorNormal = table.ColorText
   661  	edit.CursorHover = table.ColorText
   662  	edit.CursorTextNormal = table.ColorEdit
   663  	edit.CursorTextHover = table.ColorEdit
   664  	edit.BorderColor = table.ColorBorder
   665  	edit.TextNormal = table.ColorText
   666  	edit.TextHover = table.ColorText
   667  	edit.TextActive = table.ColorText
   668  	edit.SelectedNormal = table.ColorText
   669  	edit.SelectedHover = table.ColorText
   670  	edit.SelectedTextNormal = table.ColorEdit
   671  	edit.SelectedTextHover = table.ColorEdit
   672  	edit.RowPadding = 2
   673  	edit.Padding = image.Point{4, 4}
   674  	edit.ScrollbarSize = image.Point{4, 4}
   675  	edit.Border = 1
   676  	edit.Rounding = 0
   677  
   678  	/* property */
   679  	property = &style.Property
   680  
   681  	*property = Property{}
   682  	property.Normal = MakeItemColor(table.ColorProperty)
   683  	property.Hover = MakeItemColor(table.ColorProperty)
   684  	property.Active = MakeItemColor(table.ColorProperty)
   685  	property.BorderColor = table.ColorBorder
   686  	property.LabelNormal = table.ColorText
   687  	property.LabelHover = table.ColorText
   688  	property.LabelActive = table.ColorText
   689  	property.SymLeft = label.SymbolTriangleLeft
   690  	property.SymRight = label.SymbolTriangleRight
   691  	property.Padding = image.Point{4, 4}
   692  	property.Border = 1
   693  	property.Rounding = 10
   694  	property.DrawBegin = nil
   695  	property.Draw = nil
   696  	property.DrawEnd = nil
   697  
   698  	/* property buttons */
   699  	button = &style.Property.DecButton
   700  
   701  	*button = Button{}
   702  	button.Normal = MakeItemColor(table.ColorProperty)
   703  	button.Hover = MakeItemColor(table.ColorProperty)
   704  	button.Active = MakeItemColor(table.ColorProperty)
   705  	button.BorderColor = color.RGBA{0, 0, 0, 0}
   706  	button.TextBackground = table.ColorProperty
   707  	button.TextNormal = table.ColorText
   708  	button.TextHover = table.ColorText
   709  	button.TextActive = table.ColorText
   710  	button.Padding = image.Point{0.0, 0.0}
   711  	button.TouchPadding = image.Point{0.0, 0.0}
   712  	button.Border = 0.0
   713  	button.SymbolBorderWidth = 1
   714  	button.Rounding = 0.0
   715  	button.DrawBegin = nil
   716  	button.DrawEnd = nil
   717  	style.Property.IncButton = style.Property.DecButton
   718  
   719  	/* property edit */
   720  	edit = &style.Property.Edit
   721  
   722  	*edit = Edit{}
   723  	edit.Normal = MakeItemColor(table.ColorProperty)
   724  	edit.Hover = MakeItemColor(table.ColorProperty)
   725  	edit.Active = MakeItemColor(table.ColorProperty)
   726  	edit.BorderColor = color.RGBA{0, 0, 0, 0}
   727  	edit.CursorNormal = table.ColorText
   728  	edit.CursorHover = table.ColorText
   729  	edit.CursorTextNormal = table.ColorEdit
   730  	edit.CursorTextHover = table.ColorEdit
   731  	edit.TextNormal = table.ColorText
   732  	edit.TextHover = table.ColorText
   733  	edit.TextActive = table.ColorText
   734  	edit.SelectedNormal = table.ColorText
   735  	edit.SelectedHover = table.ColorText
   736  	edit.SelectedTextNormal = table.ColorEdit
   737  	edit.SelectedTextHover = table.ColorEdit
   738  	edit.Padding = image.Point{0, 0}
   739  	edit.Border = 0
   740  	edit.Rounding = 0
   741  
   742  	/* combo */
   743  	combo = &style.Combo
   744  
   745  	combo.Normal = MakeItemColor(table.ColorCombo)
   746  	combo.Hover = MakeItemColor(table.ColorCombo)
   747  	combo.Active = MakeItemColor(table.ColorCombo)
   748  	combo.BorderColor = table.ColorBorder
   749  	combo.LabelNormal = table.ColorText
   750  	combo.LabelHover = table.ColorText
   751  	combo.LabelActive = table.ColorText
   752  	combo.SymNormal = label.SymbolTriangleDown
   753  	combo.SymHover = label.SymbolTriangleDown
   754  	combo.SymActive = label.SymbolTriangleDown
   755  	combo.ContentPadding = image.Point{4, 4}
   756  	combo.ButtonPadding = image.Point{0, 4}
   757  	combo.Spacing = image.Point{4, 0}
   758  	combo.Border = 1
   759  	combo.Rounding = 0
   760  
   761  	/* combo button */
   762  	button = &style.Combo.Button
   763  
   764  	*button = Button{}
   765  	button.Normal = MakeItemColor(table.ColorCombo)
   766  	button.Hover = MakeItemColor(table.ColorCombo)
   767  	button.Active = MakeItemColor(table.ColorCombo)
   768  	button.BorderColor = color.RGBA{0, 0, 0, 0}
   769  	button.TextBackground = table.ColorCombo
   770  	button.TextNormal = table.ColorText
   771  	button.TextHover = table.ColorText
   772  	button.TextActive = table.ColorText
   773  	button.Padding = image.Point{2.0, 2.0}
   774  	button.TouchPadding = image.Point{0.0, 0.0}
   775  	button.Border = 0.0
   776  	button.SymbolBorderWidth = 1
   777  	button.Rounding = 0.0
   778  	button.DrawBegin = nil
   779  	button.DrawEnd = nil
   780  
   781  	/* tab */
   782  	tab = &style.Tab
   783  
   784  	tab.Background = MakeItemColor(table.ColorTabHeader)
   785  	tab.BorderColor = table.ColorBorder
   786  	tab.Text = table.ColorText
   787  	tab.SymMinimize = label.SymbolTriangleDown
   788  	tab.SymMaximize = label.SymbolTriangleRight
   789  	tab.Border = 1
   790  	tab.Rounding = 0
   791  	tab.Padding = image.Point{4, 4}
   792  	tab.Spacing = image.Point{4, 4}
   793  
   794  	/* tab button */
   795  	button = &style.Tab.TabButton
   796  
   797  	*button = Button{}
   798  	button.Normal = MakeItemColor(table.ColorTabHeader)
   799  	button.Hover = MakeItemColor(table.ColorTabHeader)
   800  	button.Active = MakeItemColor(table.ColorTabHeader)
   801  	button.BorderColor = color.RGBA{0, 0, 0, 0}
   802  	button.TextBackground = table.ColorTabHeader
   803  	button.TextNormal = table.ColorText
   804  	button.TextHover = table.ColorText
   805  	button.TextActive = table.ColorText
   806  	button.Padding = image.Point{2.0, 2.0}
   807  	button.TouchPadding = image.Point{0.0, 0.0}
   808  	button.Border = 0.0
   809  	button.SymbolBorderWidth = 2
   810  	button.Rounding = 0.0
   811  	button.DrawBegin = nil
   812  	button.DrawEnd = nil
   813  
   814  	/* node button */
   815  	button = &style.Tab.NodeButton
   816  
   817  	*button = Button{}
   818  	button.Normal = MakeItemColor(table.ColorWindow)
   819  	button.Hover = MakeItemColor(table.ColorWindow)
   820  	button.Active = MakeItemColor(table.ColorWindow)
   821  	button.BorderColor = color.RGBA{0, 0, 0, 0}
   822  	button.TextBackground = table.ColorTabHeader
   823  	button.TextNormal = table.ColorText
   824  	button.TextHover = table.ColorText
   825  	button.TextActive = table.ColorText
   826  	button.Padding = image.Point{2.0, 2.0}
   827  	button.TouchPadding = image.Point{0.0, 0.0}
   828  	button.Border = 0.0
   829  	button.SymbolBorderWidth = 2
   830  	button.Rounding = 0.0
   831  	button.DrawBegin = nil
   832  	button.DrawEnd = nil
   833  
   834  	/* window header */
   835  	win = &style.NormalWindow
   836  
   837  	win.Header.Align = HeaderRight
   838  	win.Header.CloseSymbol = label.SymbolX
   839  	win.Header.MinimizeSymbol = label.SymbolMinus
   840  	win.Header.MaximizeSymbol = label.SymbolPlus
   841  	win.Header.Normal = MakeItemColor(table.ColorHeader)
   842  	win.Header.Hover = MakeItemColor(table.ColorHeader)
   843  	win.Header.Active = MakeItemColor(table.ColorHeaderFocused)
   844  	win.Header.LabelNormal = table.ColorText
   845  	win.Header.LabelHover = table.ColorText
   846  	win.Header.LabelActive = table.ColorText
   847  	win.Header.LabelPadding = image.Point{2, 2}
   848  	win.Header.Padding = image.Point{2, 2}
   849  	win.Header.Spacing = image.Point{0, 0}
   850  
   851  	/* window header close button */
   852  	button = &style.NormalWindow.Header.CloseButton
   853  
   854  	*button = Button{}
   855  	button.Normal = MakeItemColor(table.ColorHeader)
   856  	button.Hover = MakeItemColor(table.ColorHeader)
   857  	button.Active = MakeItemColor(table.ColorHeaderFocused)
   858  	button.BorderColor = color.RGBA{0, 0, 0, 0}
   859  	button.TextBackground = table.ColorHeader
   860  	button.TextNormal = table.ColorText
   861  	button.TextHover = table.ColorText
   862  	button.TextActive = table.ColorText
   863  	button.Padding = image.Point{0.0, 0.0}
   864  	button.TouchPadding = image.Point{0.0, 0.0}
   865  	button.Border = 0.0
   866  	button.SymbolBorderWidth = 1
   867  	button.Rounding = 0.0
   868  	button.DrawBegin = nil
   869  	button.DrawEnd = nil
   870  
   871  	/* window header minimize button */
   872  	button = &style.NormalWindow.Header.MinimizeButton
   873  
   874  	*button = Button{}
   875  	button.Normal = MakeItemColor(table.ColorHeader)
   876  	button.Hover = MakeItemColor(table.ColorHeader)
   877  	button.Active = MakeItemColor(table.ColorHeaderFocused)
   878  	button.BorderColor = color.RGBA{0, 0, 0, 0}
   879  	button.TextBackground = table.ColorHeader
   880  	button.TextNormal = table.ColorText
   881  	button.TextHover = table.ColorText
   882  	button.TextActive = table.ColorText
   883  	button.Padding = image.Point{0.0, 0.0}
   884  	button.TouchPadding = image.Point{0.0, 0.0}
   885  	button.Border = 0.0
   886  	button.SymbolBorderWidth = 1
   887  	button.Rounding = 0.0
   888  	button.DrawBegin = nil
   889  	button.DrawEnd = nil
   890  
   891  	/* window */
   892  	win.Background = table.ColorWindow
   893  	win.FixedBackground = MakeItemColor(table.ColorWindow)
   894  	win.BorderColor = table.ColorBorder
   895  	win.Scaler = MakeItemColor(table.ColorText)
   896  	win.FooterPadding = image.Point{100, 100}
   897  	win.Rounding = 0.0
   898  	win.ScalerSize = image.Point{9, 9}
   899  	win.Padding = image.Point{0, 0}
   900  	win.Spacing = image.Point{0, 0}
   901  	win.ScrollbarSize = image.Point{10, 10}
   902  	win.MinSize = image.Point{64, 64}
   903  	win.Border = 0
   904  
   905  	style.MenuWindow = style.NormalWindow
   906  	style.TooltipWindow = style.NormalWindow
   907  	style.ComboWindow = style.NormalWindow
   908  	style.ContextualWindow = style.NormalWindow
   909  	style.GroupWindow = style.NormalWindow
   910  
   911  	style.MenuWindow.BorderColor = table.ColorBorder
   912  	style.MenuWindow.Border = 1
   913  	style.MenuWindow.Spacing = image.Point{2, 2}
   914  
   915  	style.TooltipWindow.BorderColor = table.ColorBorder
   916  	style.TooltipWindow.Border = 1
   917  	style.TooltipWindow.Padding = image.Point{2, 2}
   918  
   919  	style.ComboWindow.BorderColor = table.ColorBorder
   920  	style.ComboWindow.Border = 1
   921  
   922  	style.ContextualWindow.BorderColor = table.ColorText
   923  	style.ContextualWindow.Border = 1
   924  
   925  	style.GroupWindow.BorderColor = table.ColorBorder
   926  	style.GroupWindow.Border = 1
   927  	style.GroupWindow.Padding = image.Point{2, 2}
   928  	style.GroupWindow.Spacing = image.Point{2, 2}
   929  
   930  	style.Scale(scaling)
   931  
   932  	return style
   933  }
   934  
   935  func MakeItemImage(img *image.RGBA) Item {
   936  	var i Item
   937  	i.Type = ItemImage
   938  	i.Data.Image = img
   939  	return i
   940  }
   941  
   942  func MakeItemColor(col color.RGBA) Item {
   943  	var i Item
   944  	i.Type = ItemColor
   945  	i.Data.Color = col
   946  	return i
   947  }
   948  
   949  func ItemHide() Item {
   950  	var i Item
   951  	i.Type = ItemColor
   952  	i.Data.Color = color.RGBA{0, 0, 0, 0}
   953  	return i
   954  }
   955  
   956  type Theme int
   957  
   958  const (
   959  	DefaultTheme Theme = iota
   960  	WhiteTheme
   961  	RedTheme
   962  	DarkTheme
   963  )
   964  
   965  var whiteThemeTable = ColorTable{
   966  	ColorText:                  color.RGBA{48, 48, 48, 255},
   967  	ColorWindow:                color.RGBA{207, 207, 207, 255},
   968  	ColorHeader:                color.RGBA{207, 207, 207, 255},
   969  	ColorHeaderFocused:         color.RGBA{0xc3, 0x9a, 0x9a, 255},
   970  	ColorBorder:                color.RGBA{0, 0, 0, 255},
   971  	ColorButton:                color.RGBA{48, 128, 207, 255},
   972  	ColorButtonHover:           color.RGBA{127, 168, 207, 255},
   973  	ColorButtonActive:          color.RGBA{160, 160, 160, 255},
   974  	ColorToggle:                color.RGBA{150, 150, 150, 255},
   975  	ColorToggleHover:           color.RGBA{120, 120, 120, 255},
   976  	ColorToggleCursor:          color.RGBA{207, 207, 207, 255},
   977  	ColorSelect:                color.RGBA{207, 207, 207, 255},
   978  	ColorSelectActive:          color.RGBA{190, 190, 190, 255},
   979  	ColorSlider:                color.RGBA{190, 190, 190, 255},
   980  	ColorSliderCursor:          color.RGBA{80, 80, 80, 255},
   981  	ColorSliderCursorHover:     color.RGBA{48, 48, 48, 255},
   982  	ColorSliderCursorActive:    color.RGBA{60, 60, 60, 255},
   983  	ColorProperty:              color.RGBA{207, 207, 207, 255},
   984  	ColorEdit:                  color.RGBA{150, 150, 150, 255},
   985  	ColorEditCursor:            color.RGBA{0, 0, 0, 255},
   986  	ColorCombo:                 color.RGBA{207, 207, 207, 255},
   987  	ColorChart:                 color.RGBA{160, 160, 160, 255},
   988  	ColorChartColor:            color.RGBA{45, 45, 45, 255},
   989  	ColorChartColorHighlight:   color.RGBA{255, 0, 0, 255},
   990  	ColorScrollbar:             color.RGBA{180, 180, 180, 255},
   991  	ColorScrollbarCursor:       color.RGBA{140, 140, 140, 255},
   992  	ColorScrollbarCursorHover:  color.RGBA{150, 150, 150, 255},
   993  	ColorScrollbarCursorActive: color.RGBA{160, 160, 160, 255},
   994  	ColorTabHeader:             color.RGBA{180, 180, 180, 255},
   995  }
   996  
   997  var redThemeTable = ColorTable{
   998  	ColorText:                  color.RGBA{190, 190, 190, 255},
   999  	ColorWindow:                color.RGBA{30, 33, 40, 215},
  1000  	ColorHeader:                color.RGBA{181, 45, 69, 220},
  1001  	ColorHeaderFocused:         color.RGBA{0xb5, 0x0c, 0x2c, 0xdc},
  1002  	ColorBorder:                color.RGBA{51, 55, 67, 255},
  1003  	ColorButton:                color.RGBA{181, 45, 69, 255},
  1004  	ColorButtonHover:           color.RGBA{190, 50, 70, 255},
  1005  	ColorButtonActive:          color.RGBA{195, 55, 75, 255},
  1006  	ColorToggle:                color.RGBA{51, 55, 67, 255},
  1007  	ColorToggleHover:           color.RGBA{45, 60, 60, 255},
  1008  	ColorToggleCursor:          color.RGBA{181, 45, 69, 255},
  1009  	ColorSelect:                color.RGBA{51, 55, 67, 255},
  1010  	ColorSelectActive:          color.RGBA{181, 45, 69, 255},
  1011  	ColorSlider:                color.RGBA{51, 55, 67, 255},
  1012  	ColorSliderCursor:          color.RGBA{181, 45, 69, 255},
  1013  	ColorSliderCursorHover:     color.RGBA{186, 50, 74, 255},
  1014  	ColorSliderCursorActive:    color.RGBA{191, 55, 79, 255},
  1015  	ColorProperty:              color.RGBA{51, 55, 67, 255},
  1016  	ColorEdit:                  color.RGBA{51, 55, 67, 225},
  1017  	ColorEditCursor:            color.RGBA{190, 190, 190, 255},
  1018  	ColorCombo:                 color.RGBA{51, 55, 67, 255},
  1019  	ColorChart:                 color.RGBA{51, 55, 67, 255},
  1020  	ColorChartColor:            color.RGBA{170, 40, 60, 255},
  1021  	ColorChartColorHighlight:   color.RGBA{255, 0, 0, 255},
  1022  	ColorScrollbar:             color.RGBA{30, 33, 40, 255},
  1023  	ColorScrollbarCursor:       color.RGBA{64, 84, 95, 255},
  1024  	ColorScrollbarCursorHover:  color.RGBA{70, 90, 100, 255},
  1025  	ColorScrollbarCursorActive: color.RGBA{75, 95, 105, 255},
  1026  	ColorTabHeader:             color.RGBA{181, 45, 69, 220},
  1027  }
  1028  
  1029  var darkThemeTable = ColorTable{
  1030  	ColorText:                  color.RGBA{207, 207, 207, 255},
  1031  	ColorWindow:                color.RGBA{48, 48, 48, 255},
  1032  	ColorHeader:                color.RGBA{51, 51, 56, 220},
  1033  	ColorHeaderFocused:         color.RGBA{0x29, 0x29, 0x37, 0xdc},
  1034  	ColorBorder:                color.RGBA{48, 88, 128, 255},
  1035  	ColorButton:                color.RGBA{48, 128, 207, 255},
  1036  	ColorButtonHover:           color.RGBA{58, 93, 121, 255},
  1037  	ColorButtonActive:          color.RGBA{63, 98, 126, 255},
  1038  	ColorToggle:                color.RGBA{50, 58, 61, 255},
  1039  	ColorToggleHover:           color.RGBA{45, 53, 56, 255},
  1040  	ColorToggleCursor:          color.RGBA{48, 128, 207, 255},
  1041  	ColorSelect:                color.RGBA{48, 48, 48, 255},
  1042  	ColorSelectActive:          color.RGBA{48, 128, 207, 255},
  1043  	ColorSlider:                color.RGBA{50, 58, 61, 255},
  1044  	ColorSliderCursor:          color.RGBA{48, 128, 207, 245},
  1045  	ColorSliderCursorHover:     color.RGBA{53, 88, 116, 255},
  1046  	ColorSliderCursorActive:    color.RGBA{58, 93, 121, 255},
  1047  	ColorProperty:              color.RGBA{50, 58, 61, 255},
  1048  	ColorEdit:                  color.RGBA{50, 58, 61, 225},
  1049  	ColorEditCursor:            color.RGBA{207, 207, 207, 255},
  1050  	ColorCombo:                 color.RGBA{50, 58, 61, 255},
  1051  	ColorChart:                 color.RGBA{50, 58, 61, 255},
  1052  	ColorChartColor:            color.RGBA{48, 128, 207, 255},
  1053  	ColorChartColorHighlight:   color.RGBA{255, 0, 0, 255},
  1054  	ColorScrollbar:             color.RGBA{50, 58, 61, 255},
  1055  	ColorScrollbarCursor:       color.RGBA{48, 128, 207, 255},
  1056  	ColorScrollbarCursorHover:  color.RGBA{53, 88, 116, 255},
  1057  	ColorScrollbarCursorActive: color.RGBA{58, 93, 121, 255},
  1058  	ColorTabHeader:             color.RGBA{48, 128, 207, 255},
  1059  }
  1060  
  1061  func FromTheme(theme Theme, scaling float64) *Style {
  1062  	switch theme {
  1063  	case DefaultTheme:
  1064  		fallthrough
  1065  	default:
  1066  		return FromTable(defaultThemeTable, scaling)
  1067  	case WhiteTheme:
  1068  		return FromTable(whiteThemeTable, scaling)
  1069  	case RedTheme:
  1070  		return FromTable(redThemeTable, scaling)
  1071  	case DarkTheme:
  1072  		return FromTable(darkThemeTable, scaling)
  1073  	}
  1074  }
  1075  
  1076  func (style *Style) Unscaled() *Style {
  1077  	if style.unscaled == nil {
  1078  		unscaled := &Style{}
  1079  		*unscaled = *style
  1080  		style.unscaled = unscaled
  1081  	}
  1082  
  1083  	return style.unscaled
  1084  }
  1085  
  1086  func (style *Style) Scale(scaling float64) {
  1087  	unscaled := style.unscaled
  1088  	if unscaled != nil {
  1089  		*style = *unscaled
  1090  		style.unscaled = unscaled
  1091  	} else {
  1092  		unscaled = &Style{}
  1093  		*unscaled = *style
  1094  		style.unscaled = unscaled
  1095  	}
  1096  
  1097  	style.Scaling = scaling
  1098  
  1099  	if style.Font == (font.Face{}) || style.defaultFont == style.Font {
  1100  		style.DefaultFont(scaling)
  1101  		style.defaultFont = style.Font
  1102  	} else {
  1103  		style.defaultFont = font.Face{}
  1104  	}
  1105  
  1106  	style.unscaled.Font = style.Font
  1107  	style.unscaled.defaultFont = style.defaultFont
  1108  
  1109  	if scaling == 1.0 {
  1110  		return
  1111  	}
  1112  
  1113  	scale := func(x *int) {
  1114  		*x = int(float64(*x) * scaling)
  1115  	}
  1116  
  1117  	scaleu := func(x *uint16) {
  1118  		*x = uint16(float64(*x) * scaling)
  1119  	}
  1120  
  1121  	scalept := func(p *image.Point) {
  1122  		if scaling == 1.0 {
  1123  			return
  1124  		}
  1125  		scale(&p.X)
  1126  		scale(&p.Y)
  1127  	}
  1128  
  1129  	scalebtn := func(button *Button) {
  1130  		scalept(&button.Padding)
  1131  		scalept(&button.ImagePadding)
  1132  		scalept(&button.TouchPadding)
  1133  		scale(&button.Border)
  1134  		scale(&button.SymbolBorderWidth)
  1135  		scaleu(&button.Rounding)
  1136  	}
  1137  
  1138  	z := style
  1139  
  1140  	scalept(&z.Text.Padding)
  1141  
  1142  	scalebtn(&z.Button)
  1143  	scalebtn(&z.ContextualButton)
  1144  	scalebtn(&z.MenuButton)
  1145  
  1146  	scalept(&z.Checkbox.Padding)
  1147  	scalept(&z.Checkbox.TouchPadding)
  1148  
  1149  	scalept(&z.Option.Padding)
  1150  	scalept(&z.Option.TouchPadding)
  1151  
  1152  	scalept(&z.Selectable.Padding)
  1153  	scalept(&z.Selectable.TouchPadding)
  1154  	scaleu(&z.Selectable.Rounding)
  1155  
  1156  	scalept(&z.Slider.CursorSize)
  1157  	scalept(&z.Slider.Padding)
  1158  	scalept(&z.Slider.Spacing)
  1159  	scaleu(&z.Slider.Rounding)
  1160  	scale(&z.Slider.BarHeight)
  1161  
  1162  	scalebtn(&z.Slider.IncButton)
  1163  
  1164  	scalept(&z.Progress.Padding)
  1165  	scaleu(&z.Progress.Rounding)
  1166  
  1167  	scalept(&z.Scrollh.Padding)
  1168  	scale(&z.Scrollh.Border)
  1169  	scaleu(&z.Scrollh.Rounding)
  1170  
  1171  	scalebtn(&z.Scrollh.IncButton)
  1172  	scalebtn(&z.Scrollh.DecButton)
  1173  	scalebtn(&z.Scrollv.IncButton)
  1174  	scalebtn(&z.Scrollv.DecButton)
  1175  
  1176  	scaleedit := func(edit *Edit) {
  1177  		scale(&edit.RowPadding)
  1178  		scalept(&edit.Padding)
  1179  		scalept(&edit.ScrollbarSize)
  1180  		scale(&edit.Border)
  1181  		scaleu(&edit.Rounding)
  1182  	}
  1183  
  1184  	scaleedit(&z.Edit)
  1185  
  1186  	scalept(&z.Property.Padding)
  1187  	scale(&z.Property.Border)
  1188  	scaleu(&z.Property.Rounding)
  1189  
  1190  	scalebtn(&z.Property.IncButton)
  1191  	scalebtn(&z.Property.DecButton)
  1192  
  1193  	scaleedit(&z.Property.Edit)
  1194  
  1195  	scalept(&z.Combo.ContentPadding)
  1196  	scalept(&z.Combo.ButtonPadding)
  1197  	scalept(&z.Combo.Spacing)
  1198  	scale(&z.Combo.Border)
  1199  	scaleu(&z.Combo.Rounding)
  1200  
  1201  	scalebtn(&z.Combo.Button)
  1202  
  1203  	scale(&z.Tab.Border)
  1204  	scaleu(&z.Tab.Rounding)
  1205  	scalept(&z.Tab.Padding)
  1206  	scalept(&z.Tab.Spacing)
  1207  
  1208  	scalebtn(&z.Tab.TabButton)
  1209  	scalebtn(&z.Tab.NodeButton)
  1210  
  1211  	scalewin := func(win *Window) {
  1212  		scalept(&win.Header.Padding)
  1213  		scalept(&win.Header.Spacing)
  1214  		scalept(&win.Header.LabelPadding)
  1215  		scalebtn(&win.Header.CloseButton)
  1216  		scalebtn(&win.Header.MinimizeButton)
  1217  		scalept(&win.FooterPadding)
  1218  		scaleu(&win.Rounding)
  1219  		scalept(&win.ScalerSize)
  1220  		scalept(&win.Padding)
  1221  		scalept(&win.Spacing)
  1222  		scalept(&win.ScrollbarSize)
  1223  		scalept(&win.MinSize)
  1224  		scale(&win.Border)
  1225  	}
  1226  
  1227  	scalewin(&z.NormalWindow)
  1228  	scalewin(&z.MenuWindow)
  1229  	scalewin(&z.TooltipWindow)
  1230  	scalewin(&z.ComboWindow)
  1231  	scalewin(&z.ContextualWindow)
  1232  	scalewin(&z.GroupWindow)
  1233  }
  1234  
  1235  func (style *Style) DefaultFont(scaling float64) {
  1236  	style.Font = font.DefaultFont(12, scaling)
  1237  	style.defaultFont = style.Font
  1238  }
  1239  
  1240  func (style *Style) Defaults() {
  1241  	if style.Scaling == 0.0 {
  1242  		style.Scaling = 1.0
  1243  	}
  1244  	if style.Font == (font.Face{}) {
  1245  		style.DefaultFont(style.Scaling)
  1246  	}
  1247  }