This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch main
in repository ego.

View the commit online.

commit c1239e6c3271b15d76231d7b1a1da20e39dc0906
Author: [email protected] <[email protected]>
AuthorDate: Wed Apr 1 18:48:33 2026 -0600

    fix(ego-docgen): set default text on all text-capable widgets
    
    Always try to set a humanized widget name on text parts (efl.text,
    elm.text) so screenshots show meaningful labels. Widgets like
    frame, alert_popup, and list_item now display their name.
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
 cmd/ego-docgen/main.go             |  18 +++++++++++-----
 cmd/ego-docgen/widgets.go          |  43 +++++++++++++++++++++++++++++++------
 docs/widgets/grid_item/default.png | Bin 810 -> 774 bytes
 docs/widgets/list_item/default.png | Bin 521 -> 519 bytes
 docs/widgets/tab_bar/tab.png       | Bin 488 -> 783 bytes
 5 files changed, 49 insertions(+), 12 deletions(-)

diff --git a/cmd/ego-docgen/main.go b/cmd/ego-docgen/main.go
index 5bfaedc..5becc19 100644
--- a/cmd/ego-docgen/main.go
+++ b/cmd/ego-docgen/main.go
@@ -193,12 +193,20 @@ func renderWidget(ws WidgetStyle, cfg WidgetConfig, themePath string) (*image.NR
 		return nil, fmt.Errorf("edje_object_file_set failed for group %q", ws.Group)
 	}
 
-	// Set label text on the first matching text part.
-	if cfg.Text != "" {
-		cText := C.CString(cfg.Text)
+	// Resolve the label text: use the explicit config value when provided,
+	// otherwise derive a human-readable label from the widget name so that
+	// screenshots always show meaningful content rather than blank parts.
+	labelText := cfg.Text
+	if labelText == "" {
+		labelText = humanize(ws.Widget)
+	}
+
+	// Set label text on the first matching text part, trying EFL-style part
+	// names before falling back to legacy elm-style names.
+	{
+		cText := C.CString(labelText)
 		defer C.free(unsafe.Pointer(cText))
-		// Try the EFL-style part first, then the legacy elm-style part.
-		for _, partName := range []string{"efl.text", "elm.text", "efl.text.main", "elm.text.main"} {
+		for _, partName := range []string{"efl.text", "elm.text", "efl.text.title", "elm.text.main", "efl.text.main"} {
 			cPart := C.CString(partName)
 			if C.ego_part_text_set(obj, cPart, cText) != 0 {
 				C.free(unsafe.Pointer(cPart))
diff --git a/cmd/ego-docgen/widgets.go b/cmd/ego-docgen/widgets.go
index 738e41b..4dac88b 100644
--- a/cmd/ego-docgen/widgets.go
+++ b/cmd/ego-docgen/widgets.go
@@ -1,5 +1,7 @@
 package main
 
+import "strings"
+
 // WidgetConfig holds rendering hints for a specific widget type.  The values
 // are used when creating the headless buffer window that the Edje object is
 // loaded into.
@@ -23,20 +25,22 @@ var defaultConfig = WidgetConfig{
 
 // widgetConfigs maps a widget base name (as parsed from the EDJ group by
 // parseGroup) to its rendering configuration.  Entries are only needed when
-// the default 200×100 size or empty text is not appropriate.
+// the default 200×100 size or an explicit text override is required.
+//
+// Text fields are omitted when the humanized widget name (see humanize) is
+// a good-enough label; renderWidget will set it automatically via the
+// fallback text logic.  Only set Text here when a value that differs from
+// the humanized name is needed (numeric values, abbreviated labels, etc.).
 var widgetConfigs = map[string]WidgetConfig{
 	"button": {
-		Text:   "Button",
 		Width:  160,
 		Height: 48,
 	},
 	"check": {
-		Text:   "Check",
 		Width:  160,
 		Height: 48,
 	},
 	"radio": {
-		Text:   "Radio",
 		Width:  160,
 		Height: 48,
 	},
@@ -50,6 +54,8 @@ var widgetConfigs = map[string]WidgetConfig{
 		Height:   60,
 		Progress: 0.6,
 	},
+	// spin and spin_button use numeric override text — humanized name is
+	// not meaningful as a value display.
 	"spin": {
 		Text:   "42",
 		Width:  160,
@@ -70,7 +76,6 @@ var widgetConfigs = map[string]WidgetConfig{
 		Height: 320,
 	},
 	"frame": {
-		Text:   "Frame",
 		Width:  220,
 		Height: 140,
 	},
@@ -86,6 +91,7 @@ var widgetConfigs = map[string]WidgetConfig{
 		Width:  200,
 		Height: 24,
 	},
+	// text widget needs a descriptive phrase rather than just "Text".
 	"text": {
 		Text:   "Sample text",
 		Width:  240,
@@ -95,6 +101,7 @@ var widgetConfigs = map[string]WidgetConfig{
 		Width:  240,
 		Height: 140,
 	},
+	// popup and alert_popup carry message-style override labels.
 	"popup": {
 		Text:   "Popup message",
 		Width:  280,
@@ -125,11 +132,13 @@ var widgetConfigs = map[string]WidgetConfig{
 		Width:  300,
 		Height: 200,
 	},
+	// tags uses a short example tag value rather than the widget name.
 	"tags": {
 		Text:   "tag1",
 		Width:  240,
 		Height: 60,
 	},
+	// textpath overrides with a descriptive phrase that suits a path layout.
 	"textpath": {
 		Text:   "Path text",
 		Width:  240,
@@ -139,6 +148,8 @@ var widgetConfigs = map[string]WidgetConfig{
 		Width:  260,
 		Height: 200,
 	},
+	// navigation_bar abbreviates the humanized "Navigation Bar" to match
+	// typical header bar length constraints in the theme.
 	"navigation_bar": {
 		Text:   "Navigation",
 		Width:  320,
@@ -153,7 +164,6 @@ var widgetConfigs = map[string]WidgetConfig{
 		Height: 200,
 	},
 	"list_item": {
-		Text:   "List item",
 		Width:  240,
 		Height: 48,
 	},
@@ -166,10 +176,11 @@ var widgetConfigs = map[string]WidgetConfig{
 		Height: 200,
 	},
 	"grid_item": {
-		Text:   "Grid item",
 		Width:  120,
 		Height: 120,
 	},
+	// group_item abbreviates the humanized "Group Item" to just "Group"
+	// because the item row already implies the "item" context visually.
 	"group_item": {
 		Text:   "Group",
 		Width:  240,
@@ -197,3 +208,21 @@ func configFor(widget string) WidgetConfig {
 	}
 	return defaultConfig
 }
+
+// humanize converts a snake_case widget name into Title Case words suitable
+// for use as a default display label in screenshots.
+//
+// Examples:
+//
+//	"button"       → "Button"
+//	"spin_button"  → "Spin Button"
+//	"alert_popup"  → "Alert Popup"
+func humanize(name string) string {
+	parts := strings.Split(name, "_")
+	for i, p := range parts {
+		if len(p) > 0 {
+			parts[i] = strings.ToUpper(p[:1]) + p[1:]
+		}
+	}
+	return strings.Join(parts, " ")
+}
diff --git a/docs/widgets/grid_item/default.png b/docs/widgets/grid_item/default.png
index a8166a9..9fde318 100644
Binary files a/docs/widgets/grid_item/default.png and b/docs/widgets/grid_item/default.png differ
diff --git a/docs/widgets/list_item/default.png b/docs/widgets/list_item/default.png
index 26d2cf1..0b122d8 100644
Binary files a/docs/widgets/list_item/default.png and b/docs/widgets/list_item/default.png differ
diff --git a/docs/widgets/tab_bar/tab.png b/docs/widgets/tab_bar/tab.png
index 7352764..8937c70 100644
Binary files a/docs/widgets/tab_bar/tab.png and b/docs/widgets/tab_bar/tab.png differ

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to