Skip to content

Commit

Permalink
More ribbon API prototyping
Browse files Browse the repository at this point in the history
For #56
  • Loading branch information
kirill-grouchnikov committed Dec 14, 2022
1 parent 6065c1f commit c3bd7cc
Show file tree
Hide file tree
Showing 11 changed files with 5,614 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ 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.projection.Projection
import org.pushingpixels.aurora.component.ribbon.resize.CoreRibbonResizePolicies
import org.pushingpixels.aurora.component.ribbon.resize.RibbonBandResizePolicy

Expand All @@ -41,10 +42,13 @@ sealed interface AbstractRibbonBand {
infix fun RibbonGalleryProjection.at(that: PresentationPriority):
Pair<RibbonGalleryProjection, PresentationPriority> = Pair(this, that)

infix fun <C: ContentModel, P: PresentationModel> Projection<C, P>.with(that: RibbonComponentPresentationModel):
Pair<Projection<C, P>, RibbonComponentPresentationModel> = 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 componentProjections: List<Pair<Projection<ContentModel, PresentationModel>, RibbonComponentPresentationModel>> = emptyList(),
val galleryProjections: List<Pair<RibbonGalleryProjection, PresentationPriority>> = emptyList(),
)

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

object RibbonBandCommandButtonPresentationStates {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ object CoreRibbonResizeSequencingPolicies {
*
* @author Kirill Grouchnikov
*/
class RoundRobin() : RibbonBandResizeSequencingPolicy {
class RoundRobin : RibbonBandResizeSequencingPolicy {
// The index of the next ribbon task for collapsing.
private var nextIndex = 0

Expand All @@ -56,4 +56,26 @@ object CoreRibbonResizeSequencingPolicies {
return result
}
}

class CollapseFromLast: RibbonBandResizeSequencingPolicy {
// The index of the next ribbon task for collapsing.
private var nextIndex = 0

override fun reset(ribbonTask: RibbonTask) {
nextIndex = ribbonTask.bands.size - 1
}

override fun next(ribbonTask: RibbonTask): AbstractRibbonBand {
val result: AbstractRibbonBand = ribbonTask.bands[nextIndex]

// check whether the current resize policy on the returned ribbon
// band is the last
val resizePolicies: List<RibbonBandResizePolicy> = result.resizePolicies
// if (result.getCurrentResizePolicy() === resizePolicies[resizePolicies.size - 1]) {
// nextIndex--
// if (nextIndex < 0) nextIndex = 0
// }
return result
}
}
}

Large diffs are not rendered by default.

Loading

0 comments on commit c3bd7cc

Please sign in to comment.