Browse Source
Merge in DESIGN/design from ~LEVY.XIE/design:newui to newui * commit 'cbc073dab0da298547d4647828e8cf46936ed370': REPORT-107972 按钮组、颜色选择框、树适配dpi切换 REPORT-107972 按钮组、颜色选择框、树适配dpi切换newui
Levy.Xie-解安森
1 year ago
24 changed files with 451 additions and 265 deletions
@ -0,0 +1,39 @@
|
||||
package com.fine.theme.light.ui; |
||||
|
||||
import com.fine.theme.utils.FineUIUtils; |
||||
|
||||
import javax.swing.JComponent; |
||||
import javax.swing.border.LineBorder; |
||||
import javax.swing.plaf.ComponentUI; |
||||
import javax.swing.plaf.PanelUI; |
||||
|
||||
/** |
||||
* 按钮组UI,应用于 |
||||
* |
||||
* @author Levy.Xie |
||||
* @since 11.0 |
||||
* Created on 2023/12/15 |
||||
*/ |
||||
public class FineButtonGroupUI extends PanelUI { |
||||
|
||||
/** |
||||
* 创建UI |
||||
* |
||||
* @param c 组件 |
||||
* @return ComponentUI |
||||
*/ |
||||
public static ComponentUI createUI(JComponent c) { |
||||
return new FineButtonGroupUI(); |
||||
} |
||||
|
||||
@Override |
||||
public void installUI(JComponent c) { |
||||
super.installUI(c); |
||||
c.setBorder(new LineBorder(FineUIUtils.getUIColor("defaultBorderColor", "Component.borderColor"))); |
||||
} |
||||
|
||||
@Override |
||||
public void uninstallUI(JComponent c) { |
||||
super.uninstallUI(c); |
||||
} |
||||
} |
@ -0,0 +1,49 @@
|
||||
package com.fine.theme.light.ui; |
||||
|
||||
import com.fine.theme.utils.FineUIUtils; |
||||
|
||||
import javax.swing.JComponent; |
||||
import javax.swing.plaf.ComponentUI; |
||||
import javax.swing.plaf.PanelUI; |
||||
import java.awt.Dimension; |
||||
|
||||
/** |
||||
* 选择框面板UI,应用于 {@link com.fr.design.style.AbstractSelectBox} |
||||
* |
||||
* @author Levy.Xie |
||||
* @since 11.0 |
||||
* Created on 2023/12/15 |
||||
*/ |
||||
public class FineSelectBoxUI extends PanelUI { |
||||
|
||||
private static final int DEFAULT_BOX_HEIGHT = 24; |
||||
|
||||
protected int boxHeight; |
||||
|
||||
/** |
||||
* 创建UI |
||||
* |
||||
* @param c 组件 |
||||
* @return ComponentUI |
||||
*/ |
||||
public static ComponentUI createUI(JComponent c) { |
||||
return new FineSelectBoxUI(); |
||||
} |
||||
|
||||
@Override |
||||
public void installUI(JComponent c) { |
||||
super.installUI(c); |
||||
boxHeight = FineUIUtils.getAndScaleInt("ComboBox.comboHeight", DEFAULT_BOX_HEIGHT); |
||||
c.setBorder(new FineRoundBorder()); |
||||
} |
||||
|
||||
@Override |
||||
public void uninstallUI(JComponent c) { |
||||
super.uninstallUI(c); |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize(JComponent c) { |
||||
return new Dimension(c.getWidth(), boxHeight); |
||||
} |
||||
} |
@ -0,0 +1,16 @@
|
||||
package com.fine.theme.utils; |
||||
|
||||
import com.formdev.flatlaf.FlatClientProperties; |
||||
|
||||
/** |
||||
* FR-UI中使用的各类属性 |
||||
* |
||||
* @author Levy.Xie |
||||
* @since 11.0 |
||||
* Created on 2023/12/15 |
||||
*/ |
||||
public interface FineClientProperties extends FlatClientProperties { |
||||
|
||||
String BUTTON_TYPE_GROUP = "group"; |
||||
|
||||
} |
@ -1,61 +0,0 @@
|
||||
package com.fr.design.gui.ibutton; |
||||
|
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* Created with IntelliJ IDEA. |
||||
* User: pony |
||||
* Date: 13-5-27 |
||||
* Time: 下午4:51 |
||||
* To change this template use File | Settings | File Templates. |
||||
*/ |
||||
public class FiveButtonLayout extends GridLayout { |
||||
private static final double SECOND_ROW = 1.25; |
||||
|
||||
public FiveButtonLayout(int rows) { |
||||
super(rows, 3, 1, 1); |
||||
} |
||||
|
||||
/** |
||||
* 容器布局 |
||||
* |
||||
* @param parent 容器 |
||||
*/ |
||||
public void layoutContainer(Container parent) { |
||||
synchronized (parent.getTreeLock()) { |
||||
Insets insets = parent.getInsets(); |
||||
int ncomponents = parent.getComponentCount(); |
||||
int nrows = 2; |
||||
int ncols = 3; |
||||
if (ncomponents == 3) { |
||||
nrows = 1; |
||||
ncols = 3; |
||||
} |
||||
|
||||
if (ncomponents == 0) { |
||||
return; |
||||
} |
||||
if (nrows > 0) { |
||||
ncols = (ncomponents + nrows - 1) / nrows; |
||||
} else { |
||||
nrows = (ncomponents + ncols - 1) / ncols; |
||||
} |
||||
int w = parent.getWidth() - (insets.left + insets.right); |
||||
int h = parent.getHeight() - (insets.top + insets.bottom); |
||||
w = (w - (ncols - 1)) / ncols; |
||||
h = (h - (nrows - 1)) / nrows; |
||||
for (int i = 0, x = insets.left, y = insets.top; i < ncols; i++, x += w + 1) { |
||||
parent.getComponent(i).setBounds(x, y, w, h); |
||||
} |
||||
int line2w = (int) (SECOND_ROW * w); |
||||
int secondRowCount = ncomponents - ncols; |
||||
int startx = (parent.getWidth() - line2w * secondRowCount - secondRowCount - 1) / 2; |
||||
for (int i = ncols, x = startx, y = insets.top + h + 1; i < ncomponents; i++, x += line2w + 1) { |
||||
parent.getComponent(i).setBounds(x, y, line2w, h); |
||||
} |
||||
|
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,44 @@
|
||||
package com.fr.design.gui.storybook.components; |
||||
|
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.storybook.Story; |
||||
import com.fr.design.gui.storybook.StoryBoard; |
||||
import com.fr.design.style.background.texture.TextureSelectBox; |
||||
import com.fr.design.style.color.ColorSelectBox; |
||||
import com.fr.design.style.color.NewColorSelectPane; |
||||
|
||||
import static com.fine.swing.ui.layout.Layouts.cell; |
||||
import static com.fine.swing.ui.layout.Layouts.flex; |
||||
|
||||
/** |
||||
* @author Levy.Xie |
||||
* @since 11.0 |
||||
* Created on 2023/12/18 |
||||
*/ |
||||
@Story |
||||
public class SelectBoxStoryBoard extends StoryBoard { |
||||
|
||||
public SelectBoxStoryBoard() { |
||||
super("选择框面板"); |
||||
add( |
||||
cell(new UILabel("颜色下拉选择面板")).with(this :: h3), |
||||
cell(new MockColorSelectBox(50)), |
||||
cell(new UILabel("纹理下拉选择面板")).with(this :: h3), |
||||
cell(new TextureSelectBox(50)), |
||||
flex() |
||||
); |
||||
} |
||||
|
||||
private static class MockColorSelectBox extends ColorSelectBox { |
||||
|
||||
public MockColorSelectBox(int preferredWidth) { |
||||
super(preferredWidth); |
||||
} |
||||
|
||||
@Override |
||||
protected NewColorSelectPane getColorSelectPane() { |
||||
return new NewColorSelectPane(true, true); |
||||
} |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue