public TilePopup() { super(true, false); // init widgets FlowPanel Content = new FlowPanel(); Label levelLabel = new Label("Level:"); levelBox = new IntegerBox(); // setup widgets levelBox.setWidth("50px"); levelBox.setMaxLength(2); levelBox.addKeyUpHandler( new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { hide(); } } }); // build Content.add(levelLabel); Content.add(levelBox); this.add(Content); }
private Widget createGifPanel() { VerticalPanel panel = new VerticalPanel(); panel.setSize("100%", "100%"); Label label = new Label("Visible options"); panel.add(label); HorizontalPanel checks = new HorizontalPanel(); panel.add(checks); backgroundCheck = new CheckBox("Tile"); checks.add(backgroundCheck); backgroundCheck.addValueChangeHandler( new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { PoseEditor.poseEditor.setReservedSettingPreview(true); } }); boneCheck = new CheckBox("Bone"); checks.add(boneCheck); boneCheck.addValueChangeHandler( new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { PoseEditor.poseEditor.setReservedSettingPreview(true); } }); ikCheck = new CheckBox("IK"); checks.add(ikCheck); ikCheck.addValueChangeHandler( new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { PoseEditor.poseEditor.setReservedSettingPreview(true); } }); // camera control Label label5 = new Label("Camera"); panel.add(label5); HorizontalPanel h4 = new HorizontalPanel(); panel.add(h4); settingPositionXRange = InputRangeWidget.createInputRange(-300, 300, 0); HorizontalPanel hx = new HorizontalPanel(); hx.setWidth("100px"); h4.add(hx); hx.add( HTML5Builder.createRangeLabel( "X-Position:", settingPositionXRange, PoseEditor.poseEditor.getPosDivided())); h4.add(settingPositionXRange); settingPositionXRange.addInputRangeListener( new InputRangeListener() { @Override public void changed(int newValue) { PoseEditor.poseEditor.setRootPositionRangeValues( settingPositionXRange.getValue(), settingPositionYRange.getValue(), settingPositionZRange.getValue()); PoseEditor.poseEditor.setReservedSettingPreview(true); } }); settingPositionYRange = InputRangeWidget.createInputRange(-300, 300, 0); HorizontalPanel hy = new HorizontalPanel(); hy.setWidth("100px"); h4.add(hy); hy.add( HTML5Builder.createRangeLabel( "Y-Position:", settingPositionYRange, PoseEditor.poseEditor.getPosDivided())); h4.add(settingPositionYRange); settingPositionYRange.addInputRangeListener( new InputRangeListener() { @Override public void changed(int newValue) { PoseEditor.poseEditor.setRootPositionRangeValues( settingPositionXRange.getValue(), settingPositionYRange.getValue(), settingPositionZRange.getValue()); PoseEditor.poseEditor.setReservedSettingPreview(true); // updatePreviewCanvas(); } }); settingPositionZRange = InputRangeWidget.createInputRange(0, 1000, 0); HorizontalPanel hz = new HorizontalPanel(); hz.setWidth("100px"); h4.add(hz); hz.add( HTML5Builder.createRangeLabel( "Z-Position:", settingPositionZRange, PoseEditor.poseEditor.getPosDivided())); h4.add(settingPositionZRange); settingPositionZRange.addInputRangeListener( new InputRangeListener() { @Override public void changed(int newValue) { PoseEditor.poseEditor.setRootPositionRangeValues( settingPositionXRange.getValue(), settingPositionYRange.getValue(), settingPositionZRange.getValue()); PoseEditor.poseEditor.setReservedSettingPreview(true); } }); // transparent and basic material can't support because need recreate model. Label label3 = new Label("Size"); panel.add(label3); HorizontalPanel sizePanel = new HorizontalPanel(); sizePanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); panel.add(sizePanel); sizePanel.add(new Label("Width:")); widthBox = new IntegerBox(); widthBox.setWidth("50px"); sizePanel.add(widthBox); widthBox.addValueChangeHandler( new ValueChangeHandler<Integer>() { @Override public void onValueChange(ValueChangeEvent<Integer> event) { updateCanvasSize(); } }); sizePanel.add(new Label("Height:")); heightBox = new IntegerBox(); heightBox.setWidth("50px"); sizePanel.add(heightBox); heightBox.addValueChangeHandler( new ValueChangeHandler<Integer>() { @Override public void onValueChange(ValueChangeEvent<Integer> event) { updateCanvasSize(); } }); Button reset1 = new Button( "Reset size", new ClickHandler() { @Override public void onClick(ClickEvent event) { widthBox.setValue(gifWidth); heightBox.setValue(gifHeight); updateCanvasSize(); } }); sizePanel.add(reset1); Label label4 = new Label("GifAnime Options"); panel.add(label4); HorizontalPanel h1 = new HorizontalPanel(); panel.add(h1); h1.add(new Label("Quality")); qualityBox = new ValueListBox<Integer>( new Renderer<Integer>() { @Override public String render(Integer value) { if (value == 10) { return "medium(10)"; } if (value == 1) { return "High(1)"; } if (value == 20) { return "low(20)"; } return "" + value; } @Override public void render(Integer object, Appendable appendable) throws IOException {} }); List<Integer> acceptableValues = Lists.newArrayList(); for (int i = 20; i > 0; i--) { acceptableValues.add(i); } qualityBox.setValue(20); // low qualityBox.setAcceptableValues(acceptableValues); h1.add(qualityBox); h1.add(new Label("Speed")); speedBox = new ValueListBox<Integer>( new Renderer<Integer>() { @Override public String render(Integer value) { if (value == 1000) { return "slow(1000ms)"; } if (value == 50) { return "first(50ms)"; } if (value == 500) { return "medium(500ms)"; } return "" + value; } @Override public void render(Integer object, Appendable appendable) throws IOException {} }); List<Integer> acceptableValues2 = Lists.newArrayList(); for (int i = 1; i <= 20; i++) { acceptableValues2.add(i * 50); } speedBox.setValue(300); // low speedBox.setAcceptableValues(acceptableValues2); h1.add(speedBox); // background Label label2 = new Label("Background"); panel.add(label2); HorizontalPanel bgTypes = new HorizontalPanel(); bgTypes.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); panel.add(bgTypes); transparentBt = new RadioButton("bgtype", "Transparent"); transparentBt.addValueChangeHandler( new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { updatePreviewCanvas(); } }); // bgTypes.add(transparentBt);//stop because not support so far colorBt = new RadioButton("bgtype", "Color"); bgTypes.add(colorBt); /* colorBt.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { updatePreviewCanvas(); } }); */ colorBt.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { updatePreviewCanvas(); } }); colorBox = new ColorBox(); colorBox.setValue("#333333"); bgTypes.add(colorBox); imageBt = new RadioButton("bgtype", "Image"); bgTypes.add(imageBt); imageBt.addValueChangeHandler( new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { updatePreviewCanvas(); } }); Button colorUpdateBt = new Button( "Update", new ClickHandler() { @Override public void onClick(ClickEvent event) { updatePreviewCanvas(); } }); bgTypes.add(colorUpdateBt); bgImageLabel = new Label(); bgImageLabel.setWidth("100px"); bgImageUpload = FileUtils.createSingleFileUploadForm( new DataURLListener() { @Override public void uploaded(File file, String text) { bgImageLabel.setText(Ascii.truncate(file.getFileName(), 15, "...")); ImageElementUtils.createWithLoader( text, new ImageElementListener() { @Override public void onLoad(ImageElement element) { bgImage = element; imageBt.setValue(true); updatePreviewCanvas(); } @Override public void onError(String url, ErrorEvent event) { LogUtils.log(event.getNativeEvent()); } }); } }, true); bgTypes.add(bgImageUpload); bgTypes.add(bgImageLabel); Button reset = new Button( "Reset", new ClickHandler() { @Override public void onClick(ClickEvent event) { bgImageLabel.setText(""); bgImage = null; updatePreviewCanvas(); } }); bgTypes.add(reset); // size // TODO support size bgCanvas = CanvasUtils.createCanvas(gifWidth, gifHeight); panel.add(bgCanvas); return panel; }