1
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/ModalWindow.java'
|
2
|
--- src/com/goldencode/p2j/ui/client/gui/ModalWindow.java 2015-08-26 22:14:27 +0000
|
3
|
+++ src/com/goldencode/p2j/ui/client/gui/ModalWindow.java 2015-09-09 21:33:23 +0000
|
4
|
@@ -74,7 +74,8 @@
|
5
|
|
6
|
titleBar = new WindowTitleBar(WidgetId.nextID(),
|
7
|
false,
|
8
|
- new CaptionButtonType[] {CaptionButtonType.CLOSE});
|
9
|
+ new CaptionButtonType[] {CaptionButtonType.CLOSE},
|
10
|
+ title);
|
11
|
windowPane.add(titleBar);
|
12
|
windowPane.add(contentPane);
|
13
|
add(windowPane);
|
14
|
|
15
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/WindowGuiImpl.java'
|
16
|
--- src/com/goldencode/p2j/ui/client/gui/WindowGuiImpl.java 2015-09-04 13:38:15 +0000
|
17
|
+++ src/com/goldencode/p2j/ui/client/gui/WindowGuiImpl.java 2015-09-09 21:32:42 +0000
|
18
|
@@ -1316,8 +1316,7 @@
|
19
|
protected void reset()
|
20
|
{
|
21
|
super.reset();
|
22
|
-
|
23
|
- titleBar = new WindowTitleBar(WidgetId.nextID());
|
24
|
+ titleBar = new WindowTitleBar(WidgetId.nextID(), title());
|
25
|
// TODO: what is the layout mgr for the GUI window (the workspace)?
|
26
|
workspace = new WindowWorkSpace(WidgetId.nextID(), ScrollBar.Bars.BOTH);
|
27
|
|
28
|
|
29
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/WindowTitleBar.java'
|
30
|
--- src/com/goldencode/p2j/ui/client/gui/WindowTitleBar.java 2015-09-08 22:00:49 +0000
|
31
|
+++ src/com/goldencode/p2j/ui/client/gui/WindowTitleBar.java 2015-09-09 21:45:30 +0000
|
32
|
@@ -93,15 +93,18 @@
|
33
|
*
|
34
|
* @param id
|
35
|
* The widget's ID.
|
36
|
+ * @param windowTitle
|
37
|
+ * The window title.
|
38
|
*/
|
39
|
- public WindowTitleBar(WidgetId id)
|
40
|
+ public WindowTitleBar(WidgetId id, String windowTitle)
|
41
|
{
|
42
|
this(id, true, new CaptionButtonType[]
|
43
|
{
|
44
|
CaptionButtonType.ICONIFY,
|
45
|
CaptionButtonType.MAXIMIZE,
|
46
|
CaptionButtonType.CLOSE
|
47
|
- });
|
48
|
+ },
|
49
|
+ windowTitle);
|
50
|
}
|
51
|
|
52
|
/**
|
53
|
@@ -113,8 +116,11 @@
|
54
|
* If <code>true</code> the window's window icon will be shown.
|
55
|
* @param buttonTypes
|
56
|
* Array of button types to create on the bar.
|
57
|
+ * @param windowTitle
|
58
|
+ * The window title.
|
59
|
*/
|
60
|
- public WindowTitleBar(WidgetId id, boolean showWindowIcon, CaptionButtonType[] buttonTypes)
|
61
|
+ public WindowTitleBar(WidgetId id, boolean showWindowIcon, CaptionButtonType[] buttonTypes,
|
62
|
+ String windowTitle)
|
63
|
{
|
64
|
nativeInsets = new NativeInsets(2, 2, 2, 2);
|
65
|
|
66
|
@@ -139,6 +145,7 @@
|
67
|
}
|
68
|
|
69
|
title = new WindowTitle(WidgetId.nextID());
|
70
|
+ title.setTitle(windowTitle);
|
71
|
this.add(title);
|
72
|
|
73
|
buttons = new CaptionButton[buttonTypes.length];
|
74
|
@@ -582,6 +589,9 @@
|
75
|
private class WindowTitle
|
76
|
extends Label<GuiOutputManager>
|
77
|
{
|
78
|
+
|
79
|
+ private String title;
|
80
|
+ private boolean titleIsChanged;
|
81
|
/**
|
82
|
* Basic c'tor.
|
83
|
*
|
84
|
@@ -592,7 +602,29 @@
|
85
|
{
|
86
|
super(id, "", WindowTitleBar.this.getId().asInt());
|
87
|
}
|
88
|
-
|
89
|
+
|
90
|
+ /**
|
91
|
+ * Returns the window title.
|
92
|
+ *
|
93
|
+ * @return The title
|
94
|
+ */
|
95
|
+ public String getTitle()
|
96
|
+ {
|
97
|
+ return title;
|
98
|
+ }
|
99
|
+
|
100
|
+ /**
|
101
|
+ * Sets the window title.
|
102
|
+ *
|
103
|
+ * @param title
|
104
|
+ * The title to set
|
105
|
+ */
|
106
|
+ public void setTitle(String title)
|
107
|
+ {
|
108
|
+ this.title = title;
|
109
|
+ this.titleIsChanged = true;
|
110
|
+ }
|
111
|
+
|
112
|
/**
|
113
|
* Draw this window title.
|
114
|
*/
|
115
|
@@ -603,7 +635,12 @@
|
116
|
String windowTitle = window.title();
|
117
|
|
118
|
final String title = (windowTitle == null ? WindowGuiImpl.DEFAULT_TITLE : windowTitle);
|
119
|
- gd.setTitle(title);
|
120
|
+
|
121
|
+ if (titleIsChanged || !title.equals(getTitle()))
|
122
|
+ {
|
123
|
+ gd.setTitle(title);
|
124
|
+ titleIsChanged = false;
|
125
|
+ }
|
126
|
NativePoint origin = physicalLocation();
|
127
|
final NativeDimension d = physicalDimension();
|
128
|
final NativeRectangle clip = clipRectangle(origin, d);
|
129
|
|
130
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js'
|
131
|
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2015-09-09 15:55:53 +0000
|
132
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2015-09-09 21:13:14 +0000
|
133
|
@@ -734,9 +734,6 @@
|
134
|
fontId = p2j.socket.readInt32BinaryMessage(message, idx + 1);
|
135
|
|
136
|
setFont(this.ctx, fontId);
|
137
|
-
|
138
|
- //sets font for the task bar
|
139
|
- taskBar.setDefaultFont(fontId);
|
140
|
break;
|
141
|
case ops.SET_FONT_STYLE:
|
142
|
var style = p2j.socket.readInt32BinaryMessage(message, idx + 1);
|
143
|
@@ -1605,6 +1602,7 @@
|
144
|
p2j.fonts,
|
145
|
p2j.logger);
|
146
|
taskBar = desktop.getTaskBar();
|
147
|
+ taskBar.setFont(cfg);
|
148
|
};
|
149
|
|
150
|
/**
|
151
|
|
152
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js'
|
153
|
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js 2015-09-09 15:55:53 +0000
|
154
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js 2015-09-09 21:13:14 +0000
|
155
|
@@ -202,19 +202,56 @@
|
156
|
function TaskBar(peer, bg, fg, fontsManager, logger)
|
157
|
{
|
158
|
var DRAGGED_OPACITY = 0.3;
|
159
|
- var TOP_PADDING = 2;
|
160
|
- var LEFT_PADDING = 2;
|
161
|
+ /**
|
162
|
+ * Top padding from the task bar border
|
163
|
+ */
|
164
|
+ var TOP_PADDING = 2;
|
165
|
+ /**
|
166
|
+ * Bottom padding from the task bar border
|
167
|
+ */
|
168
|
+ var BOTTOM_PADDING = 2;
|
169
|
+ /**
|
170
|
+ * Left padding from the task bar border
|
171
|
+ */
|
172
|
+ var LEFT_PADDING = 2;
|
173
|
+ /**
|
174
|
+ * Right padding from the task bar border
|
175
|
+ */
|
176
|
+ var RIGHT_PADDING = 2;
|
177
|
+ /**
|
178
|
+ * Margin around the icon
|
179
|
+ */
|
180
|
var ICON_MARGIN = 1;
|
181
|
- var TEXT_MARGIN = 1;
|
182
|
- var TASK_BAR_TITLE = "Task Bar";
|
183
|
+ /**
|
184
|
+ * Margin around the text
|
185
|
+ */
|
186
|
+ var TEXT_MARGIN = 4;
|
187
|
+ /**
|
188
|
+ * The task bar title.
|
189
|
+ */
|
190
|
+ var TASK_BAR_TITLE = "Task Bar";
|
191
|
+ /**
|
192
|
+ * The default task icon widget dimension: 40 x32
|
193
|
+ */
|
194
|
var TASK_ICON_WIDTH = 40;
|
195
|
var TASK_ICON_HEIGHT = 32;
|
196
|
+ /**
|
197
|
+ * The space between task icons.
|
198
|
+ */
|
199
|
var SHIFT = 2;
|
200
|
|
201
|
- var TASK_BAR_FONT_ID = createDefaultFont();
|
202
|
-
|
203
|
-
|
204
|
+ /**
|
205
|
+ * The task bar font id uses negative number in order
|
206
|
+ * to be different from fonts created for p2j windows
|
207
|
+ */
|
208
|
+ var TASK_BAR_FONT_ID = -1;
|
209
|
+
|
210
|
+ var LIGHTEN_COLOR_INTENSE = 10;
|
211
|
+ /**
|
212
|
+ * The task bar dragged panel
|
213
|
+ */
|
214
|
var dragged;
|
215
|
+
|
216
|
var canvas = document.createElement('canvas');
|
217
|
canvas.className="canvas";
|
218
|
canvas.style["height"] = "100%";
|
219
|
@@ -246,20 +283,6 @@
|
220
|
}
|
221
|
|
222
|
/**
|
223
|
- * Creates the default font for the task bar.
|
224
|
- * It is added for the standalone test.
|
225
|
- */
|
226
|
- function createDefaultFont()
|
227
|
- {
|
228
|
- var font = 1;
|
229
|
- var name = "sans-serif";
|
230
|
- var size = 8;
|
231
|
- var style = 1;
|
232
|
- var b64Font = "";
|
233
|
- return fontsManager.createFont(font, name, size, style, b64Font);
|
234
|
- };
|
235
|
-
|
236
|
- /**
|
237
|
* The default task bar tooltip.
|
238
|
*/
|
239
|
function setDefaultTooltip()
|
240
|
@@ -311,7 +334,7 @@
|
241
|
var y;
|
242
|
if (horizontalLayout)
|
243
|
{
|
244
|
- x = width - viewLogButton.width - LEFT_PADDING;
|
245
|
+ x = width - viewLogButton.width - RIGHT_PADDING;
|
246
|
// to place on the centered horizontal line of the task bar.
|
247
|
y = (height - viewLogButton.height) / 2;
|
248
|
}
|
249
|
@@ -319,7 +342,7 @@
|
250
|
{
|
251
|
// to place on the centered vertical line of the task bar.
|
252
|
x = (width - viewLogButton.width) / 2;
|
253
|
- y = height - viewLogButton.height - TOP_PADDING;
|
254
|
+ y = height - viewLogButton.height - BOTTOM_PADDING;
|
255
|
}
|
256
|
viewLogButton.setLocation(x, y);
|
257
|
viewLogButton.draw();
|
258
|
@@ -358,7 +381,7 @@
|
259
|
horizontalLayout = false;
|
260
|
}
|
261
|
|
262
|
- var unified = calculateTaskIconWidth(width, height, horizontalLayout);
|
263
|
+ var unified = calculateTaskIconWidth(width, height, SHIFT, horizontalLayout);
|
264
|
setUnifiedDimension(unified, TASK_ICON_HEIGHT, horizontalLayout);
|
265
|
|
266
|
var x;
|
267
|
@@ -474,6 +497,8 @@
|
268
|
* The task bar width in pixels.
|
269
|
* @param {Number} height
|
270
|
* The task bar height in pixels.
|
271
|
+ * @param {Number} space
|
272
|
+ * The space between widgets in pixels.
|
273
|
* @param {Boolean} horizontalLayout
|
274
|
* Indicates the task bar layout, true if the task bar is along a horizontal line, otherwise,
|
275
|
* it is along a vertical line.
|
276
|
@@ -481,16 +506,20 @@
|
277
|
* @return {Number}
|
278
|
* The unified task icon width.
|
279
|
*/
|
280
|
- function calculateTaskIconWidth(width, height, horizontalLayout)
|
281
|
+ function calculateTaskIconWidth(width, height, space, horizontalLayout)
|
282
|
{
|
283
|
+ var numberOfWidgets = taskIcons.length + sysButtons.length;
|
284
|
+ var wasteSpaceWidth = space * (numberOfWidgets - 1);
|
285
|
var maxWidth;
|
286
|
if (horizontalLayout)
|
287
|
{
|
288
|
- maxWidth = width / (taskIcons.length + sysButtons.length);
|
289
|
+ // LEFT_PADDING widget1 SPACE widget2 .... SPACE widgetn RIGHT_PADDING
|
290
|
+ maxWidth = (width - wasteSpaceWidth - LEFT_PADDING - RIGHT_PADDING) / numberOfWidgets;
|
291
|
}
|
292
|
else
|
293
|
{
|
294
|
- maxWidth = height / (taskIcons.length + sysButtons.length);
|
295
|
+ // TOP_PADDING widget1 SPACE widget2 .... SPACE widgetn BOTTOM_PADDING
|
296
|
+ maxWidth = (height - wasteSpaceWidth - TOP_PADDING - BOTTOM_PADDING)/ numberOfWidgets;
|
297
|
}
|
298
|
var taskIconsWidth = calculateMaximalIconWidth(taskIcons, horizontalLayout);
|
299
|
if (taskIconsWidth > 0)
|
300
|
@@ -520,7 +549,7 @@
|
301
|
*/
|
302
|
function setUnifiedDimension(unifiedWidth, unifiedHeight, horizontalLayout)
|
303
|
{
|
304
|
- function set(element, index, array)
|
305
|
+ function setDimension(element, index, array)
|
306
|
{
|
307
|
if (horizontalLayout)
|
308
|
{
|
309
|
@@ -534,8 +563,8 @@
|
310
|
}
|
311
|
array[index].horizontalLayout = horizontalLayout;
|
312
|
};
|
313
|
- taskIcons.forEach(set);
|
314
|
- sysButtons.forEach(set);
|
315
|
+ taskIcons.forEach(setDimension);
|
316
|
+ sysButtons.forEach(setDimension);
|
317
|
};
|
318
|
|
319
|
/**
|
320
|
@@ -625,15 +654,40 @@
|
321
|
return taskIcon;
|
322
|
};
|
323
|
|
324
|
- this.setDefaultFont = setDefaultFont;
|
325
|
+ this.setFont = setFont;
|
326
|
|
327
|
/**
|
328
|
* Sets the default font to be used by the task bar.
|
329
|
+ *
|
330
|
+ * @param {Object} fontConfig
|
331
|
+ * The font configuration { name : 'sans-serif', size : 8 }.
|
332
|
*/
|
333
|
- function setDefaultFont(fontId)
|
334
|
+ function setFont(fontConfig)
|
335
|
{
|
336
|
- TASK_BAR_FONT_ID = fontId;
|
337
|
- };
|
338
|
+ var font = TASK_BAR_FONT_ID;
|
339
|
+ var name;
|
340
|
+ if (fontConfig.name)
|
341
|
+ {
|
342
|
+ name = fontConfig.name;
|
343
|
+ }
|
344
|
+ else
|
345
|
+ {
|
346
|
+ name = "sans-serif";
|
347
|
+ }
|
348
|
+ var size;
|
349
|
+ if (fontConfig.size)
|
350
|
+ {
|
351
|
+ size = fontConfig.size;
|
352
|
+ }
|
353
|
+ else
|
354
|
+ {
|
355
|
+ size = 8;
|
356
|
+ }
|
357
|
+ // bold
|
358
|
+ var style = 1;
|
359
|
+ var b64Font = "";
|
360
|
+ return fontsManager.createFont(font, name, size, style, b64Font);
|
361
|
+ }
|
362
|
|
363
|
/**
|
364
|
* Find the window task that represents the target window.
|
365
|
@@ -849,6 +903,31 @@
|
366
|
canvas.addEventListener("mouseover", changeTooltipOverWidget);
|
367
|
canvas.addEventListener("mouseleave", function(event) { setDefaultTooltip(); });
|
368
|
|
369
|
+ // add MDN resize throttler
|
370
|
+ window.addEventListener("resize", resizeThrottler, false);
|
371
|
+
|
372
|
+ /**
|
373
|
+ * The id of the scheduled resize function
|
374
|
+ */
|
375
|
+ var resizeTimeout;
|
376
|
+
|
377
|
+ /**
|
378
|
+ * Redraws this task bar if the browser window is changing its size,
|
379
|
+ * with the frequency that doesn' exceed one time per 100 ms
|
380
|
+ */
|
381
|
+ function resizeThrottler()
|
382
|
+ {
|
383
|
+ // ignore resize events as long as an actualResizeHandler execution is in the queue
|
384
|
+ if (!resizeTimeout)
|
385
|
+ {
|
386
|
+ resizeTimeout = window.setTimeout(
|
387
|
+ function()
|
388
|
+ {
|
389
|
+ resizeTimeout = null;
|
390
|
+ doLayout(peer.offsetWidth, peer.offsetHeight);
|
391
|
+ }, 100);
|
392
|
+ }
|
393
|
+ };
|
394
|
/**
|
395
|
* Returns rgba(r,g,b,a) string representation for the target color
|
396
|
* with the target transparency.
|
397
|
@@ -997,33 +1076,43 @@
|
398
|
var textWidth = fontsManager.getTextWidth(TASK_BAR_FONT_ID, that.title);
|
399
|
var textHeight = fontsManager.getTextHeight(TASK_BAR_FONT_ID, that.title);
|
400
|
ctx.font = fontsManager.getFontName(TASK_BAR_FONT_ID);
|
401
|
-
|
402
|
var xTextPos;
|
403
|
var yTextPos;
|
404
|
if (that.horizontalLayout)
|
405
|
{
|
406
|
- var xShift = 0;
|
407
|
+ var xShift = TEXT_MARGIN;
|
408
|
if (that.iconWidth > 0)
|
409
|
{
|
410
|
xShift += that.iconWidth + 2 * ICON_MARGIN;
|
411
|
}
|
412
|
- xTextPos = that.x + (that.width - textWidth + xShift) / 2;
|
413
|
+ xTextPos = that.x + (that.width - TEXT_MARGIN - textWidth + xShift) / 2;
|
414
|
yTextPos = that.y + (that.height + textHeight) / 2;
|
415
|
}
|
416
|
else
|
417
|
{
|
418
|
- var yShift = 0;
|
419
|
+ var yShift = TEXT_MARGIN;
|
420
|
if (that.iconHeight > 0)
|
421
|
{
|
422
|
yShift += that.iconHeight + 2 * ICON_MARGIN;
|
423
|
}
|
424
|
xTextPos = that.x + (that.width - textHeight) / 2;
|
425
|
- yTextPos = that.y + (that.height - textWidth + yShift) / 2;
|
426
|
+ yTextPos = that.y + (that.height - TEXT_MARGIN - textWidth + yShift) / 2;
|
427
|
ctx.translate(xTextPos, yTextPos);
|
428
|
ctx.rotate(Math.PI / 2);
|
429
|
xTextPos = 0;
|
430
|
yTextPos = 0;
|
431
|
}
|
432
|
+ if (active)
|
433
|
+ {
|
434
|
+ var textRgb = canvasRenderer.parseColor(ctx.fillStyle);
|
435
|
+ var selectedTextRgb = canvasRenderer.lightenColor(textRgb).map(
|
436
|
+ function(channel)
|
437
|
+ {
|
438
|
+ return LIGHTEN_COLOR_INTENSE * channel;
|
439
|
+ });
|
440
|
+ ctx.fillStyle = canvasRenderer.createColorString(selectedTextRgb);
|
441
|
+ }
|
442
|
+
|
443
|
canvasRenderer.drawText(
|
444
|
that.title,
|
445
|
xTextPos,
|
446
|
|