Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/jsDocs into lp:ubuntu-ui-toolkit/staging

Proposed by Christian Dywan on 2015-07-05
Status: Superseded
Proposed branch: lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/jsDocs
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 615 lines (+476/-10)
10 files modified
components.api (+5/-5)
documentation/ubuntu-ui-toolkit-common.qdocconf (+2/-1)
modules/Ubuntu/Components/1.2/mathUtils.js (+23/-4)
modules/Ubuntu/Components/1.3/colorUtils.js (+36/-0)
modules/Ubuntu/Components/1.3/dateUtils.js (+145/-0)
modules/Ubuntu/Components/1.3/mathUtils.js (+61/-0)
modules/Ubuntu/Components/1.3/pageUtils.js (+10/-0)
modules/Ubuntu/Components/1.3/scrollbarUtils.js (+141/-0)
modules/Ubuntu/Components/1.3/sliderUtils.js (+48/-0)
modules/Ubuntu/Components/qmldir (+5/-0)
To merge this branch: bzr merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/jsDocs
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing on 2015-07-05
Ubuntu SDK team 2015-07-05 Pending
Review via email: mp+263853@code.launchpad.net

This proposal has been superseded by a proposal from 2015-07-07.

Commit Message

Include Javascript libraries in QML documentation

Description of the Change

Note: I duplicated all Javascript files because docs don't include older API folders.

To post a comment you must log in.
1548. By Zoltan Balogh on 2015-07-06

In the initctl test fixture, add the option to unset an environment variable. lp:~canonical-platform-qa/ubuntu-ui-toolkit/fixture_unset_env

1549. By Zoltan Balogh on 2015-07-06

Fix AlamrModel segfault when updating elements. lp:~zsombi/ubuntu-ui-toolkit/alarmmodel-segfault

1550. By Christian Dywan on 2015-07-07

Add a deprecated note to ListItems.ThinDivider. Fixes: https://bugs.launchpad.net/bugs/1470951.

Approved by PS Jenkins bot.

1551. By Christian Dywan on 2015-07-17

Fix annotations and include popupUtils

1552. By Christian Dywan on 2015-07-17

Tweak the wording of popupUtils::open

1553. By Christian Dywan on 2015-07-23

Move Slider-/ Scrollbar-/ ColorUtils into Ambiance for 1.3

These are all internal components.

1554. By Christian Dywan on 2015-07-23

Fix types in qmldir of Ambiance theme

1555. By Christian Dywan on 2015-07-24

Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/staging

1556. By Christian Dywan on 2015-07-24

Add js files to .pro files

1557. By Christian Dywan on 2015-07-24

Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/staging

1558. By Christian Dywan on 2015-07-24

Change excluse dir in ubuntu-ui-toolkit-common.qdocconf

1559. By Christian Dywan on 2015-07-24

qdoc tweaks

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components.api'
2--- components.api 2015-06-22 23:24:26 +0000
3+++ components.api 2015-07-06 12:20:28 +0000
4@@ -203,7 +203,7 @@
5 function push(var data)
6 function clear()
7 function QQuickMimeData* newData()
8-Ubuntu.Components.ColorUtils 0.1 1.0
9+Ubuntu.Components.ColorUtils 0.1 1.0 1.3
10 Ubuntu.Components.ComboButton 1.1: Button
11 property double collapsedHeight
12 default readonly property QtObject comboList
13@@ -265,7 +265,7 @@
14 property url source
15 property QSizeF sourceSize
16 readonly property int status
17-Ubuntu.Components.DateUtils 0.1 1.0
18+Ubuntu.Components.DateUtils 0.1 1.0 1.3
19 Ubuntu.Components.Popups.DefaultSheet 1.0 0.1: SheetBase
20 property bool doneButton
21 signal closeClicked()
22@@ -496,7 +496,7 @@
23 Ubuntu.Components.MainView 1.3: MainViewBase
24 property bool automaticOrientation
25 default readonly property QtObject contentsItem
26-Ubuntu.Components.MathUtils 0.1 1.0
27+Ubuntu.Components.MathUtils 0.1 1.0 1.3
28 Ubuntu.Components.MimeData 1.0 0.1: QtObject
29 property color color
30 property var data
31@@ -793,7 +793,7 @@
32 Ubuntu.Components.Scrollbar 1.3: StyledItem
33 property int align
34 property Flickable flickableItem
35-Ubuntu.Components.ScrollbarUtils 0.1 1.0
36+Ubuntu.Components.ScrollbarUtils 0.1 1.0 1.3
37 Ubuntu.Components.Sections 1.3: StyledItem
38 readonly property Action actions
39 property var model
40@@ -850,7 +850,7 @@
41 property double minimumValue
42 readonly property bool pressed
43 property double value
44-Ubuntu.Components.SliderUtils 0.1 1.0
45+Ubuntu.Components.SliderUtils 0.1 1.0 1.3
46 Ubuntu.Components.SortBehavior 1.1: QtObject
47 property Qt.SortOrder order
48 property string property
49
50=== modified file 'documentation/ubuntu-ui-toolkit-common.qdocconf'
51--- documentation/ubuntu-ui-toolkit-common.qdocconf 2015-05-05 16:23:29 +0000
52+++ documentation/ubuntu-ui-toolkit-common.qdocconf 2015-07-06 12:20:28 +0000
53@@ -21,8 +21,9 @@
54 excludedirs += ../modules/Ubuntu/Components/Popups/1.2
55 excludedirs += ../modules/Ubuntu/Components/Themes/Ambiance
56 excludedirs += ../modules/Ubuntu/Components/Themes/SuruDark
57+excludedirs += ../documentation/autopilot-helpers/_build/html/_static
58 imagedirs = images
59-sources.fileextensions = "*.qml *.qdoc *.cpp"
60+sources.fileextensions = "*.qml *.qdoc *.cpp *.js"
61 headers.fileextensions = "*.h"
62 # exclude qml files that have the component documented in a separate qdoc file
63 excludefiles = $BLD/../modules/Ubuntu/Components/MainView.qml
64
65=== modified file 'modules/Ubuntu/Components/1.2/mathUtils.js'
66--- modules/Ubuntu/Components/1.2/mathUtils.js 2015-04-30 08:32:44 +0000
67+++ modules/Ubuntu/Components/1.2/mathUtils.js 2015-07-06 12:20:28 +0000
68@@ -14,9 +14,19 @@
69 * along with this program. If not, see <http://www.gnu.org/licenses/>.
70 */
71
72+/*!
73+ \qmltype mathUtils
74+ \inqmlmodule Ubuntu.Components 1.2
75+ \ingroup ubuntu
76+ \brief Various mathematical utility functions.
77+ */
78+
79 .pragma library
80
81-// Ensure the value x is between min and max
82+/*!
83+ \qmlmethod clamp(x, min, max)
84+ Ensure the value x is between min and max
85+ */
86 function clamp(x, min, max) {
87 if (min <= max) {
88 return Math.max(min, Math.min(x, max));
89@@ -26,17 +36,26 @@
90 }
91 }
92
93-// Get the linear interpolation
94+/*!
95+ \qmlmethod lerp(delta, from, to)
96+ Get the linear interpolation
97+ */
98 function lerp(delta, from, to) {
99 return ((1.0 - delta) * from) + (delta * to);
100 }
101
102-// Linearly project a value x from [xmin, xmax] into [ymin, ymax]
103+/*!
104+ \qmlmethod getFlickableChild(item)
105+ Linearly project a value x from [xmin, xmax] into [ymin, ymax]
106+ */
107 function projectValue(x, xmin, xmax, ymin, ymax) {
108 return ((x - xmin) * ymax - (x - xmax) * ymin) / (xmax - xmin)
109 }
110
111-// Linearly project a value x, but in addition to projectValue it's clamped to xmin/xmax first
112+/*!
113+ \qmlmethod clampAndProject(x, xmin, xmax, ymin, ymax)
114+ Linearly project a value x, but in addition to projectValue it's clamped to xmin/xmax first
115+ */
116 function clampAndProject(x, xmin, xmax, ymin, ymax) {
117 return projectValue(clamp(x, xmin, xmax), xmin, xmax, ymin, ymax)
118 }
119
120=== added file 'modules/Ubuntu/Components/1.3/colorUtils.js'
121--- modules/Ubuntu/Components/1.3/colorUtils.js 1970-01-01 00:00:00 +0000
122+++ modules/Ubuntu/Components/1.3/colorUtils.js 2015-07-06 12:20:28 +0000
123@@ -0,0 +1,36 @@
124+/*
125+ * Copyright (C) 2013-2015 Canonical, Ltd.
126+ *
127+ * This program is free software; you can redistribute it and/or modify
128+ * it under the terms of the GNU General Public License as published by
129+ * the Free Software Foundation; version 3.
130+ *
131+ * This program is distributed in the hope that it will be useful,
132+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
133+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
134+ * GNU General Public License for more details.
135+ *
136+ * You should have received a copy of the GNU General Public License
137+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
138+ */
139+
140+/*!
141+ \qmltype colorUtils
142+ \inqmlmodule Ubuntu.Components 1.3
143+ \ingroup ubuntu
144+ \brief Various chromatic utility functions.
145+ */
146+
147+.pragma library
148+
149+/*!
150+ \qmlmethod luminance(hexcolor)
151+ Get the luminance for a color.
152+ */
153+function luminance(hexcolor){
154+ hexcolor = String(hexcolor)
155+ var r = parseInt(hexcolor.substr(1,2),16);
156+ var g = parseInt(hexcolor.substr(3,2),16);
157+ var b = parseInt(hexcolor.substr(5,2),16);
158+ return ((r*212)+(g*715)+(b*73))/1000/255;
159+}
160
161=== added file 'modules/Ubuntu/Components/1.3/dateUtils.js'
162--- modules/Ubuntu/Components/1.3/dateUtils.js 1970-01-01 00:00:00 +0000
163+++ modules/Ubuntu/Components/1.3/dateUtils.js 2015-07-06 12:20:28 +0000
164@@ -0,0 +1,145 @@
165+/*
166+ * Copyright 2013-2015 Canonical Ltd.
167+ *
168+ * This program is free software; you can redistribute it and/or modify
169+ * it under the terms of the GNU Lesser General Public License as published by
170+ * the Free Software Foundation; version 3.
171+ *
172+ * This program is distributed in the hope that it will be useful,
173+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
174+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
175+ * GNU Lesser General Public License for more details.
176+ *
177+ * You should have received a copy of the GNU Lesser General Public License
178+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
179+ */
180+
181+/*!
182+ \qmltype dateUtils
183+ \inqmlmodule Ubuntu.Components 1.3
184+ \ingroup ubuntu
185+ \brief Various date utility functions.
186+ */
187+
188+.pragma library
189+
190+/*
191+ Extending Date with few prototypes
192+ */
193+Date.msPerDay = 86400e3
194+Date.msPerWeek = Date.msPerDay * 7
195+
196+/*!
197+ \qmlmethod Date::midnight()
198+ The function returns a Date object with the current date and hour set to
199+ midnight.
200+ */
201+Date.prototype.midnight = function() {
202+ this.setHours(0, 0, 0, 0);
203+ return this;
204+}
205+
206+/*!
207+ \qmlmethod Date::getInvalidDate()
208+ The function returns an invalid date object.
209+ Example of use:
210+ \code
211+ var invalidDate = Date.prototype.getInvalidDate.call();
212+ var otherInvalidDate = (new Date()).getInvalidDate();
213+ \endcode
214+ */
215+Date.prototype.getInvalidDate = function() {
216+ return new Date(-1, -1);
217+}
218+
219+/*!
220+ \qmlmethod Date::isValid()
221+ The function checks whether the date object is a valid one, meaning the year,
222+ month and date fields are positive numbers
223+ */
224+Date.prototype.isValid = function() {
225+ if (Object.prototype.toString.call(this) !== "[object Date]") {
226+ return false;
227+ }
228+ return (this.getFullYear() > 0) && (this.getMonth() >= 0) && (this.getDate() > 0);
229+}
230+
231+/*!
232+ \qmlmethod Date::daysInMonth()
233+ The function returns the number of days in the month set in the Date object.
234+ */
235+Date.prototype.daysInMonth = function() {
236+ return [
237+ 31/*an*/, 28/*Feb*/, 31/*Mar*/, 30/*Apr*/, 31/*May*/, 30/*Jun*/,
238+ 31/*Jul*/, 31/*Aug*/, 30/*Sep*/, 31/*Oct*/, 30/*Nov*/, 31/*Dec*/
239+ ][this.getMonth()] + (this.getMonth() === 1) * this.leapYear();
240+}
241+
242+/*!
243+ \qmlmethod Date::leapYear()
244+ The function checks whether the year in the Date object is a leap year or not.
245+ */
246+Date.prototype.leapYear = function() {
247+ var year = this.getFullYear();
248+ return year % 400 == 0 || (year % 100 !== 0 && year % 4 == 0);
249+}
250+
251+/*!
252+ \qmlmethod Date::monthsTo(date)
253+ The function returns the distance in months (not calendaristic months) between
254+ the Date object and the given one as parameter.
255+ */
256+Date.prototype.monthsTo = function(target) {
257+ return target.getMonth() - this.getMonth() + (12 * (target.getFullYear() - this.getFullYear()));
258+}
259+
260+/*!
261+ \qmlmethod Date::daysTo(date)
262+ Same as monthsTo, but returns the distance in days.
263+ */
264+Date.prototype.daysTo = function(target) {
265+ return !target.isValid() ? 0 : Math.ceil((target - this) / Date.msPerDay);
266+}
267+
268+/*!
269+ \qmlmethod Date::hoursTo(date)
270+ Same as monthsTo, but returns the distance in hours.
271+ */
272+Date.prototype.hoursTo = function(target) {
273+ return !target.isValid() ? 0 : Math.ceil((target.getTime() - this.getTime()) / (1000 * 60 * 60));
274+}
275+
276+/*!
277+ \qmlmethod Date::minutesTo(date)
278+ Same as monthsTo, but returns the distance in minutes.
279+ */
280+Date.prototype.minutesTo = function(target) {
281+ return !target.isValid() ? 0 : Math.ceil((target.getTime() - this.getTime()) / (1000 * 60));
282+}
283+
284+/*!
285+ \qmlmethod Date::secondsTo(date)
286+ Same as monthsTo, but returns the distance in seconds.
287+ */
288+Date.prototype.secondsTo = function(target) {
289+ return !target.isValid() ? 0 : Math.ceil((target.getTime() - this.getTime()) / 1000);
290+}
291+
292+/*!
293+ \qmlmethod Date::getWeek()
294+ The function returns the week number of the date stored in the object.
295+ */
296+Date.prototype.getWeek = function() {
297+ // Copy date so don't modify original
298+ var date = new Date(this);
299+ date.setHours(0, 0, 0, 0);
300+ // Set to nearest Thursday: current date + 4 - current day number
301+ // Make Sunday's day number 7
302+ date.setDate(date.getDate() + 4 - (date.getDay() || 7));
303+ // Get first day of year
304+ var yearStart = new Date(date.getFullYear(), 0, 1);
305+ // Calculate full weeks to nearest Thursday
306+ var weekNo = Math.ceil((((date - yearStart) / 86400000) + 1) / 7);
307+ // Return array of year and week number
308+ return weekNo;
309+}
310
311=== added file 'modules/Ubuntu/Components/1.3/mathUtils.js'
312--- modules/Ubuntu/Components/1.3/mathUtils.js 1970-01-01 00:00:00 +0000
313+++ modules/Ubuntu/Components/1.3/mathUtils.js 2015-07-06 12:20:28 +0000
314@@ -0,0 +1,61 @@
315+/*
316+ * Copyright 2012-2015 Canonical Ltd.
317+ *
318+ * This program is free software; you can redistribute it and/or modify
319+ * it under the terms of the GNU Lesser General Public License as published by
320+ * the Free Software Foundation; version 3.
321+ *
322+ * This program is distributed in the hope that it will be useful,
323+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
324+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
325+ * GNU Lesser General Public License for more details.
326+ *
327+ * You should have received a copy of the GNU Lesser General Public License
328+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
329+ */
330+
331+/*!
332+ \qmltype mathUtils
333+ \inqmlmodule Ubuntu.Components 1.3
334+ \ingroup ubuntu
335+ \brief Various mathematical utility functions.
336+ */
337+
338+.pragma library
339+
340+/*!
341+ \qmlmethod clamp(x, min, max)
342+ Ensure the value x is between min and max
343+ */
344+function clamp(x, min, max) {
345+ if (min <= max) {
346+ return Math.max(min, Math.min(x, max));
347+ } else {
348+ // swap min/max if min > max
349+ return clamp(x, max, min);
350+ }
351+}
352+
353+/*!
354+ \qmlmethod lerp(delta, from, to)
355+ Get the linear interpolation
356+ */
357+function lerp(delta, from, to) {
358+ return ((1.0 - delta) * from) + (delta * to);
359+}
360+
361+/*!
362+ \qmlmethod getFlickableChild(item)
363+ Linearly project a value x from [xmin, xmax] into [ymin, ymax]
364+ */
365+function projectValue(x, xmin, xmax, ymin, ymax) {
366+ return ((x - xmin) * ymax - (x - xmax) * ymin) / (xmax - xmin)
367+}
368+
369+/*!
370+ \qmlmethod clampAndProject(x, xmin, xmax, ymin, ymax)
371+ Linearly project a value x, but in addition to projectValue it's clamped to xmin/xmax first
372+ */
373+function clampAndProject(x, xmin, xmax, ymin, ymax) {
374+ return projectValue(clamp(x, xmin, xmax), xmin, xmax, ymin, ymax)
375+}
376
377=== modified file 'modules/Ubuntu/Components/1.3/pageUtils.js'
378--- modules/Ubuntu/Components/1.3/pageUtils.js 2015-04-25 08:54:58 +0000
379+++ modules/Ubuntu/Components/1.3/pageUtils.js 2015-07-06 12:20:28 +0000
380@@ -15,6 +15,15 @@
381 */
382
383 /*!
384+ \qmltype pageUtils
385+ \inqmlmodule Ubuntu.Components 1.3
386+ \ingroup ubuntu
387+ \internal
388+ \brief Page-related utility functions.
389+ */
390+
391+/*!
392+ \qmlmethod isVerticalFlickable(object)
393 Return true if the object is a Flickable that can be flicked in vertical direction.
394 */
395 function isVerticalFlickable(object) {
396@@ -30,6 +39,7 @@
397 }
398
399 /*!
400+ \qmlmethod getFlickableChild(item)
401 Return the first child of the item that is flickable in the vertical direction.
402 */
403 function getFlickableChild(item) {
404
405=== added file 'modules/Ubuntu/Components/1.3/scrollbarUtils.js'
406--- modules/Ubuntu/Components/1.3/scrollbarUtils.js 1970-01-01 00:00:00 +0000
407+++ modules/Ubuntu/Components/1.3/scrollbarUtils.js 2015-07-06 12:20:28 +0000
408@@ -0,0 +1,141 @@
409+/*
410+ * Copyright 2012-2015 Canonical Ltd.
411+ *
412+ * This program is free software; you can redistribute it and/or modify
413+ * it under the terms of the GNU Lesser General Public License as published by
414+ * the Free Software Foundation; version 3.
415+ *
416+ * This program is distributed in the hope that it will be useful,
417+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
418+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
419+ * GNU Lesser General Public License for more details.
420+ *
421+ * You should have received a copy of the GNU Lesser General Public License
422+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
423+ */
424+
425+/*!
426+ \qmltype scrollbarUtils
427+ \inqmlmodule Ubuntu.Components 1.3
428+ \ingroup ubuntu
429+ \brief Various scrolling utility functions.
430+ */
431+
432+.pragma library
433+
434+Qt.include("mathUtils.js")
435+
436+/*!
437+ \internal
438+ Object storing property names used in calculations.
439+ */
440+var _obj = {
441+ scrollbar: null,
442+ vertical: false,
443+ propOrigin: "",
444+ propContent: "",
445+ propPosRatio: "",
446+ propSizeRatio: "",
447+ propCoordinate: "",
448+ propSize: "",
449+ refresh: function () {
450+ _obj.vertical = (_obj.scrollbar.align === Qt.AlignLeading) || (_obj.scrollbar.align === Qt.AlignTrailing)
451+ _obj.propOrigin = (_obj.vertical) ? "originY" : "originX";
452+ _obj.propContent = (_obj.vertical) ? "contentY" : "contentX";
453+ _obj.propPosRatio = (_obj.vertical) ? "yPosition" : "xPosition";
454+ _obj.propSizeRatio = (_obj.vertical) ? "heightRatio" : "widthRatio";
455+ _obj.propCoordinate = (_obj.vertical) ? "y" : "x";
456+ _obj.propSize = (_obj.vertical) ? "height" : "width";
457+ }
458+}
459+
460+/*!
461+ \internal
462+ Checks whether the _obj is valid or not. Must be called in every function
463+ as those can be invoked prior to the host (style) component completion.
464+ */
465+function __check(sb) {
466+ if (sb !== null && (_obj.scrollbar !== sb)) {
467+ _obj.scrollbar = sb;
468+ sb.flickableItemChanged.connect(_obj.refresh);
469+ sb.alignChanged.connect(_obj.refresh);
470+ _obj.refresh();
471+ }
472+
473+ return _obj.scrollbar;
474+}
475+
476+/*!
477+ \qmlmethod isVertical(scrollbar)
478+ Returns whether the scrollbar is vertical or horizontal.
479+ */
480+function isVertical(scrollbar) {
481+ if (!__check(scrollbar)) return 0;
482+ return _obj.vertical;
483+}
484+
485+/*!
486+ \qmlmethod sliderPos(scrollbar, min, max)
487+ Calculates the slider position based on the visible area's ratios.
488+ */
489+function sliderPos(scrollbar, min, max) {
490+ if (!__check(scrollbar)) return 0;
491+ return clamp(scrollbar.flickableItem.visibleArea[_obj.propPosRatio] * scrollbar.flickableItem[_obj.propSize], min, max);
492+}
493+
494+/*!
495+ \qmlmethod sliderSize(scrollbar, min, max)
496+ Calculates the slider size for ListViews based on the visible area's position
497+ and size ratios, clamping it between min and max.
498+
499+ The function can be used in Scrollbar styles to calculate the size of the slider.
500+ */
501+function sliderSize(scrollbar, min, max) {
502+ if (!__check(scrollbar)) return 0;
503+ var sizeRatio = scrollbar.flickableItem.visibleArea[_obj.propSizeRatio];
504+ var posRatio = scrollbar.flickableItem.visibleArea[_obj.propPosRatio];
505+ var sizeUnderflow = (sizeRatio * max) < min ? min - (sizeRatio * max) : 0
506+ var startPos = posRatio * (max - sizeUnderflow)
507+ var endPos = (posRatio + sizeRatio) * (max - sizeUnderflow) + sizeUnderflow
508+ var overshootStart = startPos < 0 ? -startPos : 0
509+ var overshootEnd = endPos > max ? endPos - max : 0
510+
511+ // overshoot adjusted start and end
512+ var adjustedStartPos = startPos + overshootStart
513+ var adjustedEndPos = endPos - overshootStart - overshootEnd
514+
515+ // final position and size of thumb
516+ var position = adjustedStartPos + min > max ? max - min : adjustedStartPos
517+ var result = (adjustedEndPos - position) < min ? min : (adjustedEndPos - position)
518+
519+ return result;
520+}
521+
522+/*!
523+ \qmlmethod scrollAndClamp(scrollbar, amount, min, max)
524+ The function calculates and clamps the position to be scrolled to the minimum
525+ and maximum values.
526+
527+ The scroll and drag functions require a slider that does not have any minimum
528+ size set (meaning the minimum is set to 0.0). Implementations should consider
529+ using an invisible cursor to drag the slider and the ListView position.
530+ */
531+function scrollAndClamp(scrollbar, amount, min, max) {
532+ if (!__check(scrollbar)) return 0;
533+ return scrollbar.flickableItem[_obj.propOrigin] +
534+ clamp(scrollbar.flickableItem[_obj.propContent] - scrollbar.flickableItem[_obj.propOrigin] + amount,
535+ min, max);
536+}
537+
538+/*!
539+ \qmlmethod dragAndClamp(scrollbar, cursor, contentSize, pageSize)
540+ The function calculates the new position of the dragged slider. The amount is
541+ relative to the contentSize, which is either the flickable's contentHeight or
542+ contentWidth or other calculated value, depending on its orientation. The pageSize
543+ specifies the visibleArea, and it is usually the heigtht/width of the scrolling area.
544+ */
545+function dragAndClamp(scrollbar, cursor, contentSize, pageSize) {
546+ if (!__check(scrollbar)) return 0;
547+ scrollbar.flickableItem[_obj.propContent] =
548+ scrollbar.flickableItem[_obj.propOrigin] + cursor[_obj.propCoordinate] * contentSize / pageSize;
549+}
550
551=== added file 'modules/Ubuntu/Components/1.3/sliderUtils.js'
552--- modules/Ubuntu/Components/1.3/sliderUtils.js 1970-01-01 00:00:00 +0000
553+++ modules/Ubuntu/Components/1.3/sliderUtils.js 2015-07-06 12:20:28 +0000
554@@ -0,0 +1,48 @@
555+/*
556+ * Copyright 2013-2015 Canonical Ltd.
557+ *
558+ * This program is free software; you can redistribute it and/or modify
559+ * it under the terms of the GNU Lesser General Public License as published by
560+ * the Free Software Foundation; version 3.
561+ *
562+ * This program is distributed in the hope that it will be useful,
563+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
564+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
565+ * GNU Lesser General Public License for more details.
566+ *
567+ * You should have received a copy of the GNU Lesser General Public License
568+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
569+ */
570+
571+/*!
572+ \qmltype sliderUtils
573+ \inqmlmodule Ubuntu.Components 1.3
574+ \ingroup ubuntu
575+ \brief Various sliding utility functions.
576+ */
577+
578+.pragma library
579+
580+/*!
581+ \qmlmethod liveValue(item)
582+ The function returns the live value of the slider.
583+ */
584+function liveValue(item) {
585+ return item.__internals.liveValue;
586+}
587+
588+/*!
589+ \qmlmethod normalizedValue(item)
590+ The function returns the normalized live value of the slider.
591+ */
592+function normalizedValue(item) {
593+ return item.__internals.normalizedValue;
594+}
595+
596+/*!
597+ \qmlmethod isPressed(item)
598+ The function returns whether the slider is being pressed or not.
599+ */
600+function isPressed(item) {
601+ return item.__internals.isPressed;
602+}
603
604=== modified file 'modules/Ubuntu/Components/qmldir'
605--- modules/Ubuntu/Components/qmldir 2015-05-24 14:14:36 +0000
606+++ modules/Ubuntu/Components/qmldir 2015-07-06 12:20:28 +0000
607@@ -141,3 +141,8 @@
608 PullToRefresh 1.3 1.3/PullToRefresh.qml
609 UbuntuListView 1.3 1.3/UbuntuListView11.qml
610 Captions 1.3 1.3/Captions.qml
611+MathUtils 1.3 1.3/mathUtils.js
612+SliderUtils 1.3 1.3/sliderUtils.js
613+ScrollbarUtils 1.3 1.3/scrollbarUtils.js
614+ColorUtils 1.3 1.3/colorUtils.js
615+DateUtils 1.3 1.3/dateUtils.js

Subscribers

People subscribed via source and target branches