style.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. package style
  2. import . "gitlab.com/beoran/ebsgo/zori/types"
  3. type Flag int
  4. const (
  5. BORDER = Flag(1)
  6. FILL = Flag(2)
  7. DEFAULT = Flag(3)
  8. )
  9. /**
  10. * For style: not all combinations make sense. How to improve this?
  11. *
  12. * What is available in CSS 1:
  13. *
  14. * font : font of the text (with many sub details in CCS not relevant here).
  15. * color: text color of an element
  16. * background-color: background color of an element.
  17. * background-image: background image of an element.
  18. * background-repeat: determines how/if the image is repeated.
  19. * background-attachment: fixed with regard to the canvas.
  20. * background-position: initial position of the background image.
  21. * word-spacing: text spacing
  22. * letter-spacing: text spacing
  23. * text-decoration: text decoration (underline, overline, etc)
  24. * vertical-align: vertical alignment, top, center, bottom based on the parent.
  25. * text-transform:
  26. * text-align: text alignment, left, right, centered.
  27. * text-indent: Text indentation.
  28. * line-height: Height of a line of text.
  29. * margin: sizes of the margin
  30. * padding: sizes of the padding
  31. * border-width: sizes of the border
  32. * border-color: color of the border
  33. * border-style: style of the border (per side)
  34. * border: border style, general of per side
  35. * width: width of the box
  36. * height: height of the box
  37. * float: floating
  38. * clear: float control
  39. * display: display type (visual, block, hiden, none, etc)
  40. * white-space: white space display.
  41. * list-style: list styling with type, image and position of the image.
  42. *
  43. * Squeezing it down to an essential subset we can retain the following:
  44. *
  45. * text.font : Font for texts.
  46. * text.color : Color for texts.
  47. * text.flags : Style flags, merges horizontal alignment, decoration, etc.
  48. *
  49. * back.color : Background color.
  50. * back.image : Background image.
  51. * back.flags : Style flags, solid background, no background, etc.
  52. * back.radius : Size of corner for image_scale9 algorithm.
  53. *
  54. * border.color : Border color.
  55. * border.size : Border size (thickness).
  56. * border.flags : Border style flags.
  57. * border.radius: Rounded corners radius.
  58. *
  59. * cursor.color : Text cursor color.
  60. *
  61. * mouse.back : Mouse cursor background information.
  62. * mouse.border : Mouse cursor border.
  63. * keyjoy.back : Keyjoy cursor background information.
  64. * keyjoy.border : Keyjoy cursor border.
  65. *
  66. *
  67. * width, height, margins and padding are not considered style but positioning.
  68. * The keyjoy and mouse cursor and a border are only available
  69. * per-screen.
  70. *
  71. * The text cursor has a color only.
  72. *
  73. * 1. Text can have a font, a color and font flags (centered, etc)
  74. * 2. A rectangle / container / widget can have a background image combined
  75. * with a background color it can have draw flags for the background image and
  76. * for the color (fill or not). Furthermore it can have a border color.
  77. * Possibly (through not suupported now) would be a background
  78. *
  79. *
  80. */
  81. type Basic struct {
  82. Color Color
  83. Bitmap
  84. Flag
  85. Radius int
  86. }
  87. /* The style of the background of a widget. */
  88. type Background struct {
  89. Basic
  90. }
  91. /* The style of the border of a widget. */
  92. type Border struct {
  93. Basic
  94. Size int
  95. }
  96. /* A text style has all elements needed to style a piece of text.
  97. * It consists of the text color, font and font flags flags applied to a part of the GUI.
  98. */
  99. type Text struct {
  100. Color
  101. Font
  102. }
  103. /* A theme is a set of style elements for a widget or cursor. */
  104. type Theme struct {
  105. Background
  106. Border
  107. Text
  108. }
  109. type Themed interface {
  110. Theme() * Theme
  111. }
  112. type BasicTheme struct {
  113. MyTheme Theme
  114. }
  115. func (bs BasicTheme) Theme() * Theme {
  116. return & bs.MyTheme
  117. }