Skip to content

Commit

Permalink
fix: take text offsets into account on all text based pages when dete…
Browse files Browse the repository at this point in the history
…cting click/hover style

Closes #251
  • Loading branch information
klikli-dev committed Sep 1, 2024
1 parent 7a7ee0b commit 9c55805
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,12 @@ public Style getClickedComponentStyleAt(double pMouseX, double pMouseY) {
}
}

var textY = this.getTextY();
var textStyle = this.getClickedComponentStyleAtForTextHolder(this.page.getText(), 0, textY, BookEntryScreen.PAGE_WIDTH, BookEntryScreen.PAGE_HEIGHT - textY, pMouseX, pMouseY);
var x = this.parentScreen.getBook().getBookTextOffsetX();
var y = this.getTextY() + this.parentScreen.getBook().getBookTextOffsetY();
var width = BookEntryScreen.PAGE_WIDTH + this.parentScreen.getBook().getBookTextOffsetWidth() - x; //always remove the offset x from the width to avoid overflow
var height = BookEntryScreen.PAGE_HEIGHT + this.parentScreen.getBook().getBookTextOffsetHeight() - y; //always remove the offset y from the height to avoid overflow

var textStyle = this.getClickedComponentStyleAtForTextHolder(this.page.getText(), x, y, width, height, pMouseX, pMouseY);
if (textStyle != null) {
return textStyle;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,12 @@ public Style getClickedComponentStyleAt(double pMouseX, double pMouseY) {
return multiblockNameStyle;
}

var textY = this.getTextY();
var textStyle = this.getClickedComponentStyleAtForTextHolder(this.page.getText(), 0, textY, BookEntryScreen.PAGE_WIDTH, BookEntryScreen.PAGE_HEIGHT - textY, pMouseX, pMouseY);
var x = this.parentScreen.getBook().getBookTextOffsetX();
var y = this.getTextY() + this.parentScreen.getBook().getBookTextOffsetY();
var width = BookEntryScreen.PAGE_WIDTH + this.parentScreen.getBook().getBookTextOffsetWidth() - x; //always remove the offset x from the width to avoid overflow
var height = BookEntryScreen.PAGE_HEIGHT + this.parentScreen.getBook().getBookTextOffsetHeight() - y; //always remove the offset y from the height to avoid overflow

var textStyle = this.getClickedComponentStyleAtForTextHolder(this.page.getText(), x, y, width, height, pMouseX, pMouseY);
if (textStyle != null) {
return textStyle;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ public Style getClickedComponentStyleAt(double pMouseX, double pMouseY) {

//titles are not markdown enabled here, so no links

var textY = this.getTextY();
var textStyle = this.getClickedComponentStyleAtForTextHolder(this.page.getText(), 0, textY, BookEntryScreen.PAGE_WIDTH, BookEntryScreen.PAGE_HEIGHT - textY, pMouseX, pMouseY);
var x = this.parentScreen.getBook().getBookTextOffsetX();
var y = this.getTextY() + this.parentScreen.getBook().getBookTextOffsetY();
var width = BookEntryScreen.PAGE_WIDTH + this.parentScreen.getBook().getBookTextOffsetWidth() - x; //always remove the offset x from the width to avoid overflow
var height = BookEntryScreen.PAGE_HEIGHT + this.parentScreen.getBook().getBookTextOffsetHeight() - y; //always remove the offset y from the height to avoid overflow

var textStyle = this.getClickedComponentStyleAtForTextHolder(this.page.getText(), x, y, width, height, pMouseX, pMouseY);
if (textStyle != null) {
return textStyle;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ public Style getClickedComponentStyleAt(double pMouseX, double pMouseY) {
}
}

var textY = this.getTextY();
var textStyle = this.getClickedComponentStyleAtForTextHolder(this.page.getText(), 0, textY, BookEntryScreen.PAGE_WIDTH, BookEntryScreen.PAGE_HEIGHT - textY, pMouseX, pMouseY);
var x = this.parentScreen.getBook().getBookTextOffsetX();
var y = this.getTextY() + this.parentScreen.getBook().getBookTextOffsetY();
var width = BookEntryScreen.PAGE_WIDTH + this.parentScreen.getBook().getBookTextOffsetWidth() - x; //always remove the offset x from the width to avoid overflow
var height = BookEntryScreen.PAGE_HEIGHT + this.parentScreen.getBook().getBookTextOffsetHeight() - y; //always remove the offset y from the height to avoid overflow

var textStyle = this.getClickedComponentStyleAtForTextHolder(this.page.getText(), x, y, width, height, pMouseX, pMouseY);
if (textStyle != null) {
return textStyle;
}
Expand Down

0 comments on commit 9c55805

Please sign in to comment.