Skip to content

Commit

Permalink
p2
Browse files Browse the repository at this point in the history
  • Loading branch information
subhra74 committed Aug 13, 2023
1 parent 5ba2fe7 commit 7f8536a
Show file tree
Hide file tree
Showing 24 changed files with 1,685 additions and 102 deletions.
31 changes: 19 additions & 12 deletions app/src/main/java/muon/App.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package muon;

import muon.ui.styles.AppTheme;
import muon.ui.styles.FlatLookAndFeel;
import muon.ui.widgets.HomePanel;
import muon.ui.widgets.TabItem;
import muon.ui.widgets.SessionManagerDialog;
import muon.ui.widgets.TabbedPanel;
import muon.util.FontIcon;
import muon.util.AppUtils;
import muon.util.IconCode;
import muon.util.IconFont;

import javax.swing.*;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.MatteBorder;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.awt.event.MouseAdapter;
Expand All @@ -38,12 +39,18 @@ public static void main(String[] args) throws InterruptedException, InvocationTa
//JFrame.setDefaultLookAndFeelDecorated(false);
JFrame f = new JFrame();
//f.setUndecorated(true);
f.setSize(800, 600);
f.setSize(AppUtils.calculateDefaultWindowSize());
f.setLocationRelativeTo(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setBackground(Color.BLACK);
f.setBackground(Color.BLACK);
f.add(new HomePanel());
f.getContentPane().setBackground(AppTheme.INSTANCE.getBackground());
f.setBackground(AppTheme.INSTANCE.getBackground());
final var hp = new HomePanel(null, e -> {
new SessionManagerDialog(f).setVisible(true);
f.getContentPane().removeAll();
f.getContentPane().add(createMainPanel());
f.getContentPane().validate();
});
f.add(hp);
//var toolbar = createToolbar();
//f.add(toolbar, BorderLayout.NORTH);
//f.add(createMainPanel());
Expand Down Expand Up @@ -72,6 +79,7 @@ private static JPanel createFileBrowser(EmptyBorder border, boolean right) {

addressBar.add(addressIcon, BorderLayout.WEST);
var txtAddress = new JTextField();
txtAddress.putClientProperty("textField.noBorder",Boolean.TRUE);
txtAddress.setBackground(c1);
txtAddress.setForeground(new Color(100, 100, 100));
txtAddress.setBorder(new EmptyBorder(0, 0, 0, 0));
Expand Down Expand Up @@ -294,7 +302,7 @@ private static JPanel createBottomPanel() {
return panel;
}

private static JPanel createContentPanel(){
private static JPanel createContentPanel() {
var mainTop = new JPanel(new GridLayout(1, 2));
mainTop.add(createFileBrowser(new MatteBorder(0, 0, 0, 1, new Color(15, 15, 15)), false));
mainTop.add(createFileBrowser(border, true));
Expand All @@ -318,12 +326,11 @@ private static JPanel createMainPanel() {
new Color(31, 31, 31),
new Color(130, 130, 130),
new Color(180, 180, 180),
FontIcon.RI_INSTANCE_LINE,
FontIcon.RI_CLOSE_LINE,
IconCode.RI_CLOSE_LINE,
Color.BLACK
);
tabbedPanel.addTab("tab1", FontIcon.RI_INSTANCE_LINE, createContentPanel());
tabbedPanel.addTab("tab2", FontIcon.RI_INSTANCE_LINE, createContentPanel());
tabbedPanel.addTab("tab1", IconCode.RI_INSTANCE_LINE, createContentPanel());
tabbedPanel.addTab("tab2", IconCode.RI_INSTANCE_LINE, createContentPanel());
//
//
//
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/muon/model/ISessionListItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package muon.model;

public interface ISessionListItem {
String getName();
String getUser();
}
123 changes: 120 additions & 3 deletions app/src/main/java/muon/ui/styles/AppTheme.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,132 @@
package muon.ui.styles;

import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import java.awt.*;

public class AppTheme {
public static final AppTheme INSTANCE=new AppTheme();
public static final AppTheme INSTANCE = new AppTheme();
public static Insets BUTTON_MARGIN = new Insets(150, 15, 5, 15);

public Color getBackground(){
public Color getBackground() {
return new Color(31, 31, 31);
}

public Color getTabSelectionColor(){
public Color getButtonBackground() {
return new Color(35, 35, 35);
}

public Color getButtonRollOverBackground() {
return new Color(40, 40, 40);
}

public Color getButtonPressedBackground() {
return new Color(27, 27, 27);
}

public Color getDarkControlBackground() {
return new Color(24, 24, 24);
}

public Color getForeground() {
return new Color(120, 120, 120);
}

public Color getLightForeground() {
return new Color(100, 100, 100);
}

public Color getHomePanelButtonColor() {
return new Color(31, 31, 31);
}

public Color getButtonBorderColor() {
return new Color(54, 54, 54);
}

public Color getTextFieldBorderColor() {
return new Color(64, 64, 64);
}

public Color getSelectionColor() {
return new Color(52, 117, 233);
}

public Color getSelectionForeground() {
return Color.WHITE;
}

public int getButtonBorderArc() {
return 7;
}

public Color getSplitPaneBackground() {
return Color.BLACK;
}

public Color getListSelectionColor(){
return new Color(46,67,110);
}

public Object[] getDefaultStyles() {
Font widgetFont = new Font(Font.DIALOG, Font.PLAIN, 12);
return new Object[]{
"Button.font", widgetFont,
"Button.background", getButtonBackground(),
"Button.foreground", getForeground(),
"Button.light", getButtonRollOverBackground(),
"Button.highlight", getButtonPressedBackground(),
"Button.border", new EmptyBorder(new Insets(5, 15, 5, 15)),

"Label.font", widgetFont,
"Label.background", getBackground(),
"Label.foreground", getForeground(),
"Label.disabledForeground", getForeground(),
"Label.disabledShadow", getForeground(),
"Label.border", null,

"TextField.background", getBackground(),
"TextField.border", new EmptyBorder(5, 5, 5, 5),
"TextField.foreground", getForeground(),
"TextField.selectionBackground", getSelectionColor(),
"TextField.selectionForeground", getSelectionForeground(),
"TextField.caretForeground", getForeground(),

"PasswordField.background", getBackground(),
"PasswordField.border", new LineBorder(Color.RED, 5),
"PasswordField.foreground", getForeground(),
"PasswordField.selectionBackground", getSelectionColor(),
"PasswordField.selectionForeground", getSelectionForeground(),
"PasswordField.caretForeground", getForeground(),

"Tree.background", getBackground(),
"Tree.foreground", getForeground(),
// "Tree.openIcon", new FontIcon(FontIconCodes.RI_FOLDER_OPEN_FILL,
// 24, 24, 16.0f, getForeground()),
// "Tree.closedIcon", new FontIcon(FontIconCodes.RI_FOLDER_FILL,
// 24, 24, 16.0f, getForeground()),
// "Tree.leafIcon", new FontIcon(FontIconCodes.RI_CLOSE_LINE,
// 24, 24, 16.0f, getForeground()),
"Tree.selectionForeground", getSelectionForeground(),
"Tree.textForeground", getForeground(),
"Tree.selectionBackground", getListSelectionColor(),
"Tree.textBackground", getBackground(),
"Tree.rendererFillBackground", true,
//"Tree.rendererMargins", new Insets(25,25,5,5),
"Tree.selectionBorderColor", getListSelectionColor(),

"SplitPane.background", Color.BLACK,
"SplitPane.border", new EmptyBorder(0, 0, 0, 0),
"SplitPaneDivider.border", new EmptyBorder(0, 0, 0, 0),

"ComboBox.background", getBackground(),
"ComboBox.foreground", getForeground(),
"ComboBox.border", new EmptyBorder(0, 0, 0, 0),
"ComboBox.padding", new Insets(5, 5, 5, 5),
"ComboBox.squareButton", Boolean.FALSE,
"ComboBox.Border", new EmptyBorder(3,3,3,3),

"Panel.background", getBackground(),
};
}
}
66 changes: 33 additions & 33 deletions app/src/main/java/muon/ui/styles/FlatButtonUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,67 +4,67 @@
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
import java.awt.*;
import java.awt.geom.RoundRectangle2D;

public class FlatButtonUI extends BasicButtonUI {
static FlatButtonUI buttonUI;

public static ComponentUI createUI(JComponent c) {
if (buttonUI == null) {
buttonUI = new FlatButtonUI();
}
return buttonUI;
return new FlatButtonUI();
}

@Override
public void installUI(JComponent c) {
super.installUI(c);
if (c instanceof JButton) {
JButton btn = (JButton) c;
if (c instanceof JButton btn) {
btn.setRolloverEnabled(true);
if (btn.getBackground() == null) {
btn.setBackground(AppTheme.INSTANCE.getButtonBackground());
}
if (btn.getClientProperty("button.arc") == null) {
btn.putClientProperty("button.arc", AppTheme.INSTANCE.getButtonBorderArc());
}
btn.setOpaque(false);
}
}

protected void paintButtonNormal(Graphics g, AbstractButton b) {
if (!b.isOpaque()) {
if (b.isContentAreaFilled()) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2.setPaint(b.getBackground());
g2.fillRect(0, 0, b.getWidth(), b.getHeight());
g2.setColor(b.getBackground());
Integer arc = (Integer) b.getClientProperty("button.arc");
g2.fillRoundRect(0, 0, b.getWidth(), b.getHeight(), arc, arc);

if (b.isBorderPainted()) {
g2.setColor(AppTheme.INSTANCE.getButtonBorderColor());
g2.drawRoundRect(0, 0, b.getWidth() - 1, b.getHeight() - 1, arc, arc);
}
}
}

protected void paintButtonPressed(Graphics g, AbstractButton b) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2.setColor(b.getBackground());
// Color color = (Color) b.getClientProperty("xdmbutton.pressedcolor");
// if (color != null) {
// g2.setPaint(color);
// } else {
// g2.setPaint(Color.GRAY);
// }
g2.fillRect(0, 0, b.getWidth(), b.getHeight());
if (!Boolean.TRUE.equals(b.getClientProperty("button.noPressed"))) {
Graphics2D g2 = (Graphics2D) g;
g2.setColor(AppTheme.INSTANCE.getButtonPressedBackground());
Integer arc = (Integer) b.getClientProperty("button.arc");
g2.fillRoundRect(0, 0, b.getWidth(), b.getHeight(), arc, arc);
}
}

protected void paintButtonRollOver(Graphics g, AbstractButton b) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
// if (b.getClientProperty("xdmbutton.grayrollover") != null) {
// g2.setPaint(Color.DARK_GRAY);
// } else {
// g2.setPaint(ColorResource.getSelectionColor());
// }
g2.setColor(b.getBackground());
g2.fillRect(0, 0, b.getWidth(), b.getHeight());
if (b.isRolloverEnabled()) {
Graphics2D g2 = (Graphics2D) g;
g2.setColor(AppTheme.INSTANCE.getButtonRollOverBackground());
Integer arc = (Integer) b.getClientProperty("button.arc");
g2.fillRoundRect(0, 0, b.getWidth(), b.getHeight(), arc, arc);
}
}

public void paint(Graphics g, JComponent c) {
try {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);

AbstractButton b = (AbstractButton) c;
ButtonModel bm = b.getModel();
Expand Down
Loading

0 comments on commit 7f8536a

Please sign in to comment.