Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
meikpiep committed Jan 6, 2025
1 parent d57a751 commit cd2540a
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 36 deletions.
53 changes: 40 additions & 13 deletions gauguin-app/src/main/kotlin/org/piepmeyer/gauguin/ui/grid/GridUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,47 @@ class GridUI :
val maximumWidth = (gridSize.width * maximumCellSizeInDP * resources.displayMetrics.density).toInt()
val maximumHeight = (gridSize.height * maximumCellSizeInDP * resources.displayMetrics.density).toInt()

return when {
widthMode == MeasureSpec.UNSPECIFIED && heightMode == MeasureSpec.UNSPECIFIED ->
Pair(maximumWidth, maximumHeight)
widthMode == MeasureSpec.EXACTLY && heightMode == MeasureSpec.EXACTLY ->
Pair(widthSize, heightSize)
else -> {
val cellSize = potentialCellSize(widthSize, heightSize)

Pair(
min(widthSize, cellSize.first * gridSize.width),
min(heightSize, cellSize.second * gridSize.height),
)
println("on measure: $widthMode x $heightMode")
println("on measure2: $widthSize x $heightSize")

val measured =
when {
widthMode == MeasureSpec.UNSPECIFIED && heightMode == MeasureSpec.UNSPECIFIED -> {
println("both unspecified: $maximumWidth x $maximumHeight")

Pair(maximumWidth, maximumHeight)
}
widthMode == MeasureSpec.EXACTLY && heightMode == MeasureSpec.EXACTLY -> {
println("both exectly: $widthSize x $heightSize")

Pair(widthSize, heightSize)
}
/*widthMode == MeasureSpec.EXACTLY && heightMode == MeasureSpec.AT_MOST -> {
println("most: $widthSize x $heightSize")
Pair(widthSize, min(widthSize, heightSize))
}*/
else -> {
val cellSize = potentialCellSize(widthSize, heightSize)

println("else with cellSize $cellSize")
println(
"else with ${min(
widthSize,
cellSize.first * gridSize.width,
)} x ${min(heightSize, cellSize.second * gridSize.height)}",
)

Pair(
min(widthSize, cellSize.first * gridSize.width),
min(heightSize, cellSize.second * gridSize.height),
)
}
}
}

println("measured: ${measured.first} x ${measured.second}")

return measured
}

override fun onSizeChanged(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<FrameLayout
android:id="@+id/bottomSheet"
style="@style/Widget.Material3.BottomSheet"
app:backgroundTint="?attr/colorSurfaceVariant"
android:layout_width="match_parent"
android:layout_height="500dp"
android:orientation="horizontal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,42 @@
android:layout_height="match_parent"
android:layout_width="match_parent" >

<org.piepmeyer.gauguin.ui.grid.GridUI
android:id="@+id/newGridPreview"
android:transitionName="grid"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/newGameSizeCardView"
/>

<com.google.android.material.card.MaterialCardView
android:id="@+id/newGameSizeCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintHeight_max="100dp"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/newGameNewAlgorithmSwitch"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
style="?attr/materialCardViewElevatedStyle">
style="?attr/materialCardViewFilledStyle">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
>

<org.piepmeyer.gauguin.ui.grid.GridUI
android:id="@+id/newGridPreview"
android:transitionName="grid"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/widthslider"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
/>

<com.google.android.material.button.MaterialButtonToggleGroup
android:id="@+id/squareRectangularToggleGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="@id/widthslider"
app:layout_constraintBottom_toBottomOf="@id/heigthslider"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:singleSelection="true"
app:selectionRequired="true"
>
Expand All @@ -68,7 +67,9 @@
android:layout_height="wrap_content"
app:layout_constraintStart_toEndOf="@id/squareRectangularToggleGroup"
app:layout_constraintEnd_toStartOf="@id/newGameGridSize"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toBottomOf="@id/newGridPreview"
app:layout_constraintBottom_toTopOf="@id/heigthslider"
android:layout_marginTop="16dp"
android:valueFrom="3.0"
android:valueTo="11.0"
android:stepSize="1.0"/>
Expand All @@ -91,9 +92,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toBottomOf="@id/newGridPreview"
app:layout_constraintBottom_toBottomOf="parent"
/>

Expand Down

0 comments on commit cd2540a

Please sign in to comment.