mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
move grid & chessboard to registry
GitOrigin-RevId: a7b654dccbf2c5936c5bfcaa51171ed2b48d6432
This commit is contained in:
committed by
intellij-monorepo-bot
parent
50dfd1c608
commit
f7fe2b1c08
@@ -31,6 +31,8 @@
|
||||
|
||||
<projectService serviceImplementation="org.intellij.images.search.ImageTagManager"/>
|
||||
<registryKey key="ide.images.wheel.zooming" defaultValue="true"/>
|
||||
<registryKey key="ide.images.show.chessboard" defaultValue="false"/>
|
||||
<registryKey key="ide.images.show.grid" defaultValue="false"/>
|
||||
</extensions>
|
||||
|
||||
<actions>
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.intellij.images.actions;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import org.intellij.images.options.DefaultImageEditorSettings;
|
||||
import org.intellij.images.ui.ImageComponentDecorator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -39,6 +40,7 @@ public final class ToggleTransparencyChessboardAction extends ToggleAction {
|
||||
ImageComponentDecorator decorator = e.getData(ImageComponentDecorator.DATA_KEY);
|
||||
if (decorator != null && decorator.isEnabledForActionPlace(e.getPlace())) {
|
||||
decorator.setTransparencyChessboardVisible(state);
|
||||
DefaultImageEditorSettings.INSTANCE.setShowChessboard(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.util.JDOMExternalizable
|
||||
import com.intellij.openapi.util.JDOMExternalizer
|
||||
import com.intellij.ui.JBColor
|
||||
import com.intellij.util.addOptionTag
|
||||
import org.intellij.images.options.DefaultImageEditorSettings
|
||||
import org.intellij.images.options.GridOptions
|
||||
import org.jdom.Element
|
||||
import java.awt.Color
|
||||
@@ -29,12 +30,13 @@ import java.beans.PropertyChangeSupport
|
||||
* Grid options implementation.
|
||||
*/
|
||||
internal class GridOptionsImpl(private val propertyChangeSupport: PropertyChangeSupport) : GridOptions {
|
||||
private var showDefault: Boolean? = null
|
||||
private var showDefault: Boolean = DefaultImageEditorSettings.showGrid
|
||||
private var lineMinZoomFactor = GridOptions.DEFAULT_LINE_ZOOM_FACTOR
|
||||
private var lineSpan = GridOptions.DEFAULT_LINE_SPAN
|
||||
private var lineColor: Color? = null
|
||||
|
||||
override fun isShowDefault(): Boolean {
|
||||
return showDefault ?: false
|
||||
return showDefault
|
||||
}
|
||||
|
||||
override fun getLineZoomFactor(): Int {
|
||||
@@ -50,14 +52,6 @@ internal class GridOptionsImpl(private val propertyChangeSupport: PropertyChange
|
||||
EditorColorsManager.getInstance().globalScheme.getColor(GRID_LINE_COLOR_KEY) ?: JBColor.DARK_GRAY
|
||||
}
|
||||
|
||||
fun setShowDefault(showDefault: Boolean) {
|
||||
val oldValue = this.showDefault
|
||||
if (oldValue != showDefault) {
|
||||
this.showDefault = showDefault
|
||||
propertyChangeSupport.firePropertyChange(GridOptions.ATTR_SHOW_DEFAULT, oldValue, this.showDefault)
|
||||
}
|
||||
}
|
||||
|
||||
fun setLineMinZoomFactor(lineMinZoomFactor: Int) {
|
||||
val oldValue = this.lineMinZoomFactor
|
||||
if (oldValue != lineMinZoomFactor) {
|
||||
@@ -75,14 +69,14 @@ internal class GridOptionsImpl(private val propertyChangeSupport: PropertyChange
|
||||
}
|
||||
|
||||
override fun inject(options: GridOptions) {
|
||||
isShowDefault = options.isShowDefault
|
||||
showDefault = options.isShowDefault
|
||||
setLineMinZoomFactor(options.lineZoomFactor)
|
||||
setLineSpan(options.lineSpan)
|
||||
}
|
||||
|
||||
override fun setOption(name: String, value: Any): Boolean {
|
||||
if (GridOptions.ATTR_SHOW_DEFAULT == name) {
|
||||
isShowDefault = value as Boolean
|
||||
showDefault = value as Boolean
|
||||
}
|
||||
else if (GridOptions.ATTR_LINE_ZOOM_FACTOR == name) {
|
||||
setLineMinZoomFactor(value as Int)
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.intellij.images.options.impl;
|
||||
import com.intellij.openapi.util.JDOMExternalizable;
|
||||
import com.intellij.openapi.util.JDOMExternalizer;
|
||||
import com.intellij.util.JdomKt;
|
||||
import org.intellij.images.options.DefaultImageEditorSettings;
|
||||
import org.intellij.images.options.TransparencyChessboardOptions;
|
||||
import org.jdom.Element;
|
||||
|
||||
@@ -30,7 +31,6 @@ import java.beans.PropertyChangeSupport;
|
||||
* @author <a href="mailto:aefimov.box@gmail.com">Alexey Efimov</a>
|
||||
*/
|
||||
final class TransparencyChessboardOptionsImpl implements TransparencyChessboardOptions, JDOMExternalizable {
|
||||
private boolean showDefault = true;
|
||||
private int cellSize = DEFAULT_CELL_SIZE;
|
||||
private Color whiteColor = DEFAULT_WHITE_COLOR;
|
||||
private Color blackColor = DEFAULT_BLACK_COLOR;
|
||||
@@ -42,7 +42,7 @@ final class TransparencyChessboardOptionsImpl implements TransparencyChessboardO
|
||||
|
||||
@Override
|
||||
public boolean isShowDefault() {
|
||||
return showDefault;
|
||||
return DefaultImageEditorSettings.INSTANCE.getShowChessboard();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,11 +61,6 @@ final class TransparencyChessboardOptionsImpl implements TransparencyChessboardO
|
||||
}
|
||||
|
||||
void setShowDefault(boolean showDefault) {
|
||||
boolean oldValue = this.showDefault;
|
||||
if (oldValue != showDefault) {
|
||||
this.showDefault = showDefault;
|
||||
propertyChangeSupport.firePropertyChange(ATTR_SHOW_DEFAULT, oldValue, this.showDefault);
|
||||
}
|
||||
}
|
||||
|
||||
void setCellSize(int cellSize) {
|
||||
@@ -136,38 +131,9 @@ final class TransparencyChessboardOptionsImpl implements TransparencyChessboardO
|
||||
|
||||
@Override
|
||||
public void writeExternal(Element element) {
|
||||
JdomKt.addOptionTag(element, ATTR_SHOW_DEFAULT, Boolean.toString(showDefault), "setting");
|
||||
JdomKt.addOptionTag(element, ATTR_SHOW_DEFAULT, Boolean.toString(isShowDefault()), "setting");
|
||||
JdomKt.addOptionTag(element, ATTR_CELL_SIZE, Integer.toString(cellSize), "setting");
|
||||
JDOMExternalizerEx.write(element, ATTR_WHITE_COLOR, whiteColor);
|
||||
JDOMExternalizerEx.write(element, ATTR_BLACK_COLOR, blackColor);
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof TransparencyChessboardOptions)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TransparencyChessboardOptions otherOptions = (TransparencyChessboardOptions)o;
|
||||
|
||||
return cellSize == otherOptions.getCellSize() &&
|
||||
showDefault == otherOptions.isShowDefault() &&
|
||||
(blackColor != null ?
|
||||
blackColor.equals(otherOptions.getBlackColor()) :
|
||||
otherOptions.getBlackColor() == null) &&
|
||||
(whiteColor != null ?
|
||||
whiteColor.equals(otherOptions.getWhiteColor()) :
|
||||
otherOptions.getWhiteColor() == null);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result;
|
||||
result = (showDefault ? 1 : 0);
|
||||
result = 29 * result + cellSize;
|
||||
result = 29 * result + (whiteColor != null ? whiteColor.hashCode() : 0);
|
||||
result = 29 * result + (blackColor != null ? blackColor.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user