-
Notifications
You must be signed in to change notification settings - Fork 15
fix: Mark label as selected when programatically calling selectCategory()
#73
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
base: master
Are you sure you want to change the base?
Changes from all commits
d9f0189
7579045
5bd7764
ce1b793
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ import gg.essential.vigilance.data.Category | |
| import gg.essential.vigilance.gui.elementa.GuiScaleOffsetConstraint | ||
| import gg.essential.vigilance.utils.onLeftClick | ||
|
|
||
| class CategoryLabel(private val gui: SettingsGui, private val category: Category) : UIContainer() { | ||
| class CategoryLabel(private val gui: SettingsGui, internal val category: Category) : UIContainer() { | ||
|
|
||
| private val text by UIText(category.name).constrain { | ||
| y = CenterConstraint() | ||
|
|
@@ -54,11 +54,6 @@ class CategoryLabel(private val gui: SettingsGui, private val category: Category | |
|
|
||
| fun select() { | ||
| gui.selectCategory(category) | ||
|
|
||
| isSelected = true | ||
| text.animate { | ||
| setColorAnimation(Animations.OUT_EXP, 0.5f, VigilancePalette.textActive.toConstraint()) | ||
| } | ||
| } | ||
|
|
||
| fun deselect() { | ||
|
|
@@ -67,4 +62,11 @@ class CategoryLabel(private val gui: SettingsGui, private val category: Category | |
| setColorAnimation(Animations.OUT_EXP, 0.5f, VigilancePalette.text.toConstraint()) | ||
| } | ||
| } | ||
|
|
||
| fun markSelected() { | ||
| isSelected = true | ||
| text.animate { | ||
| setColorAnimation(Animations.OUT_EXP, 0.5f, VigilancePalette.textActive.toConstraint()) | ||
| } | ||
| } | ||
|
Comment on lines
+65
to
+71
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For symmetry I think we should also make a |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -184,7 +184,16 @@ class SettingsGui( | |
| newCategory.scrollToTop() | ||
| currentCategory = newCategory | ||
|
|
||
| sidebarScroller.childrenOfType<CategoryLabel>().firstOrNull { it.isSelected }?.deselect() | ||
| val labels = sidebarScroller.childrenOfType<CategoryLabel>() | ||
|
|
||
| labels | ||
| .firstOrNull { it.isSelected } | ||
| ?.deselect() | ||
|
|
||
| // We compare names because the `items` field could technically be the same but the `Category` could be a different instance. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But can the same argument not be made for |
||
| labels | ||
| .firstOrNull { it.category.name == category.name } | ||
| ?.markSelected() | ||
| } | ||
|
|
||
| override fun updateGuiScale() { | ||
|
|
||
There was a problem hiding this comment.
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
CategoryLabeldoes, but it's too late for that one). When would it ever make sense for a third-party to call this method (rather thanselect)? If there's no such case, then it should beinternal, not part of our public API.