From 8914cf78a103ebfb6aea9d6cdd0cd084c690b36d Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Fri, 19 Nov 2021 11:37:46 +0100 Subject: [PATCH] Typography: Theme Editor: added `h1.regular`, `h2.regular` and `h3.regular` to preview --- .../themeeditor/FlatThemePreviewFonts.java | 25 ++++++++++++++++++- .../themeeditor/FlatThemePreviewFonts.jfd | 14 ++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewFonts.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewFonts.java index 9a8d2510..e604c8c7 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewFonts.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewFonts.java @@ -101,16 +101,19 @@ public class FlatThemePreviewFonts //---- h1Preview ---- h1Preview.setFontType("H1"); h1Preview.setFontStyle("h1"); + h1Preview.setFontStyleRegular("h1.regular"); add(h1Preview, "cell 0 3,gapx 12"); //---- h2Preview ---- h2Preview.setFontType("H2"); h2Preview.setFontStyle("h2"); + h2Preview.setFontStyleRegular("h2.regular"); add(h2Preview, "cell 0 4,gapx 12"); //---- h3Preview ---- h3Preview.setFontType("H3"); h3Preview.setFontStyle("h3"); + h3Preview.setFontStyleRegular("h3.regular"); add(h3Preview, "cell 0 5,gapx 12"); //---- h4Preview ---- @@ -163,7 +166,7 @@ public class FlatThemePreviewFonts add(monospacedPreview, "cell 0 15,gapx 12"); //---- scaleLabel ---- - scaleLabel.setText("Fonts are scaled by:"); + scaleLabel.setText("Fonts in preview are scaled by:"); add(scaleLabel, "cell 0 16,gapx 12"); //---- scaleValueLabel ---- @@ -185,6 +188,7 @@ public class FlatThemePreviewFonts { private String fontType; private String fontStyle; + private String fontStyleRegular; private FontPreview() { initComponents(); @@ -193,6 +197,8 @@ public class FlatThemePreviewFonts previewLabel.addPropertyChangeListener( "font", e -> { updateDescription( previewLabel.getFont() ); } ); + + preview2Label.setVisible( false ); } public String getFontType() { @@ -202,6 +208,7 @@ public class FlatThemePreviewFonts public void setFontType( String fontType ) { this.fontType = fontType; previewLabel.setText( fontType ); + preview2Label.setText( " / " + fontType ); } public String getFontStyle() { @@ -213,6 +220,16 @@ public class FlatThemePreviewFonts previewLabel.putClientProperty( FlatClientProperties.STYLE_CLASS, fontStyle ); } + public String getFontStyleRegular() { + return fontStyleRegular; + } + + public void setFontStyleRegular( String fontStyleRegular ) { + this.fontStyleRegular = fontStyleRegular; + preview2Label.putClientProperty( FlatClientProperties.STYLE_CLASS, fontStyleRegular ); + preview2Label.setVisible( fontStyleRegular != null ); + } + private void updateDescription( Font font ) { int baseSize = getDefaultFont().getSize(); int fontSize = font.getSize(); @@ -236,6 +253,7 @@ public class FlatThemePreviewFonts private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents previewLabel = new JLabel(); + preview2Label = new JLabel(); descLabel = new JLabel(); //======== this ======== @@ -251,6 +269,10 @@ public class FlatThemePreviewFonts previewLabel.setText("preview"); add(previewLabel, "cell 0 0"); + //---- preview2Label ---- + preview2Label.setText("preview"); + add(preview2Label, "cell 0 0,gapx 0"); + //---- descLabel ---- descLabel.setText("description"); descLabel.putClientProperty("FlatLaf.styleClass", "medium"); @@ -260,6 +282,7 @@ public class FlatThemePreviewFonts // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables private JLabel previewLabel; + private JLabel preview2Label; private JLabel descLabel; // JFormDesigner - End of variables declaration //GEN-END:variables } diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewFonts.jfd b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewFonts.jfd index 002e1736..e0dfb9b3 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewFonts.jfd +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewFonts.jfd @@ -37,6 +37,7 @@ new FormModel { name: "h1Preview" "fontType": "H1" "fontStyle": "h1" + "fontStyleRegular": "h1.regular" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 3,gapx 12" } ) @@ -44,6 +45,7 @@ new FormModel { name: "h2Preview" "fontType": "H2" "fontStyle": "h2" + "fontStyleRegular": "h2.regular" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 4,gapx 12" } ) @@ -51,6 +53,7 @@ new FormModel { name: "h3Preview" "fontType": "H3" "fontStyle": "h3" + "fontStyleRegular": "h3.regular" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 5,gapx 12" } ) @@ -128,7 +131,7 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "scaleLabel" - "text": "Fonts are scaled by:" + "text": "Fonts in preview are scaled by:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 16,gapx 12" } ) @@ -165,6 +168,15 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 0" } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "preview2Label" + "text": "preview" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0,gapx 0" + } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "descLabel" "text": "description"