Portal tweaks - use standard fonts, etc.
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/NavigationBar.java Wed Jul 14 15:59:19 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/NavigationBar.java Thu Jul 15 09:59:29 2010 -0500
@@ -22,11 +22,14 @@
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.RowDataFactory;
import org.eclipse.jface.layout.RowLayoutFactory;
+import org.eclipse.jface.resource.FontDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
@@ -34,7 +37,6 @@
class NavigationBar extends RoundedCornerComposite {
- private static final String FONT_NAME = "Arial"; //$NON-NLS-1$
private PortalEditor portalEditor;
@@ -58,10 +60,15 @@
this.portalEditor = portalEditor;
buttonToPageMap = new LinkedHashMap<Button, IPortalPage>();
GridDataFactory.swtDefaults().grab(true, false).align(SWT.CENTER, SWT.TOP).indent(10, 10).applyTo(this);
- RowLayoutFactory.swtDefaults().margins(3, 3).pack(false).wrap(false).applyTo(this);
+ RowLayoutFactory.swtDefaults().margins(3, 3).wrap(false).applyTo(this);
listener = new ButtonListener();
- buttonFont = this.portalEditor.createFont(FONT_NAME, 12, SWT.NORMAL);
- selectedButtonFont = this.portalEditor.createFont(FONT_NAME, 12, SWT.BOLD);
+ selectedButtonFont = JFaceResources.getHeaderFont();
+ FontData[] fontData = selectedButtonFont.getFontData();
+ for (FontData fd : fontData) {
+ fd.setStyle(SWT.NORMAL);
+ }
+ FontDescriptor desc = FontDescriptor.createFrom(fontData);
+ buttonFont = portalEditor.createFont(desc);
}
public void initUI() {
@@ -74,9 +81,9 @@
Button b = new Button(bar, SWT.TOGGLE | SWT.FLAT);
b.setFont(buttonFont);
b.setText(page.getText());
- b.setImage(this.portalEditor.createImage(page.getImageDescriptor()));
+ b.setImage(portalEditor.createImage(page.getImageDescriptor(), 16, 16));
b.addSelectionListener(listener);
- RowDataFactory.swtDefaults().hint(200, SWT.DEFAULT).applyTo(b);
+ RowDataFactory.swtDefaults().applyTo(b);
buttonToPageMap.put(b, page);
}
@@ -87,7 +94,14 @@
other.setFont(buttonFont);
}
button.setSelection(true);
- this.portalEditor.showPage(buttonToPageMap.get(button));
+ portalEditor.showPage(buttonToPageMap.get(button));
button.setFont(selectedButtonFont);
+ layout();
+ }
+
+ @Override
+ public void layout() {
+ super.layout();
+ pack();
}
}
\ No newline at end of file
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/PortalEditor.java Wed Jul 14 15:59:19 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/PortalEditor.java Thu Jul 15 09:59:29 2010 -0500
@@ -30,11 +30,13 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.resource.FontDescriptor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Resource;
import org.eclipse.swt.widgets.Composite;
@@ -219,7 +221,7 @@
Image newImage = new Image(composite.getDisplay(), rect.width, rect.height);
GC gc = new GC(newImage);
gc.setForeground(composite.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- gc.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_GRAY));
+ gc.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
gc.fillGradientRectangle(0, 0, rect.width, rect.height, true);
gc.dispose();
composite.setBackgroundImage(newImage);
@@ -282,15 +284,21 @@
return input;
}
- Image createImage(ImageDescriptor desc) {
-// Image image = new Image(Display.getCurrent(), desc.getImageData().scaledTo(16, 16));
- Image image = desc.createImage();
+ Image createImage(ImageDescriptor desc, int width, int height) {
+ Image image;
+ ImageData data = desc.getImageData();
+ if (data.width != width || data.height != height) {
+ image = new Image(Display.getCurrent(), desc.getImageData().scaledTo(width, height));
+ }
+ else {
+ image = desc.createImage();
+ }
resources.add(image);
return image;
}
- Font createFont(String name, int height, int style) {
- Font font = new Font(Display.getCurrent(), name, height, style);
+ Font createFont(FontDescriptor desc) {
+ Font font = desc.createFont(Display.getCurrent());
resources.add(font);
return font;
}
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/RoundedCornerComposite.java Wed Jul 14 15:59:19 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/RoundedCornerComposite.java Thu Jul 15 09:59:29 2010 -0500
@@ -36,11 +36,11 @@
super.drawBackground(gc, x, y, width, height);
if (background != null) {
gc.setBackground(background);
- gc.fillRoundRectangle(0, 0, width, height, 5, 5);
+ gc.fillRoundRectangle(0, 0, width, height, 6, 6);
}
if (outline != null) {
gc.setForeground(outline);
- gc.drawRoundRectangle(2, 2, width - 4, height - 4, 5, 5);
+ gc.drawRoundRectangle(2, 2, width - 4, height - 4, 6, 6);
}
}
}
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/SharedBackgroundComposite.java Wed Jul 14 15:59:19 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/SharedBackgroundComposite.java Thu Jul 15 09:59:29 2010 -0500
@@ -57,6 +57,7 @@
height = Math.min(height, imageBounds.height - y);
if (width > 0 && height > 0)
gc.drawImage(image, x, y, width, height, 0, 0, width, height);
+// gc.drawText(getClass().getSimpleName(), 2, 2);
// gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WHITE));
// gc.drawRectangle(1, 1, width - 2, height - 2);
}
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/TaskBar.java Wed Jul 14 15:59:19 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/TaskBar.java Thu Jul 15 09:59:29 2010 -0500
@@ -24,6 +24,7 @@
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.RowDataFactory;
import org.eclipse.jface.layout.RowLayoutFactory;
+import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
@@ -35,8 +36,6 @@
class TaskBar extends RoundedCornerComposite {
- private static final String FONT_NAME = "Arial"; //$NON-NLS-1$
-
private final class ActionListener implements IHyperlinkListener {
@Override
public void linkActivated(HyperlinkEvent e) {
@@ -57,7 +56,6 @@
}
}
- private PortalEditor portalEditor;
private Map<Hyperlink, IAction> linkToActionMap;
private ActionListener listener;
@@ -65,7 +63,6 @@
super(parent, portalEditor.getBackgroundParent(),
parent.getDisplay().getSystemColor(SWT.COLOR_BLACK),
parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- this.portalEditor = portalEditor;
createTitle(actionBar);
createActions(actionBar);
GridDataFactory.swtDefaults().grab(true, true).align(SWT.CENTER, SWT.BEGINNING).applyTo(this);
@@ -74,7 +71,7 @@
private void createTitle(IActionBar actionBar) {
Label l = new Label(this, SWT.LEFT);
- l.setFont(portalEditor.createFont(FONT_NAME, 10, SWT.BOLD));
+ l.setFont(JFaceResources.getBannerFont());
l.setBackground(l.getDisplay().getSystemColor(SWT.COLOR_WHITE));
l.setText(actionBar.getTitle());
RowDataFactory.swtDefaults().applyTo(l);
@@ -95,7 +92,6 @@
linkToActionMap.put(link, action);
link.addHyperlinkListener(listener);
}
-// updateAllActionsUI();
}
public void runAction(Hyperlink link) {
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/HomePage.java Wed Jul 14 15:59:19 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/HomePage.java Thu Jul 15 09:59:29 2010 -0500
@@ -28,7 +28,7 @@
@Override
public Control createControl(Composite parent, IEditorPart part) {
Composite composite = new Composite(parent, SWT.NONE);
- composite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
+ composite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
return composite;
}
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/SupportPage.java Wed Jul 14 15:59:19 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/view/SupportPage.java Thu Jul 15 09:59:29 2010 -0500
@@ -28,7 +28,7 @@
@Override
public Control createControl(Composite parent, IEditorPart part) {
Composite composite = new Composite(parent, SWT.NONE);
- composite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ composite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
return composite;
}