-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add focusable variants of widgets (#28)
- Loading branch information
1 parent
98f52a0
commit 8f96ef9
Showing
12 changed files
with
366 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
core-scene2d/src/de/golfgl/gdx/controllers/focusable/FocusableActorCompat.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,23 @@ | ||
package de.golfgl.gdx.controllers.focusable; | ||
|
||
import com.badlogic.gdx.scenes.scene2d.Actor; | ||
import com.badlogic.gdx.scenes.scene2d.Stage; | ||
import de.golfgl.gdx.controllers.ControllerMenuStage; | ||
|
||
/** | ||
* Convenience wrapper for setting a focusable actor when the stage is typed {@link Stage} | ||
*/ | ||
public class FocusableActorCompat { | ||
|
||
private FocusableActorCompat() { | ||
} | ||
|
||
/** | ||
* Usable in {@link Actor#setStage(Stage)} to set an actor as focusable without casting every time. | ||
*/ | ||
public static void setFocusable(Actor actor, Stage stage) { | ||
if (stage instanceof ControllerMenuStage) { | ||
((ControllerMenuStage) stage).addFocusableActor(actor); | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
core-scene2d/src/de/golfgl/gdx/controllers/focusable/FocusableButton.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,55 @@ | ||
package de.golfgl.gdx.controllers.focusable; | ||
|
||
import com.badlogic.gdx.scenes.scene2d.Actor; | ||
import com.badlogic.gdx.scenes.scene2d.Stage; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Button; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Skin; | ||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; | ||
|
||
public class FocusableButton extends Button { | ||
|
||
public FocusableButton(Skin skin) { | ||
super(skin); | ||
} | ||
|
||
public FocusableButton(Skin skin, String styleName) { | ||
super(skin, styleName); | ||
} | ||
|
||
public FocusableButton(Actor child, Skin skin, String styleName) { | ||
super(child, skin, styleName); | ||
} | ||
|
||
public FocusableButton(Actor child, ButtonStyle style) { | ||
super(child, style); | ||
} | ||
|
||
public FocusableButton(ButtonStyle style) { | ||
super(style); | ||
} | ||
|
||
public FocusableButton() { | ||
} | ||
|
||
public FocusableButton(Drawable up) { | ||
super(up); | ||
} | ||
|
||
public FocusableButton(Drawable up, Drawable down) { | ||
super(up, down); | ||
} | ||
|
||
public FocusableButton(Drawable up, Drawable down, Drawable checked) { | ||
super(up, down, checked); | ||
} | ||
|
||
public FocusableButton(Actor child, Skin skin) { | ||
super(child, skin); | ||
} | ||
|
||
@Override | ||
protected void setStage(Stage stage) { | ||
super.setStage(stage); | ||
FocusableActorCompat.setFocusable(this, stage); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
core-scene2d/src/de/golfgl/gdx/controllers/focusable/FocusableCheckBox.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,25 @@ | ||
package de.golfgl.gdx.controllers.focusable; | ||
|
||
import com.badlogic.gdx.scenes.scene2d.Stage; | ||
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Skin; | ||
|
||
public class FocusableCheckBox extends CheckBox { | ||
public FocusableCheckBox(String text, Skin skin) { | ||
super(text, skin); | ||
} | ||
|
||
public FocusableCheckBox(String text, Skin skin, String styleName) { | ||
super(text, skin, styleName); | ||
} | ||
|
||
public FocusableCheckBox(String text, CheckBoxStyle style) { | ||
super(text, style); | ||
} | ||
|
||
@Override | ||
protected void setStage(Stage stage) { | ||
super.setStage(stage); | ||
FocusableActorCompat.setFocusable(this, stage); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
core-scene2d/src/de/golfgl/gdx/controllers/focusable/FocusableImage.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,50 @@ | ||
package de.golfgl.gdx.controllers.focusable; | ||
|
||
import com.badlogic.gdx.graphics.Texture; | ||
import com.badlogic.gdx.graphics.g2d.NinePatch; | ||
import com.badlogic.gdx.graphics.g2d.TextureRegion; | ||
import com.badlogic.gdx.scenes.scene2d.Stage; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Image; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Skin; | ||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; | ||
import com.badlogic.gdx.utils.Scaling; | ||
|
||
public class FocusableImage extends Image { | ||
|
||
public FocusableImage() { | ||
} | ||
|
||
public FocusableImage(NinePatch patch) { | ||
super(patch); | ||
} | ||
|
||
public FocusableImage(TextureRegion region) { | ||
super(region); | ||
} | ||
|
||
public FocusableImage(Texture texture) { | ||
super(texture); | ||
} | ||
|
||
public FocusableImage(Skin skin, String drawableName) { | ||
super(skin, drawableName); | ||
} | ||
|
||
public FocusableImage(Drawable drawable) { | ||
super(drawable); | ||
} | ||
|
||
public FocusableImage(Drawable drawable, Scaling scaling) { | ||
super(drawable, scaling); | ||
} | ||
|
||
public FocusableImage(Drawable drawable, Scaling scaling, int align) { | ||
super(drawable, scaling, align); | ||
} | ||
|
||
@Override | ||
protected void setStage(Stage stage) { | ||
super.setStage(stage); | ||
FocusableActorCompat.setFocusable(this, stage); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
core-scene2d/src/de/golfgl/gdx/controllers/focusable/FocusableImageButton.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,39 @@ | ||
package de.golfgl.gdx.controllers.focusable; | ||
|
||
import com.badlogic.gdx.scenes.scene2d.Stage; | ||
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Skin; | ||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; | ||
|
||
public class FocusableImageButton extends ImageButton { | ||
|
||
public FocusableImageButton(Skin skin) { | ||
super(skin); | ||
} | ||
|
||
public FocusableImageButton(Skin skin, String styleName) { | ||
super(skin, styleName); | ||
} | ||
|
||
public FocusableImageButton(ImageButtonStyle style) { | ||
super(style); | ||
} | ||
|
||
public FocusableImageButton(Drawable imageUp) { | ||
super(imageUp); | ||
} | ||
|
||
public FocusableImageButton(Drawable imageUp, Drawable imageDown) { | ||
super(imageUp, imageDown); | ||
} | ||
|
||
public FocusableImageButton(Drawable imageUp, Drawable imageDown, Drawable imageChecked) { | ||
super(imageUp, imageDown, imageChecked); | ||
} | ||
|
||
@Override | ||
protected void setStage(Stage stage) { | ||
super.setStage(stage); | ||
FocusableActorCompat.setFocusable(this, stage); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
core-scene2d/src/de/golfgl/gdx/controllers/focusable/FocusableImageTextButton.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,26 @@ | ||
package de.golfgl.gdx.controllers.focusable; | ||
|
||
import com.badlogic.gdx.scenes.scene2d.Stage; | ||
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Skin; | ||
|
||
public class FocusableImageTextButton extends ImageTextButton { | ||
|
||
public FocusableImageTextButton(String text, Skin skin) { | ||
super(text, skin); | ||
} | ||
|
||
public FocusableImageTextButton(String text, Skin skin, String styleName) { | ||
super(text, skin, styleName); | ||
} | ||
|
||
public FocusableImageTextButton(String text, ImageTextButtonStyle style) { | ||
super(text, style); | ||
} | ||
|
||
@Override | ||
protected void setStage(Stage stage) { | ||
super.setStage(stage); | ||
FocusableActorCompat.setFocusable(this, stage); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
core-scene2d/src/de/golfgl/gdx/controllers/focusable/FocusableLabel.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,35 @@ | ||
package de.golfgl.gdx.controllers.focusable; | ||
|
||
import com.badlogic.gdx.graphics.Color; | ||
import com.badlogic.gdx.scenes.scene2d.Stage; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Label; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Skin; | ||
|
||
public class FocusableLabel extends Label { | ||
|
||
public FocusableLabel(CharSequence text, Skin skin) { | ||
super(text, skin); | ||
} | ||
|
||
public FocusableLabel(CharSequence text, Skin skin, String styleName) { | ||
super(text, skin, styleName); | ||
} | ||
|
||
public FocusableLabel(CharSequence text, Skin skin, String fontName, Color color) { | ||
super(text, skin, fontName, color); | ||
} | ||
|
||
public FocusableLabel(CharSequence text, Skin skin, String fontName, String colorName) { | ||
super(text, skin, fontName, colorName); | ||
} | ||
|
||
public FocusableLabel(CharSequence text, LabelStyle style) { | ||
super(text, style); | ||
} | ||
|
||
@Override | ||
protected void setStage(Stage stage) { | ||
super.setStage(stage); | ||
FocusableActorCompat.setFocusable(this, stage); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
core-scene2d/src/de/golfgl/gdx/controllers/focusable/FocusableTextArea.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,26 @@ | ||
package de.golfgl.gdx.controllers.focusable; | ||
|
||
import com.badlogic.gdx.scenes.scene2d.Stage; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Skin; | ||
import com.badlogic.gdx.scenes.scene2d.ui.TextArea; | ||
|
||
public class FocusableTextArea extends TextArea { | ||
|
||
public FocusableTextArea(String text, Skin skin) { | ||
super(text, skin); | ||
} | ||
|
||
public FocusableTextArea(String text, Skin skin, String styleName) { | ||
super(text, skin, styleName); | ||
} | ||
|
||
public FocusableTextArea(String text, TextFieldStyle style) { | ||
super(text, style); | ||
} | ||
|
||
@Override | ||
protected void setStage(Stage stage) { | ||
super.setStage(stage); | ||
FocusableActorCompat.setFocusable(this, stage); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
core-scene2d/src/de/golfgl/gdx/controllers/focusable/FocusableTextButton.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,26 @@ | ||
package de.golfgl.gdx.controllers.focusable; | ||
|
||
import com.badlogic.gdx.scenes.scene2d.Stage; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Skin; | ||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; | ||
|
||
public class FocusableTextButton extends TextButton { | ||
|
||
public FocusableTextButton(String text, Skin skin) { | ||
super(text, skin); | ||
} | ||
|
||
public FocusableTextButton(String text, Skin skin, String styleName) { | ||
super(text, skin, styleName); | ||
} | ||
|
||
public FocusableTextButton(String text, TextButtonStyle style) { | ||
super(text, style); | ||
} | ||
|
||
@Override | ||
protected void setStage(Stage stage) { | ||
super.setStage(stage); | ||
FocusableActorCompat.setFocusable(this, stage); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
core-scene2d/src/de/golfgl/gdx/controllers/focusable/FocusableTextField.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,26 @@ | ||
package de.golfgl.gdx.controllers.focusable; | ||
|
||
import com.badlogic.gdx.scenes.scene2d.Stage; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Skin; | ||
import com.badlogic.gdx.scenes.scene2d.ui.TextField; | ||
|
||
public class FocusableTextField extends TextField { | ||
|
||
public FocusableTextField(String text, Skin skin) { | ||
super(text, skin); | ||
} | ||
|
||
public FocusableTextField(String text, Skin skin, String styleName) { | ||
super(text, skin, styleName); | ||
} | ||
|
||
public FocusableTextField(String text, TextFieldStyle style) { | ||
super(text, style); | ||
} | ||
|
||
@Override | ||
protected void setStage(Stage stage) { | ||
super.setStage(stage); | ||
FocusableActorCompat.setFocusable(this, stage); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
core-scene2d/src/de/golfgl/gdx/controllers/focusable/FocusableWidget.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,14 @@ | ||
package de.golfgl.gdx.controllers.focusable; | ||
|
||
import com.badlogic.gdx.scenes.scene2d.Stage; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Widget; | ||
|
||
public class FocusableWidget extends Widget { | ||
|
||
|
||
@Override | ||
protected void setStage(Stage stage) { | ||
super.setStage(stage); | ||
FocusableActorCompat.setFocusable(this, stage); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
core-scene2d/src/de/golfgl/gdx/controllers/focusable/FocusableWidgetGroup.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,21 @@ | ||
package de.golfgl.gdx.controllers.focusable; | ||
|
||
import com.badlogic.gdx.scenes.scene2d.Actor; | ||
import com.badlogic.gdx.scenes.scene2d.Stage; | ||
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup; | ||
|
||
public class FocusableWidgetGroup extends WidgetGroup { | ||
|
||
public FocusableWidgetGroup() { | ||
} | ||
|
||
public FocusableWidgetGroup(Actor... actors) { | ||
super(actors); | ||
} | ||
|
||
@Override | ||
protected void setStage(Stage stage) { | ||
super.setStage(stage); | ||
FocusableActorCompat.setFocusable(this, stage); | ||
} | ||
} |