Skip to content

Commit

Permalink
unfinished editor view implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
crissNb committed Jan 14, 2024
1 parent 4bdb01b commit f5af722
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
12 changes: 12 additions & 0 deletions src/main/java/org/gecko/view/inspector/Inspector.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

public class Inspector extends ScrollPane {

private boolean isCollapsed = false;

public Inspector(
List<InspectorElement<?>> elements,
ActionManager actionManager,
Expand Down Expand Up @@ -55,6 +57,16 @@ public Inspector(
setFitToWidth(true);
}

public void toggleCollapse() {
isCollapsed = !isCollapsed;

if (isCollapsed) {
setPrefWidth(0);
} else {
setPrefWidth(300);
}
}

public Node getView() {
return this;
}
Expand Down
35 changes: 31 additions & 4 deletions src/main/java/org/gecko/view/views/EditorView.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,59 @@

import javafx.scene.Node;
import javafx.scene.control.ToolBar;
import javafx.scene.layout.Pane;
import org.gecko.actions.ActionManager;
import org.gecko.view.inspector.Inspector;
import org.gecko.view.inspector.InspectorFactory;
import org.gecko.view.views.shortcuts.ShortcutHandler;
import org.gecko.viewmodel.EditorViewModel;

public class EditorView {
private final EditorViewModel viewModel;
private final ToolBar toolBar;
private final ShortcutHandler shortcutHandler;
private final InspectorFactory inspectorFactory;

public EditorView(EditorViewModel viewModel, ToolBar toolBar, ShortcutHandler shortcutHandler) {
private Inspector currentInspector;
private Pane currentView;

public EditorView(
ActionManager actionManager,
EditorViewModel viewModel,
ToolBar toolBar,
ShortcutHandler shortcutHandler) {
this.viewModel = viewModel;
this.toolBar = toolBar;
this.shortcutHandler = shortcutHandler;
this.inspectorFactory = new InspectorFactory(actionManager, this, viewModel);

viewModel
.getFocusedElement()
.addListener(
(observable, oldValue, newValue) -> {
if (newValue != null) {
currentInspector = inspectorFactory.createInspector(newValue);
} else {
currentInspector = null;
}
});
}

public void toggleInspector() {
if (currentInspector != null) {
currentInspector.toggleCollapse();
}
}

public Node drawView() {
return null;
return currentView;
}

public Node drawToolbar() {
return null;
return toolBar;
}

public Node drawInspector() {
return null;
return currentInspector;
}
}

0 comments on commit f5af722

Please sign in to comment.