137 lines
4.1 KiB
Java
137 lines
4.1 KiB
Java
|
|
package org.openautonomousconnection.webclient.ui;
|
||
|
|
|
||
|
|
import org.openautonomousconnection.oacswing.component.OACButton;
|
||
|
|
import org.openautonomousconnection.oacswing.component.OACPanel;
|
||
|
|
import org.openautonomousconnection.oacswing.component.OACTextField;
|
||
|
|
|
||
|
|
import javax.swing.border.EmptyBorder;
|
||
|
|
import java.awt.*;
|
||
|
|
|
||
|
|
public final class BrowserDesign extends OACPanel {
|
||
|
|
|
||
|
|
private static final int HEIGHT_NAV = 44;
|
||
|
|
private static final int RADIUS = 16;
|
||
|
|
|
||
|
|
private final OACButton backButton = iconButton("«");
|
||
|
|
private final OACButton forwardButton = iconButton("»");
|
||
|
|
private final OACButton reloadButton = iconButton("↻");
|
||
|
|
|
||
|
|
private final OACTextField addressField = new OACTextField();
|
||
|
|
|
||
|
|
private final OACButton goButton = pillButton("\uD83D\uDD0D");
|
||
|
|
private final OACButton starButton = iconButton("☆");
|
||
|
|
private final OACButton menuButton = iconButton("▤");
|
||
|
|
|
||
|
|
private final FavChipBar favoritesBar = new FavChipBar();
|
||
|
|
|
||
|
|
public BrowserDesign() {
|
||
|
|
super(new BorderLayout(0, 0));
|
||
|
|
setOpaque(false);
|
||
|
|
|
||
|
|
GlassPanel card = new GlassPanel(new BorderLayout(0, 0), RADIUS,
|
||
|
|
Color.decode("#131e34"),
|
||
|
|
Color.decode("#0f172a"),
|
||
|
|
Color.decode("#2a3756"));
|
||
|
|
card.setBorder(new EmptyBorder(8, 10, 8, 10));
|
||
|
|
|
||
|
|
card.add(buildNavRow(), BorderLayout.NORTH);
|
||
|
|
card.add(favoritesBar, BorderLayout.CENTER);
|
||
|
|
|
||
|
|
add(card, BorderLayout.CENTER);
|
||
|
|
setBorder(new EmptyBorder(8, 10, 8, 10));
|
||
|
|
|
||
|
|
addressField.setBorder(new EmptyBorder(6, 10, 6, 10));
|
||
|
|
addressField.setPreferredSize(new Dimension(1, 32));
|
||
|
|
|
||
|
|
backButton.setToolTipText("Back");
|
||
|
|
forwardButton.setToolTipText("Forward");
|
||
|
|
reloadButton.setToolTipText("Reload");
|
||
|
|
goButton.setToolTipText("Open URL");
|
||
|
|
starButton.setToolTipText("Add to favorites");
|
||
|
|
menuButton.setToolTipText("Menu");
|
||
|
|
}
|
||
|
|
|
||
|
|
private static OACButton iconButton(String text) {
|
||
|
|
OACButton b = new OACButton(text);
|
||
|
|
b.setMargin(new Insets(3, 10, 3, 10));
|
||
|
|
b.setFocusable(false);
|
||
|
|
b.setPreferredSize(new Dimension(44, 32));
|
||
|
|
return b;
|
||
|
|
}
|
||
|
|
|
||
|
|
private static OACButton pillButton(String text) {
|
||
|
|
OACButton b = new OACButton(text);
|
||
|
|
b.setMargin(new Insets(3, 14, 3, 14));
|
||
|
|
b.setFocusable(false);
|
||
|
|
b.setPreferredSize(new Dimension(64, 32));
|
||
|
|
return b;
|
||
|
|
}
|
||
|
|
|
||
|
|
private Component buildNavRow() {
|
||
|
|
OACPanel row = new OACPanel(new BorderLayout(10, 0));
|
||
|
|
row.setOpaque(false);
|
||
|
|
row.setBorder(new EmptyBorder(2, 2, 8, 2));
|
||
|
|
row.setPreferredSize(new Dimension(1, HEIGHT_NAV));
|
||
|
|
|
||
|
|
OACPanel left = new OACPanel(new FlowLayout(FlowLayout.LEFT, 6, 0));
|
||
|
|
left.setOpaque(false);
|
||
|
|
left.add(backButton);
|
||
|
|
left.add(forwardButton);
|
||
|
|
left.add(reloadButton);
|
||
|
|
|
||
|
|
GlassPanel addressPill = new GlassPanel(new BorderLayout(8, 0), 14,
|
||
|
|
Color.decode("#0f172a"), Color.decode("#0b1220"), Color.decode("#2a3756"));
|
||
|
|
addressPill.setBorder(new EmptyBorder(2, 8, 2, 8));
|
||
|
|
addressPill.add(addressField, BorderLayout.CENTER);
|
||
|
|
|
||
|
|
OACPanel right = new OACPanel(new FlowLayout(FlowLayout.RIGHT, 6, 0));
|
||
|
|
right.setOpaque(false);
|
||
|
|
right.add(goButton);
|
||
|
|
right.add(starButton);
|
||
|
|
right.add(menuButton);
|
||
|
|
|
||
|
|
row.add(left, BorderLayout.WEST);
|
||
|
|
row.add(addressPill, BorderLayout.CENTER);
|
||
|
|
row.add(right, BorderLayout.EAST);
|
||
|
|
|
||
|
|
return row;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Returns the favorites bar.
|
||
|
|
*
|
||
|
|
* @return favorites bar
|
||
|
|
*/
|
||
|
|
public FavChipBar favoritesBar() {
|
||
|
|
return favoritesBar;
|
||
|
|
}
|
||
|
|
|
||
|
|
public OACButton backButton() {
|
||
|
|
return backButton;
|
||
|
|
}
|
||
|
|
|
||
|
|
public OACButton forwardButton() {
|
||
|
|
return forwardButton;
|
||
|
|
}
|
||
|
|
|
||
|
|
public OACButton reloadButton() {
|
||
|
|
return reloadButton;
|
||
|
|
}
|
||
|
|
|
||
|
|
public OACTextField addressField() {
|
||
|
|
return addressField;
|
||
|
|
}
|
||
|
|
|
||
|
|
public OACButton goButton() {
|
||
|
|
return goButton;
|
||
|
|
}
|
||
|
|
|
||
|
|
public OACButton starButton() {
|
||
|
|
return starButton;
|
||
|
|
}
|
||
|
|
|
||
|
|
public OACButton menuButton() {
|
||
|
|
return menuButton;
|
||
|
|
}
|
||
|
|
}
|