mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-10-12 09:23:38 +00:00
Added zoom level display to image editor
This commit is contained in:
parent
684f06dbdc
commit
fe2a00c46c
@ -73,6 +73,7 @@ public class AppleImageEditor extends ImageEditor implements EventHandler<MouseE
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void changeCurrentPattern(FillPattern pattern) {
|
public void changeCurrentPattern(FillPattern pattern) {
|
||||||
|
if (pattern == null) return;
|
||||||
currentFillPattern = pattern.getBytePattern();
|
currentFillPattern = pattern.getBytePattern();
|
||||||
hiBitMatters = pattern.hiBitMatters;
|
hiBitMatters = pattern.hiBitMatters;
|
||||||
lastActionX = -1;
|
lastActionX = -1;
|
||||||
|
@ -4,6 +4,7 @@ import javafx.event.ActionEvent;
|
|||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.Group;
|
import javafx.scene.Group;
|
||||||
import javafx.scene.control.ComboBox;
|
import javafx.scene.control.ComboBox;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.Menu;
|
import javafx.scene.control.Menu;
|
||||||
import javafx.scene.control.ScrollPane;
|
import javafx.scene.control.ScrollPane;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
@ -37,19 +38,22 @@ public abstract class ImageEditorTabController {
|
|||||||
protected ComboBox<Image> imageSelector; // Value injected by FXMLLoader
|
protected ComboBox<Image> imageSelector; // Value injected by FXMLLoader
|
||||||
@FXML // fx:id="imageWidthField"
|
@FXML // fx:id="imageWidthField"
|
||||||
protected TextField imageWidthField; // Value injected by FXMLLoader
|
protected TextField imageWidthField; // Value injected by FXMLLoader
|
||||||
|
@FXML
|
||||||
|
protected Label zoomLabel;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void initalize() {
|
public void initalize() {
|
||||||
assert imageCategoryField != null : "fx:id=\"imageCategoryField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
assert imageCategoryField != null : "fx:id=\"imageCategoryField\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
|
||||||
assert imageEditorAnchorPane != null : "fx:id=\"imageEditorAnchorPane\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
assert imageEditorAnchorPane != null : "fx:id=\"imageEditorAnchorPane\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
|
||||||
assert imageHeightField != null : "fx:id=\"imageHeightField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
assert imageHeightField != null : "fx:id=\"imageHeightField\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
|
||||||
assert imageNameField != null : "fx:id=\"imageNameField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
assert imageNameField != null : "fx:id=\"imageNameField\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
|
||||||
assert imagePatternMenu != null : "fx:id=\"imagePatternMenu\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
assert imagePatternMenu != null : "fx:id=\"imagePatternMenu\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
|
||||||
assert imageSelector != null : "fx:id=\"imageSelector\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
assert imageSelector != null : "fx:id=\"imageSelector\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
|
||||||
assert imageWidthField != null : "fx:id=\"imageWidthField\" was not injected: check your FXML file 'ApplicationUI.fxml'.";
|
assert imageWidthField != null : "fx:id=\"imageWidthField\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
|
||||||
assert imageEditorScrollPane != null : "fx:id\"imageEditorScrollPane\" was not injected: check your FXML file 'ApplicationUI.fxml'";
|
assert imageEditorScrollPane != null : "fx:id\"imageEditorScrollPane\" was not injected: check your FXML file 'imageEditorTab.fxml'";
|
||||||
assert imageEditorZoomGroup != null : "fx:id\"imageEditorZoomGroup\" was not injected: check your FXML file 'ApplicationUI.fxml'";
|
assert imageEditorZoomGroup != null : "fx:id\"imageEditorZoomGroup\" was not injected: check your FXML file 'imageEditorTab.fxml'";
|
||||||
assert imageEditorScrollAnchorPane != null : "fx:id\"imageEditorScrollAnchorPane\" was not injected: check your FXML file 'ApplicationUI.fxml'";
|
assert imageEditorScrollAnchorPane != null : "fx:id\"imageEditorScrollAnchorPane\" was not injected: check your FXML file 'imageEditorTab.fxml'";
|
||||||
|
assert zoomLabel != null : "fx:id=\"zoomLabel\" was not injected: check your FXML file 'imageEditorTab.fxml'.";
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public void rebuildImageSelector();
|
abstract public void rebuildImageSelector();
|
||||||
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||||||
import org.badvision.outlaweditor.ui.EntitySelectorCell;
|
import org.badvision.outlaweditor.ui.EntitySelectorCell;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import javafx.beans.binding.Bindings;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
@ -108,10 +109,15 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateZoomLabel() {
|
||||||
|
zoomLabel.setText(String.format("%1.1fx",currentImageEditor.getZoomScale()));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void imageZoomIn(ActionEvent event) {
|
public void imageZoomIn(ActionEvent event) {
|
||||||
if (currentImageEditor != null) {
|
if (currentImageEditor != null) {
|
||||||
currentImageEditor.zoomIn();
|
currentImageEditor.zoomIn();
|
||||||
|
updateZoomLabel();
|
||||||
updateScrollAreaWithScale(currentImageEditor.getZoomScale());
|
updateScrollAreaWithScale(currentImageEditor.getZoomScale());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,6 +126,7 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
|
|||||||
public void imageZoomOut(ActionEvent event) {
|
public void imageZoomOut(ActionEvent event) {
|
||||||
if (currentImageEditor != null) {
|
if (currentImageEditor != null) {
|
||||||
currentImageEditor.zoomOut();
|
currentImageEditor.zoomOut();
|
||||||
|
updateZoomLabel();
|
||||||
updateScrollAreaWithScale(currentImageEditor.getZoomScale());
|
updateScrollAreaWithScale(currentImageEditor.getZoomScale());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,8 +215,8 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
|
|||||||
currentImageEditor.setEntity(i);
|
currentImageEditor.setEntity(i);
|
||||||
currentImageEditor.buildEditorUI(imageEditorScrollAnchorPane);
|
currentImageEditor.buildEditorUI(imageEditorScrollAnchorPane);
|
||||||
currentImageEditor.buildPatternSelector(imagePatternMenu);
|
currentImageEditor.buildPatternSelector(imagePatternMenu);
|
||||||
imageEditorZoomGroup.setScaleX(1.0);
|
// imageEditorZoomGroup.setScaleX(1.0);
|
||||||
imageEditorZoomGroup.setScaleY(1.0);
|
// imageEditorZoomGroup.setScaleY(1.0);
|
||||||
imageNameField.textProperty().addListener(rebuildListener);
|
imageNameField.textProperty().addListener(rebuildListener);
|
||||||
imageCategoryField.textProperty().addListener(rebuildListener);
|
imageCategoryField.textProperty().addListener(rebuildListener);
|
||||||
if (oldEditorState != null) {
|
if (oldEditorState != null) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.effect.*?>
|
||||||
<?import java.lang.*?>
|
<?import java.lang.*?>
|
||||||
<?import java.util.*?>
|
<?import java.util.*?>
|
||||||
<?import javafx.scene.*?>
|
<?import javafx.scene.*?>
|
||||||
@ -67,6 +68,11 @@
|
|||||||
</ScrollPane>
|
</ScrollPane>
|
||||||
<Button layoutX="433.0" layoutY="5.0" mnemonicParsing="false" onAction="#imageZoomIn" styleClass="zoomInButton" text="+" AnchorPane.rightAnchor="18.0" AnchorPane.topAnchor="5.0" />
|
<Button layoutX="433.0" layoutY="5.0" mnemonicParsing="false" onAction="#imageZoomIn" styleClass="zoomInButton" text="+" AnchorPane.rightAnchor="18.0" AnchorPane.topAnchor="5.0" />
|
||||||
<Button layoutX="435.0" layoutY="37.0" mnemonicParsing="false" onAction="#imageZoomOut" prefHeight="23.999908447265625" styleClass="zoomOutButton" text="-" AnchorPane.rightAnchor="18.0" AnchorPane.topAnchor="37.0" />
|
<Button layoutX="435.0" layoutY="37.0" mnemonicParsing="false" onAction="#imageZoomOut" prefHeight="23.999908447265625" styleClass="zoomOutButton" text="-" AnchorPane.rightAnchor="18.0" AnchorPane.topAnchor="37.0" />
|
||||||
|
<Label fx:id="zoomLabel" alignment="CENTER" layoutX="428.0" layoutY="69.0" prefHeight="16.0" prefWidth="39.0" text="1x" textFill="WHITE" AnchorPane.rightAnchor="18.0" AnchorPane.topAnchor="69.0">
|
||||||
|
<effect>
|
||||||
|
<DropShadow blurType="ONE_PASS_BOX" color="#000240" height="12.0" radius="5.0" spread="0.5" width="10.0" />
|
||||||
|
</effect>
|
||||||
|
</Label>
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
</children>
|
</children>
|
||||||
|
Loading…
Reference in New Issue
Block a user