mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
grouping improvement
This commit is contained in:
+17
-2
@@ -412,8 +412,9 @@ public class Presenter implements IPlugInPort {
|
|||||||
IDIYComponent<?> component = currentProject.getComponents().get(i);
|
IDIYComponent<?> component = currentProject.getComponents().get(i);
|
||||||
for (int pointIndex = 0; pointIndex < component.getControlPointCount(); pointIndex++) {
|
for (int pointIndex = 0; pointIndex < component.getControlPointCount(); pointIndex++) {
|
||||||
Point controlPoint = component.getControlPoint(pointIndex);
|
Point controlPoint = component.getControlPoint(pointIndex);
|
||||||
// Only consider selected components.
|
// Only consider selected components that are not grouped.
|
||||||
if (selectedComponents.contains(component)) {
|
if (selectedComponents.contains(component)
|
||||||
|
&& findAllGroupedComponents(component).size() == 1) {
|
||||||
try {
|
try {
|
||||||
if (scaledPoint.distance(controlPoint) < CONTROL_POINT_SIZE) {
|
if (scaledPoint.distance(controlPoint) < CONTROL_POINT_SIZE) {
|
||||||
Set<Integer> indices = new HashSet<Integer>();
|
Set<Integer> indices = new HashSet<Integer>();
|
||||||
@@ -715,12 +716,23 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds all components that are grouped with the specified component. This
|
||||||
|
* should be called any time components are added or removed from the
|
||||||
|
* selection.
|
||||||
|
*
|
||||||
|
* @param component
|
||||||
|
* @return set of all components that belong to the same group with the
|
||||||
|
* specified component. At the minimum, set contains that single
|
||||||
|
* component.
|
||||||
|
*/
|
||||||
private Set<IDIYComponent<?>> findAllGroupedComponents(IDIYComponent<?> component) {
|
private Set<IDIYComponent<?>> findAllGroupedComponents(IDIYComponent<?> component) {
|
||||||
Set<IDIYComponent<?>> components = new HashSet<IDIYComponent<?>>();
|
Set<IDIYComponent<?>> components = new HashSet<IDIYComponent<?>>();
|
||||||
components.add(component);
|
components.add(component);
|
||||||
for (Set<IDIYComponent<?>> group : currentProject.getGroups()) {
|
for (Set<IDIYComponent<?>> group : currentProject.getGroups()) {
|
||||||
if (group.contains(component)) {
|
if (group.contains(component)) {
|
||||||
components.addAll(group);
|
components.addAll(group);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return components;
|
return components;
|
||||||
@@ -907,6 +919,9 @@ public class Presenter implements IPlugInPort {
|
|||||||
if (!componentType.isStretchable()) {
|
if (!componentType.isStretchable()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (findAllGroupedComponents(component).size() > 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return selectedComponents.contains(component);
|
return selectedComponents.contains(component);
|
||||||
// return
|
// return
|
||||||
// controlPoint.getVisibilityPolicy().equals(VisibilityPolicy.ALWAYS)
|
// controlPoint.getVisibilityPolicy().equals(VisibilityPolicy.ALWAYS)
|
||||||
|
|||||||
Reference in New Issue
Block a user