Settled on layout for PostWindow

This commit is contained in:
Snowyfox 2021-07-31 07:28:46 -04:00
parent dd42213858
commit 13132c8fa9
4 changed files with 67 additions and 20 deletions

View File

@ -16,9 +16,9 @@ JKomasto {
public
JKomasto()
{
new TimelineWindow().setVisible(true);
//new TimelineWindow().setVisible(true);
//new ComposeWindow().setVisible(true);
//new PostWindow().setVisible(true);
new PostWindow().setVisible(true);
}
// - -%- -

View File

@ -134,7 +134,7 @@ implements ActionListener {
JMenuBar menuBar = new JMenuBar();
menuBar.add(postMenu);
menuBar.add(displayMenu);
setJMenuBar(menuBar);
//setJMenuBar(menuBar);
setContentPane(postDisplay);
}
@ -157,6 +157,15 @@ PostComponent extends JPanel {
private String
author, time, text;
// - -%- -
private JButton
profile,
favouriteBoost,
replyMisc,
prevNext,
media;
// ---%-@-%---
public void
@ -189,14 +198,17 @@ PostComponent extends JPanel {
FontMetrics met = g.getFontMetrics();
g.drawString(author, 0, lineHeight);
int t1 = getWidth() - met.stringWidth(time);
g.drawString(time, t1, lineHeight);
int x1 = 56;
int x2 = getWidth() - met.stringWidth(time);
int y1 = lineHeight;
int t2 = lineHeight;
g.drawString(author, x1, y1);
g.drawString(time, x2, y1);
int y = y1;
for (String line: split(text, 48)) {
t2 += lineHeight;
g.drawString(line, 0, t2);
y += lineHeight;
g.drawString(line, x1, y);
}
}
@ -222,6 +234,38 @@ PostComponent extends JPanel {
{
author = time = text = "";
profile = new JButton("P");
profile.setSize(40, 40);
favouriteBoost = new JButton("☆/B");
favouriteBoost.setSize(40, 40);
// We have to overload the buttons to accept RMBs.
// Which perform the secondary functionality.
replyMisc = new JButton("R");
replyMisc.setSize(40, 40);
prevNext = new JButton("↓/↑");
prevNext.setSize(40, 40);
media = new JButton("M");
media.setSize(40, 40);
setLayout(null);
profile.setLocation(8, 8); add(profile);
favouriteBoost.setLocation(8, 8+48); add(favouriteBoost);
replyMisc.setLocation(8, 8+48+48); add(replyMisc);
prevNext.setLocation(8, 8+48+48+48); add(prevNext);
media.setLocation(8, 8+48+48+48+48); add(media);
/*
* Also, since it's a linear buttons now, we can just use
* a Box or FlowLayout. Though we have to have a JPanel
* for the left, and this text component on the right.
* If we are custom rendering the text then we can stay
* this way, with manual positioning.
*/
setFont(getFont().deriveFont(14f));
}

View File

@ -66,6 +66,18 @@ implements ActionListener {
// And pass data to TimelineComponent.
}
public void
nextPage()
{
}
public void
previousPage()
{
}
// - -%- -
public void
@ -166,9 +178,6 @@ implements ActionListener {
this.posts.clear();
this.posts.addAll(posts);
syncPreviewsToPosts();
// We don't store pagination information. We need the
// model manager to inform us about page availability.
}
public void
@ -208,15 +217,9 @@ implements ActionListener {
actionPerformed(ActionEvent eA)
{
Object src = eA.getSource();
if (src == next)
{
}
else if (src == prev)
{
}
if (src == next) primaire.nextPage();
else if (src == prev) primaire.previousPage();
/*
* I think the page previews will just forward to us.
* But I think they'll have to tell us where they are

BIN
ref1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB