Added custom Ocean theme.

Changed ComposeWindow to have tabs.
This commit is contained in:
Snowyfox 2022-05-27 08:28:18 -04:00
parent b4bfebc80a
commit 2d4747d892
31 changed files with 212 additions and 92 deletions

View File

@ -10,6 +10,11 @@ import javax.swing.JSeparator;
import javax.swing.Box; import javax.swing.Box;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.UIManager;
import javax.swing.JToggleButton;
import javax.swing.ButtonGroup;
import javax.swing.border.Border; import javax.swing.border.Border;
import java.awt.GridLayout; import java.awt.GridLayout;
import java.awt.BorderLayout; import java.awt.BorderLayout;
@ -22,8 +27,13 @@ import java.awt.Cursor;
import java.awt.Color; import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.Insets; import java.awt.Insets;
import java.awt.FlowLayout;
import java.awt.Component;
import java.awt.Container;
import javax.swing.event.CaretListener; import javax.swing.event.CaretListener;
import javax.swing.event.CaretEvent; import javax.swing.event.CaretEvent;
import java.util.List;
import java.util.ArrayList;
import cafe.biskuteri.hinoki.Tree; import cafe.biskuteri.hinoki.Tree;
import java.io.IOException; import java.io.IOException;
@ -48,6 +58,9 @@ ComposeWindow extends JFrame {
private AttachmentsComponent private AttachmentsComponent
attachmentsDisplay; attachmentsDisplay;
private JTabbedPane
tabs;
// ---%-@-%--- // ---%-@-%---
public synchronized void public synchronized void
@ -117,22 +130,6 @@ ComposeWindow extends JFrame {
contentsDisplay.setSubmitting(false); contentsDisplay.setSubmitting(false);
} }
public void
showContentsPage()
{
setContentPane(contentsDisplay);
revalidate();
contentsDisplay.requestFocusInWindow();
}
public void
showAttachmentsPage()
{
setContentPane(attachmentsDisplay);
revalidate();
attachmentsDisplay.requestFocusInWindow();
}
// - -%- - // - -%- -
private synchronized void private synchronized void
@ -173,17 +170,22 @@ ComposeWindow extends JFrame {
this.primaire = primaire; this.primaire = primaire;
this.api = primaire.getMastodonApi(); this.api = primaire.getMastodonApi();
final Dimension SZ = new Dimension(360, 270); Dimension sz = new Dimension(360, 270);
getContentPane().setPreferredSize(SZ);
pack();
setDefaultCloseOperation(DISPOSE_ON_CLOSE); setDefaultCloseOperation(DISPOSE_ON_CLOSE);
contentsDisplay = new ComposeComponent(this); contentsDisplay = new ComposeComponent(this);
attachmentsDisplay = new AttachmentsComponent(this); attachmentsDisplay = new AttachmentsComponent(this);
newComposition(); newComposition();
showContentsPage(); tabs = new JTabbedPane();
contentsDisplay.setPreferredSize(sz);
tabs.addTab("Text", contentsDisplay);
tabs.addTab("Media", attachmentsDisplay);
setBackground((Color)UIManager.get("TabbedPane.tabAreaBackground"));
setContentPane(tabs);
pack();
setIconImage(primaire.getProgramIcon()); setIconImage(primaire.getProgramIcon());
} }
@ -331,7 +333,8 @@ implements ActionListener, CaretListener, KeyListener {
actionPerformed(ActionEvent eA) actionPerformed(ActionEvent eA)
{ {
if (eA.getSource() == showAttachmentsPage) if (eA.getSource() == showAttachmentsPage)
primaire.showAttachmentsPage(); //primaire.showAttachmentsPage();
;
if (eA.getSource() == submit) if (eA.getSource() == submit)
primaire.submit(); primaire.submit();
@ -343,8 +346,14 @@ implements ActionListener, CaretListener, KeyListener {
public void public void
keyPressed(KeyEvent eK) keyPressed(KeyEvent eK)
{ {
boolean esc = eK.getKeyCode() == KeyEvent.VK_ESCAPE; boolean esc = eK.getKeyCode() == KeyEvent.VK_ESCAPE;
if (esc) showAttachmentsPage.requestFocusInWindow(); if (esc)
{
Container fcr = getFocusCycleRootAncestor();
fcr.getFocusTraversalPolicy()
.getComponentAfter(fcr, text)
.requestFocusInWindow();
}
else updateTextLength(); else updateTextLength();
} }
@ -420,11 +429,11 @@ implements ActionListener, CaretListener, KeyListener {
submit = new JButton("Submit"); submit = new JButton("Submit");
submit.addActionListener(this); submit.addActionListener(this);
showAttachmentsPage = new JButton("Media"); showAttachmentsPage = new JButton("Media");
showAttachmentsPage.addActionListener(this); showAttachmentsPage.addActionListener(this);
Box bottom = Box.createHorizontalBox(); Box bottom = Box.createHorizontalBox();
bottom.add(showAttachmentsPage); //bottom.add(showAttachmentsPage);
bottom.add(Box.createGlue()); bottom.add(Box.createGlue());
bottom.add(textLength); bottom.add(textLength);
bottom.add(Box.createHorizontalStrut(12)); bottom.add(Box.createHorizontalStrut(12));
@ -459,22 +468,22 @@ implements ActionListener {
// - -%- - // - -%- -
private Attachment[] private List<Attachment>
working; working;
private JButton private JPanel
attachment1, selections;
attachment2,
attachment3, private ButtonGroup
attachment4; selectionsGroup;
private JButton
add;
private JButton private JButton
delete, delete,
revert; revert;
private JButton
close;
private JLabel private JLabel
descriptionLabel; descriptionLabel;
@ -483,14 +492,54 @@ implements ActionListener {
// ---%-@-%--- // ---%-@-%---
private void
updateButtons()
{
selections.removeAll();
Dimension sz = add.getPreferredSize();
int i = 1;
for (Attachment attachment: working)
{
JToggleButton button = new JToggleButton();
button.setPreferredSize(sz);
button.setMargin(add.getMargin());
button.setText(Integer.toString(i++));
selections.add(button);
}
if (working.size() < 4) selections.add(add);
int bw = sz.width;
int hgap = 4;
int count = Math.min(1 + working.size(), 4);
int w = count * bw + (count - 1) * hgap;
int h = bw;
selections.setPreferredSize(new Dimension(w, h));
selections.setMaximumSize(new Dimension(w, h));
}
public void public void
actionPerformed(ActionEvent eA) actionPerformed(ActionEvent eA)
{ {
Object src = eA.getSource(); Object src = eA.getSource();
if (src == close) if (false)
{
// Clicked on filled attachment button.
}
if (src == add)
{
// Invoke file picker. Try to get file.
// Try to upload file. So on.
// Then add to working.
working.add(new Attachment());
updateButtons();
}
if (src == delete)
{ {
primaire.showContentsPage();
return; return;
} }
@ -498,11 +547,6 @@ implements ActionListener {
{ {
return; return;
} }
if (src == delete)
{
return;
}
} }
// ---%-@-%--- // ---%-@-%---
@ -514,79 +558,89 @@ implements ActionListener {
Border b1 = BorderFactory.createEmptyBorder(8, 8, 8, 8); Border b1 = BorderFactory.createEmptyBorder(8, 8, 8, 8);
Border b2 = BorderFactory.createEmptyBorder(4, 4, 4, 4); Border b2 = BorderFactory.createEmptyBorder(4, 4, 4, 4);
Border b3 = BorderFactory.createLineBorder(Color.GRAY); Border b3 = BorderFactory.createLineBorder(Color.GRAY);
Border bc = BorderFactory.createCompoundBorder(b3, b2); Border b4 = BorderFactory.createEmptyBorder(4, 8, 8, 8);
Border b5 = BorderFactory.createEtchedBorder();
Border bc1 = BorderFactory.createCompoundBorder(b3, b2);
Border bc2 = BorderFactory.createCompoundBorder(b4, b2);
attachment1 = new JButton("+"); add = new JButton("+");
attachment2 = new JButton("+"); add.setPreferredSize(new Dimension(32, 32));
attachment3 = new JButton("+"); add.setMargin(new Insets(0, 0, 0, 0));
attachment4 = new JButton("+"); add.addActionListener(this);
attachment1.setMargin(new Insets(0, 0, 0, 0));
attachment2.setMargin(new Insets(0, 0, 0, 0));
attachment3.setMargin(new Insets(0, 0, 0, 0));
attachment4.setMargin(new Insets(0, 0, 0, 0));
attachment1.addActionListener(this);
attachment2.addActionListener(this);
attachment3.addActionListener(this);
attachment4.addActionListener(this);
JPanel leftleft = new JPanel(); selections = new JPanel();
leftleft.setOpaque(false); selections.setOpaque(false);
leftleft.setLayout(null); selections.setLayout(new GridLayout(1, 0, 4, 0));
// BoxLayout wasn't listening to my
// preferred nor minimum sizes. working = new ArrayList<Attachment>();
attachment1.setSize(40, 40); updateButtons();
attachment2.setSize(40, 40);
attachment3.setSize(40, 40);
attachment4.setSize(40, 40);
attachment1.setLocation(0, 0);
attachment2.setLocation(0, 44);
attachment3.setLocation(0, 88);
attachment4.setLocation(0, 132);
leftleft.add(attachment1);
leftleft.add(attachment2);
leftleft.add(attachment3);
leftleft.add(attachment4);
leftleft.setPreferredSize(new Dimension(40, 172));
JSeparator line = new JSeparator(JSeparator.VERTICAL);
JPanel left = new JPanel();
left.setLayout(new BorderLayout(8, 0));
left.add(leftleft, BorderLayout.CENTER);
left.add(line, BorderLayout.EAST);
JButton del = new JButton("D");
JButton rev = new JButton("R");
JButton ml = new JButton("");
JButton mr = new JButton("");
del.setMargin(new Insets(0, 0, 0, 0));
//ml.setMargin(new Insets(0, 0, 0, 0));
//mr.setMargin(new Insets(0, 0, 0, 0));
rev.setMargin(new Insets(0, 0, 0, 0));
JPanel actions = new JPanel();
actions.setOpaque(false);
actions.setLayout(new GridLayout(1, 4, 4, 4));
actions.add(del);
actions.add(rev);
actions.add(ml);
actions.add(mr);
actions.setPreferredSize(new Dimension(108, 24));
actions.setMaximumSize(new Dimension(108, 24));
delete = new JButton("Delete"); delete = new JButton("Delete");
revert = new JButton("Revert"); revert = new JButton("Revert");
close = new JButton("Save all & close");
delete.addActionListener(this); delete.addActionListener(this);
revert.addActionListener(this); revert.addActionListener(this);
close.addActionListener(this);
Box top = Box.createHorizontalBox();
top.add(selections);
top.add(Box.createGlue());
Box bottom = Box.createHorizontalBox(); Box bottom = Box.createHorizontalBox();
bottom.add(close); bottom.add(ml);
bottom.add(Box.createGlue()); bottom.add(mr);
bottom.add(delete); bottom.add(Box.createHorizontalStrut(8));
bottom.add(Box.createHorizontalStrut(16)); bottom.add(delete);
bottom.add(revert); bottom.add(Box.createGlue());
bottom.add(revert);
description = new JTextArea(); description = new JTextArea();
description.setLineWrap(true); description.setLineWrap(true);
description.setWrapStyleWord(true); description.setWrapStyleWord(true);
java.awt.Font f = description.getFont(); java.awt.Font f = description.getFont();
description.setFont(f.deriveFont(16f)); description.setFont(f.deriveFont(16f));
description.setBorder(bc); description.setBorder(bc1);
descriptionLabel = new JLabel("Description"); descriptionLabel = new JLabel("Description");
descriptionLabel.setLabelFor(description); descriptionLabel.setLabelFor(description);
JPanel row1 = new JPanel(); JPanel row1 = new JPanel();
row1.setOpaque(false); row1.setOpaque(false);
row1.setLayout(new BorderLayout()); row1.setLayout(new BorderLayout());
row1.add(descriptionLabel, BorderLayout.NORTH); row1.add(descriptionLabel, BorderLayout.NORTH);
row1.add(description, BorderLayout.CENTER); row1.add(description, BorderLayout.CENTER);
Box right = Box.createVerticalBox();
right.add(row1); /*
Box row2 = Box.createHorizontalBox();
row2.add(Box.createGlue());
row2.add(delete);
row2.add(Box.createHorizontalStrut(8));
row2.add(revert);
*/
Box centre = Box.createVerticalBox();
centre.setBorder(b4);
centre.add(row1);
setLayout(new BorderLayout(8, 8)); setLayout(new BorderLayout(8, 8));
add(right, BorderLayout.CENTER); add(centre, BorderLayout.CENTER);
add(left, BorderLayout.WEST); add(top, BorderLayout.NORTH);
add(bottom, BorderLayout.SOUTH); add(bottom, BorderLayout.SOUTH);
setBorder(b1); setBorder(b1);

View File

@ -17,6 +17,11 @@ import java.time.Period;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException; import java.time.format.DateTimeParseException;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.OceanTheme;
import javax.swing.plaf.ColorUIResource;
import javax.swing.UIDefaults;
import cafe.biskuteri.hinoki.Tree; import cafe.biskuteri.hinoki.Tree;
@ -86,11 +91,72 @@ JKomasto {
public Image public Image
getProgramIcon() { return programIcon; } getProgramIcon() { return programIcon; }
// ---%-@-%---
private static class
MetalTheme extends OceanTheme {
private ColorUIResource
lightPink = new ColorUIResource(246, 240, 240),
mildPink = new ColorUIResource(238, 233, 233),
white = new ColorUIResource(250, 250, 250),
darkPink = new ColorUIResource(242, 230, 230),
veryDarkPink = new ColorUIResource(164, 160, 160);
// -=%=-
public ColorUIResource
getPrimary2() { return darkPink; }
public ColorUIResource
getSecondary2() { return white; }
public ColorUIResource
getSecondary3() { return mildPink; }
public ColorUIResource
getSecondary1() { return veryDarkPink; }
public ColorUIResource
getPrimary1() { return veryDarkPink; }
public void
addCustomEntriesToTable(UIDefaults table)
{
super.addCustomEntriesToTable(table);
table.put(
"TabbedPane.tabAreaBackground",
getPrimary1()
);
table.put(
"TabbedPane.contentAreaColor",
getSecondary3()
);
table.put(
"TabbedPane.selected",
getSecondary3()
);
table.put(
"MenuBar.gradient",
java.util.Arrays.asList(new Object[] {
1f, 0f,
getWhite(),
getSecondary3(),
getSecondary1()
})
);
}
}
// ---%-@-%--- // ---%-@-%---
public static void public static void
main(String... args) main(String... args)
{ {
//System.setProperty("swing.boldMetal", "false");
MetalLookAndFeel.setCurrentTheme(new MetalTheme());
new JKomasto().loginWindow.setVisible(true); new JKomasto().loginWindow.setVisible(true);
} }

0
graphics/Federated.xcf Normal file → Executable file
View File

0
graphics/Flags.xcf Normal file → Executable file
View File

0
graphics/Home.xcf Normal file → Executable file
View File

0
graphics/Hourglass.xcf Normal file → Executable file
View File

0
graphics/Kettle.xcf Normal file → Executable file
View File

0
graphics/boostToggled.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

0
graphics/boostUntoggled.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

0
graphics/button.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

0
graphics/disabledOverlay.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

0
graphics/favouriteToggled.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 353 B

After

Width:  |  Height:  |  Size: 353 B

0
graphics/favouriteUntoggled.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

0
graphics/federated.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

0
graphics/home.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

0
graphics/kettle.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

0
graphics/miscToggled.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

0
graphics/miscUntoggled.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
graphics/nextToggled.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
graphics/nextUntoggled.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

0
graphics/postWindow.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 978 B

After

Width:  |  Height:  |  Size: 978 B

BIN
graphics/prevToggled.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
graphics/prevUntoggled.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

0
graphics/ref1.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

0
graphics/replyToggled.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

0
graphics/replyUntoggled.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

0
graphics/selectedOverlay.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 313 B

After

Width:  |  Height:  |  Size: 313 B

0
graphics/test1.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

0
graphics/test2.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

0
graphics/test3.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

0
graphics/test4.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB