~zsombi/ubuntu-ui-toolkit/crossFadeImage_SourceSize_fix

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
 * Copyright (C) 2012 Canonical Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; version 3.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*!
    \page resolution-independence.html resolution-independence
    \title Resolution Independence
    \nextpage {Ubuntu User Interface Toolkit}

    The objective of resolution independence is to make it easy for graphical
    user interfaces in Ubuntu to scale to all the form factors that Ubuntu
    targets: phones, tablets, laptops and desktops.
    The approach taken combines simplicity for the designers and developers
    with visual fidelity, quality and usability.


    \part Measurement Units

    A new measurement unit is defined called the grid unit, abbreviated \b{\e gu}.
    1 grid unit translates to a given number of pixels depending on the type of
    screen that the user interface is displayed on.
    For example, on a laptop computer 1 grid unit will typically translate to 8 pixels.
    The number of pixels per grid unit is chosen in order to preserve the perceived
    visual size of UI elements and therefore depends on the density of the display
    and the distance the user is to the screen. We also ensure that 1 grid unit is
    always an integer number of pixel.

    Examples:

    \table
    \header
      \li Device
      \li Conversion
    \row
      \li Most laptops
      \li 1 gu = 8 px
    \row
      \li Retina laptops
      \li 1 gu = 16 px
    \row
      \li Phone with 4 inch screen at HD resolution (around 720x1,280 pixels)
      \li 1 gu = 18 px
    \row
      \li Tablet with 10 inch screen at HD resolution (around 720x1,280 pixels)
      \li 1 gu = 10 px
    \endtable

    The grid unit defines a visual rhythm in Ubuntu and should be used for all measurements.
    Sizes of elements, spacing, margins, etc. should all use multiples of 1 gu.

    It is available from QML as a method of the global object \b units, instance of \l Units.

    Example Usage:
    \code
    import Ubuntu.Components 0.1

    Item {
        width: units.gu(2)
        height: units.gu(5)
    }
    \endcode

    Exceptionally, in order to accommodate for the rare cases where measurements of less
    than 1 gu are needed another unit is available: the density independent pixel,
    abbreviated \b{\e dp}. 1 dp typically translates to 1 pixel on laptops and low
    density mobile phones and tablets.

    Example Usage:
    \code
    import Ubuntu.Components 0.1

    Rectangle {
        height: units.dp(1)
    }
    \endcode

    \part Bitmaps

    Vector graphics, fonts and programmatically drawn elements will usually scale well
    to the different devices. On the other hand, bitmaps will typically require a bit
    more care.

    The size of a bitmap needs to be adequate to render well on a given
    device. The toolkit allows to design multiple versions of a bitmap and choose
    the appropriate one dynamically depending on the device the application is
    being run on.
    In order to know for what target device a given version of a bitmap was
    produced, we define a file naming convention based on the number of pixel
    per grid unit of the device.

    Example:

    If the target device the bitmap is produced for has 10 pixels per
    grid unit, then the file name of the bitmap should be suffixed with @10:
    \e my_bitmap.png should be renamed to \e my_bitmap@10.png.


    In order to support the highest possible resolution devices on the market, we
    recommend to always design bitmaps for a device that would have 30 pixels per
    grid unit (@30 suffix). The system will perform a high quality downscaling of
    the bitmap when needed on lower resolution screens.

    Example:

    If the destination size of the bitmap is 10 gu * 10 gu and the developer
    targets a device that has 18 pixels per grid unit (1 gu = 18 px), the bitmap
    should still be created as if 1 gu = 30 px which results in a 300 px * 300 px
    bitmap. When testing on the device the bitmap will be downscaled by a factor
    of 30 / 18 = 1.66667.


    \part Fonts

    It is critical for the font sizes to be consistent across Ubuntu and to
    have a rhythm defining them.
    Instead of setting the font size in pixels or points, it is imperative to
    define the font size in terms of literals:

    \table
    \row
      \li \b x-large
    \row
      \li \b large
    \row
      \li \b medium
    \row
      \li \b small
    \row
      \li \b x-small
    \endtable

    Example Usage:
    \code
    import Ubuntu.Components 0.1

    Label {
        fontSize: "small"
    }
    \endcode

    For reference when designing, these sizes correspond to the following
    pixel measurements:

    \table
    \header
      \li Font Size
      \li Desktop
      \li Smart Phone with 4" HD screen
      \li Tablet with 10" HD screen
    \row
      \li \b{\e x-large}
      \li 34 px
      \li 76 px
      \li 42 px
    \row
      \li \b{\e large}
      \li 20 px
      \li 45 px
      \li 25 px
    \row
      \li \b{\e medium}
      \li 14 px
      \li 31 px
      \li 18 px
    \row
      \li \b{\e small}
      \li 12 px
      \li 27 px
      \li 15 px
    \row
      \li \b{\e x-small}
      \li 10 px
      \li 22 px
      \li 12 px
    \endtable

 */