Skip to content

Commit

Permalink
Fixed documentation, changing focus request system
Browse files Browse the repository at this point in the history
  • Loading branch information
lukflug committed Nov 11, 2020
1 parent c674aa9 commit cea932c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 40 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# PanelStudio
A simple yet flexible library to create ClickGUIs designed for use in Minecraft utility mods. It was originally designed for a private client, but made open source, so that it could be used for [GameSense](https://github.com/IUDevman/gamesense-client). Here are some screenshots of what is possible with this client:
A simple yet flexible library to create ClickGUIs designed for use in Minecraft utility mods. It was originally designed for a private client, but made open source, so that it could be used for [GameSense](https://github.com/IUDevman/gamesense-client). Here are some screenshots of what is possible with this library:
* CyberHack Theme:
![cyberhack](https://cdn.discordapp.com/attachments/755077474861449277/770697901499744286/2020-10-27_18.16.50.png)
* GameSense 2.0 Theme:
Expand Down
39 changes: 22 additions & 17 deletions src/main/java/com/lukflug/panelstudio/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ public class Context {
* The current {@link Interface}.
*/
private Interface inter;
/**
* The current {@link FoucsManager}.
*/
private FocusManager manager;
/**
* The size of the component.
* The width is decided by the parent, while the height is decided by the component.
Expand All @@ -36,18 +32,22 @@ public class Context {
* Only has meaning if the mouse cursor is hovering over the component.
*/
private boolean onTop;
/**
* Set to true by the child using {@link #requestFocus()}.
* Used to indicate that the focus within the parent should be given to the child component.
*/
private boolean focusRequested=false;

/**
* Constructor that should be used when a parent is calling a method by the child.
* {@link #inter}, {@link #manager} and {@link #onTop} are inherited without modification.
* {@link #inter} and {@link #onTop} are inherited without modification.
* @param context the context of the parent
* @param border the horizontal border (left and right) for the child
* @param offset the vertical position of the child relative to the parent's position
* @param focus focus state of the parent
*/
public Context (Context context, int border, int offset, boolean focus) {
inter=context.getInterface();
manager=context.getFocusManager();
size=new Dimension(context.getSize().width-border*2,0);
position=new Point(context.getPos());
position.translate(border,offset);
Expand All @@ -58,15 +58,13 @@ public Context (Context context, int border, int offset, boolean focus) {
/**
* Constructor that should be used by the root parent (i.e. {@link ClickGUI}).
* @param inter the current {@link Interface}
* @param manager the current {@link FocusManager}
* @param width the width of the component
* @param position the position of the component
* @param focus set to false, to disable the component from having focus
* @param onTop set to false, if a component is above another component at the current cursor position
*/
public Context (Interface inter, FocusManager manager, int width, Point position, boolean focus, boolean onTop) {
public Context (Interface inter, int width, Point position, boolean focus, boolean onTop) {
this.inter=inter;
this.manager=manager;
size=new Dimension(width,0);
this.position=new Point(position);
this.focus=focus;
Expand All @@ -81,14 +79,6 @@ public Interface getInterface() {
return inter;
}

/**
* Returns the current {@link FocusManager}.
* @return the current {@link FocusManager}
*/
public FocusManager getFocusManager() {
return manager;
}

/**
* Returns the component size.
* @return the component size
Expand Down Expand Up @@ -128,6 +118,21 @@ public boolean hasFocus() {
public boolean onTop() {
return onTop;
}

/**
* Used to indicate to the parent that the current component has to have focus within the parent.
*/
public void requestFocus() {
focusRequested=true;
}

/**
* Returns {@link #focusRequested}.
* @return whether the child is requesting focus.
*/
public boolean foucsRequested() {
return focusRequested;
}

/**
* Get mouse hover state.
Expand Down
13 changes: 0 additions & 13 deletions src/main/java/com/lukflug/panelstudio/FocusManager.java

This file was deleted.

9 changes: 0 additions & 9 deletions src/main/java/com/lukflug/panelstudio/Focusable.java

This file was deleted.

4 changes: 4 additions & 0 deletions src/main/java/com/lukflug/panelstudio/Interface.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public interface Interface {
* @see #getButton(int)
*/
public static final int LBUTTON=0;
/**
* ID for the right mouse button.
* @see #getButton(int)
*/
public static final int RBUTTON=1;

/**
Expand Down

0 comments on commit cea932c

Please sign in to comment.