Skip to content

Commit 70dbea3

Browse files
author
zhourenjian
committed
Improve user experience on task bar, tray, shortcut bar and others.
1 parent 5947abd commit 70dbea3

File tree

12 files changed

+633
-98
lines changed

12 files changed

+633
-98
lines changed

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/internal/ResizeSystem.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public static void updateResize() {
115115

116116
/**
117117
* @j2sNative
118+
* $wt.widgets.ShellManager.layoutTasks();
118119
* $wt.widgets.ShellManager.layoutShortcuts();
119120
*/ {}
120121
}

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/internal/dnd/DNDUtils.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,21 @@ public static boolean onmousedown(Object e, DragAndDrop oThis) {
104104
document.onmousemove = DNDUtils.bindFunctionWith (DNDUtils.onmousemove, oThis);
105105
document.onkeyup = DNDUtils.bindFunctionWith (DNDUtils.onkeyup, oThis);
106106
document.onmouseup = DNDUtils.bindFunctionWith (DNDUtils.onmouseup, oThis); //oThis.element.onmouseup;
107-
/*
108-
* Why ? Sep 16, 2006
109-
evt.preventDefault ();
110-
evt.stopPropagation ();
111-
return false;
112-
*/
107+
boolean isOpera = false;
108+
/**
109+
* @j2sNative
110+
* var dua = navigator.userAgent;
111+
* isOpera = dua.indexOf("Opera") >= 0;
112+
*/ {}
113+
if (isOpera) {
114+
/*
115+
* Why ? Sep 16, 2006
116+
* Opera will have text selection. Sep 15, 2008
117+
*/
118+
evt.preventDefault ();
119+
evt.stopPropagation ();
120+
return false;
121+
}
113122
return true;
114123
}
115124
public static boolean onkeyup(Object e, DragAndDrop oThis) {

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/package.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ $WTC$$.registerCSS = function (clazzName, cssText) {
152152
*/
153153
if (!ClazzLoader.isResourceExisted (clazzName, cssPath, basePath)) {
154154
$WTC$$.registeredCSSs[$WTC$$.registeredCSSs.length] = clazzName;
155-
if (cssText == null || $WTC$$.cssForcedUsingFile) {
155+
if (window["swt.debugging"] == true || cssText == null || $WTC$$.cssForcedUsingFile) {
156156
var cssLink = document.createElement ("LINK");
157157
cssLink.rel = "stylesheet";
158158
cssLink.id = cssID;

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/AboutJava2Script.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ public class AboutJava2Script {
4444
*/
4545
public static void openAbout(Shell objShell) {
4646
try {
47-
Shell aboutShell = new Shell(objShell, SWT.TOOL);
47+
Shell aboutShell = null;
48+
if (objShell == null) {
49+
aboutShell = new Shell(SWT.TOOL);
50+
} else {
51+
aboutShell = new Shell(objShell, SWT.TOOL);
52+
}
4853
aboutShell.setText("About Java2Script");
4954

5055
createContents(aboutShell);
@@ -56,6 +61,7 @@ public static void openAbout(Shell objShell) {
5661
gridLayout.horizontalSpacing = 0;
5762
aboutShell.setLayout(gridLayout);
5863

64+
aboutShell.setMinimumSize(442, 301);
5965
aboutShell.open();
6066
aboutShell.layout();
6167
aboutShell.pack();

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Decorations.java

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -391,17 +391,25 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
391391
}
392392
if ((style & (SWT.TITLE | SWT.CLOSE | SWT.MIN | SWT.MAX | SWT.BORDER)) != 0) {
393393
width += 8;
394-
height += 8;
394+
height += 5;
395395
x -= 4;
396-
y -= 4;
396+
y -= 3;
397+
if (OS.isIE50 || OS.isIE55 || OS.isIE60) {
398+
y -= 2;
399+
}
397400
} else {
398401
width += 6;
399402
height += 6;
400403
x -= 3;
401404
y -= 3;
402405
}
406+
if ((style & SWT.BORDER) != 0) {
407+
width += 4;
408+
height += 2;
409+
x += 1;
410+
//y += 1;
411+
}
403412
}
404-
// System.err.println( new Rectangle (x, y, width, height));
405413
return new Rectangle (x, y, width, height);
406414
/*
407415
/* Get the size of the trimmings *-/
@@ -696,7 +704,7 @@ void nextWindowLocation(int wHint, int hHint) {
696704

697705
int delta = OS.getStringPlainHeight("A") + 4 + 6 + 1;
698706
if (window.defaultWindowLeft == null) {
699-
window.defaultWindowLeft = "64";
707+
window.defaultWindowLeft = "160";
700708
} else {
701709
int num = Integer.parseInt("" + window.defaultWindowLeft);
702710
num += delta;
@@ -706,7 +714,7 @@ void nextWindowLocation(int wHint, int hHint) {
706714
window.defaultWindowLeft = "" + num;
707715
}
708716
if (window.defaultWindowTop == null) {
709-
window.defaultWindowTop = "64";
717+
window.defaultWindowTop = "48";
710718
} else {
711719
int num = Integer.parseInt("" + window.defaultWindowTop);
712720
num += delta;
@@ -1723,7 +1731,9 @@ public void setMaximized (boolean maximized) {
17231731
* window.setTimeout (function () {
17241732
* var lastShell = ShellManager.getTopMaximizedShell ();
17251733
* if (lastShell == null || lastShell.titleBar == null) return;
1726-
* ShellManager.topbarContainerEl.style.display = "block";
1734+
* if (ShellManager.topbarContainerEl != null) {
1735+
* ShellManager.topbarContainerEl.style.display = "block";
1736+
* }
17271737
* ShellManager.updateTopMaximized ();
17281738
* ShellManager.lastMMed = new Date().getTime();
17291739
* }, 250);
@@ -1882,7 +1892,9 @@ public void setMinimized (boolean minimized) {
18821892
* @j2sNative
18831893
* if (window["ShellManager"] != null && this.parent == null && minimized) {
18841894
* this.handle.style.display = "none";
1885-
* ShellManager.sidebarEl.style.display = "block";
1895+
* if (ShellManager.sidebarEl != null) {
1896+
* ShellManager.sidebarEl.style.display = "block";
1897+
* }
18861898
* ShellManager.updateItems ();
18871899
* ShellManager.lastMMed = new Date().getTime();
18881900
* return;
@@ -2194,6 +2206,19 @@ public void setText (String string) {
21942206
}
21952207
}
21962208
shellTitle.appendChild(document.createTextNode(string));
2209+
/**
2210+
* @j2sNative
2211+
* if (window["ShellManager"] != null && this.parent == null
2212+
* && (this.getStyle() & 4) == 0) { // SWT.TOOL
2213+
* if (ShellManager.sidebarEl != null) {
2214+
* ShellManager.sidebarEl.style.display = "block";
2215+
* }
2216+
* window.setTimeout (function () {
2217+
* ShellManager.updateItems ();
2218+
* ShellManager.lastMMed = new Date().getTime();
2219+
* }, 50);
2220+
* }
2221+
*/ {}
21972222
}
21982223
}
21992224

@@ -2312,12 +2337,18 @@ protected boolean SetWindowPos(Object hWnd, Object hWndInsertAfter, int X, int Y
23122337
int dw = 8;
23132338
//int dh = 28;
23142339
int tbh = OS.getContainerHeight(titleBar);
2315-
int dh = 8 + tbh;
2340+
if (tbh == 0 || tbh == 20 || tbh > 30) { // FIXME
2341+
tbh = 22;
2342+
}
2343+
if (OS.isIE && (tbh == 19)) {
2344+
tbh = 21;
2345+
}
2346+
int dh = 5 + tbh;
23162347
int dww = 8;
23172348
if ((style & SWT.BORDER) != 0) {
2318-
dw += 2;
2319-
dh += 3;
2320-
dww += 2;
2349+
dw += 4;
2350+
dh += 4;
2351+
dww += 4;
23212352
}
23222353
if (OS.existedCSSClass(handle, "shell-menu-bar")) {
23232354
shellMenuBar.style.top = (3 + tbh) + "px";
@@ -2330,11 +2361,11 @@ protected boolean SetWindowPos(Object hWnd, Object hWndInsertAfter, int X, int Y
23302361
dh += mbh + 1;
23312362
tbh += mbh + 1;
23322363
}
2333-
contentHandle.style.top = (3 + tbh) + "px";
2364+
contentHandle.style.top = (((style & SWT.BORDER) != 0 ? 1 : 1) + tbh) + "px";
23342365
contentHandle.style.height = ((height - dh >= 0) ? height - dh : 0) + "px";
23352366
contentHandle.style.width = ((width - dw) > 0 ? width - dw : 0) + "px";
23362367
titleBar.style.width = ((width - dww) > 0 ? width - dww : 0) + "px";
2337-
updateShellTitle(width);
2368+
updateShellTitle(width - dww + 8);
23382369
} else {
23392370
int dw = 8;
23402371
int dh = 8;
@@ -2359,8 +2390,10 @@ protected boolean SetWindowPos(Object hWnd, Object hWndInsertAfter, int X, int Y
23592390
contentHandle.style.width = (width - dw > 0 ? width - dw : 0) + "px";
23602391
}
23612392
if ((style & SWT.BORDER) != 0) {
2362-
cx -= 4;
2393+
cx -= 6;
23632394
cy -= 4;
2395+
} else {
2396+
cx -= 2;
23642397
}
23652398
Element el = (Element) hWnd;
23662399
el.style.left = X + "px";

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Display.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,6 +2255,14 @@ public Image getSystemImage (int id) {
22552255
public Tray getSystemTray () {
22562256
checkDevice ();
22572257
if (tray != null) return tray;
2258+
for (int i = 0; i < Displays.length; i++) {
2259+
Display disp = Displays[i];
2260+
if (disp != null) {
2261+
if (disp.tray != null) {
2262+
return disp.tray;
2263+
}
2264+
}
2265+
}
22582266
return tray = new Tray (this, SWT.NONE);
22592267
}
22602268

@@ -3104,7 +3112,6 @@ public boolean readAndDispatch () {
31043112
private boolean messageLoop = false;
31053113
public void run() {
31063114
runPopups ();
3107-
// System.out.println("I'm entering the run");
31083115
// System.out.println("msg " + Display.this.msgs);
31093116
// List layoutQueue = new ArrayList();
31103117
MESSAGE[] msgs = Display.this.msgs;
@@ -3693,7 +3700,6 @@ void sendEvent (int eventType, Event event) {
36933700
}
36943701

36953702
void sendMessage(MESSAGE msg) {
3696-
// System.out.println("message:" + msg.control);
36973703
msgs[msgs.length] = msg;
36983704
}
36993705
/**

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Shell.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,17 @@ int callWindowProc (int hwnd, int msg, int wParam, int lParam) {
489489
public void close () {
490490
checkWidget ();
491491
closeWidget ();
492+
/**
493+
* @j2sNative
494+
* if (window["ShellManager"] != null && (this.getStyle() & 4) == 0) { // SWT.TOOL
495+
* ShellManager.removeShellItem (this);
496+
* if (ShellManager.sidebarEl != null) {
497+
* ShellManager.sidebarEl.style.display = "block";
498+
* }
499+
* ShellManager.updateItems ();
500+
* ShellManager.lastMMed = new Date().getTime();
501+
* }
502+
*/ {}
492503
}
493504

494505
protected void createHandle () {
@@ -940,6 +951,13 @@ public void open () {
940951
* if (window["ShellManager"] != null && this.parent == null
941952
* && (this.getStyle() & 4) == 0) { // SWT.TOOL
942953
* ShellManager.createShellItem (this);
954+
* if (ShellManager.sidebarEl != null) {
955+
* ShellManager.sidebarEl.style.display = "block";
956+
* }
957+
* window.setTimeout (function () {
958+
* ShellManager.updateItems ();
959+
* ShellManager.lastMMed = new Date().getTime();
960+
* }, 50);
943961
* }
944962
*/ {}
945963
}
@@ -1373,6 +1391,13 @@ public void setVisible (boolean visible) {
13731391
* } else {
13741392
* ShellManager.createShellItem (this);
13751393
* }
1394+
* if (ShellManager.sidebarEl != null) {
1395+
* ShellManager.sidebarEl.style.display = "block";
1396+
* }
1397+
* window.setTimeout (function () {
1398+
* ShellManager.updateItems ();
1399+
* ShellManager.lastMMed = new Date().getTime();
1400+
* }, 50);
13761401
* }
13771402
*/ {}
13781403

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/ShellManager.css

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@
22
position:absolute;
33
top:0;
44
left:0;
5-
z-index:3690;
5+
/*z-index:3690;*/
66
}
77
.shell-manager-bar {
88
position:absolute;
99
left:0;
10-
width:120px;
10+
width:48px;
11+
background-color:rgb(57,61,254);
12+
border-style:solid solid solid none;
13+
border-width:1px;
14+
border-color:buttonshadow;
15+
opacity:0.85;
16+
filter:Alpha(Opacity=85);
17+
}
18+
.shell-manager-bar-minimized {
19+
position:absolute;
20+
left:0;
21+
width:8px;
1122
background-color:rgb(57,61,254);
1223
border-style:solid solid solid none;
1324
border-width:1px;
@@ -21,7 +32,7 @@
2132
cursor:default;
2233
font-family:Arial, sans-serif;
2334
position:absolute;
24-
left:1em;
35+
left:16px;
2536
width:150px;
2637
height:2em;
2738
background-color:buttonface;
@@ -36,12 +47,14 @@
3647
filter:Alpha(Opacity=95);
3748
}
3849
.shell-top-item {
39-
border:1px solid darkred;
50+
/*border:1px solid darkred;*/
4051
opacity:1;
4152
filter:Alpha(Opacity=100);
4253
}
4354
.shell-top-item:hover, a.shell-top-item:hover {
44-
border:1px solid navy;
55+
/*border:1px solid navy;*/
56+
opacity:0.55;
57+
filter:Alpha(Opacity=55);
4558
}
4659
a.shell-item:focus {
4760
background-color:buttonhighlight;
@@ -55,7 +68,7 @@ a.shell-item:focus {
5568
width:16px;
5669
height:16px;
5770
position:relative;
58-
left:4px;
71+
left:8px;
5972
top:50%;
6073
margin-top:-7px;
6174
_margin-top:-8px;
@@ -65,17 +78,17 @@ a.shell-item:focus {
6578
}
6679
.shell-item-text {
6780
position:relative;
68-
width:120px;
81+
/*width:108px;*/
6982
overflow:hidden;
7083
height:1.5em;
7184
white-space:nowrap;
7285
top:50%;
73-
left:24px;
74-
_left:6px;
75-
margin-top:-0.5em;
86+
left:36px;
87+
_left:18px;
88+
margin-top:-0.6em;
7689
}
7790
*:first-child+html .shell-item-text { /* IE7 */
78-
left:6px;
91+
left:18px;
7992
}
8093
.shell-manager-topbar-container {
8194
position:absolute;
@@ -113,14 +126,15 @@ a.shell-item:focus {
113126
background-color:menu;
114127
background-repeat:no-repeat;
115128
background-position:center center;
129+
background-image: url('images/z-logo.png');
116130
border:1px solid buttonshadow;
117131
margin:0;
118132
padding:0;
119133
font-size:0;
120134
opacity:0.6;
121135
filter:Alpha(Opacity=60);
122136
}
123-
.shortcut-bar-minized {
137+
.shortcut-bar-minimized {
124138
position:absolute;
125139
bottom:0;
126140
height:8px;
@@ -137,12 +151,14 @@ a.shell-item:focus {
137151
filter:Alpha(Opacity=95);
138152
}
139153
.shortcut-active-item {
140-
border:1px solid darkred;
154+
/*border:1px solid darkred;*/
141155
opacity:1;
142156
filter:Alpha(Opacity=100);
143157
}
144158
.shortcut-active-item:hover, a.shortcut-active-item:hover {
145-
border:1px solid navy;
159+
/*border:1px solid navy;*/
160+
opacity:0.6;
161+
filter:Alpha(Opacity=60);
146162
}
147163
.swt-widgets-shellmanager {
148164
width:324px;

0 commit comments

Comments
 (0)