Skip to content

Commit

Permalink
First pass for level 2 tile command menu buttons
Browse files Browse the repository at this point in the history
One line of text and 2 lines of extra text

For #56
  • Loading branch information
kirill-grouchnikov committed Feb 14, 2023
1 parent e8c501c commit 4310188
Show file tree
Hide file tree
Showing 5 changed files with 758 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ internal fun <M : BaseCommandMenuContentModel,
for (extraText in preLayoutInfo.extraTexts) {
CommandButtonExtraTextContent(
extraText, modelStateInfoForText, currStateForText, resolvedTextStyle,
presentationModel.textOverflow
presentationModel.textOverflow, layoutManager.getExtraTextMaxLines()
)
}

Expand Down Expand Up @@ -1581,7 +1581,7 @@ private fun CommandButtonTextContent(
@Composable
private fun CommandButtonExtraTextContent(
text: String, modelStateInfo: ModelStateInfo, currState: ComponentState,
style: TextStyle, overflow: TextOverflow
style: TextStyle, overflow: TextOverflow, maxLines: Int
) {
val decorationAreaType = AuroraSkin.decorationAreaType
val skinColors = AuroraSkin.colors
Expand Down Expand Up @@ -1627,7 +1627,7 @@ private fun CommandButtonExtraTextContent(
text = text,
color = disabledFgColor,
style = style,
maxLines = 1,
maxLines = maxLines,
overflow = overflow
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ interface CommandButtonLayoutManager : MeasureScope {
presentationModel: BaseCommandButtonPresentationModel
): CommandButtonPreLayoutInfo

fun getExtraTextMaxLines() : Int = 1

/**
* Returns the preferred size of a projected button for the specified parameters.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,17 @@ import androidx.compose.foundation.layout.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.Paragraph
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.*
import org.pushingpixels.aurora.component.layout.CommandButtonLayoutManager
import org.pushingpixels.aurora.component.layout.CommandButtonLayoutManagerTile
import org.pushingpixels.aurora.component.model.*
import org.pushingpixels.aurora.component.projection.BaseCommandButtonProjection
import org.pushingpixels.aurora.component.utils.appmenu.CommandButtonLayoutManagerAppMenuLevel2
import org.pushingpixels.aurora.component.utils.appmenu.CommandButtonLayoutManagerRibbonApplicationMenuButton
import org.pushingpixels.aurora.component.utils.popup.RibbonApplicationMenuPopupHandler
import org.pushingpixels.aurora.theming.*
import org.pushingpixels.aurora.theming.colorscheme.AuroraColorScheme

data class RibbonApplicationMenuContentModel(
val groups: List<CommandGroup>,
Expand Down Expand Up @@ -82,7 +77,7 @@ object RibbonApplicationMenuButtonPresentationStates {
textStyle: TextStyle,
fontFamilyResolver: FontFamily.Resolver
): CommandButtonLayoutManager {
return CommandButtonLayoutManagerTile(
return CommandButtonLayoutManagerAppMenuLevel2(
layoutDirection,
density,
textStyle,
Expand All @@ -94,7 +89,9 @@ object RibbonApplicationMenuButtonPresentationStates {

object RibbonApplicationMenuSizingConstants {
val DefaultFooterContentPadding = PaddingValues(start = 12.dp, top = 6.dp, end = 12.dp, bottom = 6.dp)
val DefaultLevel2PanelWidth = 240.dp
val DefaultLevel2PanelWidth = 320.dp
val DefaultLevel1ItemContentPadding = PaddingValues(start = 8.dp, top = 6.dp, end = 8.dp, bottom = 6.dp)
val DefaultLevel2ItemContentPadding = PaddingValues(start = 8.dp, top = 6.dp, end = 8.dp, bottom = 6.dp)
}

data class RibbonApplicationMenuCommandPopupMenuPresentationModel(
Expand All @@ -103,10 +100,11 @@ data class RibbonApplicationMenuCommandPopupMenuPresentationModel(
val itemIconActiveFilterStrategy: IconFilterStrategy = IconFilterStrategy.Original,
val itemIconEnabledFilterStrategy: IconFilterStrategy = IconFilterStrategy.Original,
val itemIconDisabledFilterStrategy: IconFilterStrategy = IconFilterStrategy.ThemedFollowColorScheme,
val itemContentPadding: PaddingValues = CommandButtonSizingConstants.CompactButtonContentPadding,
val itemHorizontalAlignment: HorizontalAlignment = HorizontalAlignment.Fill,
val footerContentPadding: PaddingValues = RibbonApplicationMenuSizingConstants.DefaultFooterContentPadding,
val level2PanelWidth: Dp = RibbonApplicationMenuSizingConstants.DefaultLevel2PanelWidth
val level2PanelWidth: Dp = RibbonApplicationMenuSizingConstants.DefaultLevel2PanelWidth,
val level1ItemContentPadding: PaddingValues = RibbonApplicationMenuSizingConstants.DefaultLevel1ItemContentPadding,
val level2ItemContentPadding: PaddingValues = RibbonApplicationMenuSizingConstants.DefaultLevel2ItemContentPadding
) : BaseCommandPopupMenuPresentationModel

data class RibbonApplicationMenuCommandButtonPresentationModel(
Expand All @@ -115,7 +113,7 @@ data class RibbonApplicationMenuCommandButtonPresentationModel(
override val popupMenuPresentationModel: RibbonApplicationMenuCommandPopupMenuPresentationModel =
RibbonApplicationMenuCommandPopupMenuPresentationModel(
itemPresentationState = CommandButtonPresentationState.Tile,
itemContentPadding = PaddingValues(horizontal = 6.dp, vertical = 8.dp)
level1ItemContentPadding = PaddingValues(horizontal = 6.dp, vertical = 8.dp)
),
override val popupPlacementStrategy: PopupPlacementStrategy = PopupPlacementStrategy.Downward.HAlignStart,
override val popupKeyTip: String? = null,
Expand Down
Loading

0 comments on commit 4310188

Please sign in to comment.