X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2FColorHelper.java;h=0b65d2bec8ecf83891cd766bfd4cef246f0772d2;hb=ab6fe55865636188226545f5047a606ebd95674c;hp=b44a975ebee7815fe2f1ff288e21c1cbcd639334;hpb=dff3e01498ac766a7f1ec7b18ce2cc5acd257cb5;p=Mograsim.git diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/ColorHelper.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/ColorHelper.java index b44a975e..0b65d2be 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/ColorHelper.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/ColorHelper.java @@ -4,7 +4,6 @@ import java.util.function.Consumer; import java.util.function.Supplier; import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Device; import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.mograsim.preferences.ColorDefinition; @@ -14,24 +13,27 @@ public class ColorHelper { public static void executeWithDifferentForeground(GeneralGC gc, ColorDefinition col, Runnable exec) { - executeWithDifferentColor(gc.getDevice(), col, gc::getForeground, gc::setForeground, exec); + executeWithDifferentColor(col, gc::getForeground, gc::setForeground, exec); } public static void executeWithDifferentBackground(GeneralGC gc, ColorDefinition col, Runnable exec) { - executeWithDifferentColor(gc.getDevice(), col, gc::getBackground, gc::setBackground, exec); + executeWithDifferentColor(col, gc::getBackground, gc::setBackground, exec); } - private static void executeWithDifferentColor(Device device, ColorDefinition col, Supplier getColor, Consumer setColor, - Runnable exec) + private static void executeWithDifferentColor(ColorDefinition col, Supplier getColor, Consumer setColor, Runnable exec) { - ColorManager cm = ColorManager.current(); - Color oldColor = getColor.get(); - Color newColor = cm.toColor(device, col); - setColor.accept(newColor); - exec.run(); - setColor.accept(oldColor); - cm.dispose(newColor); + if (col == null) + exec.run(); + else + { + ColorManager cm = ColorManager.current(); + Color oldColor = getColor.get(); + Color newColor = cm.toColor(col); + setColor.accept(newColor); + exec.run(); + setColor.accept(oldColor); + } } private ColorHelper()