From: jooyoul_lee Date: Wed, 14 May 2014 11:01:28 +0000 (+0900) Subject: NSCREEN : change group selection color, etc. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F96%2F20996%2F1;p=sdk%2Fide%2Fweb-ui-builder-eplugin.git NSCREEN : change group selection color, etc. 1. change group selection color and bg color 2. show enabled item count on group title. 3. view minimum size set. Change-Id: I4ccad5dec21f3ceb47acde16ad3ae95522a169c6 Signed-off-by: jooyoul_lee --- diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenGroup.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenGroup.java index d43c7fe..d14471a 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenGroup.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenGroup.java @@ -46,6 +46,7 @@ public class NScreenGroup extends Composite { private String title = null; private NScreenBaseComposite owner = null; private boolean fold = true; + private int enableCount = 0; private Listener foldingListener = new Listener() { @@ -82,22 +83,31 @@ public class NScreenGroup extends Composite { e.gc.setBackground(color); e.gc.fillRectangle(rect); e.gc.setForeground(ColorResource.BLACK); - - if (null != title) { - e.gc.setFont(FontUtil.NSCREEN_GROUP); - Point textWH = FontUtil.getTextArea(title, e.gc); - int x = rect.x + (rect.width - textWH.x) / 2; - int y = rect.y + (GROUP_LABEL_HEIGHT - textWH.y) / 2; - - if (hasSelection()) { - if (getSelectedItem().isItemEnabled()) { - e.gc.setForeground(ColorResource.NSE_BG); - } else { - e.gc.setForeground(ColorResource.NSD_BG); - } + StringBuffer buffer = new StringBuffer(); + if (null == title) { + buffer.append("FEATURE"); + } else { + buffer.append(title); + } + buffer.append(" (").append(enableCount).append("/").append(items.size()).append(")"); + + e.gc.setFont(FontUtil.NSCREEN_GROUP); + Point textWH = FontUtil.getTextArea(buffer.toString(), e.gc); + int x = rect.x + (rect.width - textWH.x) / 2; + int y = rect.y + (GROUP_LABEL_HEIGHT - textWH.y) / 2; + + if (hasSelection()) { + e.gc.setBackground(ColorResource.HNE_BG); + e.gc.fillRectangle(rect.x + ITEM_W_MARGIN, rect.y, rect.width - ITEM_W_MARGIN * 2, + height); + if (getSelectedItem().isItemEnabled()) { + e.gc.setForeground(ColorResource.PSE_BG); + } else { + // e.gc.setForeground(ColorResource.NSD_BG); + e.gc.setForeground(ColorResource.PSE_BG); } - e.gc.drawText(title, x, y); } + e.gc.drawText(buffer.toString(), x, y); e.gc.setBackground(ColorResource.NSD_FG); int fY = (GROUP_LABEL_HEIGHT - FOLD_HEIGHT) / 2; @@ -168,6 +178,9 @@ public class NScreenGroup extends Composite { data = (FormData) getLayoutData(); data.height = getGroupHeight(); + if (model.isEnablePage(owner.getNScreenPageModel().getPageData().getName())) { + increaseEnableCount(); + } return newNScreen; } @@ -370,4 +383,18 @@ public class NScreenGroup extends Composite { } } } + + public int getEnableCount() { + return enableCount; + } + + public void increaseEnableCount() { + enableCount++; + redraw(); + } + + public void decreaseEnableCount() { + enableCount--; + redraw(); + } } diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenItem.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenItem.java index 8e5c77d..f946caa 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenItem.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenItem.java @@ -61,8 +61,8 @@ public class NScreenItem extends Composite { private NScreenModel model = null; private NScreenHistory history = null; -// private float scale = 0f; -// private String lastResolution = null; + // private float scale = 0f; + // private String lastResolution = null; // ui only data private NScreenItem reference = null; @@ -134,17 +134,16 @@ public class NScreenItem extends Composite { int index = items.indexOf(this); if (model.getType() != NScreenType.ORIENTATION) { - if (model.getLink(getPageId()) != NScreenModel.NONE) { - menu.getItem(MENU_LINK_CUT).setEnabled(true); - } else { - if (index > 0 && items.get(index - 1).isItemEnabled() && !isRoot()) { - menu.getItem(MENU_LINK_UP).setEnabled(true); - } - if (index < size - 1 && items.get(index + 1).isItemEnabled() && !isRoot()) { - menu.getItem(MENU_LINK_DOWN).setEnabled(true); - } - } - + // if (model.getLink(getPageId()) != NScreenModel.NONE) { + // menu.getItem(MENU_LINK_CUT).setEnabled(true); + // } else { + // if (index > 0 && items.get(index - 1).isItemEnabled() && !isRoot()) { + // menu.getItem(MENU_LINK_UP).setEnabled(true); + // } + // if (index < size - 1 && items.get(index + 1).isItemEnabled() && !isRoot()) { + // menu.getItem(MENU_LINK_DOWN).setEnabled(true); + // } + // } if (model.getType() != NScreenType.PIXELRATIO) { if (index > 0 && !model.isLinked(getPageId()) && !isRoot()) { menu.getItem(MENU_MOVE_UP).setEnabled(true); @@ -167,15 +166,8 @@ public class NScreenItem extends Composite { history = new NScreenHistory(); history.setModelName(this.model.getName()); canvas = new Canvas(this, SWT.TRANSPARENT); - -// if (model.getType() != NScreenType.COMMON) { -// if (model.isEnablePage(getPageId())) { -// setSelection(true); -// } -// } - addMouseListener(); - canvas.addListener(SWT.KeyUp, keyListener); + // canvas.addListener(SWT.KeyUp, keyListener); canvas.addPaintListener(new PaintListener() { @Override @@ -270,9 +262,11 @@ public class NScreenItem extends Composite { public void setItemEnabled(boolean enabled) { if (enabled) { // enable model.addEnablePage(getPageId()); + parent.increaseEnableCount(); state = STATE_NORMAL; } else { // disable model.addDisablePage(getPageId()); + parent.decreaseEnableCount(); } } @@ -291,9 +285,9 @@ public class NScreenItem extends Composite { } public String getFileName() { -// if (model.isLinked(getPageId())) { -// return reference.getFileName(); -// } + // if (model.isLinked(getPageId())) { + // return reference.getFileName(); + // } String pageId = parent.getNScreenPageModel().getPageData().getName(); String screenFileName = model.getFileName(); StringBuffer strBuffer = new StringBuffer(); @@ -428,10 +422,11 @@ public class NScreenItem extends Composite { String targetFileName = getFileName(); String filePath = parent.getNScreenPageModel().getAppManager().getCssFolder(); -// CssFile sourceCssFile = new CssFile(filePath + IPath.SEPARATOR + sourceFileName); + // CssFile sourceCssFile = new CssFile(filePath + IPath.SEPARATOR + sourceFileName); File sourceFile = new File(filePath + IPath.SEPARATOR + sourceFileName); File targetFile = new File(filePath + IPath.SEPARATOR + targetFileName); - parent.getNScreenPageModel().getPageData().removeCssFileByPath(filePath + IPath.SEPARATOR+sourceFileName); + parent.getNScreenPageModel().getPageData() + .removeCssFileByPath(filePath + IPath.SEPARATOR + sourceFileName); sourceFile.renameTo(targetFile); CssFile targetCssFile = new CssFile(filePath + IPath.SEPARATOR + sourceFileName); @@ -463,23 +458,22 @@ public class NScreenItem extends Composite { return false; } - public NScreenHistory getNScreenHistory() - { + public NScreenHistory getNScreenHistory() { return history; } -// public float getScale() { -// return scale; -// } -// -// public void setScale(float scale) { -// this.scale = scale; -// } -// -// public String getLastResolution() { -// return lastResolution; -// } -// -// public void setLastResolution(String last) { -// this.lastResolution = last; -// } + // public float getScale() { + // return scale; + // } + // + // public void setScale(float scale) { + // this.scale = scale; + // } + // + // public String getLastResolution() { + // return lastResolution; + // } + // + // public void setLastResolution(String last) { + // this.lastResolution = last; + // } } diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenPage.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenPage.java index 53d1c2e..0e816f4 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenPage.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenPage.java @@ -26,6 +26,8 @@ package org.tizen.webuibuilder.ui.views.nscreen; import java.util.List; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Color; @@ -48,10 +50,12 @@ import org.tizen.webuibuilder.ui.views.nscreen.model.NScreenPageModel; * The NScreenPage class that implements Page. */ public class NScreenPage extends Page { - private final int NSCREEN_TITLE_HEIGHT = 40; + // private final int NSCREEN_TITLE_HEIGHT = 40; + private final int NSCREEN_MIN_WIDTH = 295; private final NScreenPageModel mNScreenPageModel; private NScreenBaseComposite mParentComposite; - private CSSLayerBaseComposite cssLayerBaseComposite; + + // private CSSLayerBaseComposite cssLayerBaseComposite; public boolean existNscreen(int width) { List list = @@ -87,23 +91,23 @@ public class NScreenPage extends Page { * @see org.eclipse.ui.part.Page#createControl(org.eclipse.swt.widgets.Composite) */ public void createControl(Composite parent) { -// parent.setLayout(new FormLayout()); -// -// cssLayerBaseComposite = new CSSLayerBaseComposite(parent, SWT.NONE, mNScreenPageModel); -// FormData data = new FormData(); -// data.top = new FormAttachment(0, 50); -// data.left = new FormAttachment(0, 0); -// data.right = new FormAttachment(100, 0); -// data.height = 170; -// cssLayerBaseComposite.setLayoutData(data); + // parent.setLayout(new FormLayout()); + // + // cssLayerBaseComposite = new CSSLayerBaseComposite(parent, SWT.NONE, mNScreenPageModel); + // FormData data = new FormData(); + // data.top = new FormAttachment(0, 50); + // data.left = new FormAttachment(0, 0); + // data.right = new FormAttachment(100, 0); + // data.height = 170; + // cssLayerBaseComposite.setLayoutData(data); mParentComposite = new NScreenBaseComposite(parent, SWT.NONE, mNScreenPageModel); -// data = new FormData(); -// data.top = new FormAttachment(cssLayerBaseComposite, 0); -// data.left = new FormAttachment(0, 0); -// data.right = new FormAttachment(100, 0); -// data.bottom = new FormAttachment(100, 0); -// mParentComposite.setLayoutData(data); + // data = new FormData(); + // data.top = new FormAttachment(cssLayerBaseComposite, 0); + // data.left = new FormAttachment(0, 0); + // data.right = new FormAttachment(100, 0); + // data.bottom = new FormAttachment(100, 0); + // mParentComposite.setLayoutData(data); List models = mNScreenPageModel.getAppManager().getNScreenModelManger().getNScreenModels(); List groups = mParentComposite.getNScreenGroups(); @@ -142,30 +146,48 @@ public class NScreenPage extends Page { g.createLinkTree(); } - parent.addPaintListener(new PaintListener() { + parent.addControlListener(new ControlListener() { + + @Override + public void controlResized(ControlEvent e) { + // TODO Auto-generated method stub + Composite comp = (Composite) e.widget; + Rectangle rect = comp.getClientArea(); + if (rect.width < NSCREEN_MIN_WIDTH) { + comp.setSize(NSCREEN_MIN_WIDTH, rect.height); + } + } @Override - public void paintControl(PaintEvent e) { - Rectangle rect = ((Composite) e.widget).getClientArea(); - rect.height = NSCREEN_TITLE_HEIGHT; - String title = "= " + mNScreenPageModel.getPageData().getName() + " ="; - - Font oldFont = e.gc.getFont(); - Color oldBgColor = e.gc.getBackground(); - Color oldFgColor = e.gc.getForeground(); - - e.gc.setForeground(ColorResource.BLACK); - e.gc.setFont(FontUtil.NSCREEN_TITLE); - Point textWH = FontUtil.getTextArea(title, e.gc); - int x = rect.x + (rect.width - textWH.x) / 2; - int y = rect.y + (rect.height - textWH.y) / 2; - e.gc.drawText(title, x, y); - - e.gc.setFont(oldFont); - e.gc.setBackground(oldBgColor); - e.gc.setForeground(oldFgColor); + public void controlMoved(ControlEvent e) { + // TODO Auto-generated method stub + } }); + // parent.addPaintListener(new PaintListener() { + // + // @Override + // public void paintControl(PaintEvent e) { + // Rectangle rect = ((Composite) e.widget).getClientArea(); + // rect.height = NSCREEN_TITLE_HEIGHT; + // String title = "= " + mNScreenPageModel.getPageData().getName() + " ="; + // + // Font oldFont = e.gc.getFont(); + // Color oldBgColor = e.gc.getBackground(); + // Color oldFgColor = e.gc.getForeground(); + // + // e.gc.setForeground(ColorResource.BLACK); + // e.gc.setFont(FontUtil.NSCREEN_TITLE); + // Point textWH = FontUtil.getTextArea(title, e.gc); + // int x = rect.x + (rect.width - textWH.x) / 2; + // int y = rect.y + (rect.height - textWH.y) / 2; + // e.gc.drawText(title, x, y); + // + // e.gc.setFont(oldFont); + // e.gc.setBackground(oldBgColor); + // e.gc.setForeground(oldFgColor); + // } + // }); } @Override