mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 14:30:56 +03:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd7b7c6aef | ||
|
|
0bd677c46b | ||
|
|
1a131d5206 | ||
|
|
016e515ae2 | ||
|
|
456ceb3c58 | ||
|
|
2169be1b45 | ||
|
|
49eb0b0201 | ||
|
|
2e222bcdea | ||
|
|
c7fa475128 | ||
|
|
4174b065f3 |
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,6 +1,16 @@
|
||||
FlatLaf Change Log
|
||||
==================
|
||||
|
||||
## 2.0.2
|
||||
|
||||
- Native window decorations (Windows 10/11 only): Fixed rendering artifacts on
|
||||
HiDPI screens when dragging window partly offscreen and back into screen
|
||||
bounds. (issue #477)
|
||||
- Repaint component when setting client property `JComponent.outline` (issue
|
||||
#480).
|
||||
- macOS: Fixed NPE when using some icons in main menu items. (issue #483)
|
||||
|
||||
|
||||
## 2.0.1
|
||||
|
||||
- Fixed memory leak in Panel, Separator and ToolBarSeparator. (issue #471;
|
||||
|
||||
@@ -126,6 +126,8 @@ Buzz
|
||||
Applications using FlatLaf
|
||||
--------------------------
|
||||
|
||||
-  [Ultorg](https://www.ultorg.com/) (**commercial**) - a
|
||||
visual query system for relational databases
|
||||
-  [MooInfo](https://github.com/rememberber/MooInfo) -
|
||||
visual implementation of OSHI, to view information about the system and
|
||||
hardware
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
val releaseVersion = "2.0.1"
|
||||
val releaseVersion = "2.0.2"
|
||||
val developmentVersion = "2.1-SNAPSHOT"
|
||||
|
||||
version = if( java.lang.Boolean.getBoolean( "release" ) ) releaseVersion else developmentVersion
|
||||
|
||||
@@ -96,8 +96,8 @@ public class FlatHelpButtonIcon
|
||||
</svg>
|
||||
*/
|
||||
|
||||
boolean enabled = c.isEnabled();
|
||||
boolean focused = FlatUIUtils.isPermanentFocusOwner( c );
|
||||
boolean enabled = c == null || c.isEnabled();
|
||||
boolean focused = c != null && FlatUIUtils.isPermanentFocusOwner( c );
|
||||
|
||||
float xy = 0.5f;
|
||||
float wh = iconSize() - 1;
|
||||
|
||||
@@ -63,7 +63,7 @@ public class FlatMenuArrowIcon
|
||||
|
||||
@Override
|
||||
protected void paintIcon( Component c, Graphics2D g ) {
|
||||
if( !c.getComponentOrientation().isLeftToRight() )
|
||||
if( c != null && !c.getComponentOrientation().isLeftToRight() )
|
||||
g.rotate( Math.toRadians( 180 ), width / 2., height / 2. );
|
||||
|
||||
g.setColor( getArrowColor( c ) );
|
||||
@@ -82,7 +82,7 @@ public class FlatMenuArrowIcon
|
||||
if( c instanceof JMenu && ((JMenu)c).isSelected() && !isUnderlineSelection() )
|
||||
return selectionForeground;
|
||||
|
||||
return c.isEnabled() ? arrowColor : disabledArrowColor;
|
||||
return c == null || c.isEnabled() ? arrowColor : disabledArrowColor;
|
||||
}
|
||||
|
||||
protected boolean isUnderlineSelection() {
|
||||
|
||||
@@ -262,6 +262,10 @@ public class FlatButtonUI
|
||||
b.repaint();
|
||||
break;
|
||||
|
||||
case OUTLINE:
|
||||
b.repaint();
|
||||
break;
|
||||
|
||||
case STYLE:
|
||||
case STYLE_CLASS:
|
||||
if( shared && FlatStylingSupport.hasStyleProperty( b ) ) {
|
||||
@@ -569,6 +573,9 @@ public class FlatButtonUI
|
||||
public static Color buttonStateColor( Component c, Color enabledColor, Color disabledColor,
|
||||
Color focusedColor, Color hoverColor, Color pressedColor )
|
||||
{
|
||||
if( c == null )
|
||||
return enabledColor;
|
||||
|
||||
if( !c.isEnabled() )
|
||||
return disabledColor;
|
||||
|
||||
|
||||
@@ -354,6 +354,7 @@ public class FlatComboBoxUI
|
||||
break;
|
||||
|
||||
case COMPONENT_ROUND_RECT:
|
||||
case OUTLINE:
|
||||
comboBox.repaint();
|
||||
break;
|
||||
|
||||
|
||||
@@ -291,6 +291,10 @@ public class FlatScrollPaneUI
|
||||
}
|
||||
break;
|
||||
|
||||
case FlatClientProperties.OUTLINE:
|
||||
scrollpane.repaint();
|
||||
break;
|
||||
|
||||
case FlatClientProperties.STYLE:
|
||||
case FlatClientProperties.STYLE_CLASS:
|
||||
installStyle();
|
||||
|
||||
@@ -538,6 +538,7 @@ public class FlatSpinnerUI
|
||||
break;
|
||||
|
||||
case FlatClientProperties.COMPONENT_ROUND_RECT:
|
||||
case FlatClientProperties.OUTLINE:
|
||||
spinner.repaint();
|
||||
break;
|
||||
|
||||
|
||||
@@ -232,6 +232,7 @@ public class FlatTextFieldUI
|
||||
switch( e.getPropertyName() ) {
|
||||
case PLACEHOLDER_TEXT:
|
||||
case COMPONENT_ROUND_RECT:
|
||||
case OUTLINE:
|
||||
case TEXT_FIELD_PADDING:
|
||||
c.repaint();
|
||||
break;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2022 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
|
||||
*
|
||||
* https://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.icons;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.swing.Icon;
|
||||
import com.formdev.flatlaf.ui.TestUtils;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
class TestFlatIconPaintingNullComponent
|
||||
{
|
||||
static Graphics graphics;
|
||||
|
||||
@BeforeAll
|
||||
static void setup() {
|
||||
TestUtils.setup( false );
|
||||
graphics = new BufferedImage( 32, 32, BufferedImage.TYPE_INT_ARGB ).getGraphics();
|
||||
graphics.setColor( Color.white );
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void cleanup() {
|
||||
TestUtils.cleanup();
|
||||
graphics = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
void flatHelpButtonIcon() {
|
||||
paintWithoutException( new FlatHelpButtonIcon() );
|
||||
}
|
||||
|
||||
@Test
|
||||
void flatMenuArrowIcon() {
|
||||
paintWithoutException( new FlatMenuArrowIcon() );
|
||||
}
|
||||
|
||||
@Test
|
||||
void flatSearchIcon() {
|
||||
paintWithoutException( new FlatSearchIcon() );
|
||||
}
|
||||
|
||||
private void paintWithoutException( Icon icon ) {
|
||||
graphics.clearRect( 0, 0, 32, 32 );
|
||||
assertDoesNotThrow( () -> icon.paintIcon( null, graphics, 0, 0 ) );
|
||||
}
|
||||
}
|
||||
@@ -480,7 +480,7 @@ public class FlatSVGIcon
|
||||
|
||||
if( url == null ) {
|
||||
loadFailed = true;
|
||||
LoggingFacade.INSTANCE.logSevere( "FlatSVGIcon: resource '" + name + "' not found (if using Java modules, check whether icon package is opened in module-info.java)", null );
|
||||
LoggingFacade.INSTANCE.logConfig( "FlatSVGIcon: resource '" + name + "' not found (if using Java modules, check whether icon package is opened in module-info.java)", null );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -288,6 +288,7 @@ public class FlatWindowsNativeWindowBorder
|
||||
private static final int GWLP_WNDPROC = -4;
|
||||
|
||||
private static final int
|
||||
WM_MOVE = 0x0003,
|
||||
WM_ERASEBKGND = 0x0014,
|
||||
WM_NCCALCSIZE = 0x0083,
|
||||
WM_NCHITTEST = 0x0084,
|
||||
@@ -301,6 +302,10 @@ public class FlatWindowsNativeWindowBorder
|
||||
WM_LBUTTONDOWN = 0x0201,
|
||||
WM_LBUTTONUP = 0x0202,
|
||||
|
||||
WM_MOVING = 0x0216,
|
||||
WM_ENTERSIZEMOVE = 0x0231,
|
||||
WM_EXITSIZEMOVE = 0x0232,
|
||||
|
||||
WM_DWMCOLORIZATIONCOLORCHANGED = 0x0320;
|
||||
|
||||
// WM_SIZE wParam
|
||||
@@ -341,6 +346,8 @@ public class FlatWindowsNativeWindowBorder
|
||||
private final LONG_PTR defaultWndProc;
|
||||
private int wmSizeWParam = -1;
|
||||
private HBRUSH background;
|
||||
private boolean isMovingOrSizing;
|
||||
private boolean isMoving;
|
||||
|
||||
// Swing coordinates/values may be scaled on a HiDPI screen
|
||||
private int titleBarHeight;
|
||||
@@ -477,7 +484,27 @@ public class FlatWindowsNativeWindowBorder
|
||||
wParam = new WPARAM( wmSizeWParam );
|
||||
break;
|
||||
|
||||
case WM_ENTERSIZEMOVE:
|
||||
isMovingOrSizing = true;
|
||||
break;
|
||||
|
||||
case WM_EXITSIZEMOVE:
|
||||
isMovingOrSizing = isMoving = false;
|
||||
break;
|
||||
|
||||
case WM_MOVE:
|
||||
case WM_MOVING:
|
||||
if( isMovingOrSizing )
|
||||
isMoving = true;
|
||||
break;
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
// do not erase background while the user is moving the window,
|
||||
// otherwise there may be rendering artifacts on HiDPI screens with Java 9+
|
||||
// when dragging the window partly offscreen and back into the screen bounds
|
||||
if( isMoving )
|
||||
return new LRESULT( 0 );
|
||||
|
||||
return WmEraseBkgnd( hwnd, uMsg, wParam, lParam );
|
||||
|
||||
case WM_DESTROY:
|
||||
|
||||
@@ -88,6 +88,8 @@ FlatWndProc::FlatWndProc() {
|
||||
defaultWndProc = NULL;
|
||||
wmSizeWParam = -1;
|
||||
background = NULL;
|
||||
isMovingOrSizing = false;
|
||||
isMoving = false;
|
||||
}
|
||||
|
||||
HWND FlatWndProc::install( JNIEnv *env, jobject obj, jobject window ) {
|
||||
@@ -250,7 +252,27 @@ LRESULT CALLBACK FlatWndProc::WindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, L
|
||||
wParam = wmSizeWParam;
|
||||
break;
|
||||
|
||||
case WM_ENTERSIZEMOVE:
|
||||
isMovingOrSizing = true;
|
||||
break;
|
||||
|
||||
case WM_EXITSIZEMOVE:
|
||||
isMovingOrSizing = isMoving = false;
|
||||
break;
|
||||
|
||||
case WM_MOVE:
|
||||
case WM_MOVING:
|
||||
if( isMovingOrSizing )
|
||||
isMoving = true;
|
||||
break;
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
// do not erase background while the user is moving the window,
|
||||
// otherwise there may be rendering artifacts on HiDPI screens with Java 9+
|
||||
// when dragging the window partly offscreen and back into the screen bounds
|
||||
if( isMoving )
|
||||
return FALSE;
|
||||
|
||||
return WmEraseBkgnd( hwnd, uMsg, wParam, lParam );
|
||||
|
||||
case WM_DESTROY:
|
||||
|
||||
@@ -43,6 +43,8 @@ private:
|
||||
WNDPROC defaultWndProc;
|
||||
int wmSizeWParam;
|
||||
HBRUSH background;
|
||||
bool isMovingOrSizing;
|
||||
bool isMoving;
|
||||
|
||||
FlatWndProc();
|
||||
static void initIDs( JNIEnv *env, jobject obj );
|
||||
|
||||
@@ -162,7 +162,6 @@ public class FlatComponentsTest
|
||||
((JComponent)c).putClientProperty( FlatClientProperties.OUTLINE, outline );
|
||||
} );
|
||||
|
||||
repaint();
|
||||
textField1.requestFocusInWindow();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user