Skip to content

Commit

Permalink
More ribbon prototyping
Browse files Browse the repository at this point in the history
* Move action and popup key tips into command button presentation model
* Use `CommandButtonProjection at PresentationPriority` for adding command buttons to ribbon bands
* Use `RibbonGalleryProjection at PresentationPriority` for adding galleries to ribbon bands
* Add groups to ribbon bands
  • Loading branch information
kirill-grouchnikov committed Dec 13, 2022
1 parent 149193a commit 6065c1f
Show file tree
Hide file tree
Showing 40 changed files with 22,184 additions and 151 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ data class CommandButtonPresentationModel(
val textOverflow: TextOverflow = TextOverflow.Clip,
val popupPlacementStrategy: PopupPlacementStrategy = PopupPlacementStrategy.Downward.HAlignStart,
val toDismissPopupsOnActivation: Boolean = true,
val actionKeyTip: String? = null,
val popupKeyTip: String? = null,
val autoRepeatAction: Boolean = false,
val autoRepeatInitialInterval: Long = CommandButtonInteractionConstants.DefaultAutoRepeatInitialIntervalMillis,
val autoRepeatSubsequentInterval: Long = CommandButtonInteractionConstants.DefaultAutoRepeatSubsequentIntervalMillis,
Expand Down Expand Up @@ -87,6 +89,8 @@ data class CommandButtonPresentationModel(
val textOverflow: TextOverflow? = null,
val popupPlacementStrategy: PopupPlacementStrategy? = null,
val toDismissPopupsOnActivation: Boolean? = null,
val actionKeyTip: String? = null,
val popupKeyTip: String? = null,
val autoRepeatAction: Boolean? = null,
val autoRepeatInitialInterval: Long? = null,
val autoRepeatSubsequentInterval: Long? = null,
Expand Down Expand Up @@ -118,6 +122,8 @@ data class CommandButtonPresentationModel(
textOverflow = overlay.textOverflow ?: this.textOverflow,
popupPlacementStrategy = overlay.popupPlacementStrategy ?: this.popupPlacementStrategy,
toDismissPopupsOnActivation = overlay.toDismissPopupsOnActivation ?: this.toDismissPopupsOnActivation,
actionKeyTip = overlay.actionKeyTip ?: this.actionKeyTip,
popupKeyTip = overlay.popupKeyTip ?: this.popupKeyTip,
autoRepeatAction = overlay.autoRepeatAction ?: this.autoRepeatAction,
autoRepeatInitialInterval = overlay.autoRepeatInitialInterval ?: this.autoRepeatInitialInterval,
autoRepeatSubsequentInterval = overlay.autoRepeatSubsequentInterval ?: this.autoRepeatSubsequentInterval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import androidx.compose.ui.graphics.painter.Painter
import org.pushingpixels.aurora.component.model.*
import org.pushingpixels.aurora.component.projection.CommandButtonProjection
import org.pushingpixels.aurora.component.projection.Projection
import org.pushingpixels.aurora.theming.PopupPlacementStrategy

enum class PresentationPriority {
/** Top priority */
Expand All @@ -32,60 +31,17 @@ enum class PresentationPriority {
Low
}

data class RibbonCommandButtonPresentationModel(
val presentationPriority: PresentationPriority,
val popupPlacementStrategy: PopupPlacementStrategy = PopupPlacementStrategy.Downward.HAlignStart,
val popupMenuPresentationModel: CommandPopupMenuPresentationModel = CommandPopupMenuPresentationModel(),
val textClick: TextClick = TextClick.Action,
val actionRichTooltipPresentationModel: RichTooltipPresentationModel = RichTooltipPresentationModel(),
val popupRichTooltipPresentationModel: RichTooltipPresentationModel = RichTooltipPresentationModel(),
val actionKeyTip: String? = null,
val popupKeyTip: String? = null
) : PresentationModel {
data class Overlay(
val presentationPriority: PresentationPriority? = null,
val popupPlacementStrategy: PopupPlacementStrategy? = null,
val textClick: TextClick? = null,
val actionRichTooltipPresentationModel: RichTooltipPresentationModel? = null,
val popupRichTooltipPresentationModel: RichTooltipPresentationModel? = null,
val actionKeyTip: String? = null,
val popupKeyTip: String? = null
)

fun overlayWith(overlay: Overlay): RibbonCommandButtonPresentationModel {
return RibbonCommandButtonPresentationModel(
presentationPriority = overlay.presentationPriority ?: this.presentationPriority,
popupPlacementStrategy = overlay.popupPlacementStrategy ?: this.popupPlacementStrategy,
textClick = overlay.textClick ?: this.textClick,
actionRichTooltipPresentationModel = overlay.actionRichTooltipPresentationModel
?: this.actionRichTooltipPresentationModel,
popupRichTooltipPresentationModel = overlay.popupRichTooltipPresentationModel
?: this.popupRichTooltipPresentationModel,
actionKeyTip = overlay.actionKeyTip ?: this.actionKeyTip,
popupKeyTip = overlay.popupKeyTip ?: this.popupKeyTip
)
}
}
infix fun CommandButtonProjection.at(that: PresentationPriority):
Pair<CommandButtonProjection, PresentationPriority> = Pair(this, that)

data class RibbonComponentPresentationModel(
val basePresentationModel: PresentationModel,
val caption: String? = null,
val icon: Painter? = null,
val horizontalAlignment: HorizontalAlignment = HorizontalAlignment.Leading,
val keyTip: String? = null,
val isResizingAware: Boolean = false,
) : PresentationModel

fun PresentationModel.inRibbon(
horizontalAlignment: HorizontalAlignment = HorizontalAlignment.Leading,
keyTip: String? = null,
isResizingAware: Boolean = false
): RibbonComponentPresentationModel =
RibbonComponentPresentationModel(
basePresentationModel = this,
horizontalAlignment = horizontalAlignment,
keyTip = keyTip,
isResizingAware = isResizingAware
)

data class RibbonGalleryContentModel(
val icon: Painter? = null,
val commandGroups: List<CommandGroup>,
Expand All @@ -107,16 +63,10 @@ class RibbonGalleryProjection(
val presentationModel: RibbonGalleryPresentationModel
) : Projection<RibbonGalleryContentModel, RibbonGalleryPresentationModel>()

class RibbonCommandButtonProjection(
val contentModel: Command,
val presentationModel: RibbonCommandButtonPresentationModel,
val overlays: Map<Command, RibbonCommandButtonPresentationModel.Overlay>? = null
) : Projection<Command, RibbonCommandButtonPresentationModel>()

class RibbonComponentProjection(
val contentModel: Command,
val presentationModel: RibbonComponentPresentationModel
) : Projection<Command, RibbonComponentPresentationModel>()
class RibbonComponentProjection<out C: ContentModel, out P: PresentationModel>(
val projection: Projection<C, P>,
val ribbonComponentPresentationModel: RibbonComponentPresentationModel = RibbonComponentPresentationModel()
)

interface OnShowContextualMenuListener {
fun getContextualMenuContentModel(
Expand Down Expand Up @@ -154,7 +104,7 @@ data class Ribbon(
val contextualTaskGroups: List<RibbonContextualTaskGroup>?,
val anchoredCommands: List<CommandButtonProjection>?,
val taskbarCommandProjections: List<RibbonTaskbarCommandButtonProjection> = emptyList(),
val taskbarComponentProjections: List<RibbonComponentProjection> = emptyList(),
val taskbarComponentProjections: List<RibbonComponentProjection<ContentModel, PresentationModel>> = emptyList(),
val taskbarGalleryProjections: List<RibbonGalleryProjection> = emptyList(),
val taskbarKeyTipPolicy: RibbonTaskbarKeyTipPolicy,
val applicationMenuCommandButtonProjection: RibbonApplicationMenuCommandButtonProjection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.LayoutDirection
import org.pushingpixels.aurora.component.layout.CommandButtonLayoutManager
import org.pushingpixels.aurora.component.layout.CommandButtonLayoutManagerBig
import org.pushingpixels.aurora.component.model.Command
import org.pushingpixels.aurora.component.model.CommandButtonPresentationState
import org.pushingpixels.aurora.component.model.ContentModel
import org.pushingpixels.aurora.component.model.PresentationModel
import org.pushingpixels.aurora.component.projection.CommandButtonProjection
import org.pushingpixels.aurora.component.ribbon.resize.CoreRibbonResizePolicies
import org.pushingpixels.aurora.component.ribbon.resize.RibbonBandResizePolicy

Expand All @@ -36,6 +38,16 @@ sealed interface AbstractRibbonBand {
val resizePolicies: List<RibbonBandResizePolicy>
}

infix fun RibbonGalleryProjection.at(that: PresentationPriority):
Pair<RibbonGalleryProjection, PresentationPriority> = Pair(this, that)

data class RibbonBandGroup(
val title: String? = null,
val commandProjections: List<Pair<CommandButtonProjection, PresentationPriority>> = emptyList(),
val componentProjections: List<RibbonComponentProjection<ContentModel, PresentationModel>> = emptyList(),
val galleryProjections: List<Pair<RibbonGalleryProjection, PresentationPriority>> = emptyList(),
)

data class RibbonBand(
override val title: String,
override val icon: Painter? = null,
Expand All @@ -44,9 +56,7 @@ data class RibbonBand(
override val collapsedStateKeyTip: String? = null,
override val resizePolicies: List<RibbonBandResizePolicy> =
CoreRibbonResizePolicies.getCorePoliciesPermissive(),
val commandProjections: List<RibbonCommandButtonProjection> = emptyList(),
val componentProjections: List<RibbonComponentProjection> = emptyList(),
val galleryProjections: List<RibbonGalleryProjection> = emptyList(),
val groups: List<RibbonBandGroup> = emptyList()
) : AbstractRibbonBand

data class FlowRibbonBand(
Expand All @@ -57,7 +67,7 @@ data class FlowRibbonBand(
override val collapsedStateKeyTip: String? = null,
override val resizePolicies: List<RibbonBandResizePolicy> =
CoreRibbonResizePolicies.getCoreFlowPoliciesRestrictive(3),
val flowComponentProjections: List<RibbonComponentProjection> = emptyList()
val flowComponentProjections: List<RibbonComponentProjection<ContentModel, PresentationModel>> = emptyList()
) : AbstractRibbonBand

object RibbonBandCommandButtonPresentationStates {
Expand Down
Loading

0 comments on commit 6065c1f

Please sign in to comment.