Skip to content

Commit

Permalink
add keybinds and remove background for navigator panel
Browse files Browse the repository at this point in the history
  • Loading branch information
ix0rai committed Sep 30, 2023
1 parent dc14ce4 commit 23f2922
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public final class KeyBinds {
public static final KeyBind EDITOR_RELOAD_CLASS = KeyBind.builder("reload_class", EDITOR_CATEGORY).mod(InputEvent.CTRL_DOWN_MASK).key(KeyEvent.VK_F5).build();
public static final KeyBind EDITOR_QUICK_FIND = KeyBind.builder("quick_find", EDITOR_CATEGORY).mod(InputEvent.CTRL_DOWN_MASK).key(KeyEvent.VK_F).build();

public static final KeyBind ENTRY_NAVIGATOR_NEXT = KeyBind.builder("navigate_next", EDITOR_CATEGORY).mod(InputEvent.CTRL_DOWN_MASK).key(KeyEvent.VK_DOWN).build();
public static final KeyBind ENTRY_NAVIGATOR_LAST = KeyBind.builder("navigate_last", EDITOR_CATEGORY).mod(InputEvent.CTRL_DOWN_MASK).key(KeyEvent.VK_UP).build();

public static final KeyBind SAVE_MAPPINGS = KeyBind.builder("save", MENU_CATEGORY).mod(InputEvent.CTRL_DOWN_MASK).key(KeyEvent.VK_S).build();
public static final KeyBind DROP_MAPPINGS = KeyBind.builder("drop_mappings", MENU_CATEGORY).build();
public static final KeyBind RELOAD_MAPPINGS = KeyBind.builder("reload_mappings", MENU_CATEGORY).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public void onTitleChanged(EditorPanel editor, String title) {
ed.getEditor().addKeyListener(GuiUtil.onKeyPress(keyEvent -> {
if (KeyBinds.EDITOR_CLOSE_TAB.matches(keyEvent)) {
this.closeEditor(ed);
} else if (KeyBinds.ENTRY_NAVIGATOR_NEXT.matches(keyEvent)) {
this.navigator.navigateDown();
} else if (KeyBinds.ENTRY_NAVIGATOR_LAST.matches(keyEvent)) {
this.navigator.navigateUp();
}
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;
import java.awt.Color;
import java.awt.event.ItemEvent;
import java.util.ArrayList;
Expand Down Expand Up @@ -55,32 +54,43 @@ public NavigatorPanel(Gui gui) {
}

JButton up = new JButton("⋀");
up.addActionListener(event -> {
List<Entry<?>> currentEntrySet = this.entries.get(this.selectedType);
if (!currentEntrySet.isEmpty()) {
this.currentIndex--;
this.wrapIndex();

this.tryNavigate();
}
});

up.addActionListener(event -> this.navigateUp());
JButton down = new JButton("⋁");
down.addActionListener(event -> {
List<Entry<?>> currentEntrySet = this.entries.get(this.selectedType);
if (!currentEntrySet.isEmpty()) {
this.currentIndex++;
this.wrapIndex();

this.tryNavigate();
}
});
down.addActionListener(event -> this.navigateDown());

this.add(typeSelector);
this.add(up);
this.add(down);
this.add(this.statsLabel);
this.setBorder(new LineBorder(Color.BLACK));

// transparent background
this.setBackground(new Color(0, 0, 0, 0));
}

/**
* Navigates to the next entry matching the current filter.
*/
public void navigateDown() {
List<Entry<?>> currentEntrySet = this.entries.get(this.selectedType);
if (!currentEntrySet.isEmpty()) {
this.currentIndex++;
this.wrapIndex();

this.tryNavigate();
}
}

/**
* Navigates to the last entry matching the current filter.
*/
public void navigateUp() {
List<Entry<?>> currentEntrySet = this.entries.get(this.selectedType);
if (!currentEntrySet.isEmpty()) {
this.currentIndex--;
this.wrapIndex();

this.tryNavigate();
}
}

private void onTypeChange() {
Expand Down
2 changes: 2 additions & 0 deletions enigma/src/main/resources/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@
"keybind.editor.zoom_out": "Zoom in",
"keybind.editor.close_tab": "Close editor tab",
"keybind.editor.reload_class": "Reload open class",
"keybind.editor.navigate_next": "Navigate to next entry",
"keybind.editor.navigate_last": "Navigate to last entry",
"keybind.menu.search": "Search",
"keybind.menu.search_all": "Search for anything",
"keybind.menu.search_class": "Search for class",
Expand Down

0 comments on commit 23f2922

Please sign in to comment.