Skip to content

RediWM is a Wayland compositor written in Zig (OpenGL ES) that includes everything in one process

appearance: break the 610-line build into section builders

Claude5c33dcc13b8d
diff --git a/src/control_center/sections/appearance.zig b/src/control_center/sections/appearance.zig
index cfe2988..b8f0d1f 100644
--- a/src/control_center/sections/appearance.zig
+++ b/src/control_center/sections/appearance.zig
@@ -16,6 +16,7 @@ const main = @import("../../main.zig");
const panel = @import("../panel.zig");
const loader = @import("config").loader;
const Taskbar = @import("../../Taskbar.zig");
+const Server = @import("../../Server.zig");
const dock_mod = @import("../../Dock.zig");
const taskbar_items = @import("config").taskbar_items;
const cursor_theme = @import("../../cursor_theme.zig");
@@ -466,555 +467,32 @@ pub fn build(out: *Section, cc: *panel.ControlCenter) void {
const server = out.cc.server;
const arena = out.arena.allocator();
- out.presets = theme_presets.list(arena, out.cc.server.io, out.cc.server.environ, out.cc.server.config.path) catch &.{};
- var preset_labels: [][]const u8 = &.{};
- var matched_index: ?usize = null;
- if (arena.alloc([]const u8, out.presets.len)) |labels| {
- preset_labels = labels;
- for (out.presets, 0..) |preset, i| {
- preset_labels[i] = preset.name;
- if (std.mem.eql(u8, preset.id, out.cc.server.config.theme_base)) matched_index = i;
- }
- } else |_| {}
- out.theme_row_children = .{
- labelWidget(i18n.tr("Theme")),
- .{
- .name = "theme",
- .kind = .{ .select = .{
- .labels = preset_labels,
- .selected = matched_index,
- .placeholder = i18n.tr("Custom"),
- .disabled = preset_labels.len == 0,
- .owner = out,
- .on_change = &onThemePicked,
- } },
- .width = .{ .fixed = segmented_width },
- },
- };
-
- // The same presets for the taskbar alone, led by a choice that follows
- // the theme above. Its tokens are compared, not the whole theme.
- var taskbar_labels: [][]const u8 = &.{};
- var taskbar_selected: ?usize = null;
- if (arena.alloc([]const u8, out.presets.len + 1)) |labels| {
- taskbar_labels = labels;
- labels[0] = i18n.tr("Same as theme");
- if (theme.taskbar_override == null) taskbar_selected = 0;
- for (out.presets, 1..) |preset, i| {
- labels[i] = preset.name;
- const chosen = theme.taskbar_override orelse continue;
- if (taskbar_selected != null) continue;
- const parsed = preset.tokens;
- if (theme.taskbarTokensEql(parsed, chosen)) taskbar_selected = i;
- }
- } else |_| {}
- out.taskbar_theme_row_children = .{
- labelWidget(i18n.tr("Taskbar theme")),
- .{
- .name = "taskbar_theme",
- .kind = .{ .select = .{
- .labels = taskbar_labels,
- .selected = taskbar_selected,
- .placeholder = i18n.tr("Custom"),
- .disabled = taskbar_labels.len == 0,
- .owner = out,
- .on_change = &onTaskbarThemePicked,
- } },
- .width = .{ .fixed = segmented_width },
- },
- };
+ const matched_index = buildThemeRows(out, arena);
buildWallpaper(out, arena);
const pal = panel.palette();
- out.app_colors_buttons = .{
- .{ .name = "apply_gtk_colors", .kind = .{ .button = .{ .label = i18n.tr("Apply GTK colors"), .owner = out, .id = 0, .on_click = &onApplyAppColors, .state = if (out.app_colors_job != null) .disabled else .idle } }, .width = .{ .flex = 1 }, .height = .{ .fixed = 32 } },
- .{ .name = "apply_qt_colors", .kind = .{ .button = .{ .label = i18n.tr("Apply Qt colors"), .owner = out, .id = 1, .on_click = &onApplyAppColors, .state = if (out.app_colors_job != null) .disabled else .idle } }, .width = .{ .flex = 1 }, .height = .{ .fixed = 32 } },
- };
- out.app_colors_children = .{
- labelWidget(i18n.tr("App colors")),
- .{ .kind = .container, .direction = .row, .gap = 8, .children = &out.app_colors_buttons },
- appColorsNote(out, arena, pal.dim),
- };
- const dark_mode = out.cc.server.config.compositor.dark_mode;
- out.dark_label_children = .{
- .{ .kind = .{ .text = .{ .content = i18n.tr("Dark mode"), .font_size = theme.global.app_text_size, .weight = 600, .color = pal.fg } } },
- .{ .kind = .{ .text = .{ .content = i18n.tr("Apps and web pages"), .font_size = theme.global.settings_description_size, .color = pal.dim } } },
- };
- out.dark_row_children = .{
- // Flex like the other rows' text labels: an auto-width column is only
- // as wide as its measured text, which fractional scales ellipsize.
- .{ .kind = .container, .direction = .column, .gap = 2, .width = .{ .flex = 1 }, .children = &out.dark_label_children },
- .{ .name = "dark_mode", .kind = .{ .toggle = .{ .on = dark_mode, .owner = out, .on_change = &onDarkModeChanged } } },
- };
-
- const splash_on = out.cc.server.config.compositor.placeholder_delay_ms > 0;
- out.splash_label_children = .{
- .{ .kind = .{ .text = .{ .content = i18n.tr("Show launch splash"), .font_size = theme.global.app_text_size, .weight = 600, .color = pal.fg } } },
- .{ .kind = .{ .text = .{ .content = i18n.tr("Brief placeholder while apps start"), .font_size = theme.global.settings_description_size, .color = pal.dim } } },
- };
- out.splash_row_children = .{
- .{ .kind = .container, .direction = .column, .gap = 2, .width = .{ .flex = 1 }, .children = &out.splash_label_children },
- .{ .name = "launch_splash", .kind = .{ .toggle = .{ .on = splash_on, .owner = out, .on_change = &onSplashStartupChanged } } },
- };
-
- const dodge_on = out.cc.server.config.compositor.dodge_file_drags;
- out.dodge_label_children = .{
- .{ .kind = .{ .text = .{ .content = i18n.tr("Move file manager aside"), .font_size = theme.global.app_text_size, .weight = 600, .color = pal.fg } } },
- .{ .kind = .{ .text = .{ .content = i18n.tr("While dragging a file out of it"), .font_size = theme.global.settings_description_size, .color = pal.dim } } },
- };
- out.dodge_row_children = .{
- .{ .kind = .container, .direction = .column, .gap = 2, .width = .{ .flex = 1 }, .children = &out.dodge_label_children },
- .{ .name = "dodge_file_drags", .kind = .{ .toggle = .{ .on = dodge_on, .owner = out, .on_change = &onDodgeFileDragsChanged } } },
- };
-
- out.dim_label_children = .{
- .{ .kind = .{ .text = .{ .content = i18n.tr("Dim inactive windows"), .font_size = theme.global.app_text_size, .weight = 600, .color = pal.fg } } },
- .{ .kind = .{ .text = .{ .content = i18n.tr("Slightly darken and mute windows that are not focused"), .font_size = theme.global.settings_description_size, .color = pal.dim } } },
- };
- out.dim_row_children = .{
- .{ .kind = .container, .direction = .column, .gap = 2, .width = .{ .flex = 1 }, .children = &out.dim_label_children },
- .{ .name = "inactive_dim", .kind = .{ .toggle = .{ .on = out.cc.server.config.compositor.inactive_dim, .owner = out, .on_change = &onInactiveDimChanged } } },
- };
-
- const anim_enabled = out.cc.server.config.animations.enabled;
- out.anim_enabled_label_children = .{
- .{ .kind = .{ .text = .{ .content = i18n.tr("Animations"), .font_size = theme.global.app_text_size, .weight = 600, .color = pal.fg } } },
- .{ .kind = .{ .text = .{ .content = i18n.tr("Window and panel transitions"), .font_size = theme.global.settings_description_size, .color = pal.dim } } },
- };
- out.anim_enabled_row_children = .{
- .{ .kind = .container, .direction = .column, .gap = 2, .width = .{ .flex = 1 }, .children = &out.anim_enabled_label_children },
- .{ .name = "animations", .kind = .{ .toggle = .{ .on = anim_enabled, .owner = out, .on_change = &onAnimationsEnabledChanged } } },
- };
-
- const anim_speed = out.cc.server.config.animations.speed;
- out.anim_speed_row_children = .{
- labelWidget(i18n.tr("Animation speed")),
- .{
- .name = "anim_speed",
- .kind = .{ .segmented = .{ .labels = &anim_speed_labels, .selected = indexOfNearest(&anim_speed_values, anim_speed), .owner = out, .on_change = &onAnimSpeedChanged } },
- .width = .{ .fixed = segmented_width },
- },
- };
-
- const reduced_motion = out.cc.server.config.animations.reduced_motion;
- out.reduced_motion_row_children = .{
- labelWidget(i18n.tr("Reduced motion")),
- .{
- .name = "reduced_motion",
- .kind = .{ .segmented = .{ .labels = panel.translatedLabels(&reduced_motion_labels), .selected = indexOfReducedMotion(reduced_motion), .owner = out, .on_change = &onReducedMotionChanged } },
- .width = .{ .fixed = segmented_width },
- },
- };
-
- const focus_zoom = out.cc.server.config.compositor.focus_zoom;
- out.focus_zoom_children = .{
- labelWidget(i18n.tr("Window switching zoom")),
- .{ .name = "focus_zoom", .kind = .{ .segmented = .{ .labels = panel.translatedLabels(&focus_zoom_labels), .selected = @intFromEnum(focus_zoom), .owner = out, .on_change = &onFocusZoomChanged } }, .width = .{ .percent = 1 } },
- .{ .kind = .{ .text = .{ .content = focus_zoom_descriptions[@intFromEnum(focus_zoom)].get(), .font_size = theme.global.settings_description_size, .color = pal.dim } } },
- };
-
- out.drag_feedback_children = .{
- labelWidget(i18n.tr("Drag feedback")),
- .{ .name = "drag_feedback", .kind = .{ .toggle = .{ .on = out.cc.server.config.compositor.drag_feedback, .owner = out, .on_change = &onDragFeedbackChanged } } },
- };
- const drag_scale = out.cc.server.config.compositor.drag_scale;
- const drag_formatted = std.fmt.bufPrint(&out.drag_scale_value_buf, "{d:.3}×", .{drag_scale}) catch "?";
- out.drag_scale_header_children = .{ labelWidget(i18n.tr("Drag lift scale")), pillWidget(drag_formatted) };
- out.drag_scale_children = .{
- .{ .kind = .container, .direction = .row, .justify = .space_between, .children = &out.drag_scale_header_children },
- .{ .name = "drag_scale", .kind = .{ .slider = .{
- .value = drag_scale,
- .min = loader.drag_scale_min,
- .max = loader.drag_scale_max,
- .step = 0.001,
- .owner = out,
- .on_change = &onDragScaleChanged,
- } } },
- };
-
- if (out.font_families == null) {
- out.font_families = @import("ui").font_fallback.listFamilies(out.font_arena.allocator()) catch null;
- }
- const families = out.font_families orelse &.{};
- var family_index: ?usize = null;
- for (families, 0..) |family, i| {
- if (std.ascii.eqlIgnoreCase(family, t.font)) {
- family_index = i;
- break;
- }
- }
- out.family_row_children = .{
- labelWidget(i18n.tr("UI font")),
- .{
- .name = "font",
- .kind = .{ .select = .{
- .labels = families,
- .selected = family_index,
- .placeholder = arena.dupe(u8, t.font) catch i18n.tr("Current font"),
- .disabled = families.len == 0,
- .owner = out,
- .on_change = &onFontFamilyChanged,
- } },
- .width = .{ .fixed = segmented_width },
- },
- };
- if (out.cursor_themes == null) {
- out.cursor_themes = cursor_theme.list(out.font_arena.allocator(), out.cc.server.io) catch null;
- }
- const cursor_themes = out.cursor_themes orelse &.{};
- var cursor_labels: [][]const u8 = &.{};
- if (arena.alloc([]const u8, cursor_themes.len)) |labels| {
- for (cursor_themes, labels) |ct, *l| l.* = ct.label;
- cursor_labels = labels;
- } else |_| {}
- const active_cursor = out.cc.server.input.cursorThemeName();
- out.cursor_row_children = .{
- labelWidget(i18n.tr("Cursor theme")),
- .{
- .name = "cursor_theme",
- .kind = .{ .select = .{
- .labels = cursor_labels,
- .selected = cursor_theme.indexOf(cursor_themes, active_cursor),
- .placeholder = arena.dupe(u8, active_cursor) catch i18n.tr("Current theme"),
- .disabled = cursor_labels.len == 0,
- .owner = out,
- .on_change = &onCursorThemePicked,
- } },
- .width = .{ .fixed = segmented_width },
- },
- };
- out.font_row_children = .{
- labelWidget(i18n.tr("Font size")),
- .{
- .name = "font_size",
- .kind = .{ .segmented = .{ .labels = panel.translatedLabels(&font_labels), .selected = indexOfNearest(&font_values, t.font_size), .owner = out, .on_change = &onFontSizeChanged } },
- .width = .{ .fixed = segmented_width },
- },
- };
- out.radius_row_children = .{
- labelWidget(i18n.tr("Radius")),
- .{
- .name = "radius",
- .kind = .{ .segmented = .{ .labels = panel.translatedLabels(&radius_labels), .selected = if (theme.radiusPreset(t)) |preset| @intFromEnum(preset) else radius_labels.len, .owner = out, .on_change = &onRadiusChanged } },
- .width = .{ .fixed = segmented_width },
- },
- };
- out.shadow_row_children = .{
- labelWidget(i18n.tr("Shadow")),
- .{
- .name = "shadow",
- .kind = .{ .segmented = .{ .labels = panel.translatedLabels(&shadow_labels), .selected = indexOfNearest(&shadow_size_values, t.shadow_size), .owner = out, .on_change = &onShadowChanged } },
- .width = .{ .fixed = segmented_width },
- },
- };
+ buildColorRows(out, arena, pal);
- out.glow_label_children = .{
- .{ .kind = .{ .text = .{ .content = i18n.tr("Edge glow"), .font_size = theme.global.app_text_size, .weight = 600, .color = pal.fg } } },
- .{ .kind = .{ .text = .{ .content = i18n.tr("Light the active window's edge near the pointer"), .font_size = theme.global.settings_description_size, .color = pal.dim } } },
- };
- out.glow_row_children = .{
- .{ .kind = .container, .direction = .column, .gap = 2, .width = .{ .flex = 1 }, .children = &out.glow_label_children },
- .{ .name = "border_glow", .kind = .{ .toggle = .{ .on = t.border_glow_enabled, .owner = out, .on_change = &onBorderGlowChanged } } },
- };
+ buildBehaviorRows(out, pal);
- const opacity_val = std.math.clamp(t.window_bg[3], 0.0, 1.0);
- const opacity_formatted = std.fmt.bufPrint(&out.opacity_value_buf, "{d}%", .{@as(i32, @intFromFloat(@round(opacity_val * 100.0)))}) catch "?";
- out.opacity_header_children = .{ labelWidget(i18n.tr("Window chrome opacity")), pillWidget(opacity_formatted) };
- const opacity_header: Widget = .{ .kind = .container, .direction = .row, .justify = .space_between, .children = &out.opacity_header_children };
- const opacity_slider: Widget = .{
- .name = "chrome_opacity",
- .kind = .{ .slider = .{
- .value = opacity_val,
- .min = 0.0,
- .max = 1.0,
- .step = 0.01,
- .owner = out,
- .on_change = &onChromeOpacityChanged,
- } },
- };
- out.opacity_group_children = .{ opacity_header, opacity_slider };
- const opacity_row: Widget = .{ .kind = .container, .direction = .column, .gap = 8, .children = &out.opacity_group_children };
+ buildFontRows(out, arena, t, pal);
- const darkness_val = theme.chromeDarkness(t.window_bg);
- const darkness_formatted = std.fmt.bufPrint(&out.darkness_value_buf, "{d}%", .{@as(i32, @intFromFloat(@round(darkness_val * 100.0)))}) catch "?";
- out.darkness_header_children = .{ labelWidget(i18n.tr("Window chrome darkness")), pillWidget(darkness_formatted) };
- const darkness_header: Widget = .{ .kind = .container, .direction = .row, .justify = .space_between, .children = &out.darkness_header_children };
- const darkness_slider: Widget = .{
- .name = "chrome_darkness",
- .kind = .{ .slider = .{
- .value = darkness_val,
- .min = 0.0,
- .max = 1.0,
- .step = 0.01,
- .owner = out,
- .on_change = &onChromeDarknessChanged,
- } },
- };
- out.darkness_group_children = .{ darkness_header, darkness_slider };
- const darkness_row: Widget = .{ .kind = .container, .direction = .column, .gap = 8, .children = &out.darkness_group_children };
- const chrome_height_row = pxGroup(out, px_chrome_height, i18n.tr("Window chrome height"), t.chrome_height, 28, 84, 1, &PxHandler(px_chrome_height, "chrome_height", false).changed);
- out.px[px_chrome_height].group_children[1].name = "chrome_height";
- const chrome_gap_row = pxGroup(out, px_chrome_control_gap, i18n.tr("Window control gap"), t.chrome_control_gap, 0, 24, 1, &PxHandler(px_chrome_control_gap, "chrome_control_gap", false).changed);
- out.px[px_chrome_control_gap].group_children[1].name = "chrome_control_gap";
- out.chrome_group_children = .{ chrome_height_row, chrome_gap_row, opacity_row, darkness_row };
- const chrome_row: Widget = .{ .kind = .container, .direction = .column, .gap = 12, .children = &out.chrome_group_children };
+ const chrome_row = buildChromeRow(out, t);
- const inactive_val = std.math.clamp(out.cc.server.config.compositor.inactive_opacity, 0.0, 1.0);
- const inactive_formatted = std.fmt.bufPrint(&out.inactive_opacity_value_buf, "{d}%", .{@as(i32, @intFromFloat(@round(inactive_val * 100.0)))}) catch "?";
- out.inactive_opacity_header_children = .{ labelWidget(i18n.tr("Inactive window opacity")), pillWidget(inactive_formatted) };
- const inactive_opacity_header: Widget = .{ .kind = .container, .direction = .row, .justify = .space_between, .children = &out.inactive_opacity_header_children };
- const inactive_opacity_slider: Widget = .{
- .name = "inactive_opacity",
- .kind = .{ .slider = .{
- .value = inactive_val,
- .min = 0.0,
- .max = 1.0,
- .step = 0.01,
- .owner = out,
- .on_change = &onInactiveOpacityChanged,
- } },
- };
- out.inactive_opacity_group_children = .{ inactive_opacity_header, inactive_opacity_slider };
- const inactive_opacity_row: Widget = .{ .kind = .container, .direction = .column, .gap = 8, .children = &out.inactive_opacity_group_children };
+ const inactive_opacity_row = inactiveOpacityRow(out);
- // Unset means a terminal keeps its own alpha; the slider then shows opaque.
- const terminal_val = std.math.clamp(out.cc.server.config.compositor.terminal_opacity orelse 1.0, 0.0, 1.0);
- const terminal_formatted = std.fmt.bufPrint(&out.terminal_opacity_value_buf, "{d}%", .{@as(i32, @intFromFloat(@round(terminal_val * 100.0)))}) catch "?";
- out.terminal_opacity_header_children = .{ labelWidget(i18n.tr("Terminal opacity (new windows)")), pillWidget(terminal_formatted) };
- const terminal_opacity_header: Widget = .{ .kind = .container, .direction = .row, .justify = .space_between, .children = &out.terminal_opacity_header_children };
- const terminal_opacity_slider: Widget = .{
- .name = "terminal_opacity",
- .kind = .{ .slider = .{
- .value = terminal_val,
- .min = 0.0,
- .max = 1.0,
- .step = 0.01,
- .owner = out,
- .on_change = &onTerminalOpacityChanged,
- } },
- };
- out.terminal_opacity_group_children = .{ terminal_opacity_header, terminal_opacity_slider };
- const terminal_opacity_row: Widget = .{ .kind = .container, .direction = .column, .gap = 8, .children = &out.terminal_opacity_group_children };
+ const terminal_opacity_row = terminalOpacityRow(out);
const gap_val: f32 = @floatFromInt(@min(out.cc.server.config.compositor.windowGap(), max_window_gap));
const window_gap_row = pxGroup(out, px_window_gap, i18n.tr("Snapped window gap"), gap_val, 0, max_window_gap, 1, &onWindowGapChanged);
- out.taskbar_position_children = .{
- labelWidget(i18n.tr("Taskbar position")),
- .{ .name = "taskbar_position", .kind = .{ .segmented = .{ .labels = panel.translatedLabels(&.{ i18n.msg("Top"), i18n.msg("Bottom") }), .selected = @intFromEnum(out.cc.server.config.compositor.taskbar_position), .owner = out, .on_change = &onTaskbarPositionChanged } }, .width = .{ .fixed = segmented_width } },
- };
- const position_row: Widget = .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.taskbar_position_children };
- const taskbar_min: f32 = @floatFromInt(Taskbar.min_bar_height);
- const taskbar_row = pxGroup(out, px_taskbar_size, i18n.tr("Taskbar size"), std.math.clamp(t.taskbar_size, taskbar_min, 84.0), taskbar_min, 84, 2, &PxHandler(px_taskbar_size, "taskbar_size", true).changed);
- // A floating bar: its gap from the edge, its length and its corners. At
- // 0 px, 100 % and 0 px it is the original flush, full-width, square bar.
- const edge_gap_row = pxGroup(out, px_taskbar_edge_gap, i18n.tr("Taskbar gap from edge"), std.math.clamp(t.taskbar_edge_gap, 0.0, 48.0), 0, 48, 2, &PxHandler(px_taskbar_edge_gap, "taskbar_edge_gap", true).changed);
- out.px[px_taskbar_edge_gap].group_children[1].name = "taskbar_edge_gap";
- const length_row = unitGroup(out, px_taskbar_length, i18n.tr("Taskbar length"), std.math.clamp(t.taskbar_length, 30.0, 100.0), 30, 100, 2, &UnitHandler(px_taskbar_length, "taskbar_length", true, "%").changed, "%");
- out.px[px_taskbar_length].group_children[1].name = "taskbar_length";
- const radius_row = pxGroup(out, px_taskbar_radius, i18n.tr("Taskbar corner radius"), std.math.clamp(t.taskbar_radius, 0.0, 42.0), 0, 42, 1, &PxHandler(px_taskbar_radius, "taskbar_radius", true).changed);
- out.px[px_taskbar_radius].group_children[1].name = "taskbar_radius";
- // Also sets each pill's top/bottom margin within the bar (capped) —
- // see Taskbar.chipVerticalMargin — so this one slider spaces chips on
- // every side at once instead of only widening the horizontal gap.
- const chip_width_row = pxGroup(out, px_chip_width, i18n.tr("Window item width"), t.chip_width, 64, 400, 4, &PxHandler(px_chip_width, "chip_width", true).changed);
- const chip_gap_row = pxGroup(out, px_chip_gap, i18n.tr("Window item gap"), std.math.clamp(t.chip_gap, 0.0, 24.0), 0, 24, 2, &PxHandler(px_chip_gap, "chip_gap", true).changed);
- const start_gap_row = pxGroup(out, px_start_button_gap, i18n.tr("Start button gap"), std.math.clamp(t.start_button_gap, 0.0, 40.0), 0, 40, 2, &PxHandler(px_start_button_gap, "start_button_gap", true).changed);
- const start_icon_row = pxGroup(out, px_start_icon_size, i18n.tr("Start button icon size"), std.math.clamp(t.start_button_icon_size, 16.0, 42.0), 16, 42, 2, &PxHandler(px_start_icon_size, "start_button_icon_size", true).changed);
- out.clock_bold_children = .{
- labelWidget(i18n.tr("Bold clock text")),
- .{ .name = "clock_bold", .kind = .{ .toggle = .{ .on = theme.taskbar(.clock_bold), .owner = out, .on_change = &ClockStyle("clock_bold").changed } } },
- };
- out.clock_italic_children = .{
- labelWidget(i18n.tr("Italic clock text")),
- .{ .name = "clock_italic", .kind = .{ .toggle = .{ .on = theme.taskbar(.clock_italic), .owner = out, .on_change = &ClockStyle("clock_italic").changed } } },
- };
- const clock_bold_row: Widget = .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.clock_bold_children };
- const clock_italic_row: Widget = .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.clock_italic_children };
- // Each section is an inset well of raised rows; a whole row is its grip.
- inline for (0..taskbar_items.count) |i| {
- out.item_controls[i] = .{
- .{ .kind = .{ .button = .{ .label = i18n.tr("Drag to move"), .icon = .drag_handle, .variant = .ghost, .owner = out, .id = i } }, .width = .{ .fixed = 28 }, .height = .{ .fixed = 28 } },
- .{ .kind = .{ .text = .{ .content = "", .font_size = theme.global.app_text_size, .weight = 600, .color = pal.fg } }, .width = .{ .flex = 1 } },
- .{ .kind = .{ .toggle = .{ .on = false, .owner = out, .on_change = &ItemToggle(i).changed } } },
- };
- out.item_rows[i] = .{ .kind = .{ .rect = itemRowStyle(false) }, .direction = .row, .gap = 8, .@"align" = .center, .padding = .{ .top = 6, .right = 10, .bottom = 6, .left = 6 }, .children = &out.item_controls[i] };
- }
- inline for (.{ i18n.msg("LEFT"), i18n.msg("CENTER"), i18n.msg("RIGHT") }, .{ "left", "center", "right" }, 0..) |label, name, zone| {
- out.items_placeholder_body[zone] = .{
- .{ .kind = .container, .width = .{ .flex = 1 } },
- // Slack: a fractional raster scale hints wider than the logical measure.
- .{ .kind = .{ .text = .{ .content = i18n.tr("Drag items here"), .font_size = theme.global.settings_description_size, .color = pal.dim } }, .min_width = @import("ui").measure.textNatural(i18n.tr("Drag items here"), .sans, 400, theme.global.settings_description_size).w + 6 },
- .{ .kind = .container, .width = .{ .flex = 1 } },
- };
- out.items_placeholder[zone] = .{.{ .kind = .container, .height = .{ .fixed = item_row_height }, .@"align" = .center, .children = &out.items_placeholder_body[zone] }};
- out.items_section_children[zone] = .{
- sectionLabel(label.get()),
- .{ .name = "taskbar_zone_" ++ name, .kind = .{ .rect = itemZoneStyle(false) }, .direction = .column, .gap = 6, .padding = layout.Edges.all(6), .@"align" = .stretch },
- };
- }
- _ = syncItems(out, out.cc.server.config.compositor.taskbar_items, null);
- out.items_children = .{
- labelWidget(i18n.tr("Taskbar sections")),
- .{ .kind = .{ .text = .{ .content = i18n.tr("Drag an item to reorder it or move it to another section. Switch it off to hide it. Battery appears when available."), .font_size = theme.global.settings_description_size, .color = pal.dim } } },
- .{ .kind = .container, .direction = .column, .gap = 6, .@"align" = .stretch, .children = &out.items_section_children[0] },
- .{ .kind = .container, .direction = .column, .gap = 6, .@"align" = .stretch, .children = &out.items_section_children[1] },
- .{ .kind = .container, .direction = .column, .gap = 6, .@"align" = .stretch, .children = &out.items_section_children[2] },
- .{ .name = "taskbar_capture_notice", .kind = .{ .text = .{ .content = if (out.cc.server.config.compositor.taskbar_items.shown(.capture))
- i18n.tr("Screen capture appears while recording or sharing your screen. Keeping it enabled is recommended.")
- else
- i18n.tr("Warning: Screen capture is hidden. Recording and screen sharing can continue without a visible indicator or Stop sharing button. Hiding it is not recommended."), .font_size = theme.global.settings_description_size, .color = pal.dim } } },
- };
- const items_group: Widget = .{ .kind = .container, .direction = .column, .gap = 8, .@"align" = .stretch, .children = &out.items_children };
- out.taskbar_section_children = .{ panel.sectionTitle(i18n.tr("Taskbar")), position_row, taskbar_row, edge_gap_row, length_row, radius_row, chip_width_row, chip_gap_row, start_gap_row, start_icon_row, clock_bold_row, clock_italic_row, items_group };
- const taskbar_section: Widget = .{ .kind = .container, .direction = .column, .gap = 12, .children = &out.taskbar_section_children };
+ const taskbar_section = buildTaskbarSection(out, t, pal);
- var output_box: wlr.Box = undefined;
- out.cc.server.output_layout.getBox(out.cc.wlr_output, &output_box);
- const menu_now = menu_size.wanted(t, @floatFromInt(output_box.width), @floatFromInt(output_box.height));
- const menu_pinned = t.start_menu_width > 0 or t.start_menu_max_height > 0;
- const menu_width_row = pxGroup(out, px_menu_width, i18n.tr("Menu width"), std.math.clamp(menu_now.width, menu_width_min, menu_width_max), menu_width_min, menu_width_max, 10, &PxHandler(px_menu_width, "start_menu_width", false).changed);
- out.px[px_menu_width].group_children[1].name = "start_menu_width";
- const menu_height_row = pxGroup(out, px_menu_height, i18n.tr("Menu height"), std.math.clamp(menu_now.height, menu_height_min, menu_height_max), menu_height_min, menu_height_max, 10, &PxHandler(px_menu_height, "start_menu_max_height", false).changed);
- out.px[px_menu_height].group_children[1].name = "start_menu_height";
- const menu_left_row = pxGroup(out, px_menu_left, i18n.tr("Menu left padding"), std.math.clamp(t.start_menu_left_pad, 0.0, 40.0), 0, 40, 2, &PxHandler(px_menu_left, "start_menu_left_pad", false).changed);
- const menu_bottom_row = pxGroup(out, px_menu_bottom, i18n.tr("Menu bottom padding"), std.math.clamp(t.start_menu_bottom_pad, 0.0, 40.0), 0, 40, 2, &PxHandler(px_menu_bottom, "start_menu_bottom_pad", false).changed);
- const icon_left_row = pxGroup(out, px_icon_left, i18n.tr("Icon left padding"), std.math.clamp(t.start_menu_icon_left_pad, 0.0, 32.0), 0, 32, 2, &PxHandler(px_icon_left, "start_menu_icon_left_pad", false).changed);
- const icon_bottom_row = pxGroup(out, px_icon_bottom, i18n.tr("Icon bottom padding"), std.math.clamp(t.start_menu_icon_bottom_pad, 0.0, 24.0), 0, 24, 2, &PxHandler(px_icon_bottom, "start_menu_icon_bottom_pad", false).changed);
- out.start_logo_buttons = .{
- .{ .name = "start_logo_choose", .kind = .{ .button = .{ .label = i18n.tr("Choose file…"), .owner = out, .on_click = &onChooseStartLogo, .state = if (folder_picker.running()) .disabled else .idle } }, .width = .auto, .min_width = 124, .height = .{ .fixed = 30 } },
- .{ .name = "start_logo_reset", .kind = .{ .button = .{ .label = i18n.tr("Reset to default"), .owner = out, .on_click = &onResetStartLogo, .state = if (t.start_button_icon.len == 0 or folder_picker.running()) .disabled else .idle } }, .width = .auto, .min_width = 140, .height = .{ .fixed = 30 } },
- };
- const logo = startLogoImage(out, arena, Taskbar.startIconSize());
- const logo_note: []const u8 = out.start_logo_error orelse blk: {
- if (t.start_button_icon.len == 0) break :blk i18n.tr("Default R logo · PNG or SVG");
- const name = std.fs.path.basename(t.start_button_icon);
- if (logo.failed) break :blk i18n.allocPrint(arena, i18n.tr("{name} could not be loaded · showing the default R"), .{ .name = name }) catch name;
- break :blk name;
- };
- // The logo sits on the taskbar, so it is shown on the taskbar's colour.
- var tile_bg = theme.taskbar(.taskbar_bg);
- tile_bg[3] = 1;
- out.start_logo_tile = .{.{
- .name = "start_logo_preview",
- .kind = .{ .image = logo.image },
- .width = .{ .fixed = @floatFromInt(logo.size) },
- .height = .{ .fixed = @floatFromInt(logo.size) },
- }};
- out.start_logo_info = .{
- .{ .name = "start_logo_file", .kind = .{ .text = .{ .content = logo_note, .font_size = theme.global.settings_description_size, .color = pal.dim } } },
- .{ .kind = .container, .direction = .row, .gap = 8, .children = &out.start_logo_buttons },
- };
- out.start_logo_body = .{
- .{
- .name = "start_logo_tile",
- .kind = .{ .rect = .{ .color = tile_bg, .radius = 10, .border_width = 1, .border_color = pal.border_soft } },
- .width = .{ .fixed = start_logo_tile_size },
- .height = .{ .fixed = start_logo_tile_size },
- .justify = .center,
- .@"align" = .center,
- .children = &out.start_logo_tile,
- },
- .{ .kind = .container, .direction = .column, .gap = 8, .justify = .center, .width = .{ .flex = 1 }, .children = &out.start_logo_info },
- };
- out.start_logo_children = .{
- labelWidget(i18n.tr("Start button logo")),
- .{ .kind = .container, .direction = .row, .gap = 12, .@"align" = .center, .children = &out.start_logo_body },
- };
- const logo_row: Widget = .{ .kind = .container, .direction = .column, .gap = 8, .children = &out.start_logo_children };
- out.start_size_children = .{
- .{ .name = "start_menu_size_note", .kind = .{ .text = .{ .content = if (menu_pinned) i18n.tr("Custom size") else i18n.tr("Sized to fit your screen · move a slider to set your own"), .font_size = theme.global.settings_description_size, .color = pal.dim } }, .width = .{ .flex = 1 } },
- .{ .name = "start_menu_size_auto", .kind = .{ .button = .{ .label = i18n.tr("Size to screen"), .owner = out, .on_click = &onAutoMenuSize, .state = if (menu_pinned) .idle else .disabled } }, .width = .auto, .min_width = 124, .height = .{ .fixed = 30 } },
- };
- const menu_size_row: Widget = .{ .kind = .container, .direction = .row, .gap = 8, .@"align" = .center, .children = &out.start_size_children };
- out.start_menu_section_children = .{ panel.sectionTitle(i18n.tr("Start menu")), logo_row, menu_width_row, menu_height_row, menu_size_row, menu_left_row, menu_bottom_row, icon_left_row, icon_bottom_row };
- const start_menu_section: Widget = .{ .kind = .container, .direction = .column, .gap = 12, .children = &out.start_menu_section_children };
+ const start_menu_section = buildStartMenuSection(out, arena, t, pal);
- out.theme_actions = .{
- .{ .name = "theme_reset", .kind = .{ .button = .{ .label = i18n.tr("Reset to theme"), .owner = out, .on_click = &onResetTheme } }, .height = .{ .fixed = 32 } },
- .{ .name = "theme_install", .kind = .{ .button = .{ .label = i18n.tr("Install theme…"), .owner = out, .on_click = &onInstallTheme } }, .height = .{ .fixed = 32 } },
- .{ .name = "theme_remove", .kind = .{ .button = .{ .label = i18n.tr("Remove"), .owner = out, .on_click = &onRemoveTheme, .state = if (matched_index != null and out.presets[matched_index.?].user_installed) .idle else .disabled } }, .height = .{ .fixed = 32 } },
- .{ .name = "theme_export", .kind = .{ .button = .{ .label = i18n.tr("Save look…"), .owner = out, .on_click = &onExportTheme } }, .height = .{ .fixed = 32 } },
- .{ .name = "theme_replace", .kind = .{ .button = .{ .label = i18n.tr("Replace installed theme"), .owner = out, .on_click = &onReplaceTheme, .state = if (out.theme_pending_path != null) .idle else .disabled } }, .height = .{ .fixed = 32 } },
- };
- var pack_preview: Widget = .{ .kind = .container };
- out.theme_preview_pending = false;
- if (server.config.theme_pack) |pack| {
- if (pack.root.len > 0) {
- if (theme_presets.asset(arena, server.io, pack.root, "preview.png")) |path| {
- const result = server.iconLookup(path, 192);
- if (result == .ready) {
- const entry = result.ready;
- if (arena.dupe(u32, entry.pixels)) |pixels| {
- pack_preview = .{ .name = "theme_preview", .kind = .{ .image = .{ .pixels = pixels, .width = entry.size, .height = entry.size, .fallback_icon = null } }, .width = .{ .fixed = 160 }, .height = .{ .fixed = 100 } };
- } else |_| {}
- } else if (result == .pending) out.theme_preview_pending = true;
- } else |_| {}
- }
- }
- const pack_controls = arena.dupe(Widget, &.{
- .{ .kind = .container, .direction = .row, .gap = 8, .children = out.theme_actions[0..4] },
- .{ .kind = .{ .text = .{ .content = if (out.theme_message.len > 0) out.theme_message else i18n.tr("Packs include colours and artwork. Personal edits are saved as overrides."), .font_size = theme.global.app_status_size, .color = pal.dim } } },
- .{ .kind = .container, .children = if (out.theme_pending_path != null) out.theme_actions[4..5] else &.{} },
- pack_preview,
- }) catch @constCast(&[_]Widget{});
- const icon_themes = @import("../../icon_theme.zig").listNames(arena, server.io, server.icon_theme_cfg) catch &.{};
- out.icon_theme_names = icon_themes;
- const icon_labels = arena.dupe([]const u8, icon_themes) catch @constCast(icon_themes);
- if (icon_labels.len > 0) icon_labels[0] = i18n.tr("System default");
- var icon_selected: ?usize = null;
- for (icon_themes, 0..) |name, i| if (std.mem.eql(u8, name, server.config.compositor.icon_theme)) {
- icon_selected = i;
- };
- out.icon_theme_row = .{
- labelWidget(i18n.tr("Icon theme")),
- .{ .name = "icon_theme", .kind = .{ .select = .{ .labels = icon_labels, .selected = icon_selected, .placeholder = i18n.tr("Pack or system default"), .owner = out, .on_change = &onIconThemePicked } }, .width = .{ .fixed = segmented_width } },
- };
- out.dock_children = .{
- labelWidget(i18n.tr("RediWM dock")),
- .{ .name = "dock_enabled", .kind = .{ .toggle = .{ .on = out.cc.server.config.compositor.dock_enabled, .owner = out, .on_change = &onDockChanged } } },
- };
- out.dock_position_children = .{
- labelWidget(i18n.tr("Dock position")),
- .{ .name = "dock_position", .kind = .{ .segmented = .{ .labels = panel.translatedLabels(&.{ i18n.msg("Top"), i18n.msg("Bottom"), i18n.msg("Left"), i18n.msg("Right") }), .selected = @intFromEnum(server.config.compositor.dock_position), .owner = out, .on_change = &onDockPositionChanged } }, .width = .{ .fixed = segmented_width } },
- };
- out.dock_auto_hide_children = .{
- labelWidget(i18n.tr("Auto-hide dock")),
- .{ .name = "dock_auto_hide", .kind = .{ .toggle = .{ .on = server.config.compositor.dock_auto_hide, .owner = out, .on_change = &onDockAutoHideChanged } } },
- };
- const dock_height_row = pxGroup(out, px_dock_height, i18n.tr("Dock size"), @floatFromInt(server.config.compositor.dock_height), @floatFromInt(loader.dock_height_min), @floatFromInt(loader.dock_height_max), 2, &onDockHeightChanged);
- out.px[px_dock_height].group_children[1].name = "dock_height";
- const dock_zoom_row = pxGroup(out, px_dock_hover_zoom, i18n.tr("Dock hover zoom (1.00× disables)"), server.config.compositor.dock_hover_zoom, 1, loader.dock_hover_zoom_max, 0.05, &onDockHoverZoomChanged);
- out.px[px_dock_hover_zoom].group_children[1].name = "dock_hover_zoom";
- updateDockZoomLabel(out);
- // The slider shows the opacity the dock is drawn with, whether the theme or
- // `dock_opacity` set it; the radius, whether it is the dock's own or the windows'.
- const dock_pal = theme.shellPalette();
- const dock_opacity_row = unitGroup(out, px_dock_opacity, i18n.tr("Dock opacity"), @round(dock_mod.background(&server.config.compositor, dock_pal)[3] * 100), 0, 100, 1, &onDockOpacityChanged, "%");
- out.px[px_dock_opacity].group_children[1].name = "dock_opacity";
- const dock_radius_row = pxGroup(out, px_dock_radius, i18n.tr("Dock corner radius"), std.math.clamp(dock_mod.cornerRadius(dock_pal), dock_radius_min, dock_radius_max), dock_radius_min, dock_radius_max, 1, &PxHandler(px_dock_radius, "dock_radius", false).changed);
- out.px[px_dock_radius].group_children[1].name = "dock_radius";
- out.dock_active_children = .{
- labelWidget(i18n.tr("Highlight active app")),
- .{ .name = "dock_active_highlight", .kind = .{ .toggle = .{ .on = server.config.compositor.dock_active_highlight, .owner = out, .on_change = &onDockActiveHighlightChanged } } },
- };
- out.dock_trash_children = .{
- labelWidget(i18n.tr("Show Trash")),
- .{ .name = "dock_show_trash", .kind = .{ .toggle = .{ .on = server.config.compositor.dock_show_trash, .owner = out, .on_change = &onDockShowTrashChanged } } },
- };
- out.dock_group_children = .{
- panel.sectionTitle(i18n.tr("Dock")),
- .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.dock_children },
- .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.dock_position_children },
- .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.dock_auto_hide_children },
- dock_height_row,
- dock_zoom_row,
- dock_opacity_row,
- dock_radius_row,
- .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.dock_active_children },
- .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.dock_trash_children },
- };
+ const pack_controls = buildThemePackRows(out, arena, server, pal, matched_index);
+ buildDockRows(out, server);
out.row_storage = .{
.{ .kind = .container, .direction = .column, .gap = 8, .children = pack_controls },
.{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.icon_theme_row },
@@ -1069,6 +547,21 @@ pub fn build(out: *Section, cc: *panel.ControlCenter) void {
out.root = .{ .kind = .container, .direction = .column, .gap = 8, .children = &out.top_children };
}
+const appearance_rows = @import("appearance_rows.zig");
+const buildThemeRows = appearance_rows.buildThemeRows;
+const buildColorRows = appearance_rows.buildColorRows;
+const buildBehaviorRows = appearance_rows.buildBehaviorRows;
+const buildFontRows = appearance_rows.buildFontRows;
+const buildChromeRow = appearance_rows.buildChromeRow;
+const inactiveOpacityRow = appearance_rows.inactiveOpacityRow;
+const terminalOpacityRow = appearance_rows.terminalOpacityRow;
+
+const appearance_sections = @import("appearance_sections.zig");
+const buildTaskbarSection = appearance_sections.buildTaskbarSection;
+const buildStartMenuSection = appearance_sections.buildStartMenuSection;
+const buildThemePackRows = appearance_sections.buildThemePackRows;
+const buildDockRows = appearance_sections.buildDockRows;
+
pub const strip_index = 1;
/// `row_storage`, in the order `build` fills it.
diff --git a/src/control_center/sections/appearance_rows.zig b/src/control_center/sections/appearance_rows.zig
new file mode 100644
index 0000000..a8bad4d
--- /dev/null
+++ b/src/control_center/sections/appearance_rows.zig
@@ -0,0 +1,412 @@
+//! Building the Appearance page's rows: themes and colours, motion and feedback, fonts and cursor, and window chrome.
+
+const i18n = @import("i18n");
+const std = @import("std");
+const layout = @import("ui").layout;
+const theme = @import("ui").theme;
+const theme_presets = @import("config").theme_pack;
+const Widget = layout.Widget;
+const panel = @import("../panel.zig");
+const loader = @import("config").loader;
+const cursor_theme = @import("../../cursor_theme.zig");
+const appearance_colors = @import("appearance_colors.zig");
+const appearance_themes = @import("appearance_themes.zig");
+const appearance_chrome = @import("appearance_chrome.zig");
+const appColorsNote = appearance_colors.appColorsNote;
+const onApplyAppColors = appearance_colors.onApplyAppColors;
+const onThemePicked = appearance_themes.onThemePicked;
+const onTaskbarThemePicked = appearance_themes.onTaskbarThemePicked;
+const onFontFamilyChanged = appearance_chrome.onFontFamilyChanged;
+const onFontSizeChanged = appearance_chrome.onFontSizeChanged;
+const onRadiusChanged = appearance_chrome.onRadiusChanged;
+const onShadowChanged = appearance_chrome.onShadowChanged;
+const onBorderGlowChanged = appearance_chrome.onBorderGlowChanged;
+const onChromeOpacityChanged = appearance_chrome.onChromeOpacityChanged;
+const onChromeDarknessChanged = appearance_chrome.onChromeDarknessChanged;
+const onInactiveDimChanged = appearance_chrome.onInactiveDimChanged;
+const onInactiveOpacityChanged = appearance_chrome.onInactiveOpacityChanged;
+const onTerminalOpacityChanged = appearance_chrome.onTerminalOpacityChanged;
+const onFocusZoomChanged = appearance_chrome.onFocusZoomChanged;
+const onDragFeedbackChanged = appearance_chrome.onDragFeedbackChanged;
+const onDragScaleChanged = appearance_chrome.onDragScaleChanged;
+const onAnimationsEnabledChanged = appearance_chrome.onAnimationsEnabledChanged;
+const onAnimSpeedChanged = appearance_chrome.onAnimSpeedChanged;
+const onReducedMotionChanged = appearance_chrome.onReducedMotionChanged;
+const onCursorThemePicked = appearance_chrome.onCursorThemePicked;
+const onDarkModeChanged = appearance_chrome.onDarkModeChanged;
+const onSplashStartupChanged = appearance_chrome.onSplashStartupChanged;
+const onDodgeFileDragsChanged = appearance_chrome.onDodgeFileDragsChanged;
+const appearance = @import("appearance.zig");
+const segmented_width = appearance.segmented_width;
+const font_values = appearance.font_values;
+const font_labels = appearance.font_labels;
+const radius_labels = appearance.radius_labels;
+const shadow_size_values = appearance.shadow_size_values;
+const shadow_labels = appearance.shadow_labels;
+const anim_speed_values = appearance.anim_speed_values;
+const anim_speed_labels = appearance.anim_speed_labels;
+const reduced_motion_labels = appearance.reduced_motion_labels;
+const focus_zoom_labels = appearance.focus_zoom_labels;
+const focus_zoom_descriptions = appearance.focus_zoom_descriptions;
+const indexOfReducedMotion = appearance.indexOfReducedMotion;
+const px_chrome_height = appearance.px_chrome_height;
+const px_chrome_control_gap = appearance.px_chrome_control_gap;
+const Section = appearance.Section;
+const indexOfNearest = appearance.indexOfNearest;
+const labelWidget = appearance.labelWidget;
+const pillWidget = appearance.pillWidget;
+const pxGroup = appearance.pxGroup;
+const PxHandler = appearance.PxHandler;
+
+/// The theme and taskbar theme pickers; returns the matched preset.
+pub fn buildThemeRows(out: *Section, arena: std.mem.Allocator) ?usize {
+ out.presets = theme_presets.list(arena, out.cc.server.io, out.cc.server.environ, out.cc.server.config.path) catch &.{};
+ var preset_labels: [][]const u8 = &.{};
+ var matched_index: ?usize = null;
+ if (arena.alloc([]const u8, out.presets.len)) |labels| {
+ preset_labels = labels;
+ for (out.presets, 0..) |preset, i| {
+ preset_labels[i] = preset.name;
+ if (std.mem.eql(u8, preset.id, out.cc.server.config.theme_base)) matched_index = i;
+ }
+ } else |_| {}
+ out.theme_row_children = .{
+ labelWidget(i18n.tr("Theme")),
+ .{
+ .name = "theme",
+ .kind = .{ .select = .{
+ .labels = preset_labels,
+ .selected = matched_index,
+ .placeholder = i18n.tr("Custom"),
+ .disabled = preset_labels.len == 0,
+ .owner = out,
+ .on_change = &onThemePicked,
+ } },
+ .width = .{ .fixed = segmented_width },
+ },
+ };
+
+ // The same presets for the taskbar alone, led by a choice that follows
+ // the theme above. Its tokens are compared, not the whole theme.
+ var taskbar_labels: [][]const u8 = &.{};
+ var taskbar_selected: ?usize = null;
+ if (arena.alloc([]const u8, out.presets.len + 1)) |labels| {
+ taskbar_labels = labels;
+ labels[0] = i18n.tr("Same as theme");
+ if (theme.taskbar_override == null) taskbar_selected = 0;
+ for (out.presets, 1..) |preset, i| {
+ labels[i] = preset.name;
+ const chosen = theme.taskbar_override orelse continue;
+ if (taskbar_selected != null) continue;
+ const parsed = preset.tokens;
+ if (theme.taskbarTokensEql(parsed, chosen)) taskbar_selected = i;
+ }
+ } else |_| {}
+ out.taskbar_theme_row_children = .{
+ labelWidget(i18n.tr("Taskbar theme")),
+ .{
+ .name = "taskbar_theme",
+ .kind = .{ .select = .{
+ .labels = taskbar_labels,
+ .selected = taskbar_selected,
+ .placeholder = i18n.tr("Custom"),
+ .disabled = taskbar_labels.len == 0,
+ .owner = out,
+ .on_change = &onTaskbarThemePicked,
+ } },
+ .width = .{ .fixed = segmented_width },
+ },
+ };
+ return matched_index;
+}
+
+/// The app colour buttons and the dark mode toggle.
+pub fn buildColorRows(out: *Section, arena: std.mem.Allocator, pal: theme.Theme) void {
+ out.app_colors_buttons = .{
+ .{ .name = "apply_gtk_colors", .kind = .{ .button = .{ .label = i18n.tr("Apply GTK colors"), .owner = out, .id = 0, .on_click = &onApplyAppColors, .state = if (out.app_colors_job != null) .disabled else .idle } }, .width = .{ .flex = 1 }, .height = .{ .fixed = 32 } },
+ .{ .name = "apply_qt_colors", .kind = .{ .button = .{ .label = i18n.tr("Apply Qt colors"), .owner = out, .id = 1, .on_click = &onApplyAppColors, .state = if (out.app_colors_job != null) .disabled else .idle } }, .width = .{ .flex = 1 }, .height = .{ .fixed = 32 } },
+ };
+ out.app_colors_children = .{
+ labelWidget(i18n.tr("App colors")),
+ .{ .kind = .container, .direction = .row, .gap = 8, .children = &out.app_colors_buttons },
+ appColorsNote(out, arena, pal.dim),
+ };
+ const dark_mode = out.cc.server.config.compositor.dark_mode;
+ out.dark_label_children = .{
+ .{ .kind = .{ .text = .{ .content = i18n.tr("Dark mode"), .font_size = theme.global.app_text_size, .weight = 600, .color = pal.fg } } },
+ .{ .kind = .{ .text = .{ .content = i18n.tr("Apps and web pages"), .font_size = theme.global.settings_description_size, .color = pal.dim } } },
+ };
+ out.dark_row_children = .{
+ // Flex like the other rows' text labels: an auto-width column is only
+ // as wide as its measured text, which fractional scales ellipsize.
+ .{ .kind = .container, .direction = .column, .gap = 2, .width = .{ .flex = 1 }, .children = &out.dark_label_children },
+ .{ .name = "dark_mode", .kind = .{ .toggle = .{ .on = dark_mode, .owner = out, .on_change = &onDarkModeChanged } } },
+ };
+}
+
+/// Launch splash, file-drag dodge, inactive dimming, animations, focus zoom and drag feedback.
+pub fn buildBehaviorRows(out: *Section, pal: theme.Theme) void {
+ const splash_on = out.cc.server.config.compositor.placeholder_delay_ms > 0;
+ out.splash_label_children = .{
+ .{ .kind = .{ .text = .{ .content = i18n.tr("Show launch splash"), .font_size = theme.global.app_text_size, .weight = 600, .color = pal.fg } } },
+ .{ .kind = .{ .text = .{ .content = i18n.tr("Brief placeholder while apps start"), .font_size = theme.global.settings_description_size, .color = pal.dim } } },
+ };
+ out.splash_row_children = .{
+ .{ .kind = .container, .direction = .column, .gap = 2, .width = .{ .flex = 1 }, .children = &out.splash_label_children },
+ .{ .name = "launch_splash", .kind = .{ .toggle = .{ .on = splash_on, .owner = out, .on_change = &onSplashStartupChanged } } },
+ };
+
+ const dodge_on = out.cc.server.config.compositor.dodge_file_drags;
+ out.dodge_label_children = .{
+ .{ .kind = .{ .text = .{ .content = i18n.tr("Move file manager aside"), .font_size = theme.global.app_text_size, .weight = 600, .color = pal.fg } } },
+ .{ .kind = .{ .text = .{ .content = i18n.tr("While dragging a file out of it"), .font_size = theme.global.settings_description_size, .color = pal.dim } } },
+ };
+ out.dodge_row_children = .{
+ .{ .kind = .container, .direction = .column, .gap = 2, .width = .{ .flex = 1 }, .children = &out.dodge_label_children },
+ .{ .name = "dodge_file_drags", .kind = .{ .toggle = .{ .on = dodge_on, .owner = out, .on_change = &onDodgeFileDragsChanged } } },
+ };
+
+ out.dim_label_children = .{
+ .{ .kind = .{ .text = .{ .content = i18n.tr("Dim inactive windows"), .font_size = theme.global.app_text_size, .weight = 600, .color = pal.fg } } },
+ .{ .kind = .{ .text = .{ .content = i18n.tr("Slightly darken and mute windows that are not focused"), .font_size = theme.global.settings_description_size, .color = pal.dim } } },
+ };
+ out.dim_row_children = .{
+ .{ .kind = .container, .direction = .column, .gap = 2, .width = .{ .flex = 1 }, .children = &out.dim_label_children },
+ .{ .name = "inactive_dim", .kind = .{ .toggle = .{ .on = out.cc.server.config.compositor.inactive_dim, .owner = out, .on_change = &onInactiveDimChanged } } },
+ };
+
+ const anim_enabled = out.cc.server.config.animations.enabled;
+ out.anim_enabled_label_children = .{
+ .{ .kind = .{ .text = .{ .content = i18n.tr("Animations"), .font_size = theme.global.app_text_size, .weight = 600, .color = pal.fg } } },
+ .{ .kind = .{ .text = .{ .content = i18n.tr("Window and panel transitions"), .font_size = theme.global.settings_description_size, .color = pal.dim } } },
+ };
+ out.anim_enabled_row_children = .{
+ .{ .kind = .container, .direction = .column, .gap = 2, .width = .{ .flex = 1 }, .children = &out.anim_enabled_label_children },
+ .{ .name = "animations", .kind = .{ .toggle = .{ .on = anim_enabled, .owner = out, .on_change = &onAnimationsEnabledChanged } } },
+ };
+
+ const anim_speed = out.cc.server.config.animations.speed;
+ out.anim_speed_row_children = .{
+ labelWidget(i18n.tr("Animation speed")),
+ .{
+ .name = "anim_speed",
+ .kind = .{ .segmented = .{ .labels = &anim_speed_labels, .selected = indexOfNearest(&anim_speed_values, anim_speed), .owner = out, .on_change = &onAnimSpeedChanged } },
+ .width = .{ .fixed = segmented_width },
+ },
+ };
+
+ const reduced_motion = out.cc.server.config.animations.reduced_motion;
+ out.reduced_motion_row_children = .{
+ labelWidget(i18n.tr("Reduced motion")),
+ .{
+ .name = "reduced_motion",
+ .kind = .{ .segmented = .{ .labels = panel.translatedLabels(&reduced_motion_labels), .selected = indexOfReducedMotion(reduced_motion), .owner = out, .on_change = &onReducedMotionChanged } },
+ .width = .{ .fixed = segmented_width },
+ },
+ };
+
+ const focus_zoom = out.cc.server.config.compositor.focus_zoom;
+ out.focus_zoom_children = .{
+ labelWidget(i18n.tr("Window switching zoom")),
+ .{ .name = "focus_zoom", .kind = .{ .segmented = .{ .labels = panel.translatedLabels(&focus_zoom_labels), .selected = @intFromEnum(focus_zoom), .owner = out, .on_change = &onFocusZoomChanged } }, .width = .{ .percent = 1 } },
+ .{ .kind = .{ .text = .{ .content = focus_zoom_descriptions[@intFromEnum(focus_zoom)].get(), .font_size = theme.global.settings_description_size, .color = pal.dim } } },
+ };
+
+ out.drag_feedback_children = .{
+ labelWidget(i18n.tr("Drag feedback")),
+ .{ .name = "drag_feedback", .kind = .{ .toggle = .{ .on = out.cc.server.config.compositor.drag_feedback, .owner = out, .on_change = &onDragFeedbackChanged } } },
+ };
+ const drag_scale = out.cc.server.config.compositor.drag_scale;
+ const drag_formatted = std.fmt.bufPrint(&out.drag_scale_value_buf, "{d:.3}×", .{drag_scale}) catch "?";
+ out.drag_scale_header_children = .{ labelWidget(i18n.tr("Drag lift scale")), pillWidget(drag_formatted) };
+ out.drag_scale_children = .{
+ .{ .kind = .container, .direction = .row, .justify = .space_between, .children = &out.drag_scale_header_children },
+ .{ .name = "drag_scale", .kind = .{ .slider = .{
+ .value = drag_scale,
+ .min = loader.drag_scale_min,
+ .max = loader.drag_scale_max,
+ .step = 0.001,
+ .owner = out,
+ .on_change = &onDragScaleChanged,
+ } } },
+ };
+}
+
+/// The UI font, cursor theme, font size, radius, shadow and edge glow rows.
+pub fn buildFontRows(out: *Section, arena: std.mem.Allocator, t: theme.Theme, pal: theme.Theme) void {
+ if (out.font_families == null) {
+ out.font_families = @import("ui").font_fallback.listFamilies(out.font_arena.allocator()) catch null;
+ }
+ const families = out.font_families orelse &.{};
+ var family_index: ?usize = null;
+ for (families, 0..) |family, i| {
+ if (std.ascii.eqlIgnoreCase(family, t.font)) {
+ family_index = i;
+ break;
+ }
+ }
+ out.family_row_children = .{
+ labelWidget(i18n.tr("UI font")),
+ .{
+ .name = "font",
+ .kind = .{ .select = .{
+ .labels = families,
+ .selected = family_index,
+ .placeholder = arena.dupe(u8, t.font) catch i18n.tr("Current font"),
+ .disabled = families.len == 0,
+ .owner = out,
+ .on_change = &onFontFamilyChanged,
+ } },
+ .width = .{ .fixed = segmented_width },
+ },
+ };
+ if (out.cursor_themes == null) {
+ out.cursor_themes = cursor_theme.list(out.font_arena.allocator(), out.cc.server.io) catch null;
+ }
+ const cursor_themes = out.cursor_themes orelse &.{};
+ var cursor_labels: [][]const u8 = &.{};
+ if (arena.alloc([]const u8, cursor_themes.len)) |labels| {
+ for (cursor_themes, labels) |ct, *l| l.* = ct.label;
+ cursor_labels = labels;
+ } else |_| {}
+ const active_cursor = out.cc.server.input.cursorThemeName();
+ out.cursor_row_children = .{
+ labelWidget(i18n.tr("Cursor theme")),
+ .{
+ .name = "cursor_theme",
+ .kind = .{ .select = .{
+ .labels = cursor_labels,
+ .selected = cursor_theme.indexOf(cursor_themes, active_cursor),
+ .placeholder = arena.dupe(u8, active_cursor) catch i18n.tr("Current theme"),
+ .disabled = cursor_labels.len == 0,
+ .owner = out,
+ .on_change = &onCursorThemePicked,
+ } },
+ .width = .{ .fixed = segmented_width },
+ },
+ };
+ out.font_row_children = .{
+ labelWidget(i18n.tr("Font size")),
+ .{
+ .name = "font_size",
+ .kind = .{ .segmented = .{ .labels = panel.translatedLabels(&font_labels), .selected = indexOfNearest(&font_values, t.font_size), .owner = out, .on_change = &onFontSizeChanged } },
+ .width = .{ .fixed = segmented_width },
+ },
+ };
+ out.radius_row_children = .{
+ labelWidget(i18n.tr("Radius")),
+ .{
+ .name = "radius",
+ .kind = .{ .segmented = .{ .labels = panel.translatedLabels(&radius_labels), .selected = if (theme.radiusPreset(t)) |preset| @intFromEnum(preset) else radius_labels.len, .owner = out, .on_change = &onRadiusChanged } },
+ .width = .{ .fixed = segmented_width },
+ },
+ };
+ out.shadow_row_children = .{
+ labelWidget(i18n.tr("Shadow")),
+ .{
+ .name = "shadow",
+ .kind = .{ .segmented = .{ .labels = panel.translatedLabels(&shadow_labels), .selected = indexOfNearest(&shadow_size_values, t.shadow_size), .owner = out, .on_change = &onShadowChanged } },
+ .width = .{ .fixed = segmented_width },
+ },
+ };
+
+ out.glow_label_children = .{
+ .{ .kind = .{ .text = .{ .content = i18n.tr("Edge glow"), .font_size = theme.global.app_text_size, .weight = 600, .color = pal.fg } } },
+ .{ .kind = .{ .text = .{ .content = i18n.tr("Light the active window's edge near the pointer"), .font_size = theme.global.settings_description_size, .color = pal.dim } } },
+ };
+ out.glow_row_children = .{
+ .{ .kind = .container, .direction = .column, .gap = 2, .width = .{ .flex = 1 }, .children = &out.glow_label_children },
+ .{ .name = "border_glow", .kind = .{ .toggle = .{ .on = t.border_glow_enabled, .owner = out, .on_change = &onBorderGlowChanged } } },
+ };
+}
+
+/// Window chrome height, control gap, opacity and darkness.
+pub fn buildChromeRow(out: *Section, t: theme.Theme) Widget {
+ const opacity_val = std.math.clamp(t.window_bg[3], 0.0, 1.0);
+ const opacity_formatted = std.fmt.bufPrint(&out.opacity_value_buf, "{d}%", .{@as(i32, @intFromFloat(@round(opacity_val * 100.0)))}) catch "?";
+ out.opacity_header_children = .{ labelWidget(i18n.tr("Window chrome opacity")), pillWidget(opacity_formatted) };
+ const opacity_header: Widget = .{ .kind = .container, .direction = .row, .justify = .space_between, .children = &out.opacity_header_children };
+ const opacity_slider: Widget = .{
+ .name = "chrome_opacity",
+ .kind = .{ .slider = .{
+ .value = opacity_val,
+ .min = 0.0,
+ .max = 1.0,
+ .step = 0.01,
+ .owner = out,
+ .on_change = &onChromeOpacityChanged,
+ } },
+ };
+ out.opacity_group_children = .{ opacity_header, opacity_slider };
+ const opacity_row: Widget = .{ .kind = .container, .direction = .column, .gap = 8, .children = &out.opacity_group_children };
+
+ const darkness_val = theme.chromeDarkness(t.window_bg);
+ const darkness_formatted = std.fmt.bufPrint(&out.darkness_value_buf, "{d}%", .{@as(i32, @intFromFloat(@round(darkness_val * 100.0)))}) catch "?";
+ out.darkness_header_children = .{ labelWidget(i18n.tr("Window chrome darkness")), pillWidget(darkness_formatted) };
+ const darkness_header: Widget = .{ .kind = .container, .direction = .row, .justify = .space_between, .children = &out.darkness_header_children };
+ const darkness_slider: Widget = .{
+ .name = "chrome_darkness",
+ .kind = .{ .slider = .{
+ .value = darkness_val,
+ .min = 0.0,
+ .max = 1.0,
+ .step = 0.01,
+ .owner = out,
+ .on_change = &onChromeDarknessChanged,
+ } },
+ };
+ out.darkness_group_children = .{ darkness_header, darkness_slider };
+ const darkness_row: Widget = .{ .kind = .container, .direction = .column, .gap = 8, .children = &out.darkness_group_children };
+ const chrome_height_row = pxGroup(out, px_chrome_height, i18n.tr("Window chrome height"), t.chrome_height, 28, 84, 1, &PxHandler(px_chrome_height, "chrome_height", false).changed);
+ out.px[px_chrome_height].group_children[1].name = "chrome_height";
+ const chrome_gap_row = pxGroup(out, px_chrome_control_gap, i18n.tr("Window control gap"), t.chrome_control_gap, 0, 24, 1, &PxHandler(px_chrome_control_gap, "chrome_control_gap", false).changed);
+ out.px[px_chrome_control_gap].group_children[1].name = "chrome_control_gap";
+ out.chrome_group_children = .{ chrome_height_row, chrome_gap_row, opacity_row, darkness_row };
+ const chrome_row: Widget = .{ .kind = .container, .direction = .column, .gap = 12, .children = &out.chrome_group_children };
+ return chrome_row;
+}
+
+/// The inactive window opacity slider.
+pub fn inactiveOpacityRow(out: *Section) Widget {
+ const inactive_val = std.math.clamp(out.cc.server.config.compositor.inactive_opacity, 0.0, 1.0);
+ const inactive_formatted = std.fmt.bufPrint(&out.inactive_opacity_value_buf, "{d}%", .{@as(i32, @intFromFloat(@round(inactive_val * 100.0)))}) catch "?";
+ out.inactive_opacity_header_children = .{ labelWidget(i18n.tr("Inactive window opacity")), pillWidget(inactive_formatted) };
+ const inactive_opacity_header: Widget = .{ .kind = .container, .direction = .row, .justify = .space_between, .children = &out.inactive_opacity_header_children };
+ const inactive_opacity_slider: Widget = .{
+ .name = "inactive_opacity",
+ .kind = .{ .slider = .{
+ .value = inactive_val,
+ .min = 0.0,
+ .max = 1.0,
+ .step = 0.01,
+ .owner = out,
+ .on_change = &onInactiveOpacityChanged,
+ } },
+ };
+ out.inactive_opacity_group_children = .{ inactive_opacity_header, inactive_opacity_slider };
+ const inactive_opacity_row: Widget = .{ .kind = .container, .direction = .column, .gap = 8, .children = &out.inactive_opacity_group_children };
+ return inactive_opacity_row;
+}
+
+/// The terminal opacity slider for new windows.
+pub fn terminalOpacityRow(out: *Section) Widget {
+ // Unset means a terminal keeps its own alpha; the slider then shows opaque.
+ const terminal_val = std.math.clamp(out.cc.server.config.compositor.terminal_opacity orelse 1.0, 0.0, 1.0);
+ const terminal_formatted = std.fmt.bufPrint(&out.terminal_opacity_value_buf, "{d}%", .{@as(i32, @intFromFloat(@round(terminal_val * 100.0)))}) catch "?";
+ out.terminal_opacity_header_children = .{ labelWidget(i18n.tr("Terminal opacity (new windows)")), pillWidget(terminal_formatted) };
+ const terminal_opacity_header: Widget = .{ .kind = .container, .direction = .row, .justify = .space_between, .children = &out.terminal_opacity_header_children };
+ const terminal_opacity_slider: Widget = .{
+ .name = "terminal_opacity",
+ .kind = .{ .slider = .{
+ .value = terminal_val,
+ .min = 0.0,
+ .max = 1.0,
+ .step = 0.01,
+ .owner = out,
+ .on_change = &onTerminalOpacityChanged,
+ } },
+ };
+ out.terminal_opacity_group_children = .{ terminal_opacity_header, terminal_opacity_slider };
+ const terminal_opacity_row: Widget = .{ .kind = .container, .direction = .column, .gap = 8, .children = &out.terminal_opacity_group_children };
+ return terminal_opacity_row;
+}
diff --git a/src/control_center/sections/appearance_sections.zig b/src/control_center/sections/appearance_sections.zig
new file mode 100644
index 0000000..5108dc8
--- /dev/null
+++ b/src/control_center/sections/appearance_sections.zig
@@ -0,0 +1,313 @@
+//! Building the Appearance page's Taskbar, Start menu and Dock sections and the theme pack controls.
+
+const i18n = @import("i18n");
+const std = @import("std");
+const layout = @import("ui").layout;
+const theme = @import("ui").theme;
+const theme_presets = @import("config").theme_pack;
+const Widget = layout.Widget;
+const panel = @import("../panel.zig");
+const loader = @import("config").loader;
+const Taskbar = @import("../../Taskbar.zig");
+const Server = @import("../../Server.zig");
+const dock_mod = @import("../../Dock.zig");
+const taskbar_items = @import("config").taskbar_items;
+const folder_picker = @import("../folder_picker.zig");
+const menu_size = @import("../../start_menu/size.zig");
+const wlr = @import("wlroots");
+const appearance_themes = @import("appearance_themes.zig");
+const appearance_chrome = @import("appearance_chrome.zig");
+const appearance_items = @import("appearance_items.zig");
+const appearance_dock = @import("appearance_dock.zig");
+const onChooseStartLogo = appearance_themes.onChooseStartLogo;
+const onAutoMenuSize = appearance_themes.onAutoMenuSize;
+const onResetStartLogo = appearance_themes.onResetStartLogo;
+const onResetTheme = appearance_themes.onResetTheme;
+const onInstallTheme = appearance_themes.onInstallTheme;
+const onReplaceTheme = appearance_themes.onReplaceTheme;
+const onRemoveTheme = appearance_themes.onRemoveTheme;
+const onExportTheme = appearance_themes.onExportTheme;
+const onIconThemePicked = appearance_themes.onIconThemePicked;
+const ClockStyle = appearance_chrome.ClockStyle;
+const onTaskbarPositionChanged = appearance_chrome.onTaskbarPositionChanged;
+const item_row_height = appearance_items.item_row_height;
+const itemRowStyle = appearance_items.itemRowStyle;
+const itemZoneStyle = appearance_items.itemZoneStyle;
+const syncItems = appearance_items.syncItems;
+const ItemToggle = appearance_items.ItemToggle;
+const onDockChanged = appearance_dock.onDockChanged;
+const onDockAutoHideChanged = appearance_dock.onDockAutoHideChanged;
+const onDockOpacityChanged = appearance_dock.onDockOpacityChanged;
+const onDockActiveHighlightChanged = appearance_dock.onDockActiveHighlightChanged;
+const onDockShowTrashChanged = appearance_dock.onDockShowTrashChanged;
+const onDockPositionChanged = appearance_dock.onDockPositionChanged;
+const onDockHeightChanged = appearance_dock.onDockHeightChanged;
+const updateDockZoomLabel = appearance_dock.updateDockZoomLabel;
+const onDockHoverZoomChanged = appearance_dock.onDockHoverZoomChanged;
+const menu_width_min = menu_size.min_width;
+const menu_height_min = menu_size.min_height;
+const appearance = @import("appearance.zig");
+const segmented_width = appearance.segmented_width;
+const dock_radius_min = appearance.dock_radius_min;
+const dock_radius_max = appearance.dock_radius_max;
+const px_taskbar_size = appearance.px_taskbar_size;
+const px_chip_gap = appearance.px_chip_gap;
+const px_start_button_gap = appearance.px_start_button_gap;
+const px_start_icon_size = appearance.px_start_icon_size;
+const px_menu_left = appearance.px_menu_left;
+const px_menu_bottom = appearance.px_menu_bottom;
+const px_icon_left = appearance.px_icon_left;
+const px_icon_bottom = appearance.px_icon_bottom;
+const px_chip_width = appearance.px_chip_width;
+const px_menu_width = appearance.px_menu_width;
+const px_menu_height = appearance.px_menu_height;
+const px_dock_height = appearance.px_dock_height;
+const px_dock_hover_zoom = appearance.px_dock_hover_zoom;
+const px_taskbar_edge_gap = appearance.px_taskbar_edge_gap;
+const px_taskbar_length = appearance.px_taskbar_length;
+const px_taskbar_radius = appearance.px_taskbar_radius;
+const px_dock_opacity = appearance.px_dock_opacity;
+const px_dock_radius = appearance.px_dock_radius;
+const Section = appearance.Section;
+const menu_width_max = appearance.menu_width_max;
+const menu_height_max = appearance.menu_height_max;
+const start_logo_tile_size = appearance.start_logo_tile_size;
+const startLogoImage = appearance.startLogoImage;
+const labelWidget = appearance.labelWidget;
+const sectionLabel = appearance.sectionLabel;
+const pxGroup = appearance.pxGroup;
+const unitGroup = appearance.unitGroup;
+const PxHandler = appearance.PxHandler;
+const UnitHandler = appearance.UnitHandler;
+
+/// The Taskbar section: position, geometry, clock style and the item sections.
+pub fn buildTaskbarSection(out: *Section, t: theme.Theme, pal: theme.Theme) Widget {
+ out.taskbar_position_children = .{
+ labelWidget(i18n.tr("Taskbar position")),
+ .{ .name = "taskbar_position", .kind = .{ .segmented = .{ .labels = panel.translatedLabels(&.{ i18n.msg("Top"), i18n.msg("Bottom") }), .selected = @intFromEnum(out.cc.server.config.compositor.taskbar_position), .owner = out, .on_change = &onTaskbarPositionChanged } }, .width = .{ .fixed = segmented_width } },
+ };
+ const position_row: Widget = .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.taskbar_position_children };
+ const taskbar_min: f32 = @floatFromInt(Taskbar.min_bar_height);
+ const taskbar_row = pxGroup(out, px_taskbar_size, i18n.tr("Taskbar size"), std.math.clamp(t.taskbar_size, taskbar_min, 84.0), taskbar_min, 84, 2, &PxHandler(px_taskbar_size, "taskbar_size", true).changed);
+ // A floating bar: its gap from the edge, its length and its corners. At
+ // 0 px, 100 % and 0 px it is the original flush, full-width, square bar.
+ const edge_gap_row = pxGroup(out, px_taskbar_edge_gap, i18n.tr("Taskbar gap from edge"), std.math.clamp(t.taskbar_edge_gap, 0.0, 48.0), 0, 48, 2, &PxHandler(px_taskbar_edge_gap, "taskbar_edge_gap", true).changed);
+ out.px[px_taskbar_edge_gap].group_children[1].name = "taskbar_edge_gap";
+ const length_row = unitGroup(out, px_taskbar_length, i18n.tr("Taskbar length"), std.math.clamp(t.taskbar_length, 30.0, 100.0), 30, 100, 2, &UnitHandler(px_taskbar_length, "taskbar_length", true, "%").changed, "%");
+ out.px[px_taskbar_length].group_children[1].name = "taskbar_length";
+ const radius_row = pxGroup(out, px_taskbar_radius, i18n.tr("Taskbar corner radius"), std.math.clamp(t.taskbar_radius, 0.0, 42.0), 0, 42, 1, &PxHandler(px_taskbar_radius, "taskbar_radius", true).changed);
+ out.px[px_taskbar_radius].group_children[1].name = "taskbar_radius";
+ // Also sets each pill's top/bottom margin within the bar (capped) —
+ // see Taskbar.chipVerticalMargin — so this one slider spaces chips on
+ // every side at once instead of only widening the horizontal gap.
+ const chip_width_row = pxGroup(out, px_chip_width, i18n.tr("Window item width"), t.chip_width, 64, 400, 4, &PxHandler(px_chip_width, "chip_width", true).changed);
+ const chip_gap_row = pxGroup(out, px_chip_gap, i18n.tr("Window item gap"), std.math.clamp(t.chip_gap, 0.0, 24.0), 0, 24, 2, &PxHandler(px_chip_gap, "chip_gap", true).changed);
+ const start_gap_row = pxGroup(out, px_start_button_gap, i18n.tr("Start button gap"), std.math.clamp(t.start_button_gap, 0.0, 40.0), 0, 40, 2, &PxHandler(px_start_button_gap, "start_button_gap", true).changed);
+ const start_icon_row = pxGroup(out, px_start_icon_size, i18n.tr("Start button icon size"), std.math.clamp(t.start_button_icon_size, 16.0, 42.0), 16, 42, 2, &PxHandler(px_start_icon_size, "start_button_icon_size", true).changed);
+ out.clock_bold_children = .{
+ labelWidget(i18n.tr("Bold clock text")),
+ .{ .name = "clock_bold", .kind = .{ .toggle = .{ .on = theme.taskbar(.clock_bold), .owner = out, .on_change = &ClockStyle("clock_bold").changed } } },
+ };
+ out.clock_italic_children = .{
+ labelWidget(i18n.tr("Italic clock text")),
+ .{ .name = "clock_italic", .kind = .{ .toggle = .{ .on = theme.taskbar(.clock_italic), .owner = out, .on_change = &ClockStyle("clock_italic").changed } } },
+ };
+ const clock_bold_row: Widget = .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.clock_bold_children };
+ const clock_italic_row: Widget = .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.clock_italic_children };
+ // Each section is an inset well of raised rows; a whole row is its grip.
+ inline for (0..taskbar_items.count) |i| {
+ out.item_controls[i] = .{
+ .{ .kind = .{ .button = .{ .label = i18n.tr("Drag to move"), .icon = .drag_handle, .variant = .ghost, .owner = out, .id = i } }, .width = .{ .fixed = 28 }, .height = .{ .fixed = 28 } },
+ .{ .kind = .{ .text = .{ .content = "", .font_size = theme.global.app_text_size, .weight = 600, .color = pal.fg } }, .width = .{ .flex = 1 } },
+ .{ .kind = .{ .toggle = .{ .on = false, .owner = out, .on_change = &ItemToggle(i).changed } } },
+ };
+ out.item_rows[i] = .{ .kind = .{ .rect = itemRowStyle(false) }, .direction = .row, .gap = 8, .@"align" = .center, .padding = .{ .top = 6, .right = 10, .bottom = 6, .left = 6 }, .children = &out.item_controls[i] };
+ }
+ inline for (.{ i18n.msg("LEFT"), i18n.msg("CENTER"), i18n.msg("RIGHT") }, .{ "left", "center", "right" }, 0..) |label, name, zone| {
+ out.items_placeholder_body[zone] = .{
+ .{ .kind = .container, .width = .{ .flex = 1 } },
+ // Slack: a fractional raster scale hints wider than the logical measure.
+ .{ .kind = .{ .text = .{ .content = i18n.tr("Drag items here"), .font_size = theme.global.settings_description_size, .color = pal.dim } }, .min_width = @import("ui").measure.textNatural(i18n.tr("Drag items here"), .sans, 400, theme.global.settings_description_size).w + 6 },
+ .{ .kind = .container, .width = .{ .flex = 1 } },
+ };
+ out.items_placeholder[zone] = .{.{ .kind = .container, .height = .{ .fixed = item_row_height }, .@"align" = .center, .children = &out.items_placeholder_body[zone] }};
+ out.items_section_children[zone] = .{
+ sectionLabel(label.get()),
+ .{ .name = "taskbar_zone_" ++ name, .kind = .{ .rect = itemZoneStyle(false) }, .direction = .column, .gap = 6, .padding = layout.Edges.all(6), .@"align" = .stretch },
+ };
+ }
+ _ = syncItems(out, out.cc.server.config.compositor.taskbar_items, null);
+ out.items_children = .{
+ labelWidget(i18n.tr("Taskbar sections")),
+ .{ .kind = .{ .text = .{ .content = i18n.tr("Drag an item to reorder it or move it to another section. Switch it off to hide it. Battery appears when available."), .font_size = theme.global.settings_description_size, .color = pal.dim } } },
+ .{ .kind = .container, .direction = .column, .gap = 6, .@"align" = .stretch, .children = &out.items_section_children[0] },
+ .{ .kind = .container, .direction = .column, .gap = 6, .@"align" = .stretch, .children = &out.items_section_children[1] },
+ .{ .kind = .container, .direction = .column, .gap = 6, .@"align" = .stretch, .children = &out.items_section_children[2] },
+ .{ .name = "taskbar_capture_notice", .kind = .{ .text = .{ .content = if (out.cc.server.config.compositor.taskbar_items.shown(.capture))
+ i18n.tr("Screen capture appears while recording or sharing your screen. Keeping it enabled is recommended.")
+ else
+ i18n.tr("Warning: Screen capture is hidden. Recording and screen sharing can continue without a visible indicator or Stop sharing button. Hiding it is not recommended."), .font_size = theme.global.settings_description_size, .color = pal.dim } } },
+ };
+ const items_group: Widget = .{ .kind = .container, .direction = .column, .gap = 8, .@"align" = .stretch, .children = &out.items_children };
+ out.taskbar_section_children = .{ panel.sectionTitle(i18n.tr("Taskbar")), position_row, taskbar_row, edge_gap_row, length_row, radius_row, chip_width_row, chip_gap_row, start_gap_row, start_icon_row, clock_bold_row, clock_italic_row, items_group };
+ const taskbar_section: Widget = .{ .kind = .container, .direction = .column, .gap = 12, .children = &out.taskbar_section_children };
+ return taskbar_section;
+}
+
+/// The Start menu section: the button logo, menu size and paddings.
+pub fn buildStartMenuSection(out: *Section, arena: std.mem.Allocator, t: theme.Theme, pal: theme.Theme) Widget {
+ var output_box: wlr.Box = undefined;
+ out.cc.server.output_layout.getBox(out.cc.wlr_output, &output_box);
+ const menu_now = menu_size.wanted(t, @floatFromInt(output_box.width), @floatFromInt(output_box.height));
+ const menu_pinned = t.start_menu_width > 0 or t.start_menu_max_height > 0;
+ const menu_width_row = pxGroup(out, px_menu_width, i18n.tr("Menu width"), std.math.clamp(menu_now.width, menu_width_min, menu_width_max), menu_width_min, menu_width_max, 10, &PxHandler(px_menu_width, "start_menu_width", false).changed);
+ out.px[px_menu_width].group_children[1].name = "start_menu_width";
+ const menu_height_row = pxGroup(out, px_menu_height, i18n.tr("Menu height"), std.math.clamp(menu_now.height, menu_height_min, menu_height_max), menu_height_min, menu_height_max, 10, &PxHandler(px_menu_height, "start_menu_max_height", false).changed);
+ out.px[px_menu_height].group_children[1].name = "start_menu_height";
+ const menu_left_row = pxGroup(out, px_menu_left, i18n.tr("Menu left padding"), std.math.clamp(t.start_menu_left_pad, 0.0, 40.0), 0, 40, 2, &PxHandler(px_menu_left, "start_menu_left_pad", false).changed);
+ const menu_bottom_row = pxGroup(out, px_menu_bottom, i18n.tr("Menu bottom padding"), std.math.clamp(t.start_menu_bottom_pad, 0.0, 40.0), 0, 40, 2, &PxHandler(px_menu_bottom, "start_menu_bottom_pad", false).changed);
+ const icon_left_row = pxGroup(out, px_icon_left, i18n.tr("Icon left padding"), std.math.clamp(t.start_menu_icon_left_pad, 0.0, 32.0), 0, 32, 2, &PxHandler(px_icon_left, "start_menu_icon_left_pad", false).changed);
+ const icon_bottom_row = pxGroup(out, px_icon_bottom, i18n.tr("Icon bottom padding"), std.math.clamp(t.start_menu_icon_bottom_pad, 0.0, 24.0), 0, 24, 2, &PxHandler(px_icon_bottom, "start_menu_icon_bottom_pad", false).changed);
+ out.start_logo_buttons = .{
+ .{ .name = "start_logo_choose", .kind = .{ .button = .{ .label = i18n.tr("Choose file…"), .owner = out, .on_click = &onChooseStartLogo, .state = if (folder_picker.running()) .disabled else .idle } }, .width = .auto, .min_width = 124, .height = .{ .fixed = 30 } },
+ .{ .name = "start_logo_reset", .kind = .{ .button = .{ .label = i18n.tr("Reset to default"), .owner = out, .on_click = &onResetStartLogo, .state = if (t.start_button_icon.len == 0 or folder_picker.running()) .disabled else .idle } }, .width = .auto, .min_width = 140, .height = .{ .fixed = 30 } },
+ };
+ const logo = startLogoImage(out, arena, Taskbar.startIconSize());
+ const logo_note: []const u8 = out.start_logo_error orelse blk: {
+ if (t.start_button_icon.len == 0) break :blk i18n.tr("Default R logo · PNG or SVG");
+ const name = std.fs.path.basename(t.start_button_icon);
+ if (logo.failed) break :blk i18n.allocPrint(arena, i18n.tr("{name} could not be loaded · showing the default R"), .{ .name = name }) catch name;
+ break :blk name;
+ };
+ // The logo sits on the taskbar, so it is shown on the taskbar's colour.
+ var tile_bg = theme.taskbar(.taskbar_bg);
+ tile_bg[3] = 1;
+ out.start_logo_tile = .{.{
+ .name = "start_logo_preview",
+ .kind = .{ .image = logo.image },
+ .width = .{ .fixed = @floatFromInt(logo.size) },
+ .height = .{ .fixed = @floatFromInt(logo.size) },
+ }};
+ out.start_logo_info = .{
+ .{ .name = "start_logo_file", .kind = .{ .text = .{ .content = logo_note, .font_size = theme.global.settings_description_size, .color = pal.dim } } },
+ .{ .kind = .container, .direction = .row, .gap = 8, .children = &out.start_logo_buttons },
+ };
+ out.start_logo_body = .{
+ .{
+ .name = "start_logo_tile",
+ .kind = .{ .rect = .{ .color = tile_bg, .radius = 10, .border_width = 1, .border_color = pal.border_soft } },
+ .width = .{ .fixed = start_logo_tile_size },
+ .height = .{ .fixed = start_logo_tile_size },
+ .justify = .center,
+ .@"align" = .center,
+ .children = &out.start_logo_tile,
+ },
+ .{ .kind = .container, .direction = .column, .gap = 8, .justify = .center, .width = .{ .flex = 1 }, .children = &out.start_logo_info },
+ };
+ out.start_logo_children = .{
+ labelWidget(i18n.tr("Start button logo")),
+ .{ .kind = .container, .direction = .row, .gap = 12, .@"align" = .center, .children = &out.start_logo_body },
+ };
+ const logo_row: Widget = .{ .kind = .container, .direction = .column, .gap = 8, .children = &out.start_logo_children };
+ out.start_size_children = .{
+ .{ .name = "start_menu_size_note", .kind = .{ .text = .{ .content = if (menu_pinned) i18n.tr("Custom size") else i18n.tr("Sized to fit your screen · move a slider to set your own"), .font_size = theme.global.settings_description_size, .color = pal.dim } }, .width = .{ .flex = 1 } },
+ .{ .name = "start_menu_size_auto", .kind = .{ .button = .{ .label = i18n.tr("Size to screen"), .owner = out, .on_click = &onAutoMenuSize, .state = if (menu_pinned) .idle else .disabled } }, .width = .auto, .min_width = 124, .height = .{ .fixed = 30 } },
+ };
+ const menu_size_row: Widget = .{ .kind = .container, .direction = .row, .gap = 8, .@"align" = .center, .children = &out.start_size_children };
+ out.start_menu_section_children = .{ panel.sectionTitle(i18n.tr("Start menu")), logo_row, menu_width_row, menu_height_row, menu_size_row, menu_left_row, menu_bottom_row, icon_left_row, icon_bottom_row };
+ const start_menu_section: Widget = .{ .kind = .container, .direction = .column, .gap = 12, .children = &out.start_menu_section_children };
+ return start_menu_section;
+}
+
+/// The theme pack actions and preview, and the icon theme picker; returns the pack controls.
+pub fn buildThemePackRows(out: *Section, arena: std.mem.Allocator, server: *Server, pal: theme.Theme, matched_index: ?usize) []Widget {
+ out.theme_actions = .{
+ .{ .name = "theme_reset", .kind = .{ .button = .{ .label = i18n.tr("Reset to theme"), .owner = out, .on_click = &onResetTheme } }, .height = .{ .fixed = 32 } },
+ .{ .name = "theme_install", .kind = .{ .button = .{ .label = i18n.tr("Install theme…"), .owner = out, .on_click = &onInstallTheme } }, .height = .{ .fixed = 32 } },
+ .{ .name = "theme_remove", .kind = .{ .button = .{ .label = i18n.tr("Remove"), .owner = out, .on_click = &onRemoveTheme, .state = if (matched_index != null and out.presets[matched_index.?].user_installed) .idle else .disabled } }, .height = .{ .fixed = 32 } },
+ .{ .name = "theme_export", .kind = .{ .button = .{ .label = i18n.tr("Save look…"), .owner = out, .on_click = &onExportTheme } }, .height = .{ .fixed = 32 } },
+ .{ .name = "theme_replace", .kind = .{ .button = .{ .label = i18n.tr("Replace installed theme"), .owner = out, .on_click = &onReplaceTheme, .state = if (out.theme_pending_path != null) .idle else .disabled } }, .height = .{ .fixed = 32 } },
+ };
+ var pack_preview: Widget = .{ .kind = .container };
+ out.theme_preview_pending = false;
+ if (server.config.theme_pack) |pack| {
+ if (pack.root.len > 0) {
+ if (theme_presets.asset(arena, server.io, pack.root, "preview.png")) |path| {
+ const result = server.iconLookup(path, 192);
+ if (result == .ready) {
+ const entry = result.ready;
+ if (arena.dupe(u32, entry.pixels)) |pixels| {
+ pack_preview = .{ .name = "theme_preview", .kind = .{ .image = .{ .pixels = pixels, .width = entry.size, .height = entry.size, .fallback_icon = null } }, .width = .{ .fixed = 160 }, .height = .{ .fixed = 100 } };
+ } else |_| {}
+ } else if (result == .pending) out.theme_preview_pending = true;
+ } else |_| {}
+ }
+ }
+ const pack_controls = arena.dupe(Widget, &.{
+ .{ .kind = .container, .direction = .row, .gap = 8, .children = out.theme_actions[0..4] },
+ .{ .kind = .{ .text = .{ .content = if (out.theme_message.len > 0) out.theme_message else i18n.tr("Packs include colours and artwork. Personal edits are saved as overrides."), .font_size = theme.global.app_status_size, .color = pal.dim } } },
+ .{ .kind = .container, .children = if (out.theme_pending_path != null) out.theme_actions[4..5] else &.{} },
+ pack_preview,
+ }) catch @constCast(&[_]Widget{});
+ const icon_themes = @import("../../icon_theme.zig").listNames(arena, server.io, server.icon_theme_cfg) catch &.{};
+ out.icon_theme_names = icon_themes;
+ const icon_labels = arena.dupe([]const u8, icon_themes) catch @constCast(icon_themes);
+ if (icon_labels.len > 0) icon_labels[0] = i18n.tr("System default");
+ var icon_selected: ?usize = null;
+ for (icon_themes, 0..) |name, i| if (std.mem.eql(u8, name, server.config.compositor.icon_theme)) {
+ icon_selected = i;
+ };
+ out.icon_theme_row = .{
+ labelWidget(i18n.tr("Icon theme")),
+ .{ .name = "icon_theme", .kind = .{ .select = .{ .labels = icon_labels, .selected = icon_selected, .placeholder = i18n.tr("Pack or system default"), .owner = out, .on_change = &onIconThemePicked } }, .width = .{ .fixed = segmented_width } },
+ };
+ return pack_controls;
+}
+
+/// The Dock section rows.
+pub fn buildDockRows(out: *Section, server: *Server) void {
+ out.dock_children = .{
+ labelWidget(i18n.tr("RediWM dock")),
+ .{ .name = "dock_enabled", .kind = .{ .toggle = .{ .on = out.cc.server.config.compositor.dock_enabled, .owner = out, .on_change = &onDockChanged } } },
+ };
+ out.dock_position_children = .{
+ labelWidget(i18n.tr("Dock position")),
+ .{ .name = "dock_position", .kind = .{ .segmented = .{ .labels = panel.translatedLabels(&.{ i18n.msg("Top"), i18n.msg("Bottom"), i18n.msg("Left"), i18n.msg("Right") }), .selected = @intFromEnum(server.config.compositor.dock_position), .owner = out, .on_change = &onDockPositionChanged } }, .width = .{ .fixed = segmented_width } },
+ };
+ out.dock_auto_hide_children = .{
+ labelWidget(i18n.tr("Auto-hide dock")),
+ .{ .name = "dock_auto_hide", .kind = .{ .toggle = .{ .on = server.config.compositor.dock_auto_hide, .owner = out, .on_change = &onDockAutoHideChanged } } },
+ };
+ const dock_height_row = pxGroup(out, px_dock_height, i18n.tr("Dock size"), @floatFromInt(server.config.compositor.dock_height), @floatFromInt(loader.dock_height_min), @floatFromInt(loader.dock_height_max), 2, &onDockHeightChanged);
+ out.px[px_dock_height].group_children[1].name = "dock_height";
+ const dock_zoom_row = pxGroup(out, px_dock_hover_zoom, i18n.tr("Dock hover zoom (1.00× disables)"), server.config.compositor.dock_hover_zoom, 1, loader.dock_hover_zoom_max, 0.05, &onDockHoverZoomChanged);
+ out.px[px_dock_hover_zoom].group_children[1].name = "dock_hover_zoom";
+ updateDockZoomLabel(out);
+ // The slider shows the opacity the dock is drawn with, whether the theme or
+ // `dock_opacity` set it; the radius, whether it is the dock's own or the windows'.
+ const dock_pal = theme.shellPalette();
+ const dock_opacity_row = unitGroup(out, px_dock_opacity, i18n.tr("Dock opacity"), @round(dock_mod.background(&server.config.compositor, dock_pal)[3] * 100), 0, 100, 1, &onDockOpacityChanged, "%");
+ out.px[px_dock_opacity].group_children[1].name = "dock_opacity";
+ const dock_radius_row = pxGroup(out, px_dock_radius, i18n.tr("Dock corner radius"), std.math.clamp(dock_mod.cornerRadius(dock_pal), dock_radius_min, dock_radius_max), dock_radius_min, dock_radius_max, 1, &PxHandler(px_dock_radius, "dock_radius", false).changed);
+ out.px[px_dock_radius].group_children[1].name = "dock_radius";
+ out.dock_active_children = .{
+ labelWidget(i18n.tr("Highlight active app")),
+ .{ .name = "dock_active_highlight", .kind = .{ .toggle = .{ .on = server.config.compositor.dock_active_highlight, .owner = out, .on_change = &onDockActiveHighlightChanged } } },
+ };
+ out.dock_trash_children = .{
+ labelWidget(i18n.tr("Show Trash")),
+ .{ .name = "dock_show_trash", .kind = .{ .toggle = .{ .on = server.config.compositor.dock_show_trash, .owner = out, .on_change = &onDockShowTrashChanged } } },
+ };
+ out.dock_group_children = .{
+ panel.sectionTitle(i18n.tr("Dock")),
+ .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.dock_children },
+ .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.dock_position_children },
+ .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.dock_auto_hide_children },
+ dock_height_row,
+ dock_zoom_row,
+ dock_opacity_row,
+ dock_radius_row,
+ .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.dock_active_children },
+ .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.dock_trash_children },
+ };
+}