Skip to content

Commit

Permalink
Fix visuals of disabled breadcrumb bar scroller buttons
Browse files Browse the repository at this point in the history
Explicitly specify `Original` as disabled filter strategy so that the disabled look is not applied twice on the transition-aware icon. For #8.
  • Loading branch information
kirill-grouchnikov committed Jan 4, 2022
1 parent b93107d commit b9b7766
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
Expand Up @@ -35,11 +35,14 @@ import androidx.compose.ui.unit.dp
import kotlinx.coroutines.launch
import org.pushingpixels.aurora.common.AuroraInternalApi
import org.pushingpixels.aurora.common.withAlpha
import org.pushingpixels.aurora.component.model.*
import org.pushingpixels.aurora.component.model.ActionFireTrigger
import org.pushingpixels.aurora.component.model.Command
import org.pushingpixels.aurora.component.model.CommandButtonPresentationModel
import org.pushingpixels.aurora.component.model.CommandButtonPresentationState
import org.pushingpixels.aurora.component.projection.CommandButtonProjection
import org.pushingpixels.aurora.component.utils.*
import org.pushingpixels.aurora.component.utils.ArrowSizingConstants
import org.pushingpixels.aurora.component.utils.drawArrow
import org.pushingpixels.aurora.component.utils.TransitionAwarePainter
import org.pushingpixels.aurora.component.utils.TransitionAwarePainterDelegate
import org.pushingpixels.aurora.component.utils.drawDoubleArrow
import org.pushingpixels.aurora.theming.*

Expand All @@ -57,6 +60,10 @@ fun AuroraBreadcrumbBar(commands: List<Command>, modifier: Modifier) {

val scrollerPresentationModel = CommandButtonPresentationModel(
presentationState = CommandButtonPresentationState.Small,
backgroundAppearanceStrategy = BackgroundAppearanceStrategy.Flat,
iconActiveFilterStrategy = IconFilterStrategy.Original,
iconEnabledFilterStrategy = IconFilterStrategy.Original,
iconDisabledFilterStrategy = IconFilterStrategy.Original,
contentPadding = PaddingValues(0.dp),
actionFireTrigger = ActionFireTrigger.OnRollover,
autoRepeatAction = true,
Expand Down Expand Up @@ -103,7 +110,10 @@ fun AuroraBreadcrumbBar(commands: List<Command>, modifier: Modifier) {
val dx = (iconSize.toPx() - arrowDoubleWidth) / 2
val dy = (iconSize.toPx() - arrowDoubleHeight) / 2
val alpha = if (modelStateInfoSnapshot.currModelState.isDisabled)
colors.getAlpha(decorationAreaType, modelStateInfoSnapshot.currModelState) else 1.0f
colors.getAlpha(
decorationAreaType,
modelStateInfoSnapshot.currModelState
) else 1.0f
translate(left = dx, top = dy) {
drawDoubleArrow(
drawScope = this,
Expand Down Expand Up @@ -148,7 +158,10 @@ fun AuroraBreadcrumbBar(commands: List<Command>, modifier: Modifier) {
val dx = (iconSize.toPx() - arrowDoubleWidth) / 2
val dy = (iconSize.toPx() - arrowDoubleHeight) / 2
val alpha = if (modelStateInfoSnapshot.currModelState.isDisabled)
colors.getAlpha(decorationAreaType, modelStateInfoSnapshot.currModelState) else 1.0f
colors.getAlpha(
decorationAreaType,
modelStateInfoSnapshot.currModelState
) else 1.0f
translate(left = dx, top = dy) {
drawDoubleArrow(
drawScope = this,
Expand Down
Expand Up @@ -46,7 +46,7 @@ fun main() = auroraApplication {

AuroraWindow(
skin = skin,
title = "Aurora Demo",
title = "Breadcrumb Bar Demo",
icon = radiance_menu(),
iconFilterStrategy = IconFilterStrategy.ThemedFollowText,
state = state,
Expand Down Expand Up @@ -79,7 +79,7 @@ fun AuroraApplicationScope.BreadcrumbContent(auroraSkinDefinition: MutableState<
}

Column(modifier = Modifier.fillMaxSize()) {
AuroraDecorationArea(decorationAreaType = DecorationAreaType.Toolbar) {
AuroraDecorationArea(decorationAreaType = DecorationAreaType.Header) {
AuroraBreadcrumbBar(
commands = commands,
modifier = Modifier.fillMaxWidth().auroraBackground()
Expand All @@ -94,7 +94,10 @@ fun AuroraApplicationScope.BreadcrumbContent(auroraSkinDefinition: MutableState<
.padding(horizontal = 6.dp, vertical = 4.dp)
) {
Spacer(modifier = Modifier.weight(1.0f, true))
AuroraSkinSwitcher(auroraSkinDefinition = auroraSkinDefinition)
AuroraSkinSwitcher(
auroraSkinDefinition = auroraSkinDefinition,
popupPlacementStrategy = PopupPlacementStrategy.Upward
)
}
}
}
Expand Down

0 comments on commit b9b7766

Please sign in to comment.