~ubuntu-branches/ubuntu/wily/unity-2d/wily

« back to all changes in this revision

Viewing changes to places/MultiRangeView.qml

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2011-08-25 18:16:57 UTC
  • mfrom: (1.1.19 upstream)
  • Revision ID: james.westby@ubuntu.com-20110825181657-opb29rqsxae3i98f
Tags: 4.2.0-0ubuntu1
* New upstream release:
  - [panel] application menus do not appear on first hover after dismissal
    (lp: #825262)
  - [dash] Lens icons badly scaled (lp: #825368)
  - [panel] indicators are shifted offscreen to the right (lp: #827673)
  - [panel] scrubbing from system indicators to menubar should be possible
    (lp: #706903)
  - [launcher] Closed applications don't get their launcher counts cleared
    (lp: #767367)
  - [dash] selected item should not be underlined but use the same 
    treatment as unity (lp: #817456)
  - [dash] categories should be collapsed by default (lp: #827214)
  - [dash] Ratings filter (lp: #831855)
  - [dash] Multirange filter (lp: #831856)
  - [dash] ToggleButton filter (lp: #831857)
  - [dash] Icon size must be bigger to match the mockups (lp: #831858)
  - [dash] "Refine search" right margin should be 15 pixels (lp: #832058)
  - [dash] "Refine search" should be "Filter results" (lp: #832060)
  - [dash] Font sizes should match new design (lp: #832114)
  - [panel] Glitch: application menu appearing when pressing the BFB 
    (lp: #825060)
  - [panel] Glitch: application menus are quickly opened after a drag gesture
    (lp: #825267)
  - [dash] File thumbnails aspect ratio is not respected (lp: #832204)
* debian/control: require current the current versions of nux and unity

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of unity-2d
 
3
 *
 
4
 * Copyright 2010-2011 Canonical Ltd.
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; version 3.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
import QtQuick 1.0
 
20
 
 
21
FocusScope {
 
22
    id: multiRangeView
 
23
 
 
24
    property alias model: list.model
 
25
    property alias count: list.count
 
26
    property int cellWidth: Math.floor(width / count)
 
27
 
 
28
    /* Keep track of active cells with array, from which determine index
 
29
        of leftmost and rightmost active cells.*/
 
30
    property variant activeCells: Array(count)
 
31
    property int leftActiveCell: -1
 
32
    property int rightActiveCell: -1
 
33
 
 
34
    function cellActivationChanged(cellId, state) {
 
35
        var tmp = activeCells
 
36
        tmp[cellId] = state
 
37
        activeCells = tmp
 
38
        setSelectionBarPosition()
 
39
    }
 
40
 
 
41
    function setSelectionBarPosition() {
 
42
        leftActiveCell = activeCells.indexOf(true)
 
43
        rightActiveCell = activeCells.lastIndexOf(true);
 
44
    }
 
45
 
 
46
    Rectangle {
 
47
        id: container
 
48
 
 
49
        /* FIXME: Rectangle's borders grow half inside and half outside of the
 
50
           rectangle. In order to avoid it being clipped, we adjust its size
 
51
           and position depending on its border's width.
 
52
 
 
53
           Ref.: http://lists.qt.nokia.com/pipermail/qt-qml/2010-May/000264.html
 
54
        */
 
55
        x: Math.floor(border.width / 2)
 
56
        y: Math.floor(border.width / 2)
 
57
        width: parent.width - border.width
 
58
        height: parent.height - border.width
 
59
 
 
60
        border.color: "#21ffffff" // 80% opaque white
 
61
        border.width: 1
 
62
        color: "transparent"
 
63
        radius: 5
 
64
    }
 
65
 
 
66
    ListView {
 
67
        id: list
 
68
 
 
69
        anchors.fill: parent
 
70
        orientation: ListView.Horizontal
 
71
        focus: true
 
72
        boundsBehavior: Flickable.StopAtBounds
 
73
 
 
74
        delegate: MultiRangeButton {
 
75
            height: ListView.view.height
 
76
            width: cellWidth
 
77
            text: item.name
 
78
            checked: item.active
 
79
            onClicked: item.active = !item.active
 
80
            onCheckedChanged: cellActivationChanged(model.index, checked)
 
81
            isLast: ( model.index == count-1 )
 
82
            Component.onCompleted: cellActivationChanged(model.index, item.active)
 
83
        }
 
84
    }
 
85
 
 
86
    MultiRangeSelectionBar {
 
87
        id: selectionBar
 
88
 
 
89
        visible: ( leftActiveCell != -1 && rightActiveCell != -1 )
 
90
        isFirst: ( leftActiveCell == 0 )
 
91
        isLast: ( rightActiveCell == count-1 )
 
92
        leftPos: ( leftActiveCell == 0 ) ? 0 : leftActiveCell*cellWidth-2
 
93
        /* Hack: Rounding errors can mean the right of the selectionBar fails
 
94
           to wholly cover the container Rectangle (and its border) */
 
95
        rightPos: ( rightActiveCell == count-1 ) ? parent.width : (rightActiveCell+1)*cellWidth+3
 
96
    }
 
97
}