Skip to content

Commit

Permalink
Added FileTree Navigation with UP and DOWN keys!
Browse files Browse the repository at this point in the history
  • Loading branch information
omegaui committed Feb 23, 2022
1 parent 3c06f93 commit 8129d6e
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 12 deletions.
Binary file modified out/Omega IDE-dailybuild.jar
Binary file not shown.
Binary file added res/fluent-icons/icons8-chevron-down-48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/fluent-icons/icons8-chevron-right-48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/fluent-icons/icons8-chevron-up-48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/omega/IDEUpdater.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* IDEUpdater
* Copyright (C) 2021 Omega UI
Expand Down
6 changes: 5 additions & 1 deletion src/omega/Screen.java
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,11 @@ public void dispose(){
uiManager.save();
dataManager.saveData();
if(projectFile.getProjectManager().isLanguageTagNonJava()){
projectFile.getArgumentManager().save();
if(projectFile.getArgumentManager() != null)
projectFile.getArgumentManager().save();
else{
System.out.println("This project doesn't contains any arguments to be saved! ... skipping ArgumentManager.save()");
}
}
SnippetBase.save();
getPluginReactionManager().triggerReaction(PluginReactionEvent.genNewInstance(PluginReactionEvent.EVENT_TYPE_IDE_CLOSING, this, 0));
Expand Down
8 changes: 6 additions & 2 deletions src/omega/io/IconManager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
/*
* IconManager
* Copyright (C) 2021 Omega UI
* Copyright (C) 2022 Omega UI
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -161,6 +161,10 @@ public class IconManager {
public static BufferedImage fluentcopyImage = getFluentIcon("copy-to-clipboard-48.png");
public static BufferedImage fluenteditFileImage = getFluentIcon("edit-file-48.png");
public static BufferedImage fluentrenameImage = getFluentIcon("rename-48.png");

public static BufferedImage fluentrightArrowImage = getFluentIcon("chevron-right-48.png");
public static BufferedImage fluentdownArrowImage = getFluentIcon("chevron-down-48.png");
public static BufferedImage fluentupArrowImage = getFluentIcon("chevron-up-48.png");

//Fluent GIFs
public static Image fluentneutralemojiGif = getFluentGif("neutral.gif");
Expand Down
16 changes: 12 additions & 4 deletions src/omega/ui/component/FileTreeBranch.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
/*
* FileTreeBranch
* Copyright (C) 2021 Omega UI
* Copyright (C) 2022 Omega UI
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -86,6 +86,8 @@ public class FileTreeBranch extends JComponent {
private volatile boolean expanded = false;
private volatile boolean modeLocked = false;
private volatile boolean rootMode = false;

private volatile BufferedImage arrowImage;

public FileTreeBranch(FileTreePanel fileTreePanel, File file){
this.file = file;
Expand Down Expand Up @@ -172,6 +174,12 @@ public void initKeyStrokes(){
listener.putKeyStroke((e)->{
Screen.openInTerminal(file);
}, VK_F3).setStopKeys(VK_CONTROL, VK_ALT, VK_SHIFT).useAutoReset();
listener.putKeyStroke((e)->{
fileTreePanel.transferFocusToNextBranch(FileTreeBranch.this);
}, VK_DOWN);
listener.putKeyStroke((e)->{
fileTreePanel.transferFocusToPreviousBranch(FileTreeBranch.this);
}, VK_UP);

addKeyListener(listener);
}
Expand All @@ -188,8 +196,8 @@ public void paintComponent(Graphics graphics){
g.setColor(c2);
g.setFont(PX14);
g.fillRect(0, 0, getWidth(), getHeight());
g.drawImage(image, (enter || rootMode) ? 3 : 0, getHeight()/2 - 20/2, null);
g.setColor(fileColor);
g.drawImage(image, (enter || rootMode || isFocusOwner()) ? 3 : 0, getHeight()/2 - 20/2, null);
g.setColor((!rootMode && expanded) ? TOOLMENU_COLOR3 : fileColor);
g.drawString(displayName, 30, getHeight()/2 - g.getFontMetrics().getHeight()/2 + g.getFontMetrics().getAscent() - g.getFontMetrics().getDescent() + 1);
if(isFocusOwner()){
g.fillRect(30, getHeight() - 3, g.getFontMetrics().stringWidth(displayName), 2);
Expand Down
4 changes: 2 additions & 2 deletions src/omega/ui/panel/AbstractFileTreePanel.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
/*
* AbstractFileTreePanel
* Copyright (C) 2021 Omega UI
* Copyright (C) 2022 Omega UI
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
30 changes: 28 additions & 2 deletions src/omega/ui/panel/FileTreePanel.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
/*
* FileTreePanel
* Copyright (C) 2021 Omega UI
* Copyright (C) 2022 Omega UI
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -263,6 +263,32 @@ public void paint(Graphics graphics){
super.paint(g);
g.dispose();
}

public void transferFocusToPreviousBranch(FileTreeBranch currentBranch){
int currentBranchIndex = branches.indexOf(currentBranch);
if(currentBranchIndex == 0)
return;

FileTreeBranch bx = branches.get(currentBranchIndex - 1);
bx.grabFocus();
bx.repaint();

if(!scrollPane.getViewport().getViewRect().contains(bx.getBounds()))
scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getValue() - optimumBranchSize - gap);
}

public void transferFocusToNextBranch(FileTreeBranch currentBranch){
int currentBranchIndex = branches.indexOf(currentBranch);
if(currentBranchIndex == branches.size() - 1)
return;

FileTreeBranch bx = branches.get(currentBranchIndex + 1);
bx.grabFocus();
bx.repaint();

if(!scrollPane.getViewport().getViewRect().contains(bx.getBounds()))
scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getValue() + optimumBranchSize + gap);
}

public java.io.File getRoot() {
return root;
Expand Down

0 comments on commit 8129d6e

Please sign in to comment.