mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
a better flip buttons look
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<grid id="cbd77" binding="myRoot" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="10" bottom="10" right="10"/>
|
||||
<constraints>
|
||||
<xy x="48" y="54" width="898" height="538"/>
|
||||
<xy x="48" y="54" width="533" height="341"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -16,7 +16,7 @@
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="dd95d" layout-manager="GridLayoutManager" row-count="4" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="dd95d" layout-manager="GridLayoutManager" row-count="5" column-count="7" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -26,13 +26,13 @@
|
||||
<children>
|
||||
<component id="94212" class="com.intellij.ui.ComboboxWithBrowseButton" binding="myPathField" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="4" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="2" row-span="1" col-span="5" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="fe56c" class="javax.swing.JSlider" binding="myOpacitySlider">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="2" row-span="1" col-span="4" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<paintTicks value="false"/>
|
||||
@@ -40,7 +40,7 @@
|
||||
</component>
|
||||
<component id="a265f" class="javax.swing.JSpinner" binding="myOpacitySpinner">
|
||||
<constraints>
|
||||
<grid row="1" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<grid row="1" column="6" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="64" height="16"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -48,7 +48,7 @@
|
||||
</component>
|
||||
<component id="33a0d" class="com.intellij.ui.components.JBLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="94212"/>
|
||||
@@ -57,7 +57,7 @@
|
||||
</component>
|
||||
<component id="11c6f" class="com.intellij.ui.components.JBLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="a265f"/>
|
||||
@@ -66,7 +66,7 @@
|
||||
</component>
|
||||
<grid id="246cd" binding="myFillPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="2" column="3" row-span="2" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" column="5" row-span="3" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -74,64 +74,46 @@
|
||||
</grid>
|
||||
<grid id="6d9c0" binding="myAnchorPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="2" column="4" row-span="2" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" column="6" row-span="3" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="b7299" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<grid id="b5e12" binding="myFlipPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="2" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="79d16" class="com.intellij.ui.components.JBCheckBox" binding="myThisProjectOnlyCb">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="This project only"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="24532" binding="myTargetPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<component id="8256" class="com.intellij.ui.components.JBCheckBox" binding="myFlipHorCb">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Flip horizontal"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="4bda" class="com.intellij.ui.components.JBCheckBox" binding="myFlipVerCb">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Flip vertical"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="bcce9">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
<children/>
|
||||
</grid>
|
||||
<hspacer id="47dfd">
|
||||
<component id="79d16" class="com.intellij.ui.components.JBCheckBox" binding="myThisProjectOnlyCb">
|
||||
<constraints>
|
||||
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="3" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="This project only"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="24532" binding="myTargetPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="5" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<hspacer id="d5675">
|
||||
<constraints>
|
||||
<grid row="3" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<vspacer id="bcce9">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.intellij.images.editor.actions;
|
||||
|
||||
import com.intellij.application.options.colors.ColorAndFontOptions;
|
||||
import com.intellij.application.options.colors.SimpleEditorPreview;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
@@ -38,6 +39,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.impl.IdeBackgroundUtil;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.ui.components.JBPanelWithEmptyText;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
@@ -85,12 +87,14 @@ public class BackgroundImageDialog extends DialogWrapper {
|
||||
private JPanel myPreviewPanel;
|
||||
private ComboboxWithBrowseButton myPathField;
|
||||
private JBCheckBox myThisProjectOnlyCb;
|
||||
private JBCheckBox myFlipHorCb;
|
||||
private JBCheckBox myFlipVerCb;
|
||||
private JPanel myFlipPanel;
|
||||
private JPanel myAnchorPanel;
|
||||
private JPanel myFillPanel;
|
||||
private JPanel myTargetPanel;
|
||||
|
||||
private final JBCheckBox myFlipHorCb = new JBCheckBox();
|
||||
private final JBCheckBox myFlipVerCb = new JBCheckBox();
|
||||
|
||||
boolean myAdjusting;
|
||||
private final Map<String, String> myResults = ContainerUtil.newHashMap();
|
||||
|
||||
@@ -130,7 +134,7 @@ public class BackgroundImageDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
ComboBox<String> comboBox = new ComboBox<>(new CollectionComboBoxModel<String>(), 100);
|
||||
ComboBox<String> comboBox = new ComboBox<>(new CollectionComboBoxModel<>(), 100);
|
||||
myPathField = new ComboboxWithBrowseButton(comboBox);
|
||||
}
|
||||
|
||||
@@ -219,8 +223,9 @@ public class BackgroundImageDialog extends DialogWrapper {
|
||||
toolbarComponent.setBorder(JBUI.Borders.empty());
|
||||
myTargetPanel.add(toolbarComponent);
|
||||
|
||||
myAnchorPanel.add(createAnchorPanel(myAnchorGroup), BorderLayout.CENTER);
|
||||
myFillPanel.add(createFillPanel(myFillGroup, getDisposable()), BorderLayout.CENTER);
|
||||
initFlipPanel(myFlipPanel, myFlipHorCb, myFlipVerCb);
|
||||
initAnchorPanel(myAnchorPanel, myAnchorGroup);
|
||||
initFillPanel(myFillPanel, myFillGroup, getDisposable());
|
||||
((CardLayout)myPreviewPanel.getLayout()).show(myPreviewPanel, EDITOR);
|
||||
myPathField.getComboBox().setEditable(true);
|
||||
FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, true, false)
|
||||
@@ -467,24 +472,36 @@ public class BackgroundImageDialog extends DialogWrapper {
|
||||
return ColorUtil.mix(UIUtil.getListSelectionBackground(), UIUtil.getLabelBackground(), UIUtil.isUnderDarcula() ? .5 : .75);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static JPanel createAnchorPanel(@NotNull ButtonGroup buttonGroup) {
|
||||
private static void initFlipPanel(@NotNull JPanel p, @NotNull JBCheckBox flipHorCb, @NotNull JBCheckBox flipVerCb) {
|
||||
flipHorCb.setToolTipText("Flip vertically");
|
||||
flipVerCb.setToolTipText("Flip horizontally");
|
||||
p.setLayout(new GridLayout(1, 2, 1, 1));
|
||||
Color color = getSelectionBackground();
|
||||
JBPanelWithEmptyText h = addClickablePanel(p, flipHorCb, color);
|
||||
JBPanelWithEmptyText v = addClickablePanel(p, flipVerCb, color);
|
||||
h.setLayout(new BorderLayout());
|
||||
h.add(new JBLabel(AllIcons.Actions.SplitVertically), BorderLayout.CENTER);
|
||||
v.setLayout(new BorderLayout());
|
||||
v.add(new JBLabel(AllIcons.Actions.SplitHorizontally), BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
private static void initAnchorPanel(@NotNull JPanel p, @NotNull ButtonGroup buttonGroup) {
|
||||
IdeBackgroundUtil.Anchor[] values = IdeBackgroundUtil.Anchor.values();
|
||||
String[] names = new String[values.length];
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
names[i] = values[i].name().replace('_', '-').toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
Color color = getSelectionBackground();
|
||||
JPanel buttonPanel = new JPanel(new GridLayout(3, 3, 1, 1));
|
||||
p.setLayout(new GridLayout(3, 3, 1, 1));
|
||||
for (int i = 0; i < names.length; i ++) {
|
||||
JRadioButton button = new JRadioButton(names[i], values[i] == IdeBackgroundUtil.Anchor.CENTER);
|
||||
addClickablePanel(buttonPanel, buttonGroup, button, color);
|
||||
button.setToolTipText(StringUtil.capitalize(button.getText().replace('-', ' ')));
|
||||
buttonGroup.add(button);
|
||||
addClickablePanel(p, button, color);
|
||||
}
|
||||
return buttonPanel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static JPanel createFillPanel(@NotNull ButtonGroup buttonGroup, @NotNull Disposable disposable) {
|
||||
private static void initFillPanel(@NotNull JPanel p, @NotNull ButtonGroup buttonGroup, @NotNull Disposable disposable) {
|
||||
Fill[] values = Fill.values();
|
||||
String[] names = new String[values.length];
|
||||
BufferedImage image = sampleImage();
|
||||
@@ -492,14 +509,15 @@ public class BackgroundImageDialog extends DialogWrapper {
|
||||
names[i] = values[i].name().replace('_', '-').toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
Color color = getSelectionBackground();
|
||||
JPanel buttonPanel = new JPanel(new GridLayout(1, values.length, 1, 1));
|
||||
p.setLayout(new GridLayout(1, values.length, 1, 1));
|
||||
for (int i = 0; i < values.length; i ++) {
|
||||
JRadioButton radioButton = new JRadioButton(names[i], values[i] == Fill.SCALE);
|
||||
JBPanelWithEmptyText clickablePanel = addClickablePanel(buttonPanel, buttonGroup, radioButton, color);
|
||||
JRadioButton button = new JRadioButton(names[i], values[i] == Fill.SCALE);
|
||||
buttonGroup.add(button);
|
||||
button.setToolTipText(StringUtil.capitalize(button.getText().replace('-', ' ')));
|
||||
JBPanelWithEmptyText clickablePanel = addClickablePanel(p, button, color);
|
||||
createTemporaryBackgroundTransform(
|
||||
clickablePanel, image, values[i], IdeBackgroundUtil.Anchor.CENTER, 1f, JBUI.insets(2), disposable);
|
||||
}
|
||||
return buttonPanel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -517,9 +535,9 @@ public class BackgroundImageDialog extends DialogWrapper {
|
||||
return image;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static JBPanelWithEmptyText addClickablePanel(@NotNull JPanel buttonPanel,
|
||||
@NotNull ButtonGroup buttonGroup,
|
||||
@NotNull JRadioButton button,
|
||||
@NotNull JToggleButton button,
|
||||
@NotNull Color color) {
|
||||
JBPanelWithEmptyText panel = new JBPanelWithEmptyText() {
|
||||
|
||||
@@ -551,18 +569,18 @@ public class BackgroundImageDialog extends DialogWrapper {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
//panel.putClientProperty(JComponent.TOOL_TIP_TEXT_KEY, button.getToolTipText());
|
||||
panel.getEmptyText().clear();
|
||||
new ClickListener() {
|
||||
@Override
|
||||
public boolean onClick(@NotNull MouseEvent event, int clickCount) {
|
||||
button.setSelected(true);
|
||||
button.setSelected(button instanceof JRadioButton || !button.isSelected());
|
||||
buttonPanel.invalidate();
|
||||
buttonPanel.repaint();
|
||||
return true;
|
||||
}
|
||||
}.installOn(panel);
|
||||
panel.setBorder(BorderFactory.createLineBorder(color));
|
||||
buttonGroup.add(button);
|
||||
buttonPanel.add(panel);
|
||||
return panel;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user