playHeaderLine.setSize(1, 1);
playHeaderLine.setBackground(ColorResource.BLACK);
- playHeaderLine.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent e) {
- refreshPlayHeader(true);
- }
- });
-
contentTreeContainer.setContent(contentTree);
// Content Tools Container
contentToolsContainerFormData.right = new FormAttachment(100);
contentToolsContainer.setLayoutData(contentToolsContainerFormData);
+ playHeaderLine.addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent e) {
+ refreshPlayHeader(true);
+ }
+ });
+
+ contentTreeContainer.addControlListener(new ControlListener() {
+
+ @Override
+ public void controlResized(ControlEvent e) {
+ refreshPlayHeader(true);
+
+ }
+
+ @Override
+ public void controlMoved(ControlEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+
contentHeaderContainer.getOutlineHeader().addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
if (Platform.getOS().equals(Platform.OS_WIN32)) {
SEPERATOR_WIDTH = 5;
OUTLINE_WIDTH = 2;
- } else if (Platform.getOS().equals(Platform.OS_LINUX) ||
- Platform.getOS().equals(Platform.OS_MACOSX)) {
+ } else if (Platform.getOS().equals(Platform.OS_LINUX)
+ || Platform.getOS().equals(Platform.OS_MACOSX)) {
SEPERATOR_WIDTH = 1;
OUTLINE_WIDTH = 0;
EXPANDCOLUMN_WIDTH = 1;
contentTree.getColumn(0).getWidth() + contentTree.getColumn(1).getWidth()
+ contentTree.getColumn(2).getWidth() + 9;// borderwidth;
}
-
+
return prePoint;
}
* current playheader position time
* @param path
* left moving is 0, right moving is 1
- * @param viewer
- * {@link TimelineViewer}
+ * @param incrementSize
+ * left moving is -1, right moving is 1
+ * @param scrollMove
+ * non move is 0, move is 1, have to move 2
*/
- public void refreshHScroll(double pointTime, int path, int incrementSize, boolean scrollMove) {
+ public void refreshHScroll(double pointTime, int path, int incrementSize, int scrollMove) {
TimeBar timeBar = contentHeaderContainer.getKeyframeHeader().getTimeBar();
ScrollBar hScroll = contentToolsContainer.gethScroll();
int lastTimeSel = (int) (lastTime * TimelineConstants.DEFAULT_TIME_INTERVAL);
- if (scrollMove == true) {
- int increment = lastTimeSel / TimelineConstants.DEFAULT_HSCROLL_SELECTION_INTERVAL;
- hScroll.setSelection(increment * TimelineConstants.DEFAULT_HSCROLL_SELECTION_INTERVAL);
- }
-
if (lastTimeSel <= TimelineConstants.DEFAULT_HSCROLL_SIZE) {
hScroll.setMaximum(TimelineConstants.DEFAULT_HSCROLL_SIZE);
} else {
hScroll.setMaximum(lastTimeSel + TimelineConstants.DEFAULT_HSCROLL_EXPANSION);
}
+ if (scrollMove == 1 || scrollMove == 2) {
+ int increment = lastTimeSel / TimelineConstants.DEFAULT_HSCROLL_SELECTION_INTERVAL;
+ hScroll.setSelection(increment * TimelineConstants.DEFAULT_HSCROLL_SELECTION_INTERVAL);
+ }
+
// start Time
- if (path == 0 && (startTime <= 0.0)) {
+ if ((path == 0 && (startTime <= 0.0)) || ((pointTime <= 2) && scrollMove == 2)) {
startTime = 0.0;
hScroll.setSelection(0);
+ } else if (scrollMove == 2) {
+ // last Time
+ startTime = (pointTime - 2) * 10.0;
} else {
// last Time
startTime = startTime + (incrementSize / timeBar.getScale());
}
- if (scrollMove == true) {
+ if (scrollMove == 1 || scrollMove == 2) {
timeBar.setStartTime(startTime);
timeBar.redraw();
import java.util.List;
import java.util.Map;
+import java.util.regex.Pattern;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.ScrollBar;
+import org.eclipse.swt.widgets.Text;
import org.tizen.webuibuilder.BuilderConstants;
import org.tizen.webuibuilder.animator.gef.command.AnimationPropertyChangeCommand;
import org.tizen.webuibuilder.animator.gef.viewer.AnimationEvent;
import org.tizen.webuibuilder.animator.model.AnimatorWidget;
import org.tizen.webuibuilder.animator.model.part.AnimatorPagePart;
import org.tizen.webuibuilder.animator.model.part.AnimatorPart;
+import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineContentContainer;
import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineMainContainer;
import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineViewer;
import org.tizen.webuibuilder.animator.ui.views.timeline.common.ColorResource;
-import org.tizen.webuibuilder.animator.ui.views.timeline.header.TimeBar;
+import org.tizen.webuibuilder.animator.ui.views.timeline.common.Formatter;
import org.tizen.webuibuilder.animator.ui.views.timeline.header.PlayHeader;
+import org.tizen.webuibuilder.animator.ui.views.timeline.header.TimeBar;
import org.tizen.webuibuilder.animator.ui.views.timeline.widget.KeyFrame;
import org.tizen.webuibuilder.animator.ui.views.timeline.widget.KeyFrameComponent;
import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
private Button forward = null;
private Button repeat = null;
- private CLabel timeText = null;
+ private Text timeText = null;
+ private String currentTime = null;
private Button easingPanel = null;
private Button easing = null;
// TimeText
// -------------------------------------------------------------------------------
- timeText = new CLabel(this, SWT.CENTER);
+ timeText = new Text(this, SWT.SINGLE | SWT.CENTER);
FormData timeTextFormData = new FormData();
timeTextFormData.top = new FormAttachment(0, 4);
timeTextFormData.left = new FormAttachment(0, 269);
- timeTextFormData.width = 117;
+ timeTextFormData.width = 113;
+ timeTextFormData.height = 21;
timeText.setLayoutData(timeTextFormData);
-
timeText.setBackgroundImage(ResourceManager.getImage(BuilderConstants.ICON_DIR,
"animator_toolbar_time_text.png"));
- timeText.setForeground(ColorResource.WHITE);
- timeText.setText("00 : 00 . 00");
+ setCurrentTime("00 : 00 . 000");
+
+ timeText.addFocusListener(new FocusListener() {
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ timeText.clearSelection();
+ }
+
+ @Override
+ public void focusGained(FocusEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+
+ timeText.addKeyListener(new KeyListener() {
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ // TODO Auto-generated method stub
+ char myChar = e.character;
+ int caret = timeText.getCaretPosition();
+
+ String fullTime = timeText.getText();
+ String[] first = null;
+ String[] second = null;
+ first = fullTime.split(":");
+ second = fullTime.split(Pattern.quote("."));
+
+ int firstSplit = first[0].length() - 1;
+ int secSplit = second[0].length() - 1;
+
+ boolean isNumber = Character.isDigit(myChar);
+ if (isNumber) {
+ if (caret <= firstSplit) {
+
+ setCurrentTime(fullTime);
+ setTimeTextPoint();
+ timeText.setSelection(caret);
+ } else if (caret > firstSplit + 3 && caret <= firstSplit + 5) {
+ int count = secSplit - firstSplit;
+ if (count > 5) {
+ if (firstSplit + 4 == caret) {
+ char lastSec = second[0].charAt(second[0].length() - 2);
+ fullTime = first[0] + ": " + myChar + lastSec + " ." + second[1];
+ } else {
+ char firstSec = second[0].charAt(second[0].length() - 4);
+ fullTime = first[0] + ": " + firstSec + myChar + " ." + second[1];
+ }
+ } else if (count <= 4) {
+ fullTime = first[0] + ": " + myChar + "0" + " ." + second[1];
+ } else {
+ }
+ setCurrentTime(fullTime);
+ setTimeTextPoint();
+ timeText.setSelection(caret);
+ } else if (caret > firstSplit + 8 && caret <= firstSplit + 11) {
+ int count = second[1].length();
+ if (count > 4) {
+ fullTime = second[0] + "." + second[1].substring(0, 4);
+ } else if (count == 0 || count == 1) {
+ fullTime = second[0] + "." + " 000";
+ } else if (count == 2) {
+ fullTime = second[0] + "." + second[1].substring(0, 2) + "00";
+ } else if (count == 3) {
+ fullTime = second[0] + "." + second[1].substring(0, 3) + "0";
+ }
+ setCurrentTime(fullTime);
+ setTimeTextPoint();
+ timeText.setSelection(caret);
+ } else {
+ e.doit = false;
+ }
+ }
+
+ if (caret > firstSplit && caret <= firstSplit + 2) {
+ timeText.setSelection(firstSplit + 3);
+ } else if (caret > secSplit && caret < secSplit + 3) {
+ timeText.setSelection(secSplit + 3);
+ }
+ }
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+ String fullTime = timeText.getText();
+ char myChar = e.character;
+ int caret = timeText.getCaretPosition();
+
+ int selectionCount = timeText.getSelectionCount();
+
+ String[] first = null;
+ first = fullTime.split(":");
+ int firstSplit = first[0].length() - 1;
+
+ boolean isNumber = Character.isDigit(myChar);
+ if (isNumber) {
+ if (caret <= firstSplit) {
+ } else if ((selectionCount >= 1 && caret > firstSplit + 1 && caret <= firstSplit + 5)
+ || (selectionCount == 0 && caret >= firstSplit + 3 && caret < firstSplit + 5)) {
+ } else if ((selectionCount >= 1 && caret > firstSplit + 7 && caret <= firstSplit + 11)
+ || (selectionCount == 0 && caret >= firstSplit + 8 && caret < firstSplit + 11)) {
+ } else {
+ e.doit = false;
+ }
+ } else if (e.keyCode == SWT.ARROW_LEFT || e.keyCode == SWT.ARROW_RIGHT) {
+
+ } else {
+ e.doit = false;
+ }
+ }
+ });
+
+ timeText.addMouseListener(new MouseListener() {
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ int caret = timeText.getCaretPosition();
+ String fullTime = timeText.getText();
+
+ String[] first = null;
+ String[] second = null;
+ first = fullTime.split(":");
+ second = fullTime.split(Pattern.quote("."));
+
+ int firstSplit = first[0].length() - 1;
+ int secSplit = second[0].length() - 1;
+
+ if (caret < firstSplit) {
+ timeText.setSelection(0, firstSplit);
+ } else if (caret > firstSplit && caret <= secSplit) {
+ timeText.setSelection(firstSplit + 3, secSplit);
+ } else if (caret > secSplit) {
+ timeText.setSelection(secSplit + 3, secSplit + 6);
+ }
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+
+ }
+ });
+
+ timeText.addListener(SWT.Paint, new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ GC gc = event.gc;
+ String time = timeText.getText();
+
+ gc.drawImage(ResourceManager.getImage(BuilderConstants.ICON_DIR,
+ "animator_toolbar_time_text.png"), 0, 0);
+
+ if (time != null) {
+ timeText.setForeground(ColorResource.WHITE);
+ gc.drawText(time, 22 , 3,true);
+ }
+ }
+ });
// Animation play control
// ------------------------------------------------------------------------------
marker.setCurrentPointTime(0.0);
marker.draw(true);
- timeText.setText("00 : 00 . 00");
+ setCurrentTime("00 : 00 . 000");
TimelineContentToolsContainer contentToolsContainer =
mainContainer.getContentContainer().getContentToolsContainer();
double markerTime = marker.getPlayHeaderTime();
String time = AnimatorUtils.convertTimetoTimeText(markerTime);
- timeText.setText(time);
+ setCurrentTime(time);
TimelineContentToolsContainer contentToolsContainer =
mainContainer.getContentContainer().getContentToolsContainer();
marker.setCurrentPointTime((double) millSecond / 1000);
if (Platform.getOS().equals(Platform.OS_WIN32)) {
marker.draw(false);
- } else if (Platform.getOS().equals(Platform.OS_LINUX)) {
- marker.draw(true);
- } else if (Platform.getOS().equals(Platform.OS_MACOSX)) {
+ } else if (Platform.getOS().equals(Platform.OS_LINUX)
+ || (Platform.getOS().equals(Platform.OS_MACOSX))) {
marker.draw(true);
}
double markerTime = marker.getPlayHeaderTime();
String time = AnimatorUtils.convertTimetoTimeText(markerTime);
- timeText.setText(time);
+
+ setCurrentTime(time);
timeText.redraw();
}
/*****************************************************************************************
* Class Method
*****************************************************************************************/
+
+ /**
+ * set TimeTextPoint
+ */
+ private void setTimeTextPoint() {
+ TimelineContentContainer contentContainer =
+ ((TimelineMainContainer) getParent()).getContentContainer();
+ TimeBar timeBar =
+ contentContainer.getContentHeaderContainer().getKeyframeHeader().getTimeBar();
+
+ double scale = timeBar.getScale();
+ double newTime = Formatter.toStringTimeFormat(currentTime);
+
+ contentContainer.refreshHScroll(newTime, 1, 0, 2);
+
+ double startTime = timeBar.getStartTime();
+ int positionTime = (int) ((newTime * (scale * 100.0)) - startTime * (scale * 10.0));
+
+ timeBar.setPosition(positionTime);
+ contentContainer.refreshPlayHeader(true);
+
+ timeText.clearSelection();
+
+ }
+
/**
* Set Last Animation Point
*/
double markerTime = marker.getPlayHeaderTime();
String time = AnimatorUtils.convertTimetoTimeText(markerTime);
- timeText.setText(time);
+ setCurrentTime(time);
AnimatorUtils.getActiveAnimatorBrowserViewer().showAnimationAtMoment(animationGroupId,
markerTime);
if (!beforeEaseData.equals(easeData)) {
AnimationPropertyChangeCommand propertyCommand =
new AnimationPropertyChangeCommand(
- frame,
- "-webkit-animation-timing-function",
- easeData);
+ frame,
+ "-webkit-animation-timing-function",
+ easeData);
TimelineViewer viewer = ((TimelineMainContainer) getParent()).getViewer();
viewer.getEditDomain().getCommandStack().execute(propertyCommand);
setSelectedAnimationGroupId(animationGroupId);
// redraw text button
- timeText.setText("00 : 00 . 00");
+ setCurrentTime("00 : 00 . 000");
timeText.redraw();
// redraw play button
*
* @return {@link CLabel}
*/
- public CLabel getTimeText() {
+ public Text getTimeText() {
return timeText;
}
this.map = map;
}
+ public String getCurrentTime() {
+ return currentTime;
+ }
+
+ public void setCurrentTime(String currentTime) {
+ this.currentTime = currentTime;
+ timeText.setText(currentTime);
+ }
+
/*****************************************************************************************
* Listener , Event
*****************************************************************************************/