=== modified file 'src/com/goldencode/p2j/ui/client/gui/WindowTitleBar.java' --- src/com/goldencode/p2j/ui/client/gui/WindowTitleBar.java 2015-09-09 21:55:03 +0000 +++ src/com/goldencode/p2j/ui/client/gui/WindowTitleBar.java 2015-09-10 15:14:23 +0000 @@ -590,7 +590,9 @@ extends Label { + /** The cached window title */ private String title; + /** True value indicates that the title is changed and the graphics device must be notified.*/ private boolean titleIsChanged; /** * Basic c'tor. @@ -638,6 +640,7 @@ if (titleIsChanged || !title.equals(getTitle())) { + // notify client about new title gd.setTitle(title); titleIsChanged = false; } === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js' --- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2015-09-09 21:55:03 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2015-09-10 16:31:01 +0000 @@ -1407,7 +1407,10 @@ } var win = getWindow(wid); - + + //remove its task icon + taskBar.removeTaskIcon(wid); + win.cleanup(); for (var image in images) @@ -1447,6 +1450,8 @@ var win = getWindow(wid); win.setVisible(visible); + // view/hide task icon usecases + taskBar.setTaskIconVisible(wid, visible); }; /** @@ -1597,8 +1602,8 @@ desktop = new VirtualDesktop( sendWindowStateActive, - [194, 194, 194], - [128, 128, 128], + [174, 174, 174], + [144, 144, 144], p2j.fonts, p2j.logger); taskBar = desktop.getTaskBar(); === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js' --- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js 2015-09-09 21:55:03 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js 2015-09-10 16:49:12 +0000 @@ -201,55 +201,36 @@ */ function TaskBar(peer, bg, fg, fontsManager, logger) { + /** The dragged task bar panel opacity */ var DRAGGED_OPACITY = 0.3; - /** - * Top padding from the task bar border - */ + /** Top padding from the task bar border */ var TOP_PADDING = 2; - /** - * Bottom padding from the task bar border - */ + /** Bottom padding from the task bar border */ var BOTTOM_PADDING = 2; - /** - * Left padding from the task bar border - */ + /** Left padding from the task bar border */ var LEFT_PADDING = 2; - /** - * Right padding from the task bar border - */ + /** Right padding from the task bar border */ var RIGHT_PADDING = 2; - /** - * Margin around the icon - */ + /** Margin around the icon */ var ICON_MARGIN = 1; - /** - * Margin around the text - */ + /** Margin around the text */ var TEXT_MARGIN = 4; - /** - * The task bar title. - */ + /** The task bar title. */ var TASK_BAR_TITLE = "Task Bar"; - /** - * The default task icon widget dimension: 40 x32 - */ + /** The default task icon widget dimension: 40 x32 */ var TASK_ICON_WIDTH = 40; var TASK_ICON_HEIGHT = 32; - /** - * The space between task icons. - */ + /** The space between task icons. */ var SHIFT = 2; /** - * The task bar font id uses negative number in order - * to be different from fonts created for p2j windows + * The task bar font id uses negative number in order to be different from fonts + * created for p2j windows. */ var TASK_BAR_FONT_ID = -1; var LIGHTEN_COLOR_INTENSE = 10; - /** - * The task bar dragged panel - */ + /** The task bar dragged panel */ var dragged; var canvas = document.createElement('canvas'); @@ -262,8 +243,10 @@ var ctx = canvas.getContext('2d', {alpha : true}); var strokesManager = new LineStrokes(); var canvasRenderer = new CanvasRenderer(canvas, ctx, strokesManager, fontsManager, logger); - + /** visible task icons */ var taskIcons = []; + /** hidden task icons */ + var hiddenTaskIcons = []; var viewLogButton = createViewLogButton(logger); @@ -282,9 +265,7 @@ setDefaultTooltip(); } - /** - * The default task bar tooltip. - */ + /** The default task bar tooltip. */ function setDefaultTooltip() { peer.title = TASK_BAR_TITLE; @@ -383,10 +364,11 @@ var unified = calculateTaskIconWidth(width, height, SHIFT, horizontalLayout); setUnifiedDimension(unified, TASK_ICON_HEIGHT, horizontalLayout); - + + //find first visible var x; var y; - + if (horizontalLayout) { x = LEFT_PADDING; @@ -567,10 +549,10 @@ sysButtons.forEach(setDimension); }; - /** - * Draws the task bar on the canvas. - */ - this.draw = function() + this.draw = draw; + + /** Draws the task bar on the canvas. */ + function draw() { doLayout(peer.offsetWidth, peer.offsetHeight); } @@ -588,14 +570,92 @@ */ function addTaskIcon(windowId) { - var taskIcon = new TaskIcon(windowId, TASK_ICON_WIDTH, TASK_ICON_HEIGHT, foreground, - "", null, 0, 0); - taskIcons.push(taskIcon); - // By default the task is active. Only one task can be active. - deactivateHead(); - return taskIcon; - }; - + var taskIcon = findTaskIcon(windowId); + if (taskIcon === null) + { + taskIcon = new TaskIcon(windowId, TASK_ICON_WIDTH, TASK_ICON_HEIGHT, foreground, + "", null, 0, 0); + taskIcons.push(taskIcon); + // By default the task is active. Only one task can be active. + deactivateHead(); + } + return taskIcon; + }; + + this.removeTaskIcon = removeTaskIcon; + + /** + * Removes the task icon corresponding to the given window. + * + * @param {Number} windowId + * The id of the window. + * + * @return {TaskIcon} + * The removed window task icon. + */ + function removeTaskIcon(windowId) + { + var taskIcon = findWidget(windowId, taskIcons); + if (taskIcon) + { + var index = taskIcon.index; + //shrunk the task icons by removing it + taskIcons.splice(index, 1); + return taskIcon; + } + taskIcon = findWidget(windowId, hiddenTaskIcons); + if (taskIcon) + { + var index = taskIcon.index; + //shrunk the task icons by removing it + hiddenTaskIcons.splice(index, 1); + return taskIcon; + } + return taskIcon; + }; + + this.setTaskIconVisible = setTaskIconVisible; + + /** + * View/hides the task icon for the given window. + * + * @param {Number} windowId + * The id of the window. + * @param {Boolean} visible + * The true value indicates that the target task icon becomes + * displayed on the task bar. + * + * @return {TaskIcon} + * The visible/hidden window task icon. + */ + function setTaskIconVisible(windowId, visible) + { + var taskIcon; + var widgetsToAdd; + var widgetsToRemove; + if (visible) + { + widgetsToRemove = hiddenTaskIcons; + widgetsToAdd = taskIcons; + } + else + { + widgetsToRemove = taskIcons; + widgetsToAdd = hiddenTaskIcons; + } + taskIcon = findWidget(windowId, widgetsToRemove); + if (taskIcon) + { + var index = taskIcon.index; + //shrunk the task icons by removing it + widgetsToRemove.splice(index, 1); + widgetsToAdd.push(taskIcon); + //if the task icon becomes visible it should be active + taskIcon.setActive(visible); + } + return taskIcon; + }; + /** * Deactivate the head tasks. */ @@ -628,9 +688,12 @@ function setIconForTask(windowId, iconData, iconWidth, iconHeight) { var taskIcon = findTaskIcon(windowId); - taskIcon.iconData = iconData; - taskIcon.iconWidth = iconWidth; - taskIcon.iconHeight = iconHeight; + if (taskIcon) + { + taskIcon.iconData = iconData; + taskIcon.iconWidth = iconWidth; + taskIcon.iconHeight = iconHeight; + } return taskIcon; }; @@ -650,7 +713,10 @@ function setTitleForTask(windowId, title) { var taskIcon = findTaskIcon(windowId); - taskIcon.title = title; + if (taskIcon) + { + taskIcon.title = title; + } return taskIcon; }; @@ -700,17 +766,39 @@ */ function findTaskIcon(windowId) { - for (var i = 0; i < taskIcons.length; i++) - { - var taskIcon = taskIcons[i]; + var taskIcon = findWidget(windowId, taskIcons); + if (taskIcon) + { + return taskIcon; + } + //try hidden task icons + return findWidget(windowId, hiddenTaskIcons); + }; + + /** + * Find the window task that represents the target window from the given searchable set. + * + * @param {Number} windowId + * The target window id. + * @param {Array} widgets + * The searchable array of TaskIcon. + * + * @return {TaskIcon} + * The task that represents the target window. + */ + function findWidget(windowId, widgets) + { + for (var i = 0; i < widgets.length; i++) + { + var taskIcon = widgets[i]; if (taskIcon.id === windowId) { + taskIcon.index = i; return taskIcon; } } return null; }; - /** * Collapses the given window. Sets the corresponding task icon to be inactive. * @@ -724,7 +812,6 @@ { return; } - logger.log("TaskBar.iconify(" + windowId + ")"); taskIcon.setActive(false); taskIcon.draw(); }; @@ -742,7 +829,6 @@ { return; } - logger.log("TaskBar.deiconify(" + windowId + ")"); taskIcon.setActive(true); taskIcon.draw(); }; @@ -834,7 +920,7 @@ parent.addChild(dragged); parent.style.zIndex = MAX_Z_INDEX; } - doLayout(peer.offsetWidth, peer.offsetHeight); + draw(); } event.preventDefault(); }, false); @@ -924,7 +1010,7 @@ function() { resizeTimeout = null; - doLayout(peer.offsetWidth, peer.offsetHeight); + draw(); }, 100); } }; @@ -984,6 +1070,9 @@ var active = true; this.x = 0; this.y = 0; + /**The internal index, if the task icon is on the task bar, it is set + * to the task icon postion. It holds only a temporary state.*/ + this.index = -1; /** * Defines the widget's title layout, */ @@ -1002,9 +1091,7 @@ this.setActive = setActive; - /** - * Sets an active state. - */ + /** Sets an active state. */ function setActive(value) { active = value; @@ -1012,9 +1099,7 @@ this.isActive = isActive; - /** - * Is active? - */ + /** Is active? */ function isActive() { return active; @@ -1028,7 +1113,7 @@ function draw() { var c; - if (active) + if (!active) { c = canvasRenderer.lightenColor(that.color); } @@ -1102,7 +1187,7 @@ xTextPos = 0; yTextPos = 0; } - if (active) + if (!active) { var textRgb = canvasRenderer.parseColor(ctx.fillStyle); var selectedTextRgb = canvasRenderer.lightenColor(textRgb).map(