From 611296037c3cf867975272b3f4d985fa75d7a1a5 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sat, 31 Aug 2019 13:04:46 +0200 Subject: [PATCH] MenuItems: scale gap between icon and text --- .../flatlaf/ui/FlatCheckBoxMenuItemUI.java | 43 +++++++++++++++++++ .../formdev/flatlaf/ui/FlatMenuItemUI.java | 43 +++++++++++++++++++ .../com/formdev/flatlaf/ui/FlatMenuUI.java | 43 +++++++++++++++++++ .../flatlaf/ui/FlatRadioButtonMenuItemUI.java | 43 +++++++++++++++++++ .../com/formdev/flatlaf/FlatLaf.properties | 4 ++ 5 files changed, 176 insertions(+) create mode 100644 flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatCheckBoxMenuItemUI.java create mode 100644 flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuItemUI.java create mode 100644 flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuUI.java create mode 100644 flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonMenuItemUI.java diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatCheckBoxMenuItemUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatCheckBoxMenuItemUI.java new file mode 100644 index 00000000..8d108f08 --- /dev/null +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatCheckBoxMenuItemUI.java @@ -0,0 +1,43 @@ +/* + * Copyright 2019 FormDev Software GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.formdev.flatlaf.ui; + +import static com.formdev.flatlaf.util.UIScale.scale; +import javax.swing.JComponent; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.basic.BasicCheckBoxMenuItemUI; + +/** + * Provides the Flat LaF UI delegate for {@link javax.swing.JCheckBoxMenuItem}. + * + * @author Karl Tauber + */ +public class FlatCheckBoxMenuItemUI + extends BasicCheckBoxMenuItemUI +{ + public static ComponentUI createUI( JComponent c ) { + return new FlatCheckBoxMenuItemUI(); + } + + @Override + protected void installDefaults() { + super.installDefaults(); + + // scale + defaultTextIconGap = scale( defaultTextIconGap ); + } +} diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuItemUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuItemUI.java new file mode 100644 index 00000000..9652cae8 --- /dev/null +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuItemUI.java @@ -0,0 +1,43 @@ +/* + * Copyright 2019 FormDev Software GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.formdev.flatlaf.ui; + +import static com.formdev.flatlaf.util.UIScale.scale; +import javax.swing.JComponent; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.basic.BasicMenuItemUI; + +/** + * Provides the Flat LaF UI delegate for {@link javax.swing.JMenuItem}. + * + * @author Karl Tauber + */ +public class FlatMenuItemUI + extends BasicMenuItemUI +{ + public static ComponentUI createUI( JComponent c ) { + return new FlatMenuItemUI(); + } + + @Override + protected void installDefaults() { + super.installDefaults(); + + // scale + defaultTextIconGap = scale( defaultTextIconGap ); + } +} diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuUI.java new file mode 100644 index 00000000..45836975 --- /dev/null +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuUI.java @@ -0,0 +1,43 @@ +/* + * Copyright 2019 FormDev Software GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.formdev.flatlaf.ui; + +import static com.formdev.flatlaf.util.UIScale.scale; +import javax.swing.JComponent; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.basic.BasicMenuUI; + +/** + * Provides the Flat LaF UI delegate for {@link javax.swing.JMenu}. + * + * @author Karl Tauber + */ +public class FlatMenuUI + extends BasicMenuUI +{ + public static ComponentUI createUI( JComponent c ) { + return new FlatMenuUI(); + } + + @Override + protected void installDefaults() { + super.installDefaults(); + + // scale + defaultTextIconGap = scale( defaultTextIconGap ); + } +} diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonMenuItemUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonMenuItemUI.java new file mode 100644 index 00000000..879293c5 --- /dev/null +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonMenuItemUI.java @@ -0,0 +1,43 @@ +/* + * Copyright 2019 FormDev Software GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.formdev.flatlaf.ui; + +import static com.formdev.flatlaf.util.UIScale.scale; +import javax.swing.JComponent; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.basic.BasicRadioButtonMenuItemUI; + +/** + * Provides the Flat LaF UI delegate for {@link javax.swing.JRadioButtonMenuItem}. + * + * @author Karl Tauber + */ +public class FlatRadioButtonMenuItemUI + extends BasicRadioButtonMenuItemUI +{ + public static ComponentUI createUI( JComponent c ) { + return new FlatRadioButtonMenuItemUI(); + } + + @Override + protected void installDefaults() { + super.installDefaults(); + + // scale + defaultTextIconGap = scale( defaultTextIconGap ); + } +} diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties index 6cc492f7..5098929a 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties @@ -18,13 +18,17 @@ ButtonUI=com.formdev.flatlaf.ui.FlatButtonUI CheckBoxUI=com.formdev.flatlaf.ui.FlatCheckBoxUI +CheckBoxMenuItemUI=com.formdev.flatlaf.ui.FlatCheckBoxMenuItemUI ComboBoxUI=com.formdev.flatlaf.ui.FlatComboBoxUI EditorPaneUI=com.formdev.flatlaf.ui.FlatEditorPaneUI FormattedTextFieldUI=com.formdev.flatlaf.ui.FlatFormattedTextFieldUI LabelUI=com.formdev.flatlaf.ui.FlatLabelUI +MenuUI=com.formdev.flatlaf.ui.FlatMenuUI +MenuItemUI=com.formdev.flatlaf.ui.FlatMenuItemUI PasswordFieldUI=com.formdev.flatlaf.ui.FlatPasswordFieldUI ProgressBarUI=com.formdev.flatlaf.ui.FlatProgressBarUI RadioButtonUI=com.formdev.flatlaf.ui.FlatRadioButtonUI +RadioButtonMenuItemUI=com.formdev.flatlaf.ui.FlatRadioButtonMenuItemUI ScrollBarUI=com.formdev.flatlaf.ui.FlatScrollBarUI ScrollPaneUI=com.formdev.flatlaf.ui.FlatScrollPaneUI SeparatorUI=com.formdev.flatlaf.ui.FlatSeparatorUI