Skip to content

Commit d3bec0e

Browse files
rename EditorTooltip -> EntryTooltip
use GridBagConstraintsBuilder in EntryTooltip respect scale config in EntryTooltip
1 parent 4db2292 commit d3bec0e

File tree

2 files changed

+137
-150
lines changed

2 files changed

+137
-150
lines changed

enigma-swing/src/main/java/org/quiltmc/enigma/gui/panel/EditorPanel.java

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class EditorPanel extends BaseEditorPanel {
5555
private final EditorPopupMenu popupMenu;
5656

5757
// DIY tooltip because JToolTip can't be moved or resized
58-
private final EditorTooltip tooltip = new EditorTooltip(this.gui);
58+
private final EntryTooltip entryTooltip = new EntryTooltip(this.gui);
5959

6060
@Nullable
6161
private Token lastMouseTargetToken;
@@ -66,7 +66,7 @@ public class EditorPanel extends BaseEditorPanel {
6666
this.consumeEditorMouseTarget(
6767
(token, entry) -> {
6868
this.hideTooltipTimer.stop();
69-
if (this.tooltip.isVisible()) {
69+
if (this.entryTooltip.isVisible()) {
7070
this.showTooltipTimer.stop();
7171

7272
if (!token.equals(this.lastMouseTargetToken)) {
@@ -79,7 +79,7 @@ public class EditorPanel extends BaseEditorPanel {
7979
}
8080
},
8181
() -> consumeMousePositionIn(
82-
this.tooltip.getContentPane(),
82+
this.entryTooltip.getContentPane(),
8383
(absolute, relative) -> this.hideTooltipTimer.stop(),
8484
absolute -> {
8585
this.lastMouseTargetToken = null;
@@ -95,7 +95,7 @@ public class EditorPanel extends BaseEditorPanel {
9595
ToolTipManager.sharedInstance().getInitialDelay() - MOUSE_STOPPED_MOVING_DELAY, e -> {
9696
this.consumeEditorMouseTarget((token, entry) -> {
9797
if (token.equals(this.lastMouseTargetToken)) {
98-
this.tooltip.setVisible(true);
98+
this.entryTooltip.setVisible(true);
9999
this.openTooltip(entry);
100100
}
101101
});
@@ -143,8 +143,8 @@ public void focusLost(FocusEvent e) {
143143
// global listener so tooltip hides even if clicking outside editor
144144
Toolkit.getDefaultToolkit().addAWTEventListener(
145145
e -> {
146-
if (e.getID() == MouseEvent.MOUSE_PRESSED && this.tooltip.isVisible()) {
147-
consumeMousePositionOut(this.tooltip.getContentPane(), absolute -> this.closeTooltip());
146+
if (e.getID() == MouseEvent.MOUSE_PRESSED && this.entryTooltip.isVisible()) {
147+
consumeMousePositionOut(this.entryTooltip.getContentPane(), absolute -> this.closeTooltip());
148148
}
149149
},
150150
MouseEvent.MOUSE_PRESSED
@@ -176,7 +176,7 @@ public void mouseClicked(MouseEvent e) {
176176

177177
@Override
178178
public void mousePressed(MouseEvent mouseEvent) {
179-
EditorPanel.this.tooltip.setVisible(false);
179+
EditorPanel.this.entryTooltip.setVisible(false);
180180
EditorPanel.this.mouseStoppedMovingTimer.stop();
181181
EditorPanel.this.showTooltipTimer.stop();
182182
EditorPanel.this.hideTooltipTimer.stop();
@@ -210,9 +210,9 @@ public void mouseMoved(MouseEvent e) {
210210
this.showTooltipTimer.setRepeats(false);
211211
this.hideTooltipTimer.setRepeats(false);
212212

213-
this.tooltip.setVisible(false);
213+
this.entryTooltip.setVisible(false);
214214

215-
this.tooltip.addMouseListener(new MouseAdapter() {
215+
this.entryTooltip.addMouseListener(new MouseAdapter() {
216216
@Override
217217
public void mousePressed(MouseEvent e) {
218218
if (!Config.editor().tooltip.interactable.value()) {
@@ -241,7 +241,7 @@ public void mousePressed(MouseEvent e) {
241241
}
242242
});
243243

244-
this.tooltip.addMouseMotionListener(new MouseAdapter() {
244+
this.entryTooltip.addMouseMotionListener(new MouseAdapter() {
245245
@Override
246246
public void mouseMoved(MouseEvent e) {
247247
if (Config.editor().tooltip.interactable.value()) {
@@ -289,15 +289,15 @@ public void keyTyped(KeyEvent event) {
289289
}
290290

291291
private void closeTooltip() {
292-
this.tooltip.close();
292+
this.entryTooltip.close();
293293
this.lastMouseTargetToken = null;
294294
this.mouseStoppedMovingTimer.stop();
295295
this.showTooltipTimer.stop();
296296
this.hideTooltipTimer.stop();
297297
}
298298

299299
private void openTooltip(Entry<?> target) {
300-
this.tooltip.open(target);
300+
this.entryTooltip.open(target);
301301
}
302302

303303
public void onRename(boolean isNewMapping) {
@@ -358,7 +358,7 @@ protected void setClassHandleImpl(
358358
@Override
359359
public void onDeobfRefChanged(ClassHandle h, ClassEntry deobfRef) {
360360
SwingUtilities.invokeLater(() -> EditorPanel.this.listeners.forEach(l -> l
361-
.onTitleChanged(EditorPanel.this, EditorPanel.this.getSimpleClassName()))
361+
.onTitleChanged(EditorPanel.this, EditorPanel.this.getSimpleClassName()))
362362
);
363363
}
364364

@@ -394,6 +394,18 @@ protected void setCursorReference(EntryReference<Entry<?>, Entry<?>> ref) {
394394
this.listeners.forEach(l -> l.onCursorReferenceChanged(this, ref));
395395
}
396396

397+
@Override
398+
public void offsetEditorZoom(int zoomAmount) {
399+
super.offsetEditorZoom(zoomAmount);
400+
this.entryTooltip.setZoom(zoomAmount);
401+
}
402+
403+
@Override
404+
public void resetEditorZoom() {
405+
super.resetEditorZoom();
406+
this.entryTooltip.resetZoom();
407+
}
408+
397409
public void addListener(EditorActionListener listener) {
398410
this.listeners.add(listener);
399411
}

0 commit comments

Comments
 (0)