From ba0c909ff2f134d58bdd74fdbf25730170105ef0 Mon Sep 17 00:00:00 2001 From: lukflug Date: Sat, 17 Jul 2021 15:23:11 +0200 Subject: [PATCH] Added persistent size --- .../lukflug/panelstudio/config/IPanelConfig.java | 5 +++++ .../panelstudio/widget/ResizableComponent.java | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/panelstudio/src/main/java/com/lukflug/panelstudio/config/IPanelConfig.java b/panelstudio/src/main/java/com/lukflug/panelstudio/config/IPanelConfig.java index 4ba8336..6330d92 100644 --- a/panelstudio/src/main/java/com/lukflug/panelstudio/config/IPanelConfig.java +++ b/panelstudio/src/main/java/com/lukflug/panelstudio/config/IPanelConfig.java @@ -1,5 +1,6 @@ package com.lukflug.panelstudio.config; +import java.awt.Dimension; import java.awt.Point; /** @@ -13,12 +14,16 @@ public interface IPanelConfig { */ public void savePositon (Point position); + public void saveSize (Dimension size); + /** * Load the position of the point. * @return the stored position */ public Point loadPosition(); + public Dimension loadSize(); + /** * Store the state of the panel. * @param state whether the panel is open diff --git a/panelstudio/src/main/java/com/lukflug/panelstudio/widget/ResizableComponent.java b/panelstudio/src/main/java/com/lukflug/panelstudio/widget/ResizableComponent.java index 2bd0163..e7a1d56 100644 --- a/panelstudio/src/main/java/com/lukflug/panelstudio/widget/ResizableComponent.java +++ b/panelstudio/src/main/java/com/lukflug/panelstudio/widget/ResizableComponent.java @@ -13,6 +13,7 @@ import com.lukflug.panelstudio.component.IFixedComponentProxy; import com.lukflug.panelstudio.component.IResizable; import com.lukflug.panelstudio.component.IScrollSize; +import com.lukflug.panelstudio.config.IPanelConfig; import com.lukflug.panelstudio.theme.IResizeBorderRenderer; import com.lukflug.panelstudio.theme.RendererTuple; @@ -101,6 +102,19 @@ public int getWidth (IInterface inter) { return size.getSize().width+2*renderer.getBorder(); } + @Override + public void saveConfig (IInterface inter, IPanelConfig config) { + IFixedComponentProxy.super.saveConfig(inter,config); + config.saveSize(size.getSize()); + } + + @Override + public void loadConfig (IInterface inter, IPanelConfig config) { + IFixedComponentProxy.super.loadConfig(inter,config); + Dimension s=config.loadSize(); + if (s!=null) size.setSize(s); + } + @Override public T getComponent() { return component;