feat: make stats and last rendered frame panels collapsible
The visual footprint of the client is quite big (520x800 px). This PR allows the use to collapse/expand any of the Global stats, Session infos and Last uploaded frame panels to reduce the vertical visual footprint. Fixed the wrong size detection at client start issue found by Clou.
This commit is contained in:
@@ -23,4 +23,6 @@ public interface Activity {
|
|||||||
|
|
||||||
public void show();
|
public void show();
|
||||||
|
|
||||||
|
public void resizeWindow();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ public class Settings implements Activity {
|
|||||||
currentRow++;
|
currentRow++;
|
||||||
|
|
||||||
// authentication
|
// authentication
|
||||||
CollapsibleJPanel authentication_panel = new CollapsibleJPanel(new GridLayout(2, 2));
|
CollapsibleJPanel authentication_panel = new CollapsibleJPanel(new GridLayout(2, 2), this);
|
||||||
authentication_panel.setBorder(BorderFactory.createTitledBorder("Authentication"));
|
authentication_panel.setBorder(BorderFactory.createTitledBorder("Authentication"));
|
||||||
|
|
||||||
JLabel loginLabel = new JLabel("Username:");
|
JLabel loginLabel = new JLabel("Username:");
|
||||||
@@ -185,7 +185,7 @@ public class Settings implements Activity {
|
|||||||
parent.getContentPane().add(authentication_panel, constraints);
|
parent.getContentPane().add(authentication_panel, constraints);
|
||||||
|
|
||||||
// Theme selection panel
|
// Theme selection panel
|
||||||
CollapsibleJPanel themePanel = new CollapsibleJPanel(new GridLayout(1, 3));
|
CollapsibleJPanel themePanel = new CollapsibleJPanel(new GridLayout(1, 3), this);
|
||||||
themePanel.setBorder(BorderFactory.createTitledBorder("Theme"));
|
themePanel.setBorder(BorderFactory.createTitledBorder("Theme"));
|
||||||
|
|
||||||
themeOptionsGroup = new ButtonGroup();
|
themeOptionsGroup = new ButtonGroup();
|
||||||
@@ -215,7 +215,7 @@ public class Settings implements Activity {
|
|||||||
parent.getContentPane().add(themePanel, constraints);
|
parent.getContentPane().add(themePanel, constraints);
|
||||||
|
|
||||||
// directory
|
// directory
|
||||||
CollapsibleJPanel directory_panel = new CollapsibleJPanel(new GridLayout(1, 3));
|
CollapsibleJPanel directory_panel = new CollapsibleJPanel(new GridLayout(1, 3), this);
|
||||||
directory_panel.setBorder(BorderFactory.createTitledBorder("Cache"));
|
directory_panel.setBorder(BorderFactory.createTitledBorder("Cache"));
|
||||||
JLabel cacheLabel = new JLabel("Working directory:");
|
JLabel cacheLabel = new JLabel("Working directory:");
|
||||||
directory_panel.add(cacheLabel);
|
directory_panel.add(cacheLabel);
|
||||||
@@ -249,7 +249,7 @@ public class Settings implements Activity {
|
|||||||
// compute devices
|
// compute devices
|
||||||
GridBagLayout gridbag = new GridBagLayout();
|
GridBagLayout gridbag = new GridBagLayout();
|
||||||
GridBagConstraints compute_devices_constraints = new GridBagConstraints();
|
GridBagConstraints compute_devices_constraints = new GridBagConstraints();
|
||||||
CollapsibleJPanel compute_devices_panel = new CollapsibleJPanel(gridbag);
|
CollapsibleJPanel compute_devices_panel = new CollapsibleJPanel(gridbag, this);
|
||||||
|
|
||||||
compute_devices_panel.setBorder(BorderFactory.createTitledBorder("Compute devices"));
|
compute_devices_panel.setBorder(BorderFactory.createTitledBorder("Compute devices"));
|
||||||
|
|
||||||
@@ -453,7 +453,7 @@ public class Settings implements Activity {
|
|||||||
parent.getContentPane().add(compute_devices_panel, constraints);
|
parent.getContentPane().add(compute_devices_panel, constraints);
|
||||||
|
|
||||||
// other
|
// other
|
||||||
CollapsibleJPanel advanced_panel = new CollapsibleJPanel(new GridLayout(4, 2));
|
CollapsibleJPanel advanced_panel = new CollapsibleJPanel(new GridLayout(4, 2), this);
|
||||||
advanced_panel.setBorder(BorderFactory.createTitledBorder("Advanced options"));
|
advanced_panel.setBorder(BorderFactory.createTitledBorder("Advanced options"));
|
||||||
|
|
||||||
JLabel useSysTrayLabel = new JLabel("Minimize to SysTray");
|
JLabel useSysTrayLabel = new JLabel("Minimize to SysTray");
|
||||||
@@ -542,6 +542,8 @@ public class Settings implements Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resizeWindow() {}
|
||||||
|
|
||||||
private void buildRenderBucketSizeSlider(int maxRenderbucketSize, int selectedBucketSize) {
|
private void buildRenderBucketSizeSlider(int maxRenderbucketSize, int selectedBucketSize) {
|
||||||
Hashtable<Integer, JLabel> renderbucketSizeTable = new Hashtable<Integer, JLabel>();
|
Hashtable<Integer, JLabel> renderbucketSizeTable = new Hashtable<Integer, JLabel>();
|
||||||
|
|
||||||
|
|||||||
@@ -54,9 +54,14 @@ import com.sheepit.client.Utils;
|
|||||||
import com.sheepit.client.standalone.GuiSwing;
|
import com.sheepit.client.standalone.GuiSwing;
|
||||||
import com.sheepit.client.standalone.GuiSwing.ActivityType;
|
import com.sheepit.client.standalone.GuiSwing.ActivityType;
|
||||||
|
|
||||||
|
import com.sheepit.client.standalone.swing.components.CollapsibleJPanel;
|
||||||
|
|
||||||
public class Working implements Activity {
|
public class Working implements Activity {
|
||||||
private GuiSwing parent;
|
private GuiSwing parent;
|
||||||
|
|
||||||
|
private CollapsibleJPanel session_info_panel;
|
||||||
|
private CollapsibleJPanel global_stats_panel;
|
||||||
|
private CollapsibleJPanel last_frame_panel;
|
||||||
private JLabel statusContent;
|
private JLabel statusContent;
|
||||||
private String previousStatus;
|
private String previousStatus;
|
||||||
private JLabel renderedFrameContent;
|
private JLabel renderedFrameContent;
|
||||||
@@ -97,7 +102,7 @@ public class Working implements Activity {
|
|||||||
waiting_projects_value = new JLabel("");
|
waiting_projects_value = new JLabel("");
|
||||||
connected_machines_value = new JLabel("");
|
connected_machines_value = new JLabel("");
|
||||||
user_info_total_rendertime_this_session_value = new JLabel("");
|
user_info_total_rendertime_this_session_value = new JLabel("");
|
||||||
lastRenderTime = new JLabel("");
|
lastRenderTime = new JLabel(" "); // Insert a space to ensure the component reserves the space in the screen (for the window size calculation)
|
||||||
lastRender = new JLabel("");
|
lastRender = new JLabel("");
|
||||||
userInfoQueuedUploadsAndSizeValue = new JLabel("0");
|
userInfoQueuedUploadsAndSizeValue = new JLabel("0");
|
||||||
sessionDownloadsStatsValue = new JLabel("0KB");
|
sessionDownloadsStatsValue = new JLabel("0KB");
|
||||||
@@ -139,7 +144,7 @@ public class Working implements Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// current project
|
// current project
|
||||||
JPanel current_project_panel = new JPanel(new SpringLayout());
|
JPanel current_project_panel = new JPanel(new GridLayout(5, 2));
|
||||||
current_project_panel.setBorder(BorderFactory.createTitledBorder("Project"));
|
current_project_panel.setBorder(BorderFactory.createTitledBorder("Project"));
|
||||||
|
|
||||||
JLabel current_project_status = new JLabel("Status: ", JLabel.TRAILING);
|
JLabel current_project_status = new JLabel("Status: ", JLabel.TRAILING);
|
||||||
@@ -164,7 +169,7 @@ public class Working implements Activity {
|
|||||||
current_project_panel.add(current_project_compute_method_value);
|
current_project_panel.add(current_project_compute_method_value);
|
||||||
|
|
||||||
// user info
|
// user info
|
||||||
JPanel session_info_panel = new JPanel(new SpringLayout());
|
session_info_panel = new CollapsibleJPanel(new GridLayout(7, 2), this);
|
||||||
session_info_panel.setBorder(BorderFactory.createTitledBorder("Session infos"));
|
session_info_panel.setBorder(BorderFactory.createTitledBorder("Session infos"));
|
||||||
|
|
||||||
JLabel user_info_credits_this_session = new JLabel("Points earned: ", JLabel.TRAILING);
|
JLabel user_info_credits_this_session = new JLabel("Points earned: ", JLabel.TRAILING);
|
||||||
@@ -197,7 +202,7 @@ public class Working implements Activity {
|
|||||||
session_info_panel.add(user_info_total_rendertime_this_session_value);
|
session_info_panel.add(user_info_total_rendertime_this_session_value);
|
||||||
|
|
||||||
// global stats
|
// global stats
|
||||||
JPanel global_stats_panel = new JPanel(new SpringLayout());
|
global_stats_panel = new CollapsibleJPanel(new GridLayout(4, 2), this);
|
||||||
global_stats_panel.setBorder(BorderFactory.createTitledBorder("Global stats"));
|
global_stats_panel.setBorder(BorderFactory.createTitledBorder("Global stats"));
|
||||||
|
|
||||||
JLabel global_stats_machine_connected = new JLabel("Machines connected: ", JLabel.TRAILING);
|
JLabel global_stats_machine_connected = new JLabel("Machines connected: ", JLabel.TRAILING);
|
||||||
@@ -218,7 +223,7 @@ public class Working implements Activity {
|
|||||||
global_stats_panel.add(user_info_points_total_value);
|
global_stats_panel.add(user_info_points_total_value);
|
||||||
|
|
||||||
// last frame
|
// last frame
|
||||||
JPanel last_frame_panel = new JPanel();
|
last_frame_panel = new CollapsibleJPanel(new GridLayout(2, 2), this);
|
||||||
last_frame_panel.setLayout(new BoxLayout(last_frame_panel, BoxLayout.Y_AXIS));
|
last_frame_panel.setLayout(new BoxLayout(last_frame_panel, BoxLayout.Y_AXIS));
|
||||||
last_frame_panel.setBorder(BorderFactory.createTitledBorder("Last uploaded frame"));
|
last_frame_panel.setBorder(BorderFactory.createTitledBorder("Last uploaded frame"));
|
||||||
lastRender.setIcon(new ImageIcon(new BufferedImage(200, 120, BufferedImage.TYPE_INT_ARGB)));
|
lastRender.setIcon(new ImageIcon(new BufferedImage(200, 120, BufferedImage.TYPE_INT_ARGB)));
|
||||||
@@ -270,17 +275,18 @@ public class Working implements Activity {
|
|||||||
parent.getContentPane().add(new JLabel(" "), global_constraints); // Add a separator between last panel and buttons
|
parent.getContentPane().add(new JLabel(" "), global_constraints); // Add a separator between last panel and buttons
|
||||||
parent.getContentPane().add(buttonsPanel, global_constraints);
|
parent.getContentPane().add(buttonsPanel, global_constraints);
|
||||||
|
|
||||||
Spring widthLeftColumn = getBestWidth(current_project_panel, 4, 2);
|
|
||||||
widthLeftColumn = Spring.max(widthLeftColumn, getBestWidth(global_stats_panel, 4, 2));
|
|
||||||
widthLeftColumn = Spring.max(widthLeftColumn, getBestWidth(session_info_panel, 4, 2));
|
|
||||||
alignPanel(current_project_panel, 5, 2, widthLeftColumn);
|
|
||||||
alignPanel(global_stats_panel, 4, 2, widthLeftColumn);
|
|
||||||
alignPanel(session_info_panel, 7, 2, widthLeftColumn);
|
|
||||||
|
|
||||||
// Set the proper size for the Working (if coming from Settings screen, the window size will be too big for the content!)
|
// Set the proper size for the Working (if coming from Settings screen, the window size will be too big for the content!)
|
||||||
parent.setSize(520, 820);
|
parent.setSize(520, 820);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resizeWindow() {
|
||||||
|
parent.revalidate();
|
||||||
|
parent.repaint();
|
||||||
|
|
||||||
|
// Calculate the proper size based on the status of the panels (opened/collapsed)
|
||||||
|
parent.setSize(520, (int) (session_info_panel.getHeight() + global_stats_panel.getHeight() + last_frame_panel.getHeight()) + 400);
|
||||||
|
}
|
||||||
|
|
||||||
public void setStatus(String msg_) {
|
public void setStatus(String msg_) {
|
||||||
setStatus(msg_, false);
|
setStatus(msg_, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import javax.swing.JPanel;
|
|||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
import javax.swing.border.TitledBorder;
|
import javax.swing.border.TitledBorder;
|
||||||
|
|
||||||
|
import com.sheepit.client.standalone.swing.activity.Activity;
|
||||||
|
|
||||||
public class CollapsibleJPanel extends JPanel {
|
public class CollapsibleJPanel extends JPanel {
|
||||||
|
|
||||||
private boolean isCompnentsVisible = true;
|
private boolean isCompnentsVisible = true;
|
||||||
@@ -35,10 +37,12 @@ public class CollapsibleJPanel extends JPanel {
|
|||||||
private String borderTitle = "";
|
private String borderTitle = "";
|
||||||
private int COLLAPSED_HEIGHT = 22;
|
private int COLLAPSED_HEIGHT = 22;
|
||||||
private boolean[] originalVisibilty;
|
private boolean[] originalVisibilty;
|
||||||
|
private Activity parent;
|
||||||
|
|
||||||
public CollapsibleJPanel(LayoutManager layoutManager) {
|
public CollapsibleJPanel(LayoutManager layoutManager, Activity parent) {
|
||||||
setLayout(layoutManager);
|
setLayout(layoutManager);
|
||||||
addMouseListener(new onClickHandler());
|
addMouseListener(new onClickHandler());
|
||||||
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCollapsed(boolean aFlag) {
|
public void setCollapsed(boolean aFlag) {
|
||||||
@@ -134,6 +138,9 @@ public class CollapsibleJPanel extends JPanel {
|
|||||||
if (e.getPoint().y < COLLAPSED_HEIGHT) { // Only if click is on top of panel
|
if (e.getPoint().y < COLLAPSED_HEIGHT) { // Only if click is on top of panel
|
||||||
((CollapsibleJPanel) e.getComponent()).toggleCollapsed();
|
((CollapsibleJPanel) e.getComponent()).toggleCollapsed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Recalculate the proper window size
|
||||||
|
parent.resizeWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void mouseEntered(MouseEvent e) {
|
@Override public void mouseEntered(MouseEvent e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user