mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
force components to go to front or back
This commit is contained in:
@@ -57,8 +57,7 @@ public @interface ComponentDescriptor {
|
|||||||
double zOrder();
|
double zOrder();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if the component may go beyond it's predefined layer. In that case,
|
* @return true if the component may go beyond it's predefined layer without warning the user.
|
||||||
* <code>zOrder</code> is used as initial z order of the component.
|
|
||||||
*/
|
*/
|
||||||
boolean flexibleZOrder() default false;
|
boolean flexibleZOrder() default false;
|
||||||
|
|
||||||
|
|||||||
@@ -1512,8 +1512,21 @@ public class Presenter implements IPlugInPort {
|
|||||||
@Override
|
@Override
|
||||||
public void sendSelectionToBack() {
|
public void sendSelectionToBack() {
|
||||||
LOG.info("sendSelectionToBack()");
|
LOG.info("sendSelectionToBack()");
|
||||||
|
int forceConfirmation = -1;
|
||||||
Project oldProject = currentProject.clone();
|
Project oldProject = currentProject.clone();
|
||||||
for (IDIYComponent<?> component : selectedComponents) {
|
|
||||||
|
// sort the selection in the reversed Z-order to preserve the order after moving to the back
|
||||||
|
List<IDIYComponent<?>> selection = new ArrayList<IDIYComponent<?>>(selectedComponents);
|
||||||
|
Collections.sort(selection, new Comparator<IDIYComponent<?>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(IDIYComponent<?> o1, IDIYComponent<?> o2) {
|
||||||
|
return new Integer(currentProject.getComponents().indexOf(o2)).compareTo(currentProject.getComponents()
|
||||||
|
.indexOf(o1));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (IDIYComponent<?> component : selection) {
|
||||||
ComponentType componentType =
|
ComponentType componentType =
|
||||||
ComponentProcessor.getInstance().extractComponentTypeFrom(
|
ComponentProcessor.getInstance().extractComponentTypeFrom(
|
||||||
(Class<? extends IDIYComponent<?>>) component.getClass());
|
(Class<? extends IDIYComponent<?>>) component.getClass());
|
||||||
@@ -1527,7 +1540,13 @@ public class Presenter implements IPlugInPort {
|
|||||||
ComponentProcessor.getInstance().extractComponentTypeFrom(
|
ComponentProcessor.getInstance().extractComponentTypeFrom(
|
||||||
(Class<? extends IDIYComponent<?>>) componentBefore.getClass());
|
(Class<? extends IDIYComponent<?>>) componentBefore.getClass());
|
||||||
if (!componentType.isFlexibleZOrder()
|
if (!componentType.isFlexibleZOrder()
|
||||||
&& Math.round(componentBeforeType.getZOrder()) < Math.round(componentType.getZOrder()))
|
&& Math.round(componentBeforeType.getZOrder()) < Math.round(componentType.getZOrder())
|
||||||
|
&& forceConfirmation != IView.YES_OPTION
|
||||||
|
&& (forceConfirmation =
|
||||||
|
this.view
|
||||||
|
.showConfirmDialog(
|
||||||
|
"Selected component(s) have reached the bottom of their layer. Do you want to force the selection to the back?",
|
||||||
|
"Send Selection to Back", IView.YES_NO_OPTION, IView.QUESTION_MESSAGE)) != IView.YES_OPTION)
|
||||||
break;
|
break;
|
||||||
Collections.swap(currentProject.getComponents(), index, index - 1);
|
Collections.swap(currentProject.getComponents(), index, index - 1);
|
||||||
index--;
|
index--;
|
||||||
@@ -1544,8 +1563,21 @@ public class Presenter implements IPlugInPort {
|
|||||||
@Override
|
@Override
|
||||||
public void bringSelectionToFront() {
|
public void bringSelectionToFront() {
|
||||||
LOG.info("bringSelectionToFront()");
|
LOG.info("bringSelectionToFront()");
|
||||||
|
int forceConfirmation = -1;
|
||||||
Project oldProject = currentProject.clone();
|
Project oldProject = currentProject.clone();
|
||||||
for (IDIYComponent<?> component : selectedComponents) {
|
|
||||||
|
// sort the selection in Z-order
|
||||||
|
List<IDIYComponent<?>> selection = new ArrayList<IDIYComponent<?>>(selectedComponents);
|
||||||
|
Collections.sort(selection, new Comparator<IDIYComponent<?>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(IDIYComponent<?> o1, IDIYComponent<?> o2) {
|
||||||
|
return new Integer(currentProject.getComponents().indexOf(o1)).compareTo(currentProject.getComponents()
|
||||||
|
.indexOf(o2));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (IDIYComponent<?> component : selection) {
|
||||||
ComponentType componentType =
|
ComponentType componentType =
|
||||||
ComponentProcessor.getInstance().extractComponentTypeFrom(
|
ComponentProcessor.getInstance().extractComponentTypeFrom(
|
||||||
(Class<? extends IDIYComponent<?>>) component.getClass());
|
(Class<? extends IDIYComponent<?>>) component.getClass());
|
||||||
@@ -1559,7 +1591,13 @@ public class Presenter implements IPlugInPort {
|
|||||||
ComponentProcessor.getInstance().extractComponentTypeFrom(
|
ComponentProcessor.getInstance().extractComponentTypeFrom(
|
||||||
(Class<? extends IDIYComponent<?>>) componentAfter.getClass());
|
(Class<? extends IDIYComponent<?>>) componentAfter.getClass());
|
||||||
if (!componentType.isFlexibleZOrder()
|
if (!componentType.isFlexibleZOrder()
|
||||||
&& Math.round(componentAfterType.getZOrder()) > Math.round(componentType.getZOrder()))
|
&& Math.round(componentAfterType.getZOrder()) > Math.round(componentType.getZOrder())
|
||||||
|
&& forceConfirmation != IView.YES_OPTION
|
||||||
|
&& (forceConfirmation =
|
||||||
|
this.view
|
||||||
|
.showConfirmDialog(
|
||||||
|
"Selected component(s) have reached the bottom of their layer. Do you want to force the selection to the back?",
|
||||||
|
"Send Selection to Back", IView.YES_NO_OPTION, IView.QUESTION_MESSAGE)) != IView.YES_OPTION)
|
||||||
break;
|
break;
|
||||||
Collections.swap(currentProject.getComponents(), index, index + 1);
|
Collections.swap(currentProject.getComponents(), index, index + 1);
|
||||||
index++;
|
index++;
|
||||||
|
|||||||
@@ -1766,6 +1766,10 @@
|
|||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>'Tilde' key repeats the last added component</description>
|
<description>'Tilde' key repeats the last added component</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
<description>Ability to force components to the front or back of other components even outisde their designated layer</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>Do not block the UI while checking for new version at startup (can be problematic when there's connectivity issues)</description>
|
<description>Do not block the UI while checking for new version at startup (can be problematic when there's connectivity issues)</description>
|
||||||
|
|||||||
Reference in New Issue
Block a user