diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/orgflow-ui/src/commonMain/kotlin/jp/orgflow/web/PieMenu.kt | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/modules/orgflow-ui/src/commonMain/kotlin/jp/orgflow/web/PieMenu.kt b/modules/orgflow-ui/src/commonMain/kotlin/jp/orgflow/web/PieMenu.kt index 5bca08c..e7be9af 100644 --- a/modules/orgflow-ui/src/commonMain/kotlin/jp/orgflow/web/PieMenu.kt +++ b/modules/orgflow-ui/src/commonMain/kotlin/jp/orgflow/web/PieMenu.kt @@ -277,7 +277,7 @@ fun PieMenu( // ここで切り替えること。ハブを5つ目の扇のように塗らない事。 Text("W", color = cal.pieInk, fontWeight = FontWeight.Bold) // 項目名を円の中に置く。外側に置くとどの扇の名前か分からない。 - PieInDiscLabels(items, touched, cal.pieInk) + PieInDiscLabels(items, angles, touched, cal.pieInk) } } @@ -307,7 +307,12 @@ fun PieMenu( * 並び順に応じて 45 度ずらす**項目数を検査する。 */ @Composable -private fun PieInDiscLabels(items: List<PieItem>, touched: Int, ink: Color) { +private fun PieInDiscLabels( + items: List<PieItem>, + angles: List<Float>, + touched: Int, + ink: Color, +) { val n = items.size if (n == 0) return @@ -336,9 +341,17 @@ private fun PieInDiscLabels(items: List<PieItem>, touched: Int, ink: Color) { val cx0 = maxWidth.value / 2.0 val cy0 = maxHeight.value / 2.0 val half = boxW.value / 2.0 - val stepDeg = 360.0 / n for (i in items.indices) { - val ang = (i * stepDeg - 90.0) * PI / 180.0 + // The wedge for item i is drawn at angles[i] (see distributeAngles, + // which starts at 0 and steps clockwise). The label must use the SAME + // angle, not one derived from the index. + // + // 2026-10-05: this line was `i * (360.0/n) - 90.0`, which produced a + // constant quarter-turn offset -- measured label means were + // 45.9 / 130.3 / 209.1 / 319.9 degrees against wedge centres of + // 0 / 90 / 180 / 270, so every label landed one quadrant away, on a + // separator, no matter how the offset was tuned. + val ang = (angles.getOrNull(i) ?: (i * 360f / n)) * PI.toFloat() / 180f val it = items[i] Box( Modifier.offset( |
