styles.qml 20 KB

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