Skip to content

Commit 0124a98

Browse files
committed
added action to show/hide statistics.
1 parent 4e3e0a3 commit 0124a98

File tree

10 files changed

+106
-1
lines changed

10 files changed

+106
-1
lines changed

resources/credits/icons.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ ui/icons/actions/svg/map-location.svg icon made by http://www.flaticon.com/autho
2121
ui/icons/actions/svg/placeholder.svg icon made by http://www.flaticon.com/authors/madebyoliver from www.flaticon.com
2222
ui/icons/actions/svg/graphene.svg icon made by http://www.flaticon.com/authors/freepik from www.flaticon.com
2323
ui/icons/actions/svg/database.svg icon made by http://www.flaticon.com/authors/designmodo from www.flaticon.com
24-
24+
ui/icons/actions/svg/bar-chart.svg icon made by http://www.flaticon.com/authors/freepik from www.flaticon.com

resources/messages/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ FileEditorActionSave=Save
2222

2323
SceneFileEditorActionSelection=Enable/disable showing selections
2424
SceneFileEditorActionGrid=Enable/disable showing the scene grid
25+
SceneFileEditorActionStatistics=Enable/disable showing the statistics
2526
SceneFileEditorActionMoveTool=Moving manipulator
2627
SceneFileEditorActionScaleTool=Scaling manipulator
2728
SceneFileEditorActionRotationTool=Rotating manipulator

resources/messages/messages_de.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ FileEditorActionSave=Speichern
2222

2323
SceneFileEditorActionSelection=Einschalten/Ausschalten der Auswahlmarkierung
2424
SceneFileEditorActionGrid=Einschalten/Ausschalten des Szenenrasters
25+
SceneFileEditorActionStatistics=Enable/disable showing the statistics
2526
SceneFileEditorActionMoveTool=Bewegungssmanipulator
2627
SceneFileEditorActionScaleTool=Skalierungsmanipulator
2728
SceneFileEditorActionRotationTool=Rotationsmanipulator

resources/messages/messages_ru.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ FileEditorActionSave=Сохранить
2222

2323
SceneFileEditorActionSelection=Включение/отключение отображения выделений
2424
SceneFileEditorActionGrid=Включение/отключение отображения сетки сцены
25+
SceneFileEditorActionStatistics=Включение/отключение отображения статистики
2526
SceneFileEditorActionMoveTool=Манипулятор перемещения
2627
SceneFileEditorActionScaleTool=Манипулятор маштабирования
2728
SceneFileEditorActionRotationTool=Манипулятор вращения
Lines changed: 44 additions & 0 deletions
Loading

src/com/ss/editor/Messages.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class Messages {
4242

4343
public static final String SCENE_FILE_EDITOR_ACTION_SELECTION;
4444
public static final String SCENE_FILE_EDITOR_ACTION_GRID;
45+
public static final String SCENE_FILE_EDITOR_ACTION_STATISTICS;
4546
public static final String SCENE_FILE_EDITOR_ACTION_MOVE_TOOL;
4647
public static final String SCENE_FILE_EDITOR_ACTION_SCALE_TOOL;
4748
public static final String SCENE_FILE_EDITOR_ACTION_ROTATION_TOOL;
@@ -614,6 +615,7 @@ public class Messages {
614615

615616
SCENE_FILE_EDITOR_ACTION_SELECTION = bundle.getString("SceneFileEditorActionSelection");
616617
SCENE_FILE_EDITOR_ACTION_GRID = bundle.getString("SceneFileEditorActionGrid");
618+
SCENE_FILE_EDITOR_ACTION_STATISTICS = bundle.getString("SceneFileEditorActionStatistics");
617619
SCENE_FILE_EDITOR_ACTION_MOVE_TOOL = bundle.getString("SceneFileEditorActionMoveTool");
618620
SCENE_FILE_EDITOR_ACTION_SCALE_TOOL = bundle.getString("SceneFileEditorActionScaleTool");
619621
SCENE_FILE_EDITOR_ACTION_ROTATION_TOOL = bundle.getString("SceneFileEditorActionRotationTool");

src/com/ss/editor/state/editor/impl/StatsAppState.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ public StatsAppState(@NotNull final Pane parent) {
167167
this.secondCounter = 0.0f;
168168
this.prevFps = -1;
169169
createComponents();
170+
setEnabled(false);
170171
}
171172

172173
/**

src/com/ss/editor/ui/Icons.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public interface Icons {
9090
Image DATA_16 = ICON_MANAGER.getImage("/ui/icons/actions/svg/database.svg", 16, false);
9191
Image LINKNODE_16 = ICON_MANAGER.getImage("/ui/icons/actions/16/linknode.png");
9292
Image LINK_FILE_16 = ICON_MANAGER.getImage("/ui/icons/actions/svg/link-folder-with-document.svg");
93+
Image STATISTICS_16 = ICON_MANAGER.getImage("/ui/icons/actions/svg/bar-chart.svg");
9394

9495
Image REFRESH_18 = ICON_MANAGER.getImage("/ui/icons/actions/18/refresh.png", 18);
9596
Image CLOSE_18 = ICON_MANAGER.getImage("/ui/icons/actions/18/close.png", 18);

src/com/ss/editor/ui/component/editor/impl/scene/AbstractSceneFileEditor.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ public abstract class AbstractSceneFileEditor<IM extends AbstractSceneFileEditor
220220
@Nullable
221221
private ToggleButton gridButton;
222222

223+
/**
224+
* The statistics toggle.
225+
*/
226+
@Nullable
227+
private ToggleButton statisticsButton;
228+
223229
/**
224230
* The move tool toggle.
225231
*/
@@ -438,6 +444,7 @@ protected void loadState() {
438444
editorState = currentWorkspace.getEditorState(getEditFile(), getStateConstructor());
439445
mainSplitContainer.updateFor(editorState);
440446
gridButton.setSelected(editorState.isEnableGrid());
447+
statisticsButton.setSelected(editorState.isShowStatistics());
441448
selectionButton.setSelected(editorState.isEnableSelection());
442449

443450
final TransformType transformType = TransformType.valueOf(editorState.getTransformationType());
@@ -939,6 +946,13 @@ protected void createToolbar(@NotNull final HBox container) {
939946
gridButton.selectedProperty().addListener((observable, oldValue, newValue) ->
940947
changeGridVisible(newValue));
941948

949+
statisticsButton = new ToggleButton();
950+
statisticsButton.setTooltip(new Tooltip(Messages.SCENE_FILE_EDITOR_ACTION_STATISTICS));
951+
statisticsButton.setGraphic(new ImageView(Icons.STATISTICS_16));
952+
statisticsButton.setSelected(true);
953+
statisticsButton.selectedProperty().addListener((observable, oldValue, newValue) ->
954+
changeStatisticsVisible(newValue));
955+
942956
moveToolButton = new ToggleButton();
943957
moveToolButton.setTooltip(new Tooltip(Messages.SCENE_FILE_EDITOR_ACTION_MOVE_TOOL + " (G)"));
944958
moveToolButton.setGraphic(new ImageView(Icons.MOVE_16));
@@ -962,6 +976,8 @@ protected void createToolbar(@NotNull final HBox container) {
962976
FXUtils.addClassTo(selectionButton, CSSClasses.FILE_EDITOR_TOOLBAR_BUTTON);
963977
FXUtils.addClassTo(gridButton, CSSClasses.TOOLBAR_BUTTON);
964978
FXUtils.addClassTo(gridButton, CSSClasses.FILE_EDITOR_TOOLBAR_BUTTON);
979+
FXUtils.addClassTo(statisticsButton, CSSClasses.TOOLBAR_BUTTON);
980+
FXUtils.addClassTo(statisticsButton, CSSClasses.FILE_EDITOR_TOOLBAR_BUTTON);
965981
FXUtils.addClassTo(moveToolButton, CSSClasses.TOOLBAR_BUTTON);
966982
FXUtils.addClassTo(moveToolButton, CSSClasses.FILE_EDITOR_TOOLBAR_BUTTON);
967983
FXUtils.addClassTo(rotationToolButton, CSSClasses.TOOLBAR_BUTTON);
@@ -971,6 +987,7 @@ protected void createToolbar(@NotNull final HBox container) {
971987

972988
FXUtils.addToPane(selectionButton, container);
973989
FXUtils.addToPane(gridButton, container);
990+
FXUtils.addToPane(statisticsButton, container);
974991
FXUtils.addToPane(moveToolButton, container);
975992
FXUtils.addToPane(rotationToolButton, container);
976993
FXUtils.addToPane(scaleToolButton, container);
@@ -1198,6 +1215,19 @@ private void changeGridVisible(@NotNull final Boolean newValue) {
11981215
if (editorState != null) editorState.setEnableGrid(newValue);
11991216
}
12001217

1218+
/**
1219+
* Handle changing statistics visibility.
1220+
*/
1221+
private void changeStatisticsVisible(@NotNull final Boolean newValue) {
1222+
if (isIgnoreListeners()) return;
1223+
1224+
statsAppState.setEnabled(newValue);
1225+
1226+
final ES editorState = getEditorState();
1227+
if (editorState != null) editorState.setShowStatistics(newValue);
1228+
}
1229+
1230+
12011231
/**
12021232
* Notify about transformed the object.
12031233
*/

src/com/ss/editor/ui/component/editor/state/impl/AbstractModelFileEditorState.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public abstract class AbstractModelFileEditorState extends AbstractEditorState {
2626
*/
2727
private volatile boolean enableSelection;
2828

29+
/**
30+
* Is enabled showing statistics.
31+
*/
32+
private volatile boolean showStatistics;
33+
2934
public AbstractModelFileEditorState() {
3035
this.enableGrid = true;
3136
this.enableSelection = true;
@@ -88,6 +93,25 @@ public void setTransformationType(final int transformationType) {
8893
}
8994
}
9095

96+
/**
97+
* @param showStatistics true if the statistics is need to show.
98+
*/
99+
public void setShowStatistics(final boolean showStatistics) {
100+
final boolean changed = isShowStatistics() != showStatistics;
101+
this.showStatistics = showStatistics;
102+
final Runnable changeHandler = getChangeHandler();
103+
if (changed && changeHandler != null) {
104+
changeHandler.run();
105+
}
106+
}
107+
108+
/**
109+
* @return true if the statistics is need to show.
110+
*/
111+
public boolean isShowStatistics() {
112+
return showStatistics;
113+
}
114+
91115
@Override
92116
public String toString() {
93117
return "AbstractModelFileEditorState{" +

0 commit comments

Comments
 (0)