styles.qml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. // Copyright (c) 2015 Ultimaker B.V.
  2. // Cura is released under the terms of the AGPLv3 or higher.
  3. import QtQuick 2.1
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Controls.Styles 1.1
  6. import UM 1.0 as UM
  7. QtObject {
  8. property Component sidebar_header_button: Component {
  9. ButtonStyle {
  10. background: Item {
  11. Label {
  12. anchors.right: parent.right;
  13. anchors.top: parent.top;
  14. text: "▼";
  15. property bool down: control.pressed || (control.checkable && control.checked);
  16. color: down ? UM.Theme.colors.text_pressed : control.hovered ? UM.Theme.colors.text_hover : UM.Theme.colors.text;
  17. }
  18. }
  19. label: Label {
  20. property bool down: control.pressed || (control.checkable && control.checked);
  21. font: UM.Theme.fonts.sidebar_header;
  22. color: down ? UM.Theme.colors.text_pressed : control.hovered ? UM.Theme.colors.text_hover : UM.Theme.colors.text;
  23. text: control.text;
  24. elide: Text.ElideRight;
  25. }
  26. }
  27. }
  28. property Component open_file_button: Component {
  29. ButtonStyle {
  30. background: Item {
  31. implicitWidth: UM.Theme.sizes.button.width;
  32. implicitHeight: UM.Theme.sizes.button.height;
  33. Rectangle {
  34. anchors.bottom: parent.verticalCenter;
  35. width: parent.width;
  36. height: control.hovered ? parent.height / 2 + label.height : 0;
  37. Behavior on height { NumberAnimation { duration: 100; } }
  38. opacity: control.hovered ? 1.0 : 0.0;
  39. Behavior on opacity { NumberAnimation { duration: 100; } }
  40. Label {
  41. id: label;
  42. anchors.horizontalCenter: parent.horizontalCenter;
  43. text: control.text.replace("&", "");
  44. font: UM.Theme.fonts.button_tooltip;
  45. color: UM.Theme.colors.button_tooltip_text;
  46. }
  47. }
  48. UM.AngledCornerRectangle {
  49. anchors.fill: parent;
  50. color: {
  51. if(control.hovered) {
  52. return UM.Theme.colors.button_active_hover;
  53. } else {
  54. return UM.Theme.colors.button_active;
  55. }
  56. }
  57. Behavior on color { ColorAnimation { duration: 50; } }
  58. cornerSize: UM.Theme.sizes.default_margin.width;
  59. }
  60. }
  61. label: Item {
  62. Image {
  63. anchors.centerIn: parent;
  64. source: control.iconSource;
  65. width: UM.Theme.sizes.button_icon.width;
  66. height: UM.Theme.sizes.button_icon.height;
  67. sourceSize: UM.Theme.sizes.button_icon;
  68. }
  69. }
  70. }
  71. }
  72. property Component tool_button: Component {
  73. ButtonStyle {
  74. background: Item {
  75. ///////////TODO CHANGE SIZES!!
  76. implicitWidth: UM.Theme.sizes.button.width;
  77. implicitHeight: UM.Theme.sizes.button.height;
  78. Rectangle {
  79. id: tool_button_background
  80. anchors.top: parent.verticalCenter;
  81. width: parent.width;
  82. ///////////TODO CHANGE LABELHEIGHT!!
  83. height: control.hovered ? parent.height / 2 + label.height : 0;
  84. Behavior on height { NumberAnimation { duration: 100; } }
  85. opacity: control.hovered ? 1.0 : 0.0;
  86. Behavior on opacity { NumberAnimation { duration: 100; } }
  87. Label {
  88. id: label
  89. anchors.bottom: parent.bottom
  90. text: control.text.replace("&", "");
  91. font: UM.Theme.fonts.button_tooltip;
  92. color: UM.Theme.colors.button_tooltip_text;
  93. }
  94. }
  95. Rectangle {
  96. id: buttonFace;
  97. anchors.fill: parent;
  98. property bool down: control.pressed || (control.checkable && control.checked);
  99. color: {
  100. if(!control.enabled) {
  101. return UM.Theme.colors.button_disabled;
  102. } else if(control.checkable && control.checked && control.hovered) {
  103. return UM.Theme.colors.button_active_hover;
  104. } else if(control.pressed || (control.checkable && control.checked)) {
  105. return UM.Theme.colors.button_active;
  106. } else if(control.hovered) {
  107. return UM.Theme.colors.button_hover;
  108. } else {
  109. return UM.Theme.colors.button;
  110. }
  111. }
  112. Behavior on color { ColorAnimation { duration: 50; } }
  113. Label {
  114. anchors.right: parent.right;
  115. anchors.rightMargin: UM.Theme.sizes.default_margin.width / 2;
  116. anchors.verticalCenter: parent.verticalCenter;
  117. text: "▼";
  118. font: UM.Theme.fonts.small;
  119. visible: control.menu != null;
  120. color: "white";
  121. }
  122. }
  123. }
  124. label: Item {
  125. Image {
  126. anchors.centerIn: parent;
  127. source: control.iconSource;
  128. width: UM.Theme.sizes.button_icon.width;
  129. height: UM.Theme.sizes.button_icon.height;
  130. sourceSize: UM.Theme.sizes.button_icon;
  131. }
  132. }
  133. }
  134. }
  135. property Component progressbar: Component{
  136. ProgressBarStyle {
  137. background: UM.AngledCornerRectangle {
  138. cornerSize: UM.Theme.sizes.progressbar_control.height
  139. implicitWidth: UM.Theme.sizes.progressbar.width
  140. implicitHeight: UM.Theme.sizes.progressbar.height
  141. color: UM.Theme.colors.progressbar_background
  142. }
  143. progress: UM.AngledCornerRectangle {
  144. cornerSize: UM.Theme.sizes.progressbar_control.height
  145. color: control.indeterminate ? "transparent" : UM.Theme.colors.progressbar_control
  146. UM.AngledCornerRectangle {
  147. cornerSize: UM.Theme.sizes.progressbar_control.height
  148. color: UM.Theme.colors.progressbar_control
  149. width: UM.Theme.sizes.progressbar_control.width
  150. height: UM.Theme.sizes.progressbar_control.height
  151. visible: control.indeterminate
  152. SequentialAnimation on x {
  153. id: xAnim
  154. property int animEndPoint: UM.Theme.sizes.progressbar.width - UM.Theme.sizes.progressbar_control.width
  155. running: control.indeterminate
  156. loops: Animation.Infinite
  157. NumberAnimation { from: 0; to: xAnim.animEndPoint; duration: 2000;}
  158. NumberAnimation { from: xAnim.animEndPoint; to: 0; duration: 2000;}
  159. }
  160. }
  161. }
  162. }
  163. }
  164. property Component sidebar_category: Component {
  165. ButtonStyle {
  166. background: UM.AngledCornerRectangle {
  167. implicitHeight: UM.Theme.sizes.section.height;
  168. color: {
  169. if(control.color) {
  170. return control.color;
  171. } else if(!control.enabled) {
  172. return UM.Theme.colors.setting_category_disabled;
  173. } else if(control.hovered && control.checkable && control.checked) {
  174. return UM.Theme.colors.setting_category_active_hover;
  175. } else if(control.pressed || (control.checkable && control.checked)) {
  176. return UM.Theme.colors.setting_category_active;
  177. } else if(control.hovered) {
  178. return UM.Theme.colors.setting_category_hover;
  179. } else {
  180. return UM.Theme.colors.setting_category;
  181. }
  182. }
  183. Behavior on color { ColorAnimation { duration: 50; } }
  184. cornerSize: UM.Theme.sizes.default_margin.width;
  185. }
  186. label: Item {
  187. anchors.fill: parent;
  188. anchors.margins: UM.Theme.sizes.default_margin.width;
  189. Image {
  190. id: icon;
  191. anchors.left: parent.left;
  192. anchors.verticalCenter: parent.verticalCenter;
  193. source: control.iconSource;
  194. width: UM.Theme.sizes.section_icon.width;
  195. height: UM.Theme.sizes.section_icon.height;
  196. }
  197. Label {
  198. anchors {
  199. left: icon.right;
  200. leftMargin: UM.Theme.sizes.default_margin.width;
  201. right: parent.right;
  202. verticalCenter: parent.verticalCenter;
  203. }
  204. text: control.text;
  205. font: UM.Theme.fonts.setting_category;
  206. color: UM.Theme.colors.setting_category_text;
  207. fontSizeMode: Text.HorizontalFit;
  208. minimumPointSize: 8
  209. }
  210. }
  211. }
  212. }
  213. property Component scrollview: Component {
  214. ScrollViewStyle {
  215. decrementControl: Item { }
  216. incrementControl: Item { }
  217. transientScrollBars: false
  218. scrollBarBackground: UM.AngledCornerRectangle {
  219. implicitWidth: UM.Theme.sizes.scrollbar.width;
  220. cornerSize: UM.Theme.sizes.scrollbar.width;
  221. color: UM.Theme.colors.scrollbar_background;
  222. }
  223. handle: UM.AngledCornerRectangle {
  224. id: scrollViewHandle
  225. implicitWidth: UM.Theme.sizes.scrollbar.width;
  226. cornerSize: UM.Theme.sizes.scrollbar.width;
  227. color: styleData.pressed ? UM.Theme.colors.scrollbar_handle_down : styleData.hovered ? UM.Theme.colors.scrollbar_handle_hover : UM.Theme.colors.scrollbar_handle;
  228. Behavior on color { ColorAnimation { duration: 50; } }
  229. }
  230. }
  231. }
  232. property variant setting_item: UM.SettingItemStyle {
  233. labelFont: UM.Theme.fonts.default;
  234. labelColor: UM.Theme.colors.setting_label;
  235. spacing: UM.Theme.sizes.default_margin.width;
  236. fixedHeight: UM.Theme.sizes.setting.height;
  237. controlWidth: UM.Theme.sizes.setting_control.width;
  238. controlRightMargin: UM.Theme.sizes.setting_control_margin.width;
  239. controlBorderWidth: 1;
  240. controlColor: UM.Theme.colors.setting_control;
  241. controlHighlightColor: UM.Theme.colors.setting_control_highlight;
  242. controlBorderColor: UM.Theme.colors.setting_control_border;
  243. controlTextColor: UM.Theme.colors.setting_control_text;
  244. controlFont: UM.Theme.fonts.default;
  245. validationErrorColor: UM.Theme.colors.setting_validation_error;
  246. validationWarningColor: UM.Theme.colors.setting_validation_warning;
  247. validationOkColor: UM.Theme.colors.setting_validation_ok;
  248. unitRightMargin: UM.Theme.sizes.setting_unit_margin.width;
  249. unitColor: UM.Theme.colors.setting_unit;
  250. unitFont: UM.Theme.fonts.default;
  251. }
  252. property Component checkbox: Component {
  253. CheckBoxStyle {
  254. background: Item { }
  255. indicator: Rectangle {
  256. implicitWidth: UM.Theme.sizes.checkbox.width;
  257. implicitHeight: UM.Theme.sizes.checkbox.height;
  258. color: control.hovered ? UM.Theme.colors.checkbox_hover : UM.Theme.colors.checkbox;
  259. Behavior on color { ColorAnimation { duration: 50; } }
  260. border.width: 1
  261. border.color: UM.Theme.colors.checkbox_border;
  262. Label {
  263. anchors.centerIn: parent;
  264. color: UM.Theme.colors.checkbox_mark;
  265. text: "✓";
  266. opacity: control.checked ? 1 : 0;
  267. Behavior on opacity { NumberAnimation { duration: 100; } }
  268. }
  269. }
  270. label: Label {
  271. text: control.text;
  272. color: UM.Theme.colors.checkbox_text;
  273. font: UM.Theme.fonts.default;
  274. }
  275. }
  276. }
  277. property Component slider: Component {
  278. SliderStyle {
  279. groove: Rectangle {
  280. implicitWidth: control.width;
  281. implicitHeight: UM.Theme.sizes.slider_groove.height;
  282. color: UM.Theme.colors.slider_groove;
  283. border.width: 1;
  284. border.color: UM.Theme.colors.slider_groove_border;
  285. Rectangle {
  286. anchors {
  287. left: parent.left;
  288. top: parent.top;
  289. bottom: parent.bottom;
  290. }
  291. color: UM.Theme.colors.slider_groove_fill;
  292. width: (control.value / (control.maximumValue - control.minimumValue)) * parent.width;
  293. }
  294. }
  295. handle: Rectangle {
  296. width: UM.Theme.sizes.slider_handle.width;
  297. height: UM.Theme.sizes.slider_handle.height;
  298. color: control.hovered ? UM.Theme.colors.slider_handle_hover : UM.Theme.colors.slider_handle;
  299. Behavior on color { ColorAnimation { duration: 50; } }
  300. }
  301. }
  302. }
  303. property Component layerViewSlider: Component {
  304. SliderStyle {
  305. groove: Rectangle {
  306. id: layerSliderGroove
  307. implicitWidth: control.width;
  308. implicitHeight: UM.Theme.sizes.slider_groove.height;
  309. color: UM.Theme.colors.slider_groove;
  310. border.width: 1;
  311. border.color: UM.Theme.colors.slider_groove_border;
  312. Rectangle {
  313. anchors {
  314. left: parent.left;
  315. top: parent.top;
  316. bottom: parent.bottom;
  317. }
  318. color: UM.Theme.colors.slider_groove_fill;
  319. width: (control.value / (control.maximumValue - control.minimumValue)) * parent.width;
  320. }
  321. Label {
  322. id: maxValueLabel
  323. visible: UM.LayerView.getLayerActivity && Printer.getPlatformActivity ? true : false
  324. text: control.maximumValue + 1
  325. font: control.maximumValue > 998 ? UM.Theme.fonts.small : UM.Theme.fonts.default
  326. transformOrigin: Item.BottomLeft
  327. rotation: 90
  328. x: parent.x + parent.width - maxValueLabel.height
  329. y: control.maximumValue > 998 ? parent.y + UM.Theme.sizes.slider_layerview_smalltext_margin.width : parent.y
  330. }
  331. Label {
  332. id: minValueLabel
  333. visible: UM.LayerView.getLayerActivity && Printer.getPlatformActivity ? true : false
  334. text: '1'
  335. font: control.maximumValue > 998 ? UM.Theme.fonts.small : UM.Theme.fonts.default
  336. transformOrigin: Item.BottomLeft
  337. rotation: 90
  338. x: parent.x
  339. y: control.maximumValue > 998 ? parent.y + UM.Theme.sizes.slider_layerview_smalltext_margin.width : parent.y
  340. }
  341. }
  342. handle: Rectangle {
  343. id: layerSliderControl
  344. width: UM.Theme.sizes.slider_handle.width;
  345. height: UM.Theme.sizes.slider_handle.height;
  346. color: control.hovered ? UM.Theme.colors.slider_handle_hover : UM.Theme.colors.slider_handle;
  347. Behavior on color { ColorAnimation { duration: 50; } }
  348. Label {
  349. id: valueLabel
  350. visible: UM.LayerView.getLayerActivity && Printer.getPlatformActivity ? true : false
  351. text: control.value + 1
  352. anchors.bottom: layerSliderControl.bottom
  353. anchors.right: layerSliderControl.left
  354. anchors.bottomMargin: parent.width + UM.Theme.sizes.default_margin.width
  355. font: UM.Theme.fonts.default
  356. transformOrigin: Item.BottomRight
  357. rotation: 90
  358. Rectangle {
  359. width: (parent.width + UM.Theme.sizes.tooltip_margins.width) < 35 ? 35 : parent.width + UM.Theme.sizes.tooltip_margins.width
  360. height: parent.height + (UM.Theme.sizes.tooltip_margins.height / 2)
  361. anchors.verticalCenter: parent.verticalCenter
  362. anchors.horizontalCenter: parent.horizontalCenter
  363. z: parent.z - 1
  364. color: UM.Theme.colors.slider_text_background
  365. border.width: 1
  366. border.color: UM.Theme.colors.slider_groove_fill;
  367. }
  368. }
  369. }
  370. }
  371. }
  372. property Component text_field: Component {
  373. TextFieldStyle {
  374. textColor: UM.Theme.colors.setting_control_text;
  375. font: UM.Theme.fonts.default;
  376. background: Rectangle
  377. {
  378. implicitHeight: control.height;
  379. implicitWidth: control.width;
  380. border.width: 1;
  381. border.color: UM.Theme.colors.setting_control_border;
  382. color: UM.Theme.colors.setting_validation_ok;
  383. Label {
  384. anchors.right: parent.right;
  385. anchors.rightMargin: UM.Theme.sizes.setting_unit_margin.width;
  386. anchors.verticalCenter: parent.verticalCenter;
  387. text: control.unit ? control.unit : ""
  388. color: UM.Theme.colors.setting_unit;
  389. font: UM.Theme.fonts.default;
  390. }
  391. }
  392. }
  393. }
  394. }