Browse Source
Merge in DESIGN/design from ~VITO/c-design:newui to newui * commit 'cc1abc42d649a96afe71b291300bd31e2001d3f9': REPORT-99485 修复togglebutton在工具栏的选中色 无jira任务 代码质量 REPORT-99485 工具栏UI调整 1. 颜色图表绘制 2. 下拉弹窗按钮在工具栏的绘制 REPORT-99485 修复模版tab组件鼠标移动报错newui
vito-刘恒霖
1 year ago
14 changed files with 160 additions and 185 deletions
@ -0,0 +1,66 @@ |
|||||||
|
package com.fine.theme.light.ui; |
||||||
|
|
||||||
|
import com.formdev.flatlaf.ui.FlatUIUtils; |
||||||
|
import com.fr.base.Utils; |
||||||
|
import com.fr.design.gui.ibutton.UIColorButton; |
||||||
|
|
||||||
|
import javax.swing.ButtonModel; |
||||||
|
import javax.swing.JComponent; |
||||||
|
import javax.swing.plaf.ComponentUI; |
||||||
|
import java.awt.Color; |
||||||
|
import java.awt.Graphics; |
||||||
|
import java.awt.Graphics2D; |
||||||
|
import java.awt.Rectangle; |
||||||
|
import java.awt.geom.RoundRectangle2D; |
||||||
|
|
||||||
|
import static com.fine.theme.utils.FineUIScale.scale; |
||||||
|
|
||||||
|
/** |
||||||
|
* 颜色按钮 |
||||||
|
* |
||||||
|
* @author vito |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2024/1/3 |
||||||
|
*/ |
||||||
|
public class FineColorButtonUI extends FineButtonUI { |
||||||
|
|
||||||
|
public static final float HEIGHT = 1.5f; |
||||||
|
public static final float WIDTH = 13; |
||||||
|
public static final float Y = 13.5f; |
||||||
|
|
||||||
|
/** |
||||||
|
* @param shared |
||||||
|
* @since 2 |
||||||
|
*/ |
||||||
|
protected FineColorButtonUI(boolean shared) { |
||||||
|
super(shared); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建UI |
||||||
|
*/ |
||||||
|
public static ComponentUI createUI(JComponent c) { |
||||||
|
return new FineColorButtonUI(false); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void paintIcon(Graphics g, JComponent c, Rectangle iconRect) { |
||||||
|
super.paintIcon(g, c, iconRect); |
||||||
|
UIColorButton b = (UIColorButton) c; |
||||||
|
ButtonModel model = b.getModel(); |
||||||
|
if (model.isEnabled()) { |
||||||
|
g.setColor(b.getColor()); |
||||||
|
} else { |
||||||
|
g.setColor(new Color(Utils.filterRGB(b.getColor().getRGB(), 50))); |
||||||
|
} |
||||||
|
FlatUIUtils.setRenderingHints(g); |
||||||
|
Graphics2D g2d = (Graphics2D) g; |
||||||
|
float height = scale(HEIGHT); |
||||||
|
float width = scale(WIDTH); |
||||||
|
// 计算实际大小与icon区域大小的偏移,用于居中调整
|
||||||
|
float offsetX = (iconRect.width - width) / 2.0f; |
||||||
|
RoundRectangle2D.Float colorRect = new RoundRectangle2D.Float( |
||||||
|
iconRect.x + offsetX, iconRect.y + scale(Y), width, height, height, height); |
||||||
|
g2d.fill(colorRect); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue