Merge lp:~duyi001/gephi/TimelineImprove into lp:~gephi.team/gephi/0.8

Proposed by Yestin
Status: Merged
Merged at revision: 2211
Proposed branch: lp:~duyi001/gephi/TimelineImprove
Merge into: lp:~gephi.team/gephi/0.8
Diff against target: 160 lines (+82/-33)
1 file modified
DesktopTimeline/src/org/gephi/desktop/timeline/MinimalDrawer.java (+82/-33)
To merge this branch: bzr merge lp:~duyi001/gephi/TimelineImprove
Reviewer Review Type Date Requested Status
Cezary Bartosiak Approve
Review via email: mp+55474@code.launchpad.net

Description of the change

Fix the bug I reported just now. 745476

To post a comment you must log in.
Revision history for this message
Cezary Bartosiak (cezary-bartosiak) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'DesktopTimeline/src/org/gephi/desktop/timeline/MinimalDrawer.java'
2--- DesktopTimeline/src/org/gephi/desktop/timeline/MinimalDrawer.java 2011-03-01 18:55:04 +0000
3+++ DesktopTimeline/src/org/gephi/desktop/timeline/MinimalDrawer.java 2011-03-30 06:46:27 +0000
4@@ -71,6 +71,10 @@
5 private static Cursor CURSOR_LEFT_HOOK = new Cursor(Cursor.E_RESIZE_CURSOR);
6 private static Cursor CURSOR_CENTRAL_HOOK = new Cursor(Cursor.MOVE_CURSOR);
7 private static Cursor CURSOR_RIGHT_HOOK = new Cursor(Cursor.W_RESIZE_CURSOR);
8+ private static final int LOC_RESIZE_FROM = 1;
9+ private static final int LOC_RESIZE_TO = 2;
10+ private static final int LOC_RESIZE_CENTER = 3;
11+ private static final int LOC_RESIZE_UNKNOWN = -1;
12 private static Locale LOCALE = Locale.ENGLISH;
13 private double newfrom = 0;
14 private double newto = 1;
15@@ -598,6 +602,34 @@
16 return (a < x && x < b);
17 }
18
19+ /**
20+ * Position of current x.
21+ * @param x current location
22+ * @param r width of slider
23+ * @return LOC_RESIZE_*
24+ */
25+ private int inPosition(int x, int r) {
26+ boolean resizeFrom = inRange(x, (int) sf - 1, (int) sf + r + 1);
27+ boolean resizeTo = inRange(x, (int) st - r - 1, (int) st + 1);
28+ if (resizeFrom & resizeTo) {
29+ if (inRange(x, (int) sf - 1, (int) (sf + st) / 2)) {
30+ return LOC_RESIZE_FROM;
31+ } else if (inRange(x, (int) (sf + st) / 2, (int) st + 1)) {
32+ return LOC_RESIZE_TO;
33+ }
34+ }
35+ if (resizeFrom) {
36+ return LOC_RESIZE_FROM;
37+ } else if (inRange(x, (int) sf + r, (int) st - r)) {
38+ return LOC_RESIZE_CENTER;
39+ } else if (resizeTo) {
40+ return LOC_RESIZE_TO;
41+ } else {
42+ return LOC_RESIZE_UNKNOWN;
43+ }
44+
45+ }
46+
47 public void mouseClicked(MouseEvent e) {
48 latestMousePositionX = e.getX();
49 currentMousePositionX = latestMousePositionX;
50@@ -635,15 +667,22 @@
51 int r = 16;//skin.getSelectionHookSideLength();
52
53 if (currentState == TimelineState.IDLE) {
54- if (inRange(x, (int) sf - 1, (int) sf + r + 1)) {
55- highlightedComponent = HighlightedComponent.LEFT_HOOK;
56- currentState = TimelineState.RESIZE_FROM;
57- } else if (inRange(x, (int) sf + r, (int) st - r)) {
58- highlightedComponent = HighlightedComponent.CENTER_HOOK;
59- currentState = TimelineState.MOVING;
60- } else if (inRange(x, (int) st - r - 1, (int) st + 1)) {
61- highlightedComponent = HighlightedComponent.RIGHT_HOOK;
62- currentState = TimelineState.RESIZE_TO;
63+ int position = inPosition(x, r);
64+ switch(position){
65+ case LOC_RESIZE_FROM:
66+ highlightedComponent = HighlightedComponent.LEFT_HOOK;
67+ currentState = TimelineState.RESIZE_FROM;
68+ break;
69+ case LOC_RESIZE_CENTER:
70+ highlightedComponent = HighlightedComponent.CENTER_HOOK;
71+ currentState = TimelineState.MOVING;
72+ break;
73+ case LOC_RESIZE_TO:
74+ highlightedComponent = HighlightedComponent.RIGHT_HOOK;
75+ currentState = TimelineState.RESIZE_TO;
76+ break;
77+ default:
78+ break;
79 }
80 }
81 }
82@@ -704,18 +743,24 @@
83
84 int a = 0;//settings.selection.invisibleHookMargin;
85
86- if (inRange(x, (int) sf - 1, (int) sf + r + 1)) {
87- newCursor = CURSOR_LEFT_HOOK;
88- highlightedComponent = HighlightedComponent.LEFT_HOOK;
89- } else if (inRange(x, (int) sf + r, (int) st - r)) {
90- highlightedComponent = HighlightedComponent.CENTER_HOOK;
91- newCursor = CURSOR_CENTRAL_HOOK;
92- } else if (inRange(x, (int) st - r - 1, (int) st + 1)) {
93- highlightedComponent = HighlightedComponent.RIGHT_HOOK;
94- newCursor = CURSOR_RIGHT_HOOK;
95- } else {
96- highlightedComponent = HighlightedComponent.NONE;
97- newCursor = CURSOR_DEFAULT;
98+ int position = inPosition(x, r);
99+ switch (position) {
100+ case LOC_RESIZE_FROM:
101+ newCursor = CURSOR_LEFT_HOOK;
102+ highlightedComponent = HighlightedComponent.LEFT_HOOK;
103+ break;
104+ case LOC_RESIZE_CENTER:
105+ highlightedComponent = HighlightedComponent.CENTER_HOOK;
106+ newCursor = CURSOR_CENTRAL_HOOK;
107+ break;
108+ case LOC_RESIZE_TO:
109+ highlightedComponent = HighlightedComponent.RIGHT_HOOK;
110+ newCursor = CURSOR_RIGHT_HOOK;
111+ break;
112+ default:
113+ highlightedComponent = HighlightedComponent.NONE;
114+ newCursor = CURSOR_DEFAULT;
115+ break;
116 }
117 if (newCursor != getCursor()) {
118 setCursor(newCursor);
119@@ -755,15 +800,22 @@
120 //st = (model.getToFloat() * w);
121
122 if (currentState == TimelineState.IDLE) {
123- if (inRange(x, (int) sf - 1, (int) sf + r + 1)) {
124- highlightedComponent = HighlightedComponent.LEFT_HOOK;
125- currentState = TimelineState.RESIZE_FROM;
126- } else if (inRange(x, (int) sf + r, (int) st - r)) {
127- highlightedComponent = HighlightedComponent.CENTER_HOOK;
128- currentState = TimelineState.MOVING;
129- } else if (inRange(x, (int) st - r - 1, (int) st + 1)) {
130- highlightedComponent = HighlightedComponent.RIGHT_HOOK;
131- currentState = TimelineState.RESIZE_TO;
132+ int position = inPosition(x, r);
133+ switch (position) {
134+ case LOC_RESIZE_FROM:
135+ highlightedComponent = HighlightedComponent.LEFT_HOOK;
136+ currentState = TimelineState.RESIZE_FROM;
137+ break;
138+ case LOC_RESIZE_CENTER:
139+ highlightedComponent = HighlightedComponent.CENTER_HOOK;
140+ currentState = TimelineState.MOVING;
141+ break;
142+ case LOC_RESIZE_TO:
143+ highlightedComponent = HighlightedComponent.RIGHT_HOOK;
144+ currentState = TimelineState.RESIZE_TO;
145+ break;
146+ default:
147+ break;
148 }
149 }
150 double delta = 0;
151@@ -788,9 +840,6 @@
152 sf += delta;
153 }
154 }
155-
156-
157-
158 break;
159 case RESIZE_TO:
160 if ((st + delta) <= (sf + s)) {

Subscribers

People subscribed via source and target branches