int index = delta > 0 ? 0 : 1;
for (StripItem item : affected) {
Rectangle toSet = boundsMap.get(item)[index];
item.setBounds(toSet, true, new TimingTargetAdapter() {
@Override
public void end(Animator source) {
processFocus();
}
@Override
public void timingEvent(Animator source, double fraction) {
processFocus();
}
private void processFocus() {
Point location = getDisplay().getCursorLocation();
location = toControl(location);
onProcessFocus(location.x, location.y);
}
});
}
} else {
StripItem onItem = getItem(event.x, event.y);
if (onItem != null && !onItem.equals(mouseItem)) {
Rectangle mouseBounds = mouseItem.getBounds();
StripItem[] affected = getAffectedItemsNonAnimated(mouseItem, onItem);
if (onItem.getBounds().x > mouseItem.getBounds().x) {
for (StripItem aff : affected) {
Rectangle bounds = boundsMap.get(aff)[0];
aff.setBounds(bounds, false, null);
mouseBounds.x += bounds.width;
mouseBounds.x += SPACE;
}
} else {
for (StripItem aff : affected) {
Rectangle bounds = boundsMap.get(aff)[1];
aff.setBounds(bounds, false, null);
mouseBounds.x -= bounds.width;
mouseBounds.x -= SPACE;
}
}
mouseItem.setBounds(mouseBounds, false, null);
Point location = new Point(mouseBounds.x + mouseBounds.width / 2, mouseBounds.y + mouseBounds.height / 2);
location = toDisplay(location);
getDisplay().setCursorLocation(location);
}
}
}
}
mouseMove = new Point(event.x, event.y);
}
} else if (event.type == SWT.MouseUp) {
if (event.button == 1) {
if (mouseItem != null) {
int itemState = mouseItem.getState();
boolean wasSelected = (itemState & StripItem.SELECTED) == StripItem.SELECTED;
itemState &= ~StripItem.PRESSED;
if ((itemState & StripItem.DRAGGED) == StripItem.DRAGGED) {
itemState &= ~StripItem.DRAGGED;
} else {
if (isMultiSelect()) {
if (wasSelected) {
itemState &= ~StripItem.SELECTED;
} else {
itemState |= StripItem.SELECTED;
}
} else {
if (!wasSelected) {
itemState |= StripItem.SELECTED;
for (StripItem otherItem : items) {
int otherState = otherItem.getState();
otherState &= ~StripItem.SELECTED;
otherItem.setState(otherState, animate);
}
}
}
}
mouseItem.setState(itemState, false);
reorderItems();
if (isAnimate()) {
Rectangle compute = computeBounds(mouseItem);
mouseItem.setBounds(compute, true, new TimingTargetAdapter() {
@Override
public void end(Animator source) {
processFocus();
}