protected Tooltip<?> parseTooltipFromAction(final LmlParser parser, final Actor actor, final String rawAttributeData) { final ActorConsumer<?, Actor> action = parser.parseAction(rawAttributeData, actor); if (action == null) { parser.throwErrorIfStrict( "Cannot create tooltip with unknown action ID: " + rawAttributeData + " for actor: " + action); return null; } final Object result = action.consume(actor); if (result instanceof Tooltip<?>) { // Found an action and its result is a tooltip. Attaching directly. return (Tooltip<?>) result; } else if (result instanceof Actor) { // Found an action and its result is an actor. Converting to a tooltip: return new Tooltip<Actor>((Actor) result, parser.getData().getDefaultTooltipManager()); } // Found an action and its result is a different object. Converting to string and constructing tooltip: return new TextTooltip(Nullables.toString(result), parser.getData().getDefaultTooltipManager(), parser.getData().getDefaultSkin()); }
@Override public Actor[] getActors(Skin skin) { ImageButton musicTooltip = new OwnImageButton(skin, "tooltip"); musicTooltip.addListener(new TextTooltip( I18n.bundle.format("gui.tooltip.music", SysUtilsFactory.getSysUtils().getDefaultMusicDir()), skin)); ImageButton reloadMusic = new OwnImageButton(skin, "reload"); reloadMusic.setName("reload music"); reloadMusic.addListener(new EventListener() { @Override public boolean handle(Event event) { if (event instanceof ChangeEvent) { EventManager.instance.post(Events.MUSIC_RELOAD_CMD); return true; } return false; } }); reloadMusic.addListener(new TextTooltip(I18n.bundle.get("gui.music.reload"), skin)); return new Actor[] { musicTooltip, reloadMusic }; }
private void addToolBarButton(Skin skin, ImageButton button, String icon, String text, String tooltip) { ImageButtonStyle style = new ImageButtonStyle(skin.get(ButtonStyle.class)); TextureRegion image = Ctx.assetManager.getIcon(icon); style.imageUp = new TextureRegionDrawable(image); try { TextureRegion imageDisabled = Ctx.assetManager.getIcon(icon + "_disabled"); if(imageDisabled != null) style.imageDisabled = new TextureRegionDrawable(imageDisabled); } catch (Exception e) { } button.setStyle(style); // button.row(); // button.add(new Label(text, skin)); add(button); button.setDisabled(true); TextTooltip t = new TextTooltip(tooltip, skin); button.addListener(t); }
public void addToolBarButton(ImageButton button, String icon, String text, String tooltip) { TextureRegion image = Ctx.assetManager.getIcon(icon); TextureRegion imageDisabled = Ctx.assetManager.getIcon(icon + "_disabled"); ImageButtonStyle style = new ImageButtonStyle(skin.get("plain", ButtonStyle.class)); style.imageUp = new TextureRegionDrawable(image); if(imageDisabled != null) style.imageDisabled = new TextureRegionDrawable(imageDisabled); button.setStyle(style); button.pad(6,3,6,3); addActor(button); button.setDisabled(true); TextTooltip t = new TextTooltip(tooltip, skin); button.addListener(t); }
protected void init(Skin skin, String title, String desc, Actor c, boolean mandatory, String defaultValue) { //debug(); this.mandatory = mandatory; this.setSkin(skin); LabelStyle style = new LabelStyle(skin.get(LabelStyle.class)); this.title = new Label(title, style); this.desc = new Label(desc,skin, "subtitle"); this.desc.setWrap(false); this.field = c; // row().expand(); float titleWidth = this.title.getStyle().font.getSpaceWidth() * 35; add(this.title).width(titleWidth).left().top(); this.title.setWidth(titleWidth); this.title.setWrap(true); //row().expand(); add(field).expandX().left().top(); if(USE_TOOLTIPS) { TextTooltip t = new TextTooltip(desc, skin); this.title.addListener(t); this.field.addListener(t); } else { row().expand(); add(this.desc).colspan(2).left(); } if(defaultValue != null) setText(defaultValue); }
public View (Task<?> task, Skin skin) { super(skin); this.name = new Label(task.getClass().getSimpleName(), skin); this.status = new Label("", skin); add(name); add(status).padLeft(10); StringBuilder attrs = new StringBuilder(task.getClass().getSimpleName()).append('\n'); addListener(new TextTooltip(appendTaskAttributes(attrs, task).toString(), skin)); }
public void resetProperties() { properties.clear(); if (clazz.equals(Button.class)) { newStyleProperties(ButtonStyle.class); } else if (clazz.equals(CheckBox.class)) { newStyleProperties(CheckBoxStyle.class); properties.get("checkboxOn").optional = false; properties.get("checkboxOff").optional = false; properties.get("font").optional = false; } else if (clazz.equals(ImageButton.class)) { newStyleProperties(ImageButtonStyle.class); } else if (clazz.equals(ImageTextButton.class)) { newStyleProperties(ImageTextButtonStyle.class); properties.get("font").optional = false; } else if (clazz.equals(Label.class)) { newStyleProperties(LabelStyle.class); properties.get("font").optional = false; } else if (clazz.equals(List.class)) { newStyleProperties(ListStyle.class); properties.get("font").optional = false; properties.get("fontColorSelected").optional = false; properties.get("fontColorUnselected").optional = false; properties.get("selection").optional = false; } else if (clazz.equals(ProgressBar.class)) { newStyleProperties(ProgressBarStyle.class); //Though specified as optional in the doc, there are bugs without "background" being mandatory properties.get("background").optional = false; } else if (clazz.equals(ScrollPane.class)) { newStyleProperties(ScrollPaneStyle.class); } else if (clazz.equals(SelectBox.class)) { newStyleProperties(SelectBoxStyle.class); properties.get("font").optional = false; properties.get("fontColor").optional = false; properties.get("scrollStyle").optional = false; properties.get("scrollStyle").value = "default"; properties.get("listStyle").optional = false; properties.get("listStyle").value = "default"; } else if (clazz.equals(Slider.class)) { newStyleProperties(SliderStyle.class); //Though specified as optional in the doc, there are bugs without "background" being mandatory properties.get("background").optional = false; } else if (clazz.equals(SplitPane.class)) { newStyleProperties(SplitPaneStyle.class); properties.get("handle").optional = false; } else if (clazz.equals(TextButton.class)) { newStyleProperties(TextButtonStyle.class); properties.get("font").optional = false; } else if (clazz.equals(TextField.class)) { newStyleProperties(TextFieldStyle.class); properties.get("font").optional = false; properties.get("fontColor").optional = false; } else if (clazz.equals(TextTooltip.class)) { newStyleProperties(TextTooltipStyle.class); properties.get("label").optional = false; properties.get("label").value = "default"; } else if (clazz.equals(Touchpad.class)) { newStyleProperties(TouchpadStyle.class); } else if (clazz.equals(Tree.class)) { newStyleProperties(TreeStyle.class); properties.get("plus").optional = false; properties.get("minus").optional = false; } else if (clazz.equals(Window.class)) { newStyleProperties(WindowStyle.class); properties.get("titleFont").optional = false; } }
public void ok(final String[][] data, boolean hip) { Gdx.app.postRunnable(() -> { HorizontalGroup links = new HorizontalGroup(); links.align(Align.center); links.pad(5, 5, 5, 5); links.space(10); if (hip) links.addActor(new Link(txt("gui.data.json"), linkStyle, URL_HIP_JSON_SOURCE + st.getHip())); else { links.addActor(new Link(txt("gui.data.json"), linkStyle, URL_GAIA_JSON_SOURCE + st.getId())); links.addActor(new OwnLabel("|", skin)); links.addActor(new Link(txt("gui.data.archive"), linkStyle, URL_GAIA_WEB_SOURCE + st.getId())); } table.add(links).colspan(2).padTop(pad * 2).padBottom(pad * 2); table.row(); table.add(new OwnLabel(txt("gui.data.name"), skin, "msg-17")).padLeft(pad * 2).left(); table.add(new OwnLabel(st.getName(), skin, "msg-17")).padLeft(pad * 2).padRight(pad * 2).left(); table.row(); for (int col = 0; col < data[0].length; col++) { Actor first = null; if (data.length <= 2) { first = new OwnLabel(data[0][col], skin, "ui-13"); } else { HorizontalGroup hg = new HorizontalGroup(); hg.space(5); ImageButton tooltip = new ImageButton(skin, "tooltip"); tooltip.addListener(new TextTooltip(data[2][col], skin)); hg.addActor(tooltip); hg.addActor(new OwnLabel(data[0][col], skin, "ui-13")); first = hg; } table.add(first).padLeft(10).left(); table.add(new OwnLabel(data[1][col], skin, "ui-12")).padLeft(10).padRight(10).left(); left(); table.row(); } scroll.setHeight((float) Math.min(table.getMinHeight(), Gdx.graphics.getHeight() * 0.6) + pad); finish(); }); }
public RunStateInterface(Skin skin) { super(skin); float pad = 2 * GlobalConf.SCALE_FACTOR; keyboardImg = new Image(skin.getDrawable("no-input")); keyboardImg.addListener(new TextTooltip(txt("gui.tooltip.noinput"), skin)); frameoutputImg = new Image(skin.getDrawable("frameoutput")); frameoutputImg.addListener(new TextTooltip(txt("gui.tooltip.frameoutputon"), skin)); Image dataloadPauseImg = new Image(skin.getDrawable("dataload-pause")); bgLoading = new OwnTextIconButton("", dataloadPauseImg, skin, "toggle"); TextTooltip pauseBgTT = new TextTooltip(txt("gui.tooltip.pausebg"), skin); bgLoading.addListener(pauseBgTT); bgLoading.addListener((event) -> { if (event instanceof ChangeEvent) { if (loadingPaused) { EventManager.instance.post(Events.RESUME_BACKGROUND_LOADING); loadingPaused = false; pauseBgTT.getActor().setText(txt("gui.tooltip.pausebg")); } else { EventManager.instance.post(Events.PAUSE_BACKGROUND_LOADING); loadingPaused = true; pauseBgTT.getActor().setText(txt("gui.tooltip.resumebg")); } } return false; }); int num = ScriptingFactory.getInstance().getNumRunningScripts(); Image scriptStopImg = new Image(skin.getDrawable("script-stop")); cancelScript = new OwnTextIconButton("", scriptStopImg, skin); cancelScript.addListener(new TextTooltip(I18n.bundle.format("gui.script.stop", num), skin)); cancelScript.addListener((event) -> { if (event instanceof ChangeEvent) { EventManager.instance.post(Events.CANCEL_SCRIPT_CMD); } return false; }); Image cameraStopImg = new Image(skin.getDrawable("camera-stop")); cancelCamera = new OwnTextIconButton("", cameraStopImg, skin); cancelCamera.addListener(new TextTooltip(I18n.bundle.get("gui.stop"), skin)); cancelCamera.addListener((event) -> { if (event instanceof ChangeEvent) { EventManager.instance.post(Events.STOP_CAMERA_PLAY); } return false; }); pauseBgCell = this.add().right().padTop(pad); pauseBgCell.row(); stopScriptCell = this.add().right().padTop(pad); stopScriptCell.row(); stopCameraCell = this.add().right().padTop(pad); stopCameraCell.row(); keyboardImgCell = this.add().right().padTop(pad); keyboardImgCell.row(); frameoutputImgCell = this.add().right().padTop(pad); frameoutputImgCell.row(); EventManager.instance.subscribe(this, Events.INPUT_ENABLED_CMD, Events.NUM_RUNNING_SCRIPTS, Events.CAMERA_PLAY_INFO, Events.BACKGROUND_LOADING_INFO, Events.FRAME_OUTPUT_CMD); }
@Override public void initialize() { float componentWidth = 140 * GlobalConf.SCALE_FACTOR; nf = NumberFormatFactory.getFormatter("000"); prev = new OwnImageButton(skin, "audio-bwd"); prev.addListener(event -> { if (event instanceof ChangeEvent) { EventManager.instance.post(Events.MUSIC_PREVIOUS_CMD); return true; } return false; }); prev.addListener(new TextTooltip(txt("gui.music.previous"), skin)); play = new OwnImageButton(skin, "audio-playpause"); play.setChecked(false); play.addListener(event -> { if (event instanceof ChangeEvent) { EventManager.instance.post(Events.MUSIC_PLAYPAUSE_CMD); return true; } return false; }); play.addListener(new TextTooltip(txt("gui.music.playpause"), skin)); next = new OwnImageButton(skin, "audio-fwd"); next.addListener(event -> { if (event instanceof ChangeEvent) { EventManager.instance.post(Events.MUSIC_NEXT_CMD); return true; } return false; }); next.addListener(new TextTooltip(txt("gui.music.next"), skin)); volume = new OwnSlider(Constants.MIN_SLIDER, Constants.MAX_SLIDER, 1, false, skin); volume.setName("volume"); volume.setWidth(componentWidth); volume.setValue(MusicManager.instance.getVolume() * Constants.MAX_SLIDER); volume.addListener(event -> { if (event instanceof ChangeEvent) { float value = volume.getValue(); EventManager.instance.post(Events.MUSIC_VOLUME_CMD, value / Constants.MAX_SLIDER); vol.setText(nf.format(value)); return true; } return false; }); vol = new OwnLabel(nf.format(volume.getValue()), skin, "default"); float space3 = 3 * GlobalConf.SCALE_FACTOR; VerticalGroup musicGroup = new VerticalGroup().align(Align.center).columnAlign(Align.left).space(space3); HorizontalGroup playGroup = new HorizontalGroup(); playGroup.setWidth(componentWidth); playGroup.space(45 * GlobalConf.SCALE_FACTOR); prev.align(Align.center); play.align(Align.center); next.align(Align.center); playGroup.addActor(prev); playGroup.addActor(play); playGroup.addActor(next); HorizontalGroup volGroup = new HorizontalGroup(); volGroup.space(space3); volGroup.addActor(volume); volGroup.addActor(vol); musicGroup.addActor(playGroup); musicGroup.addActor(volGroup); component = musicGroup; }
@Override public void initialize() { // Time date = new OwnLabel("date UT", skin, "lcd"); date.setName("label date"); date.setWidth(150 * GlobalConf.SCALE_FACTOR); time = new OwnLabel("time UT", skin, "lcd"); time.setName("label time"); time.setWidth(150 * GlobalConf.SCALE_FACTOR); dateEdit = new OwnImageButton(skin, "edit"); dateEdit.addListener(event -> { if (event instanceof ChangeEvent) { // Left button click if (dateDialog == null) { dateDialog = new DateDialog(stage, skin); } dateDialog.updateTime(GaiaSky.instance.time.getTime()); dateDialog.display(); } return false; }); dateEdit.addListener(new TextTooltip(txt("gui.tooltip.dateedit"), skin)); // Pace Label paceLabel = new Label(txt("gui.pace") + " ", skin); plus = new OwnImageButton(skin, "plus"); plus.setName("plus"); plus.addListener(event -> { if (event instanceof ChangeEvent) { // Plus pressed EventManager.instance.post(Events.TIME_WARP_INCREASE_CMD); return true; } return false; }); plus.addListener(new TextTooltip(txt("gui.tooltip.timewarpplus"), skin)); minus = new OwnImageButton(skin, "minus"); minus.setName("minus"); minus.addListener(event -> { if (event instanceof ChangeEvent) { // Minus pressed EventManager.instance.post(Events.TIME_WARP_DECREASE_CMD); return true; } return false; }); minus.addListener(new TextTooltip(txt("gui.tooltip.timewarpminus"), skin)); timeWarp = new OwnLabel(getFormattedTimeWrap(), skin, "warp"); timeWarp.setName("time warp"); Container<Label> wrapWrapper = new Container<Label>(timeWarp); wrapWrapper.width(80f * GlobalConf.SCALE_FACTOR); wrapWrapper.align(Align.center); VerticalGroup timeGroup = new VerticalGroup().align(Align.left).columnAlign(Align.left).space(3 * GlobalConf.SCALE_FACTOR).padTop(3 * GlobalConf.SCALE_FACTOR); HorizontalGroup dateGroup = new HorizontalGroup(); dateGroup.space(4 * GlobalConf.SCALE_FACTOR); VerticalGroup datetimeGroup = new VerticalGroup(); datetimeGroup.addActor(date); datetimeGroup.addActor(time); dateGroup.addActor(datetimeGroup); dateGroup.addActor(dateEdit); timeGroup.addActor(dateGroup); HorizontalGroup paceGroup = new HorizontalGroup(); paceGroup.space(3 * GlobalConf.SCALE_FACTOR); paceGroup.addActor(paceLabel); paceGroup.addActor(minus); paceGroup.addActor(wrapWrapper); paceGroup.addActor(plus); timeGroup.addActor(paceGroup); timeGroup.pack(); component = timeGroup; }