themes and styles

This commit is contained in:
IliaDenisov
2026-03-08 15:31:17 +02:00
parent e37a67bc99
commit 1c2fc30127
39 changed files with 2693 additions and 199 deletions
+27
View File
@@ -205,3 +205,30 @@ func (t *StyleTable) AddDerived(baseID StyleID, override StyleOverride) StyleID
t.styles[id] = derived
return id
}
// AddStyle stores a fully resolved style as a new StyleID.
// It defensively copies slice fields.
func (t *StyleTable) AddStyle(s Style) StyleID {
t.mu.Lock()
defer t.mu.Unlock()
id := t.nextID
t.nextID++
if s.StrokeDashes != nil {
cp := make([]float64, len(s.StrokeDashes))
copy(cp, s.StrokeDashes)
s.StrokeDashes = cp
}
t.styles[id] = s
return id
}
// Count returns the number of styles stored in the table.
// Intended for tests/diagnostics.
func (t *StyleTable) Count() int {
t.mu.RLock()
defer t.mu.RUnlock()
return len(t.styles)
}