Skip to content

Commit

Permalink
Move suggestion window 3 pixels right
Browse files Browse the repository at this point in the history
  • Loading branch information
nutyworks committed Mar 19, 2024
1 parent 3b5bd73 commit 13e1580
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,11 @@ public void setFocused(@Nullable Element focused) {
}

public void scrollToFocused() {
int index = indexedWidgets.indexOf(this.getFocused());
int itemsOnScreen = this.height / this.itemHeight;
this.setScrollAmount((index - itemsOnScreen / 2.0) * this.itemHeight);
if (this.getFocused() instanceof CommandWidget focusedWidget) {
int index = indexedWidgets.indexOf(focusedWidget);
int itemsOnScreen = this.height / this.itemHeight;
this.setScrollAmount((index - itemsOnScreen / 2.0) * this.itemHeight);
}
}
}

Expand Down Expand Up @@ -506,13 +508,13 @@ public void render(DrawContext context, int index, int y, int x, int entryWidth,
if (this.isFocused()) {
CalciteCommandScreen.this.commandSuggestorRenderer = () -> {
context.getMatrices().push();
context.getMatrices().translate(0, 0, 1);
context.getMatrices().translate(3, 0, 1);
ChatInputSuggestor.SuggestionWindow window = ((ChatInputSuggestorFields) this.commandSuggestor).getWindow();
if (window != null) {
((SuggestionWindowFields) window).getArea().setY(calculateSuggestionY(y));
}
if (!this.commandSuggestor.tryRenderWindow(context, mouseX, mouseY)) {
context.getMatrices().translate(0, calculateMessageY(y), 0);
context.getMatrices().translate(-3, calculateMessageY(y), 0);
this.commandSuggestor.renderMessages(context);
}
context.getMatrices().pop();
Expand Down

0 comments on commit 13e1580

Please sign in to comment.