Commit Graph

33 Commits

Author SHA1 Message Date
Oliver Eftevaag 5ae40afa97 Shapes example: use qqc2 components
Changing the example to use qt quick controls where it makes sense

Task-number: QTBUG-95739
Pick-to: 6.2
Change-Id: Id0df227657693234de4481c2316dc6c3e0545043
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-28 17:25:03 +02:00
Joerg Bornemann b4ab58d791 Raise cmake_minimum_required to VERSION 3.16 in examples
Pick-to: 6.2
Task-number: QTBUG-95636
Change-Id: I9f76b787533dad1c469fbb8c69df6c27b20a9aa3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-17 13:48:14 +02:00
Maximilian Goldstein 63b418eb54 examples: Use template literals for multiline strings
Change-Id: I660a74730edf60d0b7760162b441e3e14749e930
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-05-03 10:17:18 +02:00
Ulf Hermann 4cc91a6a0e Use functions as signal handlers when accessing parameters
Injected signal handlers are bad practice because they aren't declared.

Pick-to: 6.1
Task-number: QTBUG-89943
Change-Id: I3a691f68342a199bd63034637aa7ed438e3a037b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-12 10:30:20 +00:00
Alexandru Croitor 20d5e2d7ef CMake: Regenerate examples to set the WIN32_EXECUTABLE property
As well as the MACOSX_BUNDLE properties as necessary.

Task-number: QTBUG-87664
Task-number: QTBUG-86827
Change-Id: I46769fb543acb2cbeba122470b5e44ad478fbe4e
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-26 23:38:39 +01:00
Alexandru Croitor 903252b240 CMake: Regenerate examples to use qt_add_executable
Task-number: QTBUG-87661
Change-Id: Ie5bba408000211b24694aa0143bdf79c4a298f42
Reviewed-by: Daniel Smith <Daniel.Smith@qt.io>
2020-10-20 09:32:34 +02:00
Alexandru Croitor 965984771d CMake: Regenerate qtdeclarative/examples
Includes
- new example installation paths
- one case of QT_QMLTYPES_FILENAME addition

Change-Id: I24423da9b04b6ecc8445017fa35f148dd43b1829
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-05-29 10:01:22 +02:00
Alexandru Croitor 26c5243491 Merge remote-tracking branch 'origin/dev' into wip/cmake
Conflicts:
	dependencies.yaml
	src/qml/qml/qqmlengine.cpp

Change-Id: I6a73fd1064286f4a2232de85c2ce7f80452d4641
2020-03-12 15:03:03 +01:00
Alexandru Croitor b134476cdb Post-merge fixes
Change-Id: I2350df5368ee34d6c7072d456806e518ce533839
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-01-30 20:45:49 +00:00
Alexandru Croitor b684ba2194 Merge remote-tracking branch 'origin/dev' into wip/cmake
Conflicts:
        dependencies.yaml

Change-Id: Ie3e9dc62031a85e5e81cbdf04694b95159d49fca
2020-01-29 16:52:58 +01:00
Eskil Abrahamsen Blomfeldt 19a74ba56e Fix vertical position of PathText
The PathText would always translate to y=0, regardless of what y
was set to. We should obviously get the y coordinate of the shape
*before* translating it into position to find the distance from
the baseline.

This change also updates the example, which had not been updated
to the changed origin of the PathText, and it adds a Lancelot test
for keeping track of the PathText shape rendering.

Change-Id: I940ac956af5229842739f8d8751a1f13bb86b8e7
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-01-29 14:45:41 +01:00
Eskil Abrahamsen Blomfeldt 1ee5fed75f Introduce PathText path element
For text rendering in Qt Quick, we currently have the limitation
that when rendering text at such a large size that the distance
fields start showing artifacts, the only option is to use
NativeRendering, which will look nice, but which will use a lot
of texture memory for the glyph cache, since it will actually
cache the glyphs at the requested size.

A suggested approach would be to fall back to using triangulated
paths when the font gets large enough, but the work on this was
never completed.

It turns out that we can get this now, basically for free, since
we already support rendering arbitrary QPainterPaths using
Qt Quick Shapes. The only thing missing is the ability to add
the path of a given text to the shape. This patch fills in that
gap.

Note that this is currently not supported by nvidia renderer.

[ChangeLog][QtQuick] Added PathText path element which can be
used together with Qt Quick Shapes to get text rendering that
does not cache glyphs in a texture, but triangulates the
outlines of the glyphs instead.

Change-Id: I436e1476b129b324cf7a54f89a1b18e0579e8185
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-01-21 11:48:54 +01:00
Alexandru Croitor c2f8b9535d Merge remote-tracking branch 'origin/dev' into wip/cmake
Removed dependencies.yaml because we don't use it yet in wip/cmake.
Fixed conflict in qmlcachegen.cpp.

Change-Id: Ie1060c737bee1daa85779903598e5b6d5020d922
2019-10-14 19:02:37 +02:00
Leander Beernaert 9e633bbda7 Regenerate Examples
Change-Id: I2fbfb44bbb6d667e022bffb480feaf74ff0d0a5e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-14 09:09:55 +00:00
Ulf Hermann 291d118b0f Examples: Avoid Qt.createQmlObject()
We don't want to encourage Qt.createQmlObject(). It's the equivalent of
eval() in JavaScript.

This has the added benefit that the shapes actually react to changes in
the parameters now. Before, once a shape was drawn, it didn't get
updated when you manipulated the line width or fill controls.

Change-Id: I8d5b7598799b52043f86fd1f617e31de09331891
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2019-10-02 11:20:05 +02:00
Leander Beernaert bf58a1cc04 Update Examples with lowercase qt6_add_resources()
Re-run pro2cmake on all exampls.

Change-Id: Iafd1092beff023b407a8f29c2a5b651f2e534b75
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-20 08:38:06 +00:00
Leander Beernaert b938edcfb3 Convert Examples
This patch converts all examples in qtdeclarative except for a few
exceptions which require a public facing qml plugin api.

Change-Id: I2cd2b1bb455be8b48796893a8235dea7f8b35aa2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-23 13:51:06 +00:00
Shawn Rutledge 197c22be54 Get rid of Qt.labs.handlers import, merge into QtQuick 2.12
... and clean up imports in examples, snippets and tests accordingly.

Change-Id: I5bbe63afd2614cdc2c1ec7d179c9acd6bc03b167
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2018-07-17 15:11:51 +00:00
Shawn Rutledge 6fa746fa61 rename containsMask to containmentMask
It was pointed out that containsMask sounds like it ought to be a
boolean property.

Change-Id: I2b56823b60d64f9903b0d5108c6428e691c09ed0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io>
2018-02-27 14:00:24 +00:00
Shawn Rutledge b2b221945d demonstrate containsMask in the tapableTriangle Shape example
This isn't an improvement in behvior, it just shows that a Shape can
be used as a mask on some other Item.  But Shape.containsMode is still
important so that when the outer Rectangle's contains() calls
Shape.contains(), the latter will do the right thing.

Change-Id: I1bd127784e708f30561945a4958e4d5f0c1c0b85
Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io>
2018-01-26 08:49:40 +00:00
Shawn Rutledge bf5f171db2 QQuickShape: override contains(QPointF); demonstrate in examples
QQuickItem::contains() only checks the Item's bounding box by default.
In the case of Shapes, that can be comically imprecise, but it's fast.
So we add a containsMode property to control whether we will do that
(the default) or actually check each of the QPainterPaths within to
see whether they contain the point (FillContains).

FillContains could be optimized later: use QRegion perhaps, or download
the rendered texture from the GPU and test whether the pixel at the
point is transparent.  It may also be appropriate to add a StrokeContains
option.

The main motivation is to detect mouse (or touch) interaction within
a shaped area.  QQuickSinglePointHandler::wantsEventPoint() already
checks whether its parent Item contains the event point.  So if a
Shape has a TapHandler for example, it will respond only within the
visible bounds of the Shape rather than within the entire rectangular
bounding box as long as containsMode is set to FillContains.

Examples quick/shapes/content/tapableTriangle.qml and tiger.qml
are modified to react when a press occurs inside, and the former
is fixed to be able to run standalone via the qml runtime.  The
latter has an offset issue when run standalone but is OK within
the shape gallery example.

As a drive-by optimization, QQuickShapePrivate's variables are
re-ordered by type so that the compiler can place the bools and
enums into bitfields; and to facilitate reordering, the
initialization is done C++11-style, in the header.

[ChangeLog][QtQuick][Shape] A containsMode property is added.
If it is set to FillContains, then Shape.contains() returns true
only within the visible bounds, so its Pointer Handlers also respond
only within those bounds.

Change-Id: I31c85a9b08aa6945c58dc07febfe89ffef21274b
Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io>
2018-01-25 16:23:08 +00:00
Liang Qi 8f22b51d44 Fix outdated FDL license header
Change-Id: I38a971ed7b9d35a2b60d17b60d94e8d53b140988
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2017-12-14 13:25:47 +00:00
Liang Qi 053e953468 Fix outdated BSD license header
Change-Id: I4a771725bed2d102a8f0db27ec6ed1c90992c944
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2017-12-14 13:25:45 +00:00
Michael Brasser 7bedd55551 Add new PathAngleArc type
This type allows working with arcs in different ways (based
on angles rather than start/end positions) that can be more
intuitive for certain use cases (such as a circular
progress indicator).

[ChangeLog][QtQuick][Path] Add new PathAngleArc type

Change-Id: Icbe5fc0450edd9a4d92f9a8d03438842b72a312d
Task-number: QTBUG-62684
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2017-11-07 16:29:16 +00:00
Laszlo Agocs 9b480bade6 Rename shape example files to get rid of the old pathitem term
QQuickShape used to be known as QQuickPathItem. Avoid the old
name in publicly exposed components.

Change-Id: I70bed142e1e82c48c496ab98384318e08fba99c7
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2017-08-09 09:07:50 +00:00
Laszlo Agocs 0047b3bdc0 shapes: Add support for conical gradients
Task-number: QTBUG-61857
Change-Id: Iacefcc3b22b31ed3dbcfbf7f00c8b0ea51c63b95
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2017-08-08 12:44:23 +00:00
Laszlo Agocs 003e24d72a shapes: Add support for radial gradients
Task-number: QTBUG-61857
Change-Id: I580e503d8266a9dca69bb542c22228df4ff4bf94
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2017-08-08 08:00:30 +00:00
Berthold Krevert ce5436a9a0 Rename property to rendererType
This follows the documentation.

Change-Id: I74d8d2b45546717c6a6b252af9370c6670ef1b78
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2017-07-28 09:20:06 +00:00
Laszlo Agocs 17ded188f7 Add shapes example doc page
Change-Id: If583f5087ee3b5899f567052a9c7e356c93fddf3
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2017-07-06 21:33:52 +00:00
Laszlo Agocs 123f698c5b Allow freely mixing non-ShapePath objects in Shape
The own list property must be kept. However, we can reuse
QQuickItemPrivate's data accessors in order to start supporting
code like:

Shape {
   ..
   ShapePath { ... }
   ShapePath { ... }
   Rectangle { ... }
   Image { ... }
   // any other visual type
   // or non-visual:
   Timer { ... }
 }

Change-Id: I6d502d697cae37bf16857770273a749cee1b3aa3
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
2017-06-08 13:59:50 +00:00
Laszlo Agocs f4f89858cf Use GradientStop and rename ShapeLinearGradient to LinearGradient
Thus application code becomes:

ShapePath {
   ...
   fillGradient: LinearGradient {
      ...
      GradientStop { ... }
   }
}

which is even more clean and readable. The duplication for stops is
now avoided.

Change-Id: I50ae2f388e21683a37dc4787763dc71e16eef4f5
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
2017-06-08 10:32:18 +00:00
Laszlo Agocs 5af4c9b237 Reduce objects: Make ShapePath inherit Path
Shape { ShapePath { Path { ... } } } simply becomes
Shape { ShapePath { ... } }

Change-Id: Ie57936cd7953c8a8d6c67e78b9d73bdbe2a05316
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2017-06-07 08:33:33 +00:00
Laszlo Agocs 961da5273e Rename to Shape/ShapePath and remove public JS API
Change-Id: I299354da0632fb0b8487cfb13748ed58b97d75fd
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2017-06-02 10:16:52 +00:00