-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust layouts, added more adders and positioners
- Loading branch information
Showing
12 changed files
with
232 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
panelstudio/src/main/java/com/lukflug/panelstudio/base/IPopupDisplayer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.lukflug.panelstudio.base; | ||
|
||
import java.awt.Rectangle; | ||
|
||
import com.lukflug.panelstudio.layout.IPopupPositioner; | ||
|
||
/** | ||
* Object that can display a pop-up. | ||
* @author lukflug | ||
*/ | ||
public interface IPopupDisplayer { | ||
public void displayPopup (Object popup, Rectangle rect, IToggleable visible, IPopupPositioner positioner); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
panelstudio/src/main/java/com/lukflug/panelstudio/layout/PanelPositioner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.lukflug.panelstudio.layout; | ||
|
||
import java.awt.Point; | ||
import java.awt.Rectangle; | ||
|
||
import com.lukflug.panelstudio.base.IInterface; | ||
|
||
/** | ||
* Pop-up positioner, that positions the pop-up on the side of the panel. | ||
* @author lukflug | ||
*/ | ||
public class PanelPositioner implements IPopupPositioner { | ||
/** | ||
* The offset. | ||
*/ | ||
protected Point offset; | ||
|
||
/** | ||
* Constructor. | ||
* @param offset the offset relative to the current cursor position | ||
*/ | ||
public PanelPositioner (Point offset) { | ||
this.offset=offset; | ||
} | ||
|
||
@Override | ||
public Point getPosition(IInterface inter, Rectangle component, Rectangle panel) { | ||
return new Point(panel.x+panel.width+offset.x,component.y+offset.y); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
panelstudio/src/main/java/com/lukflug/panelstudio/layout/SinglePanelAdder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.lukflug.panelstudio.layout; | ||
|
||
import java.awt.Point; | ||
import java.util.function.Supplier; | ||
|
||
import com.lukflug.panelstudio.base.Animation; | ||
import com.lukflug.panelstudio.base.Context; | ||
import com.lukflug.panelstudio.base.SimpleToggleable; | ||
import com.lukflug.panelstudio.component.HorizontalComponent; | ||
import com.lukflug.panelstudio.component.IComponent; | ||
import com.lukflug.panelstudio.component.IFixedComponent; | ||
import com.lukflug.panelstudio.container.HorizontalContainer; | ||
import com.lukflug.panelstudio.container.IContainer; | ||
import com.lukflug.panelstudio.setting.ILabeled; | ||
import com.lukflug.panelstudio.theme.ITheme; | ||
import com.lukflug.panelstudio.widget.ClosableComponent; | ||
import com.lukflug.panelstudio.widget.ScrollBarComponent; | ||
|
||
public class SinglePanelAdder implements IComponentAdder { | ||
protected final IContainer<? super IFixedComponent> container; | ||
protected HorizontalContainer title,content; | ||
|
||
public SinglePanelAdder (IContainer<? super IFixedComponent> container, ILabeled label, ITheme theme, Point position, int width, Supplier<Animation> animation) { | ||
this.container=container; | ||
title=new HorizontalContainer(label,theme.getContainerRenderer(-1,-1,true)); | ||
content=new HorizontalContainer(label,theme.getContainerRenderer(-1,-1,true)); | ||
container.addComponent(ClosableComponent.createDraggableComponent(title,content,()->null,new SimpleToggleable(true),animation.get(),theme.getPanelRenderer(Void.class,-1,-1),theme.getScrollBarRenderer(Void.class,-1,-1),theme.getEmptySpaceRenderer(Void.class,-1,-1),(context,height)->height,context->context.getSize().width,position,width,false)); | ||
} | ||
|
||
@Override | ||
public <S extends IComponent,T extends IComponent> void addComponent(S title, T content, ITheme theme, int logicalLevel, int graphicalLevel, Point position, int width, Supplier<Animation> animation) { | ||
this.title.addComponent(new HorizontalComponent<S>(title,0,1)); | ||
this.content.addComponent(new HorizontalComponent<ScrollBarComponent<Void,T>>(new ScrollBarComponent<Void,T>(content,theme.getScrollBarRenderer(Void.class,logicalLevel,graphicalLevel),theme.getEmptySpaceRenderer(Void.class,logicalLevel,graphicalLevel)) { | ||
@Override | ||
protected int getScrollHeight(Context context, int componentHeight) { | ||
return SinglePanelAdder.this.getScrollHeight(context,componentHeight); | ||
} | ||
|
||
@Override | ||
protected int getComponentWidth(Context context) { | ||
return SinglePanelAdder.this.getComponentWidth(context); | ||
} | ||
|
||
@Override | ||
protected Void getState() { | ||
return null; | ||
} | ||
},0,1)); | ||
} | ||
|
||
@Override | ||
public void addPopup(IFixedComponent popup) { | ||
container.addComponent(popup); | ||
} | ||
|
||
protected int getScrollHeight (Context context, int componentHeight) { | ||
return componentHeight; | ||
} | ||
|
||
protected int getComponentWidth (Context context) { | ||
return context.getSize().width; | ||
} | ||
} |
Oops, something went wrong.