feat: make overlay caption bubble width fixed and left-align text
Set a fixed width on the caption bubble via `gtk_widget_set_size_request()` using the effective width parameter, and change label alignment from center to left with fill halign. Update the `--overlay-max-width` help text and README description to reflect the new fixed-width behavior (still capped at 80% of monitor width).
This commit is contained in:
@@ -106,7 +106,7 @@ Layer Shell and X11 hints are requests, not universal guarantees. Same-layer win
|
||||
| `--overlay-opacity=0.90` | `0.90` | Dark bubble opacity from `0` to `1`. |
|
||||
| `--overlay-font-size=28` | `28` | Font size in logical pixels. |
|
||||
| `--overlay-bottom-margin=100` | `100` | Bottom margin in logical pixels. |
|
||||
| `--overlay-max-width=1200` | `1200` | Width cap; the overlay also limits itself to 80% of the selected monitor. |
|
||||
| `--overlay-max-width=1200` | `1200` | Fixed caption-bubble width; it is capped at 80% of the selected monitor. |
|
||||
| `--overlay-monitor=auto` | `auto` | `auto`, a zero-based monitor index, or a connector name such as `DP-1`. |
|
||||
| `--overlay-final-timeout=4s` | `4s` | Time before the final row disappears. `0s` keeps it until replaced or hidden. |
|
||||
| `--overlay-click-through=true` | `true` | Use an empty input region where the display backend supports it. |
|
||||
|
||||
@@ -86,7 +86,7 @@ func ParseDesktop() DesktopSettings {
|
||||
flags.Float64Var(&desktop.Overlay.Opacity, "overlay-opacity", 0.90, "caption background opacity from 0 to 1")
|
||||
flags.IntVar(&desktop.Overlay.FontSize, "overlay-font-size", 28, "caption font size in logical pixels")
|
||||
flags.IntVar(&desktop.Overlay.BottomMargin, "overlay-bottom-margin", 100, "distance from the monitor bottom in logical pixels")
|
||||
flags.IntVar(&desktop.Overlay.MaxWidth, "overlay-max-width", 1200, "maximum caption width in logical pixels")
|
||||
flags.IntVar(&desktop.Overlay.MaxWidth, "overlay-max-width", 1200, "fixed caption width in logical pixels before the monitor safety cap")
|
||||
flags.StringVar(&desktop.Overlay.Monitor, "overlay-monitor", "auto", "monitor selection: auto, numeric index, or connector name")
|
||||
flags.DurationVar(&desktop.Overlay.FinalTimeout, "overlay-final-timeout", 4*time.Second, "how long a final caption remains; zero waits for replacement")
|
||||
flags.BoolVar(&desktop.Overlay.ClickThrough, "overlay-click-through", true, "pass pointer input through the caption window")
|
||||
|
||||
@@ -344,19 +344,20 @@ static CaptioneerOverlay *captioneer_overlay_new(
|
||||
overlay->bubble = box;
|
||||
gtk_widget_add_css_class(box, "captioneer-bubble");
|
||||
gtk_widget_set_halign(box, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_size_request(box, effective_width, -1);
|
||||
|
||||
overlay->final_label = gtk_label_new("");
|
||||
overlay->preview_label = gtk_label_new("");
|
||||
GtkWidget *labels[] = {overlay->final_label, overlay->preview_label};
|
||||
for (guint i = 0; i < G_N_ELEMENTS(labels); i++) {
|
||||
gtk_label_set_justify(GTK_LABEL(labels[i]), GTK_JUSTIFY_CENTER);
|
||||
gtk_label_set_xalign(GTK_LABEL(labels[i]), 0.5f);
|
||||
gtk_label_set_justify(GTK_LABEL(labels[i]), GTK_JUSTIFY_LEFT);
|
||||
gtk_label_set_xalign(GTK_LABEL(labels[i]), 0.0f);
|
||||
gtk_label_set_wrap(GTK_LABEL(labels[i]), TRUE);
|
||||
gtk_label_set_wrap_mode(GTK_LABEL(labels[i]), PANGO_WRAP_WORD_CHAR);
|
||||
gtk_label_set_lines(GTK_LABEL(labels[i]), 2);
|
||||
gtk_label_set_ellipsize(GTK_LABEL(labels[i]), PANGO_ELLIPSIZE_END);
|
||||
gtk_label_set_max_width_chars(GTK_LABEL(labels[i]), max_chars);
|
||||
gtk_widget_set_halign(labels[i], GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_halign(labels[i], GTK_ALIGN_FILL);
|
||||
gtk_box_append(GTK_BOX(box), labels[i]);
|
||||
gtk_widget_set_visible(labels[i], FALSE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user