Compare commits
2 Commits
f1556175db
...
3b99cad32b
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b99cad32b | |||
| 41e08b18a7 |
|
|
@ -127,9 +127,27 @@ func (m *ModuleTile) Dropped(pos fyne.Position, items []fyne.URI) {
|
|||
}
|
||||
}
|
||||
|
||||
// getContrastColor returns black or white text color based on background brightness
|
||||
func getContrastColor(bgColor color.Color) color.Color {
|
||||
r, g, b, _ := bgColor.RGBA()
|
||||
// Convert from 16-bit to 8-bit
|
||||
r8 := float64(r >> 8)
|
||||
g8 := float64(g >> 8)
|
||||
b8 := float64(b >> 8)
|
||||
|
||||
// Calculate relative luminance (WCAG formula)
|
||||
luminance := (0.2126*r8 + 0.7152*g8 + 0.0722*b8) / 255.0
|
||||
|
||||
// If bright background, use dark text; if dark background, use light text
|
||||
if luminance > 0.5 {
|
||||
return color.NRGBA{R: 20, G: 20, B: 20, A: 255} // Dark text
|
||||
}
|
||||
return TextColor // Light text
|
||||
}
|
||||
|
||||
func (m *ModuleTile) CreateRenderer() fyne.WidgetRenderer {
|
||||
tileColor := m.color
|
||||
labelColor := TextColor
|
||||
labelColor := getContrastColor(m.color)
|
||||
|
||||
// Dim disabled tiles
|
||||
if !m.enabled {
|
||||
|
|
@ -137,9 +155,7 @@ func (m *ModuleTile) CreateRenderer() fyne.WidgetRenderer {
|
|||
if c, ok := m.color.(color.NRGBA); ok {
|
||||
tileColor = color.NRGBA{R: c.R / 3, G: c.G / 3, B: c.B / 3, A: c.A}
|
||||
}
|
||||
if c, ok := TextColor.(color.NRGBA); ok {
|
||||
labelColor = color.NRGBA{R: c.R / 2, G: c.G / 2, B: c.B / 2, A: c.A}
|
||||
}
|
||||
labelColor = color.NRGBA{R: 100, G: 100, B: 100, A: 255}
|
||||
}
|
||||
|
||||
bg := canvas.NewRectangle(tileColor)
|
||||
|
|
|
|||
9
main.go
9
main.go
|
|
@ -9158,9 +9158,11 @@ Metadata: %s`,
|
|||
return container.NewHBox(keyLabel, valueLabel)
|
||||
}
|
||||
|
||||
// Filename gets its own full-width row to prevent overlap
|
||||
fileRow := makeRow("File", src.DisplayName)
|
||||
|
||||
// Organize metadata into a compact two-column grid
|
||||
col1 := container.NewVBox(
|
||||
makeRow("File", src.DisplayName),
|
||||
makeRow("Format", utils.FirstNonEmpty(src.Format, "Unknown")),
|
||||
makeRow("Resolution", fmt.Sprintf("%dx%d", src.Width, src.Height)),
|
||||
makeRow("Aspect Ratio", src.AspectRatioString()),
|
||||
|
|
@ -9187,7 +9189,10 @@ Metadata: %s`,
|
|||
|
||||
// Add spacing between the two columns
|
||||
spacer := layout.NewSpacer()
|
||||
info := container.NewHBox(col1, spacer, col2)
|
||||
twoColGrid := container.NewHBox(col1, spacer, col2)
|
||||
|
||||
// Combine filename row with two-column grid
|
||||
info := container.NewVBox(fileRow, twoColGrid)
|
||||
|
||||
// Copy metadata button - beside header text
|
||||
copyBtn := widget.NewButton("📋", func() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user