Skip to content

Commit

Permalink
Added persistent size
Browse files Browse the repository at this point in the history
  • Loading branch information
lukflug committed Jul 17, 2021
1 parent ad220c5 commit ba0c909
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.lukflug.panelstudio.config;

import java.awt.Dimension;
import java.awt.Point;

/**
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ba0c909

Please sign in to comment.