RCSS.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * This source file is part of libRocket, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://www.librocket.com
  5. *
  6. * Copyright (c) 2019 Michael R. P. Ragazzon
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. *
  26. */
  27. #ifndef ROCKETCORERCSS_H
  28. #define ROCKETCORERCSS_H
  29. namespace Rocket {
  30. namespace Core {
  31. #include "../../Include/Rocket/Core/Types.h"
  32. namespace Style
  33. {
  34. struct LengthPercentageAuto {
  35. enum Type { Length, Percentage, Auto } type = Length;
  36. float value = 0;
  37. LengthPercentageAuto() {}
  38. LengthPercentageAuto(Type type, float value = 0) : type(type), value(value) {}
  39. };
  40. struct LengthPercentage {
  41. enum Type { Length, Percentage } type = Length;
  42. float value = 0;
  43. };
  44. struct NumberAuto {
  45. enum Type { Number, Auto } type = Number;
  46. float value = 0;
  47. NumberAuto() {}
  48. NumberAuto(Type type, float value = 0) : type(type), value(value) {}
  49. };
  50. enum class Display { None, Block, Inline, InlineBlock };
  51. enum class Position { Static, Relative, Absolute, Fixed };
  52. enum class Float { None, Left, Right };
  53. enum class Clear { None, Left, Right, Both };
  54. struct VerticalAlign {
  55. enum Type { Baseline, Middle, Sub, Super, TextTop, TextBottom, Top, Bottom, Length } type = Baseline;
  56. float value = 0; // For length type
  57. };
  58. enum class Overflow { Visible, Hidden, Auto, Scroll };
  59. enum class Clip { None = -1, Auto = 0, NumberStart = 1}; // Can contain any positive value as number
  60. enum class Visibility { Visible, Hidden };
  61. enum class FontStyle { Normal, Italic };
  62. enum class FontWeight { Normal, Bold };
  63. enum class TextAlign { Left, Right, Center, Justify };
  64. enum class TextDecoration { None, Underline };
  65. enum class TextTransform { None, Capitalize, Uppercase, Lowercase };
  66. enum class WhiteSpace { Normal, Pre, Nowrap, Prewrap, Preline };
  67. enum class Drag { None, Drag, DragDrop, Block, Clone };
  68. enum class TabIndex { None, Auto };
  69. enum class Focus { None, Auto };
  70. enum class PointerEvents { None, Auto };
  71. struct ComputedValues
  72. {
  73. LengthPercentageAuto margin_top, margin_right, margin_bottom, margin_left;
  74. LengthPercentage padding_top, padding_right, padding_bottom, padding_left;
  75. float border_top_width = 0, border_right_width = 0, border_bottom_width = 0, border_left_width = 0;
  76. Colourb border_top_color{ 255, 255, 255 }, border_right_color{ 255, 255, 255 }, border_bottom_color{ 255, 255, 255 }, border_left_color{ 255, 255, 255 };
  77. Display display = Display::Inline;
  78. Position position = Position::Static;
  79. LengthPercentageAuto top{ LengthPercentageAuto::Auto }, right{ LengthPercentageAuto::Auto }, bottom{ LengthPercentageAuto::Auto }, left{ LengthPercentageAuto::Auto };
  80. Float _float = Float::None;
  81. Clear clear = Clear::None;
  82. NumberAuto z_index = { NumberAuto::Auto };
  83. LengthPercentageAuto width = { LengthPercentageAuto::Auto };
  84. LengthPercentage min_width, max_width;
  85. LengthPercentageAuto height = { LengthPercentageAuto::Auto };
  86. LengthPercentage min_height, max_height;
  87. float line_height = 1.2f;
  88. VerticalAlign vertical_align;
  89. Overflow overflow_x = Overflow::Visible, overflow_y = Overflow::Visible;
  90. Clip clip = Clip::Auto;
  91. Visibility visibility = Visibility::Visible;
  92. Colourb background_color = Colourb(255, 255, 255, 0);
  93. Colourb color = Colourb(255, 255, 255);
  94. Colourb image_color = Colourb(255, 255, 255);
  95. float opacity = 1;
  96. String font_family;
  97. String font_charset; // empty is same as "U+0020-007E"
  98. FontStyle font_style = FontStyle::Normal;
  99. FontWeight font_weight = FontWeight::Normal;
  100. float font_size = 12.f;
  101. TextAlign text_align = TextAlign::Left;
  102. TextDecoration text_decoration = TextDecoration::None;
  103. TextTransform text_transform = TextTransform::None;
  104. WhiteSpace white_space = WhiteSpace::Normal;
  105. String cursor;
  106. Drag drag = Drag::None;
  107. TabIndex tab_index = TabIndex::None;
  108. Focus focus = Focus::Auto;
  109. float scrollbar_margin = 0;
  110. PointerEvents pointer_events = PointerEvents::Auto;
  111. float perspective = 0;
  112. float perspective_origin_x = 0.5f, perspective_origin_y = 0.5f; // Relative
  113. String transform;
  114. float transform_origin_x = 0.5f, transform_origin_y = 0.5f, transform_origin_z = 0.f;
  115. String transition; // empty is same as "none"
  116. String animation; // empty is same as "none"
  117. };
  118. }
  119. using ComputedValues = Style::ComputedValues;
  120. }
  121. }
  122. #endif