aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/nativestyle/items
Commit message (Collapse)AuthorAgeFilesLines
* Native style/Slider: Fix tickmarks and groove for fractional numbersJan Arve Sæther2020-10-191-6/+13
| | | | | | | | | In QQuickSlider, this was very noticeable for very short ranges (e.g. a range less than 1). It also caused wrong rendering of the groove on macOS style. Change-Id: I8a88b2e107e543f5b0cef5a7093b94b08ebeb398 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Nativestyle: Slider on WindowsJan Arve Sæther2020-10-191-9/+11
| | | | | Change-Id: Iab1f01a2cccad21e178aaf13ea21469a5ce98fea Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* nativestyle, transitionDuration: make property CONSTANTRichard Moe Gustavsen2020-10-141-2/+1
| | | | | | | | | | | | | | Even if the value of transitionDuration never change, the QML engine will still complain if you use the property in a binding, saying that it's not notifyable. So to silence the engine, make it CONSTANT. Also, in macos/ScrollBar.qml, ensure we actually read the transitionDuration from a styleitem (parent is apparently not). Change-Id: I58e89e8771dd645ecd8a0b75a7e3871845d270be Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Native style, macOS: add scrollviewcornerRichard Moe Gustavsen2020-10-123-0/+180
| | | | | | | | | | | | | On macOS (Big Sur), when a ScrollView has both a vertical and a horizontal scrollbar, we should draw a corner item between them so that they look 'connected'. Since we don't have a way to draw that item using QStyle, we simply grab a section of the center of a ScrollBar groove, and use that to create a corner item. Change-Id: I4e4df25b6769e810e6b046f6842f4424450fecb3 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: add a function imageSize() rather than overriding minimumSizeRichard Moe Gustavsen2020-10-122-9/+14
| | | | | | | | | | | When not using nine patch scaling, we used to override minimumSize to instead be the actual size of the item, since we use minimumSize to also be the size of the image we draw. But this turns out to be confusing, especially while debugging. So introduce a more explicit imageSize() function instead, and leave minimumSize unchanged. Change-Id: I8d3ec25603d430a94b124713fad01bf6d277bbe5 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style, StyleItem: add property 'minimumSize'Richard Moe Gustavsen2020-10-062-0/+13
| | | | | | | | | | | | | Some items, like the scrollbar handle, can scale the handle down to 0 if no minimumSize is set. This will truncate the image drawn by QStyle. This patch will expose the minimum size read from QStyle to the QML control. We can then set ScrollBar.minimumSize to the correct value. Change-Id: Ib87e3ca7ea661bf41ab8057941fec7364b606177 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* nativestyle: SpinBox on WindowsJan Arve Sæther2020-10-061-1/+1
| | | | | Change-Id: I334af68282a59099698e46020b0644318eae5cce Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickStyleMargins: use lowercase for QML type nameMitch Curtis2020-10-021-1/+2
| | | | | | | | | | Value types must be lowercase. Fixes the following error: Invalid QML element name "StyleMargins"; value type names must begin with a lowercase letter Change-Id: I2b0ff7ed60bd8844dec95fa57d196e868c1d671d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Native style: improve debug outputRichard Moe Gustavsen2020-09-302-35/+55
| | | | | | | | | | | | | Improve the debug implementation so that you don't need to modify the application to get debug output. You can now instead just do e.g: QQC2_NATIVESTYLE_DEBUG="myButton output contentRect" QQC2_NATIVESTYLE_DEBUG="combobox ninepatchmargins" QQC2_NATIVESTYLE_DEBUG="all layoutrect" Change-Id: I58cbcfb241bc0be20cae73735bc277d0662a476a Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* windows: Add hover animation to Button and CheckBoxJan Arve Sæther2020-09-294-19/+27
| | | | | | | | Move the hover animation handling API from macOS ScrollBar down to QQuickStyleItem. Change-Id: I36c8b173a15d0f4e10a59b7f3ccfe635e05c73e7 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* NativeStyle: add focusFrameRadius to QStyleRichard Moe Gustavsen2020-09-2910-0/+16
| | | | | | | | | | | To be able to show a focus frame around a control from QML, we need to know the control's geometry and radius. For the geometry we can use the already existing layout rect. But for the latter we need to add focusFrameRadius enums to QStyle using the already existing pixel metric function. Change-Id: I45619194766cccbf824d93073a4dcea3a0893fbe Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* NativeStyle, TextField: add missing layoutRectRichard Moe Gustavsen2020-09-241-0/+1
| | | | | | | | | QQuickStyleItemTextField didn't set a layoutRect. This was just an oversight, and causes layout issues when trying to read it to position the focus frame. Change-Id: Ic959fd315da38e9700dc079c75993feca29c0c61 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: support progressbars with a range from 0 - 1Richard Moe Gustavsen2020-09-171-0/+5
| | | | | | | | | | | | | | A ProgressBar is based on floating point numbers, meaning that it can have e.g from == 0.5, to == 1.5, and value == 0.8. A ProgressBar in QStyle on the other hand is integer-based. So add some extra code to convert floats to ints before passing the values to QStyle. But only do this for ranges smaller than 100, to ensure that we don't overflow ranges that are really large. And let "to" start at 0 in case the range ends close to Number.MAX_VALUE. Change-Id: I2707647911ee31c91b435697d4ae840b304c5c69 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Remove the subControl property from ProgressBarJan Arve Sæther2020-09-102-22/+11
| | | | | | | | | | It shouldn't be needed in the API anymore, since a progress bar will either paint background and contentItem itself, or it won't paint any of those (therefore a custom progress bar have to provide both a background and a contentItem) Change-Id: Ic44fff97f5fc46453e9bbc9cada094b92fbe2aae Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix ProgressBar on WindowsJan Arve Sæther2020-09-091-1/+13
| | | | | | | | | | | | | | Also remove the two custom progress bars from the manual test where one has a custom background, and the other has a custom contentItem. If you want to customize a progress bar, you need to provide customizations for both the background and the contentItem. You cannot provide a custom background (or contentItem) alone, since its almost impossible to create a custom background that fits well with the contentItem of all the other possible styles it might be using. Change-Id: I82a87513e73f319bcecbfaed341ac4949f64c3bb Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Native style: fix namespace buildsRichard Moe Gustavsen2020-09-071-2/+2
| | | | | Change-Id: I7ef28cc93fd4acad9849fecb3d4c2cab79f0acdb Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: make StyleItem::control notifyableRichard Moe Gustavsen2020-08-281-1/+2
| | | | | | | | | | | | Even though 'control' should only be set once and never change, the QML engine will complain if you have a binding to e.g control.pressed, since both 'control' and 'pressed' in theory can change. So add a NOTIFY section to silence the engine. Change-Id: I64b79b7fd163cbeb5de78504f3b58d915edc278b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Native style: add hover effects to ScrollBar on macOSRichard Moe Gustavsen2020-08-262-0/+28
| | | | | Change-Id: I61bb0c2b1fd4dce2939bc4fe91a498a280802cb9 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: don't draw frame around TextAreaRichard Moe Gustavsen2020-08-203-147/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In controls, it's seems to be undefined if the style should draw a frame around TextArea or not. E.g the Imagine style do, but the the Fusion style does not. This is a bit unfortunate, because depending on how you use a TextArea, you might want a frame around the TextArea itself, or the ScrollView around it (including the scrollbars), or not at all (*). For this reason, we should not draw a frame around the TextArea, but leave it to the user to compose the (style independent) structure, e.g Frame { ScrollView { TextArea{} } } Frame { TextArea {} }. TextArea {} This patch will remove drawing a frame around TextArea from the native style. Then at least Fusion, macOS and Windows will work the same way. This also means that we can remove the QQuickStyleItemTextArea, since we end up not using QStyle at all for drawing a TextArea. (*) Compared to Widgets, a QPlainTextEdit inherits from QAbstractScrollArea, which inherits from QFrame. In QFrame, you can choose frameShape, and even set it to NoFrame. Change-Id: Icabfa294744e87ccf262855faa0992f2d71ec4cb Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: add DialRichard Moe Gustavsen2020-06-263-0/+172
| | | | | Change-Id: Iad09b9f6080994528d65dcddc9eda49dbba356f7 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: support checkable buttonsRichard Moe Gustavsen2020-06-261-1/+1
| | | | | Change-Id: Id80add4e7c3611f9a12695745300d335a015cb43 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: move window tests inside window() scopeRichard Moe Gustavsen2020-06-171-2/+2
| | | | | Change-Id: I0c9860eca383b45926fc2134a54807a845d6bc35 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Make sure the focus rect is drawnJan Arve Sæther2020-06-171-4/+9
| | | | | | | | | | | | | | In windows style, the focus rect is drawn when the button is drawn, but we are only drawing the bevel, so the focus rect was not drawn. We move the logic of drawing the focus rect so that it is drawn when drawing the bevel instead. Also, we have to set the QStyle::State_KeyboardFocusChange in order for the focus rect to be drawn Change-Id: I4463ae1dd0f23ecc5bb0a84c563fda33dc6e93c8 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix active focus handlingJan Arve Sæther2020-06-171-3/+3
| | | | | | | | | | We should connect to the control instead of the QQuickStyleItem This was also the case for the "enabled" and "window" properties (however, they worked fine, since those properties are inherited by the parent/child relationship) Change-Id: Ibcc5dbe8ea10201db558a534e46233617093e9b7 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Native style: add ProgressBarRichard Moe Gustavsen2020-06-173-0/+171
| | | | | Change-Id: Ie48002b083615afd4f8f8ab3b1303a8f5c39f81b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* NativeStyle: add ScrollBarRichard Moe Gustavsen2020-06-123-0/+167
| | | | | Change-Id: Ied2055866a67798ce60105e7251740a3e66b38db Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: remove prefix ('show', 'print') from the debug flagsRichard Moe Gustavsen2020-06-122-19/+25
| | | | | | | | Having them just complicates setting debug flags from QML. Add a separate debug flag "NinePatchMargins" in the drive-by. Change-Id: I56e1cc6f36368976b9325829816ab5a1bdb1f4ba Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Native style: draw contentRect using marginsRichard Moe Gustavsen2020-06-121-2/+6
| | | | | | | | | We need to draw the debug rect using the calculated margins. Otherwise the rect will be drawn wrong once the control is resized. Change-Id: Ieb188900c688205147f991b98b5aeee836571e3d Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Native style: offer layoutMargins to QML, not layoutRectRichard Moe Gustavsen2020-06-112-11/+16
| | | | | | | | | | | | | The layoutRect are, similar to contentRect, calculated based on the minimumSize of the control. Since we don't know what the actual layoutRect will be until a control is resized, we use it instead to calculate what the margins should be between the boundingRect() and layoutRect. We do the same for content rect. This will allows us to calculate the correct margins early on, before knowing what the end size of the control will be. Change-Id: I26b0aedee28533a70fd8dc4918f962f41c4f5185 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Native style: make the debug flags more type safeRichard Moe Gustavsen2020-06-112-44/+30
| | | | | | | | Take the opportunity to clean up the flags a bit, and improve how we print the options to the console. Change-Id: Ia6e81453bfd53a5bfe6328b7cb8f6abcbf2dbed1 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Fix issues with the label in GroupBoxJan Arve Sæther2020-06-102-1/+14
| | | | | | | | | | 1. Make it have the correct position, given by the labelPos property. 2. Put a Rectangle with the background color below the label to wipe away the frame strikethrough. Change-Id: I68b6f1b5fda7854f7032dd9716613d025d2eb6ed Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QDebug, print 9-patch margins tooJan Arve Sæther2020-06-101-1/+2
| | | | | Change-Id: I23f2a1ae388f3819b41ed64ca15e8af9c6629fc8 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Native style: remove unused codeRichard Moe Gustavsen2020-06-092-3/+0
| | | | | Change-Id: Ica6390311031c14c123d3f49a4f70adfa15be5c0 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Reorder properties into the same order as QMargins ctor (l,t,r,b)Jan Arve Sæther2020-06-091-1/+1
| | | | | | | | | | | Otherwise, doing a console.log(groupboxPaddings) results in: DefaultGroupBox.qml(88): QQuickStyleMargins(0, 0, 10, 0) which might mislead people into believeing that the right margin is 10. Change-Id: I25a3db40cb63d11841b72aad7bdf9889e6578e37 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* NativeStyle: add ComboBoxRichard Moe Gustavsen2020-06-093-0/+150
| | | | | | Change-Id: Ia6387857ba012ba7f6df453e64dd9419f7979db8 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Native style: make it possible to set nine patch margins from the styleRichard Moe Gustavsen2020-06-0811-13/+49
| | | | | | | | | | | | | | | | | | | Up till now, all images have been scaled using nine patch images with margins set to be at the center. This was doomed to be too simplistic at some point, at that point is now (when working on comboboxes). So instead, calculate the nine patch margins from the style. This will let the different styles set pixel perfect margins per control that matches the image they draw. If left unspecified by a style, the default implementation in QCommonStyle will return the old logic of using the center. We also add support for specifying if an image can be scaled horizontally or vertically by setting the right or bottom nine patch margin to -1 respectively. E.g on macOS, an NSButton cannot be scaled vertically, so the image we draw will not look native if we do. Change-Id: Icaf232748b8d15f06f9b289e164b5c8fb86a6c7b Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Native style: shuffle some linesRichard Moe Gustavsen2020-06-041-4/+4
| | | | | | | This change is just a refactoring of lines (no-op). Change-Id: I59c7c2e2b003f8b8c41a247d521eaef2f173ae17 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Native style: don't use padding when item is smaller than minimumsizeRichard Moe Gustavsen2020-06-041-1/+5
| | | | | | | | Set padding to 0 if the item is resized smaller than minimum, otherwise the image will be wrapped rather than scaled. Change-Id: I803f5d0ff93afcb1b03e936aae766e71675f8d33 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: don't clean geometry flagRichard Moe Gustavsen2020-06-042-15/+10
| | | | | | | | | | | | | | | | | | We used to only repaint the image upon getting a geometryChanged callback, to avoid recursion. But this turns out to fail when the resize is a result of e.g a change in the content size. In that case, we need to recalculate geometry as well, since many of the rects are calculated based on the content size. This patch will change this logic so that we always recalculate style geometry upon a item geometry change, unless we're already polishing (that latter would otherwise produce a warning). Change-Id: I06c2e527d03dca54c555ddb8ab5d9b2a9546163d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: improve debug possibilitiesRichard Moe Gustavsen2020-06-042-18/+79
| | | | | | | | | Add more debug options, which is very helpful when working with QStyle. And use an enum to store it, to use less memory. Change-Id: I03fe3a5c827735641ce952daa797ab53a31f937f Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: repaint image when geometry changesRichard Moe Gustavsen2020-06-041-2/+5
| | | | | | | | | When we don't use a nine-patch image for scaling, the size of the image will depend on the size of the item. So we need to repaint it whenever we update geometry. Change-Id: I385325621f5259e3e97ceb5e143ad73682f8b276 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: remove insets, and use layoutRectRichard Moe Gustavsen2020-06-032-13/+16
| | | | | | | | | | | | | | | We have so far used insets to ensure that the controls end up aligned inside a layout. But this is most likely wrong, since insets in QtQuickControls2 is supposed to only move the background, and not the whole control (including contents, which we used to move as well in Button.qml). So after looking at this one more time, I think the right solution is to leave insets alone, and instead provide a layoutRect from QQuickStyleItem. This rect can later be used by layouts to align the controls correctly. Change-Id: I3cd97d34ca6f629dedef3e2afd2ae9e257f9df22 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: improve type safetyRichard Moe Gustavsen2020-06-022-2/+11
| | | | | | | | | | | | A QuickStyleItem instantiated inside a QML file set property "control" to point to the control it styles. It's required that this item matches the control it styles, so that e.g a NativeStyle.Button is only used for styling a Button.qml (and not e.g a Slider.qml), since NativeStyle.Button will crash otherwise. We do a quick runtime check in debug mode rather than a compile time check to avoid to much churn in the c++ code to enforce this. Change-Id: I31dca31ab4f1fdf08780ffb01c533ac5837784f2 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: improve debugging supportRichard Moe Gustavsen2020-06-022-12/+29
| | | | | | | | Make it possible to draw the nine patch image for a control unscaled, to easy the process of debugging them. Change-Id: I6aef435b54729a511c856afa5a368d9c228e3d8a Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: add TextAreaRichard Moe Gustavsen2020-05-283-0/+146
| | | | | Change-Id: Ie8a4ea4ff232fa5aa3064b56aa7ba13f8522590d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: add FrameRichard Moe Gustavsen2020-05-273-0/+123
| | | | | Change-Id: Ide8f2910c54a378c8c9d03554718de54feb9cf20 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: support setting empty content sizeRichard Moe Gustavsen2020-05-262-3/+8
| | | | | | Change-Id: I0568d8877841b2277bdfa1f26876ace60416af98 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Native style: copy QStyle from widgets, and implement ground work for ↵Richard Moe Gustavsen2020-05-2517-0/+1691
creating native styles This is the initial patch for adding native style support to controls2. The gist of the patch is that it copies QStyle from widgets (including the mac plugin style), remove all notions of widgets, tweak it as needed, and make it compile inside the qtquickcontrols2 repository as a separate QML plugin (QtQuick.NativeStyle). The "new" QStyle is then used to draw primitives onto nine-patch-images that can be rendered by the scene graph. Each such primitive/image will be wrapped by a QQuickStyleItem (which is a subclass of QQuickItem). E.g a button background will be implemented by QQuickStyleItemButton.cpp. This item can then be placed anywhere in the QML code to draw a native-looking button background. Controls2 has its own styling API, where a style consist of a set of QML files that extend template controls written in C++. To enable native styling, we simply follow the exact same approach; We create a style folder per platform alongside the other styles in controls2. Each style will contain a set of qml files for the controls (Button.qml, Slider.qml, etc), and inside each control, the style items will be used to draw the default delegates. Since it's likely that each such qml file will be implemented equal in all the desktop styles (but not always), the native style plugin contains a set of default controls (e.g DefaultButton.qml) that a platform style can choose to inherit from and extend as needed. Included is also an example called "DesktopGallery" that can be used to test and view the controls. Change-Id: I8b45aa7d493930f552d3ad2e3e3e7184129a9d6c Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>