Commit 1ede559b authored by Tuukka Lehtonen's avatar Tuukka Lehtonen
Browse files

Merge branch 'fix-723' into 'master'

Allow overriding the node TextGridNode type created by TextGridStyle

See merge request simantics/platform!27
parents 4e6d7a3a d9247eec
......@@ -182,8 +182,12 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
private static final Comparator<Pair<TextGridStyle, MonitorTextGridResult>> ROW_PRIORITY_COMPARATOR =
(o1, o2) -> Double.compare(o1.first.getPriority(), o2.first.getPriority());
private static void refreshAll(EvaluationContext observer, INode _node) {
final TextGridNode node = ProfileVariables.claimChild(_node, "", "TextGridStyle", TextGridNode.class, observer);
protected Class<? extends TextGridNode> getTextGridNode() {
return TextGridNode.class;
}
private void refreshAll(EvaluationContext observer, INode _node) {
final TextGridNode node = ProfileVariables.claimChild(_node, "", "TextGridStyle", getTextGridNode(), observer);
if (node == null)
return;
......
......@@ -78,6 +78,11 @@ public class GraphLayerManager {
postActivation(layer, false);
}
@Override
public void focusImagesChanged(boolean value) {
// Ignore, not written to graph.
}
@Override
public void ignoreFocusChanged(boolean value) {
// Ignore, not written to graph.
......
......@@ -74,7 +74,6 @@ import org.simantics.g2d.element.handler.TerminalTopology;
import org.simantics.g2d.element.handler.Transform;
import org.simantics.g2d.layers.ILayers;
import org.simantics.g2d.layers.ILayers.ILayersListener;
import org.simantics.g2d.layers.ILayersEditor;
import org.simantics.g2d.participant.TransformUtil;
import org.simantics.g2d.scenegraph.SceneGraphConstants;
import org.simantics.g2d.utils.ElementNodeBridge;
......@@ -241,6 +240,7 @@ public class ElementPainter extends AbstractDiagramParticipant implements Compos
ILayers layers = newValue.getHint(DiagramHints.KEY_LAYERS);
if (layers != null) {
layers.addLayersListener(layersListener);
updateLayerFocusabilityProperties(layers);
}
for (TransactionContext tc : newValue.getDiagramClass().getItemsByClass(TransactionContext.class)) {
......@@ -303,18 +303,22 @@ public class ElementPainter extends AbstractDiagramParticipant implements Compos
// Layer configuration change listening and reaction logic
// ------------------------------------------------------------------------
private void updateLayerFocusabilityProperties(ILayers from) {
ICanvasContext ctx = getContext();
if(ctx != null) {
G2DSceneGraph sg = ctx.getSceneGraph();
if(sg != null) {
sg.setGlobalProperty(G2DSceneGraph.IGNORE_FOCUS, from.getIgnoreFocusSettings());
sg.setGlobalProperty(G2DSceneGraph.FOCUS_IMAGES, from.getFocusImages());
}
}
}
ILayersListener layersListener = new ILayersListener() {
@Override
public void changed() {
Object task = BEGIN("EP.layersChanged");
ICanvasContext ctx = getContext();
if(ctx != null) {
G2DSceneGraph sg = ctx.getSceneGraph();
if(sg != null) {
ILayersEditor layers = diagram.getHint(DiagramHints.KEY_LAYERS);
sg.setGlobalProperty(G2DSceneGraph.IGNORE_FOCUS, layers.getIgnoreFocusSettings());
}
}
updateLayerFocusabilityProperties(diagram.getHint(DiagramHints.KEY_LAYERS));
updateAllVisibility();
END(task);
}
......
......@@ -29,6 +29,11 @@ public interface ILayersEditor extends ILayers {
void ignoreFocusChanged(boolean value);
void ignoreVisibilityChanged(boolean value);
/**
* @since 1.48.0
*/
default void focusImagesChanged(boolean value) {}
}
void setFocusImages(boolean value);
......
......@@ -256,7 +256,16 @@ public class SimpleLayers implements ILayersEditor {
@Override
public void setFocusImages(boolean value) {
boolean changed = focusImages != value;
focusImages = value;
if (changed) {
for (ILayersListener listener : layersListeners) {
listener.changed();
}
for (ILayersEditorListener listener : layerEditorListeners) {
listener.focusImagesChanged(value);
}
}
}
}
......@@ -48,6 +48,7 @@ public class G2DSceneGraph extends G2DParentNode implements ILookupService, INod
private static final long serialVersionUID = -7066146333849901429L;
public static final String IGNORE_FOCUS = "ignoreFocus";
public static final String FOCUS_IMAGES = "focusImages";
public static final String PICK_DISTANCE = "pickDistance";
protected transient Container rootPane = null;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment