Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Mark label as selected when programatically calling selectCategory() #73

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

caoimhebyrne
Copy link
Member

When we called selectCategory() before this PR, the labels on the left-hand side of the screen did not get updated correctly. The de-selection was performed but the selection was not visible.

Now, when you selectCategory() the selection is visible, as well as the de-selection like before.

Since selectCategory() is public API, I feel like this is an important change to make :^)

Selecting the category visually and programmatically both call this
method, so it's better that we do the visual style here like we do for
deselection.
.firstOrNull { it.isSelected }
?.deselect()

// We compare names because the `items` field could technically be the same but the `Category` could be a different instance.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But can the same argument not be made for name as well? Shouldn't we just compare by reference?

@@ -392,6 +392,7 @@ public final class gg/essential/vigilance/gui/CategoryLabel : gg/essential/eleme
public fun <init> (Lgg/essential/vigilance/gui/SettingsGui;Lgg/essential/vigilance/data/Category;)V
public final fun deselect ()V
public final fun isSelected ()Z
public final fun markSelected ()V
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds like an implementation detail (granted, the entire CategoryLabel does, but it's too late for that one). When would it ever make sense for a third-party to call this method (rather than select)? If there's no such case, then it should be internal, not part of our public API.

Comment on lines +65 to +71

fun markSelected() {
isSelected = true
text.animate {
setColorAnimation(Animations.OUT_EXP, 0.5f, VigilancePalette.textActive.toConstraint())
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For symmetry I think we should also make a markDeselected (or have this method accept a selected: Boolean) which the current deselect calls, and then slap a @Deprecated on select and deselect because we shouldn't be using them any more, they only exist for backwards compatibility, we should always be using gui.selectCategory (which will in turn only use the mark* method(s)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants