Changeset View
Changeset View
Standalone View
Standalone View
applets/taskmanager/package/contents/code/layout.js
Show All 11 Lines | |||||
12 | * GNU General Public License for more details. * | 12 | * GNU General Public License for more details. * | ||
13 | * * | 13 | * * | ||
14 | * You should have received a copy of the GNU General Public License * | 14 | * You should have received a copy of the GNU General Public License * | ||
15 | * along with this program; if not, write to the * | 15 | * along with this program; if not, write to the * | ||
16 | * Free Software Foundation, Inc., * | 16 | * Free Software Foundation, Inc., * | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | ||
18 | ***************************************************************************/ | 18 | ***************************************************************************/ | ||
19 | 19 | | |||
20 | var iconSizes = ["small", "smallMedium", "medium", "large", "huge", "enormous"]; | ||||
21 | | ||||
20 | function horizontalMargins() { | 22 | function horizontalMargins() { | ||
21 | return taskFrame.margins.left + taskFrame.margins.right; | 23 | return taskFrame.margins.left + taskFrame.margins.right; | ||
22 | } | 24 | } | ||
23 | 25 | | |||
24 | function verticalMargins() { | 26 | function verticalMargins() { | ||
25 | return taskFrame.margins.top + taskFrame.margins.bottom; | 27 | return taskFrame.margins.top + taskFrame.margins.bottom; | ||
26 | } | 28 | } | ||
27 | 29 | | |||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | |||||
127 | } | 129 | } | ||
128 | 130 | | |||
129 | function preferredMinHeight() { | 131 | function preferredMinHeight() { | ||
130 | // TODO FIXME UPSTREAM: Port to proper font metrics for descenders once we have access to them. | 132 | // TODO FIXME UPSTREAM: Port to proper font metrics for descenders once we have access to them. | ||
131 | return theme.mSize(theme.defaultFont).height + 4; | 133 | return theme.mSize(theme.defaultFont).height + 4; | ||
132 | } | 134 | } | ||
133 | 135 | | |||
134 | function preferredMaxHeight() { | 136 | function preferredMaxHeight() { | ||
137 | if (tasks.vertical) { | ||||
138 | return verticalMargins() | ||||
139 | + Math.min( | ||||
140 | // Do not allow the preferred icon size to exceed the width of the vertical task manager. | ||||
141 | tasks.width, | ||||
142 | Math.max( | ||||
143 | // This assumes that we show some text and that we need some minimal vertical space for it. | ||||
144 | // In reality, we do not always show the text. We show the text only if there | ||||
145 | // is enough horizontal space for some hard coded amount of 'm' characters | ||||
146 | // - see minimumMColumns() below. | ||||
147 | // Hence in case the user prefers icons smaller than the height of his font, | ||||
148 | // the font height will win even if the text will stay invisible. | ||||
149 | // We leave it for the future developers to improve this expresssion if the | ||||
150 | // named corner case turns out to be important. | ||||
151 | units.iconSizes[iconSizes[plasmoid.configuration.iconSize]], | ||||
152 | theme.mSize(theme.defaultFont).height | ||||
153 | ) | ||||
154 | ); | ||||
155 | } else { | ||||
135 | return verticalMargins() + Math.min(units.iconSizes.small * 3, theme.mSize(theme.defaultFont).height * 3); | 156 | return verticalMargins() + Math.min(units.iconSizes.small * 3, theme.mSize(theme.defaultFont).height * 3); | ||
136 | } | 157 | } | ||
158 | } | ||||
159 | | ||||
160 | // Returns the number of 'm' characters whose joint width must be available in the task button label | ||||
161 | // so that the button text is rendered at all. | ||||
162 | function minimumMColumns() { | ||||
163 | return tasks.vertical ? 4 : 5; | ||||
164 | } | ||||
137 | 165 | | |||
138 | function taskWidth() { | 166 | function taskWidth() { | ||
139 | if (tasks.vertical) { | 167 | if (tasks.vertical) { | ||
140 | return Math.floor(taskList.width / calculateStripes()); | 168 | return Math.floor(taskList.width / calculateStripes()); | ||
141 | } else { | 169 | } else { | ||
142 | if (full() && Math.max(1, logicalTaskCount()) > tasksPerStripe()) { | 170 | if (full() && Math.max(1, logicalTaskCount()) > tasksPerStripe()) { | ||
143 | return Math.floor(taskList.width / Math.ceil(logicalTaskCount() / maxStripes())); | 171 | return Math.floor(taskList.width / Math.ceil(logicalTaskCount() / maxStripes())); | ||
144 | } else { | 172 | } else { | ||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |