diff --git a/desktop/internal/core/chrome.go b/desktop/internal/core/chrome.go index b92c58a088..2013ecee8c 100644 --- a/desktop/internal/core/chrome.go +++ b/desktop/internal/core/chrome.go @@ -46,14 +46,19 @@ type ChromeItem struct { // ID is the stable host identifier, persisted in placements. It must be unique and not // empty. ID string `json:"id"` - // DefaultZone is the zone of the default layout. Its surface (the tool stripes, the title - // bar or the status bar) is the only surface the item may ever sit in. + // DefaultZone is the zone of the default layout. The item may sit only in zones of its + // surface (the tool stripes, the title bar or the status bar), unless AlsoOnToolStripes adds + // the stripe zones. DefaultZone Zone `json:"defaultZone"` // Panel reports that the button opens a tool panel in its zone's panel slot. Only the six // tool stripe zones can host a panel. Panel bool `json:"panel,omitempty"` // OpenByDefault reports that the panel is open in the default layout. It requires Panel. OpenByDefault bool `json:"openByDefault,omitempty"` + // AlsoOnToolStripes lets a title bar item sit in the six tool stripe zones too and come back + // to the title bar. On a stripe the item still opens no panel and cannot be hidden. Only + // title bar items may set it. + AlsoOnToolStripes bool `json:"alsoOnToolStripes,omitempty"` } // Placement is the zone of one item. The order of the placements that share a zone is the @@ -133,8 +138,8 @@ func ResetChrome() ChromeAction { // MoveChrome moves the item id into zone, in front of the item before when that item sits in // zone and at the end of the zone otherwise. An empty before always means the end. The zone -// must belong to the item's own surface; moving a stripe button into the status bar fails with -// CodeInvalidRequest. +// must belong to the item's own surface, or be a stripe zone for an item marked +// AlsoOnToolStripes; moving a stripe button into the status bar fails with CodeInvalidRequest. func MoveChrome(id string, zone Zone, before string) ChromeAction { return ChromeAction{kind: chromeMove, id: id, zone: zone, before: before} } @@ -152,7 +157,8 @@ func SetChromeOpen(id string, open bool) ChromeAction { // SetChromeHidden hides or shows the tool stripe button of the item id. Hiding closes the item's // panel; showing leaves the panel as it is. A hidden item keeps its zone and position. Only tool -// stripe items can be hidden; a title or status bar item fails with CodeInvalidRequest. +// stripe items can be hidden; a title or status bar item fails with CodeInvalidRequest, also +// when it is a title bar item that sits on a stripe. func SetChromeHidden(id string, hidden bool) ChromeAction { return ChromeAction{kind: chromeSetHidden, id: id, hidden: hidden} } @@ -231,9 +237,10 @@ type chromeLayoutResponse struct { // moving an open panel takes its open state into the target zone. // // The kernel answers CodeInvalidRequest for a malformed catalog (an empty or repeated id, a -// panel outside the tool stripes, a default-open item that is not a panel) and for an action -// that names an unknown item, moves an item to another surface, opens an item that is not a -// panel or hides an item outside the tool stripes. +// panel outside the tool stripes, a default-open item that is not a panel, AlsoOnToolStripes on +// an item outside the title bar) and for an action that names an unknown item, moves an item to +// a zone it may not sit in, opens an item that is not a panel or hides an item whose default +// zone is not on a tool stripe. // // The call only computes over its arguments and is fast enough for an event handler. func (c *Client) ReduceChromeLayout(ctx context.Context, catalog []ChromeItem, state ChromeLayout, action ChromeAction) (ChromeLayout, bool, error) { diff --git a/desktop/internal/core/core_test.go b/desktop/internal/core/core_test.go index 95681f2580..078d424708 100644 --- a/desktop/internal/core/core_test.go +++ b/desktop/internal/core/core_test.go @@ -558,13 +558,15 @@ func TestReduceRecentProjectsRejectsInvalidInput(t *testing.T) { } // chromeCatalog returns the catalog the chrome layout tests use: two panels on the upper left, -// one at the bottom left, and one plain button each on the title bar and the status bar. +// one at the bottom left, two plain title bar buttons, the second of which may also sit on the +// stripes, and one plain status bar button. func chromeCatalog() []ChromeItem { return []ChromeItem{ {ID: "project", DefaultZone: ZoneLeftTop, Panel: true, OpenByDefault: true}, {ID: "commit", DefaultZone: ZoneLeftTop, Panel: true}, {ID: "git", DefaultZone: ZoneBottomLeft, Panel: true}, {ID: "run", DefaultZone: ZoneTitleTrailing}, + {ID: "settings", DefaultZone: ZoneTitleTrailing, AlsoOnToolStripes: true}, {ID: "caret", DefaultZone: ZoneStatusTrailing}, } } @@ -602,6 +604,7 @@ func TestReduceChromeLayout(t *testing.T) { {ID: "commit", Zone: ZoneLeftTop}, {ID: "git", Zone: ZoneBottomLeft}, {ID: "run", Zone: ZoneTitleTrailing}, + {ID: "settings", Zone: ZoneTitleTrailing}, {ID: "caret", Zone: ZoneStatusTrailing}, }, Open: []string{"project"}, @@ -679,6 +682,35 @@ func TestReduceChromeLayout(t *testing.T) { requireCode(t, err, CodeInvalidRequest) }) + // A title bar item marked AlsoOnToolStripes moves onto a stripe and back, keeps the title bar + // rules there (it cannot be hidden or go into the status bar), and normalize keeps it there. + t.Run("a marked title item moves onto a stripe and back", func(t *testing.T) { + layout, changed := reduce(t, defaults, MoveChrome("settings", ZoneLeftTop, "commit")) + if !changed { + t.Error("changed = false, want true") + } + if got := zoneIDs(layout, ZoneLeftTop); !slices.Equal(got, []string{"project", "settings", "commit"}) { + t.Errorf("left top = %q, want [project settings commit]", got) + } + if got := zoneIDs(layout, ZoneTitleTrailing); !slices.Equal(got, []string{"run"}) { + t.Errorf("title = %q, want [run]", got) + } + if _, changed := reduce(t, layout, NormalizeChrome()); changed { + t.Error("normalizing a stripe placement of settings: changed = true, want false") + } + _, _, err := client.ReduceChromeLayout(ctx, catalog, layout, SetChromeHidden("settings", true)) + requireCode(t, err, CodeInvalidRequest) + _, _, err = client.ReduceChromeLayout(ctx, catalog, layout, MoveChrome("settings", ZoneStatusTrailing, "")) + requireCode(t, err, CodeInvalidRequest) + back, _ := reduce(t, layout, MoveChrome("settings", ZoneTitleTrailing, "run")) + if got := zoneIDs(back, ZoneTitleTrailing); !slices.Equal(got, []string{"settings", "run"}) { + t.Errorf("title after moving back = %q, want [settings run]", got) + } + if got := zoneIDs(back, ZoneLeftTop); !slices.Equal(got, []string{"project", "commit"}) { + t.Errorf("left top after moving back = %q, want [project commit]", got) + } + }) + t.Run("toggle and set open", func(t *testing.T) { layout, changed := reduce(t, defaults, ToggleChrome("git")) if !changed || !slices.Equal(layout.Open, []string{"project", "git"}) { @@ -772,6 +804,9 @@ func TestReduceChromeLayout(t *testing.T) { } _, _, err := client.ReduceChromeLayout(ctx, repeated, ChromeLayout{}, ResetChrome()) requireCode(t, err, CodeInvalidRequest) + stripeOnStripe := []ChromeItem{{ID: "a", DefaultZone: ZoneLeftTop, AlsoOnToolStripes: true}} + _, _, err = client.ReduceChromeLayout(ctx, stripeOnStripe, ChromeLayout{}, ResetChrome()) + requireCode(t, err, CodeInvalidRequest) }) t.Run("zero action", func(t *testing.T) { @@ -842,6 +877,7 @@ func TestChromeJSON(t *testing.T) { {"layout", ChromeLayout{Placements: []Placement{{ID: "a", Zone: ZoneLeftTop}}, Open: []string{"a"}, Hidden: []string{"a"}}, `{"placements":[{"id":"a","zone":"leftTop"}],"open":["a"],"hidden":["a"]}`}, {"plain item", ChromeItem{ID: "a", DefaultZone: ZoneLeftTop}, `{"id":"a","defaultZone":"leftTop"}`}, {"panel item", ChromeItem{ID: "a", DefaultZone: ZoneLeftTop, Panel: true, OpenByDefault: true}, `{"id":"a","defaultZone":"leftTop","panel":true,"openByDefault":true}`}, + {"title item also on the stripes", ChromeItem{ID: "a", DefaultZone: ZoneTitleTrailing, AlsoOnToolStripes: true}, `{"id":"a","defaultZone":"titleTrailing","alsoOnToolStripes":true}`}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/desktop/internal/i18n/shared.generated.go b/desktop/internal/i18n/shared.generated.go index 5c1b8f81f7..fb47e40433 100644 --- a/desktop/internal/i18n/shared.generated.go +++ b/desktop/internal/i18n/shared.generated.go @@ -1922,6 +1922,7 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.tools.background": "Background", "desktop.tools.dragHint": "Drag to move elsewhere", "desktop.tools.moveTo": "Move to", + "desktop.tools.moveToTitleBar": "Move to Title Bar", "desktop.tools.structure": "Structure", "desktop.tools.withShortcut": "{name} {keys}", "desktop.updates.arrow.available": "Lithe {version} is available. Click to see what changed", @@ -4837,6 +4838,7 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.tools.background": "背景", "desktop.tools.dragHint": "可拖动到其他位置", "desktop.tools.moveTo": "移动到", + "desktop.tools.moveToTitleBar": "移到标题栏", "desktop.tools.structure": "结构", "desktop.tools.withShortcut": "{name} {keys}", "desktop.updates.arrow.available": "Lithe {version} 可更新,点击查看更新内容", diff --git a/desktop/internal/workbench/app.go b/desktop/internal/workbench/app.go index 976d009f07..f7be4f71cb 100644 --- a/desktop/internal/workbench/app.go +++ b/desktop/internal/workbench/app.go @@ -1223,6 +1223,15 @@ func (a *App) performedIn(ctx context.Context, action string, surface actionSurf return core.WithOrigin(ctx, core.Origin{Operation: id, Trigger: action}) } +// chromeSurface is the surface a click on the rearrangeable button of catalog item index +// comes from: the toolbar while the button sits in the title bar, a button on a stripe. +func (a *App) chromeSurface(index int) actionSurface { + if a.chrome.zoneOf(index).surface() == surfaceTitle { + return surfaceToolbar + } + return surfaceButton +} + // titleBarHeight is the height of the title bar on both screens; the system's window // buttons sit in it. const titleBarHeight = 40 @@ -1344,7 +1353,7 @@ func (a *App) activate(index int) { a.titleDebug(a.project) case it.id == itemTitleSearch: if a.project != nil { - a.performed("workspace.searchEverywhere.open", surfaceToolbar) + a.performed("workspace.searchEverywhere.open", a.chromeSurface(index)) a.openEverywhere(a.project) } case it.id == itemCaret: diff --git a/desktop/internal/workbench/catalog.go b/desktop/internal/workbench/catalog.go index 8743604bed..d93966c673 100644 --- a/desktop/internal/workbench/catalog.go +++ b/desktop/internal/workbench/catalog.go @@ -191,7 +191,7 @@ const ( // item is one button the workbench can show in its rearrangeable chrome. type item struct { id string - zone zone // the default zone; its surface is the only one the item may sit in + zone zone // the default zone; the item sits only in its surface's zones unless stripes is set // icon is the glyph of the button; nil for a status item that is text only. icon *gfx.Icon // label is the button's name, read by assistive technology and, on a button that is only @@ -204,6 +204,9 @@ type item struct { panel bool // open reports that the tool window is open in the default layout. open bool + // stripes lets a title bar item also sit in the six tool stripe zones. It does the same thing + // there, opens no tool window and still cannot be hidden. + stripes bool // tool is the plugin tool window the item shows; nil for a built-in item. tool *pluginservice.ToolWindow // vcs is the plugin version control provider whose window the item shows (vcs.go); nil for @@ -252,9 +255,9 @@ var catalog = []item{ {id: itemRunConfig, zone: zoneTitle, icon: &icons.FileCode, label: func(m *i18n.Messages) string { return m.Title.RunConfiguration }}, {id: itemTitleRun, zone: zoneTitle, icon: &icons.Play, label: func(m *i18n.Messages) string { return m.Title.Run }}, - {id: itemTitleDebug, zone: zoneTitle, icon: &icons.Bug, label: func(m *i18n.Messages) string { return m.Title.Debug }}, - {id: itemTitleSearch, zone: zoneTitle, icon: &icons.Search, label: func(m *i18n.Messages) string { return m.Title.Search }, shortcut: "search.everywhere"}, - {id: itemTitleSettings, zone: zoneTitle, icon: &icons.Settings, label: func(m *i18n.Messages) string { return m.Title.Settings }}, + {id: itemTitleDebug, zone: zoneTitle, icon: &icons.Bug, label: func(m *i18n.Messages) string { return m.Title.Debug }, stripes: true}, + {id: itemTitleSearch, zone: zoneTitle, icon: &icons.Search, label: func(m *i18n.Messages) string { return m.Title.Search }, shortcut: "search.everywhere", stripes: true}, + {id: itemTitleSettings, zone: zoneTitle, icon: &icons.Settings, label: func(m *i18n.Messages) string { return m.Title.Settings }, stripes: true}, {id: itemCaret, zone: zoneStatus, label: func(m *i18n.Messages) string { return m.Status.Caret }}, {id: itemLock, zone: zoneStatus, icon: &icons.LockOpen, label: func(m *i18n.Messages) string { return m.Status.Writable }}, @@ -341,7 +344,7 @@ func (c *chromeState) setItems(items []item) { c.index = make(map[string]int, len(items)) c.coreItems = make([]core.ChromeItem, len(items)) for i, it := range items { - c.coreItems[i] = core.ChromeItem{ID: it.id, DefaultZone: zoneNames[it.zone], Panel: it.panel, OpenByDefault: it.open} + c.coreItems[i] = core.ChromeItem{ID: it.id, DefaultZone: zoneNames[it.zone], Panel: it.panel, OpenByDefault: it.open, AlsoOnToolStripes: it.stripes} c.index[it.id] = i } c.zones = make([]zone, len(items)) @@ -490,6 +493,14 @@ func (c *chromeState) apply(layout core.ChromeLayout) { // hidden. func (c *chromeState) zoneOf(index int) zone { return c.zones[index] } +// allowed reports whether catalog item index may sit in zone z: a zone of the surface of its +// default zone, or a stripe zone for a title bar item that may also sit on the stripes. The +// kernel enforces the same rule; the drag asks it where the button may land. +func (c *chromeState) allowed(index int, z zone) bool { + it := c.catalog[index] + return z.surface() == it.zone.surface() || it.stripes && z.surface() == surfaceStripes +} + // isHidden reports whether the user hid the stripe button of catalog item index. func (c *chromeState) isHidden(index int) bool { return c.hiddenMark[index] } diff --git a/desktop/internal/workbench/chrome_view.go b/desktop/internal/workbench/chrome_view.go index 82e86a55bc..424f32038d 100644 --- a/desktop/internal/workbench/chrome_view.go +++ b/desktop/internal/workbench/chrome_view.go @@ -60,8 +60,10 @@ func (a *App) chromeBox(row ui.Box, id gfx.ID, i int, open bool, value string, i row = row.Tooltip(tooltip) } if open { + // The open look is the one of the buttons around it: a title bar button that sits on a + // stripe opens like the stripe's buttons. fill := a.colors.Active - if it.zone.surface() == surfaceStripes { + if a.chrome.zoneOf(i).surface() == surfaceStripes { fill = a.theme.Primary } row = row.Background(fill) @@ -208,7 +210,8 @@ func (a *App) chromeProject(c ui.C) { } // chromeTitleButton declares the title bar button of catalog item i and reports a click on -// it. The settings button's menu hangs off it. +// it. The settings button's menu hangs off it. The buttons that may also sit on the stripes +// get a context menu that moves them there (titleButtonMenu). func (a *App) chromeTitleButton(c ui.C, i int) bool { switch a.chrome.catalog[i].id { case itemRunConfig: @@ -236,19 +239,39 @@ func (a *App) chromeTitleButton(c ui.C, i int) bool { box, clicked := a.chromeGlyph(c, i, titleGlyph, a.colors.Text, a.colors.Text, a.title.gearOpen) wasOpen := a.title.gearOpen if wasOpen { - a.gearMenu(c, box) + a.gearMenu(c, box, false) } if clicked && !wasOpen { - a.title.gearOpen = true - a.title.projectOpen, a.title.runConfigOpen = false, false - c.After(a.closeBranches) + a.openGear(c) } + a.titleButtonMenu(c, i, box) return false } - _, clicked := a.chromeGlyph(c, i, titleGlyph, a.colors.Text, a.colors.Text, false) + box, clicked := a.chromeGlyph(c, i, titleGlyph, a.colors.Text, a.colors.Text, false) + a.titleButtonMenu(c, i, box) return clicked } +// openGear opens the settings button's menu and closes the other title bar menus, which +// would stay open under it otherwise. +func (a *App) openGear(c ui.C) { + a.title.gearOpen = true + a.title.projectOpen, a.title.runConfigOpen = false, false + c.After(a.closeBranches) +} + +// titleButtonMenu gives box, the title bar button of catalog item i, a context menu that +// moves it to the end of a stripe zone when the item may also sit on the stripes: the +// keyboard and pointer alternative to dragging it there, as the stripe buttons have. +func (a *App) titleButtonMenu(c ui.C, i int, box ui.Box) { + if !a.chrome.catalog[i].stripes { + return + } + ui.ContextMenu(c.Part("menu").KeyInt(i), box, func(menu *ui.MenuItems) { + a.stripeMoveMenu(c, menu, i, zoneTitle) + }) +} + // stripe is the column of tool buttons at one side of the workbench. Each stripe stacks its // top group first, leaves flexible space, then packs the split group directly above the // bottom group at the stripe's end. The split group opens in the lower half of the side @@ -318,11 +341,16 @@ func (a *App) stripeZone(c ui.C, z zone, left, dragging bool) int { ui.ContextMenu(c.Part("menu").KeyInt(i), box, a.stripeButtonMenu(c, i, z)) continue } - // The background button opens a popover, not a tool window. + // The background button opens a popover, not a tool window, and the settings + // button, when the user moved it onto a stripe, its menu. background := a.chrome.catalog[i].id == itemBackground + settings := a.chrome.catalog[i].id == itemTitleSettings open := a.chrome.isOpen(i) - if background { + switch { + case background: open = a.backdropOpen + case settings: + open = a.title.gearOpen } rest := a.colors.Subtle if open { @@ -344,6 +372,14 @@ func (a *App) stripeZone(c ui.C, z zone, left, dragging bool) int { a.performed("workspace.background.open", surfaceButton) a.backdropOpen = true } + case settings: + // The menu opens beside the button, over the workbench, rather than under it. + if open { + a.gearMenu(c, box, true) + } + if hit && !open { + a.openGear(c) + } case hit: clicked = i } @@ -724,12 +760,16 @@ func (a *App) menuClose(c ui.C) bool { return button.Clicked() } -// gearMenu declares the settings button's menu, as the macOS title bar's gear shows it, under -// anchor, the button the user can move. -func (a *App) gearMenu(c ui.C, anchor ui.Box) { +// gearMenu declares the settings button's menu, as the macOS title bar's gear shows it, at +// anchor, the button the user can move: under it in the title bar, beside it (beside) on a +// stripe, where it opens towards the workbench. +func (a *App) gearMenu(c ui.C, anchor ui.Box, beside bool) { open := true ui.Menu(c, anchor, &open, func(menu *ui.MenuItems) { menu.WidthRange(gearMenuWidth, gearMenuWidth) + if beside { + menu.Beside() + } if menu.Item(a.text.Title.Preferences).Keys(ui.Primary, ",").Clicked() { c.After(func() { a.openSettings(surfaceMenu) }) } @@ -755,6 +795,27 @@ func (a *App) gearMenu(c ui.C, anchor ui.Box) { } } +// stripeMoveMenu adds the "Move to" submenu to menu: it moves the button of catalog item i, +// which sits in zone at, to the end of one of the other stripe zones. +func (a *App) stripeMoveMenu(c ui.C, menu *ui.MenuItems, i int, at zone) { + language := a.language() + id := a.chrome.catalog[i].id + menu.Sub(i18n.Shared(language, "desktop.tools.moveTo"), func(sub *ui.MenuItems) { + for z := zoneLeftTop; z <= zoneBottomRight; z++ { + if z == at { + continue + } + target := zoneNames[z] + if sub.Item(stripeZoneMoveText(language, z)).Clicked() { + c.After(func() { + a.performed("workbench.toolWindow.move", surfaceContextMenu) + a.reduceChrome(core.MoveChrome(id, target, "")) + }) + } + } + }) +} + // stripeZoneMoveText is the "Move to" entry of a stripe button's menu for zone z. func stripeZoneMoveText(lang i18n.Language, z zone) string { switch z { @@ -777,7 +838,8 @@ func stripeZoneMoveText(lang i18n.Language, z zone) string { // in zone at: hiding its open tool window, hiding the button itself, which the "…" button // then lists, and moving it to the end of another stripe zone, the keyboard and pointer // alternative to dragging it. The "…" button cannot be hidden, since it is the way back to -// the hidden buttons, so its menu only moves it. +// the hidden buttons, so its menu only moves it. Nor can a title bar button the user moved +// onto a stripe; its menu moves it back to the title bar instead. func (a *App) stripeButtonMenu(c ui.C, i int, at zone) func(*ui.MenuItems) { return func(menu *ui.MenuItems) { language := a.language() @@ -791,7 +853,7 @@ func (a *App) stripeButtonMenu(c ui.C, i int, at zone) func(*ui.MenuItems) { }) } } - if id != itemToolWindows { + if id != itemToolWindows && a.chrome.catalog[i].zone.surface() == surfaceStripes { if menu.Item(i18n.Shared(language, "native.hideEntry")).Clicked() { c.After(func() { a.performed("workbench.toolWindow.hideEntry", surfaceContextMenu) @@ -800,20 +862,15 @@ func (a *App) stripeButtonMenu(c ui.C, i int, at zone) func(*ui.MenuItems) { } menu.Separator() } - menu.Sub(i18n.Shared(language, "desktop.tools.moveTo"), func(sub *ui.MenuItems) { - for z := zoneLeftTop; z <= zoneBottomRight; z++ { - if z == at { - continue - } - target := zoneNames[z] - if sub.Item(stripeZoneMoveText(language, z)).Clicked() { - c.After(func() { - a.performed("workbench.toolWindow.move", surfaceContextMenu) - a.reduceChrome(core.MoveChrome(id, target, "")) - }) - } + if a.chrome.catalog[i].stripes { + if menu.Item(i18n.Shared(language, "desktop.tools.moveToTitleBar")).Clicked() { + c.After(func() { + a.performed("workbench.toolWindow.move", surfaceContextMenu) + a.reduceChrome(core.MoveChrome(id, zoneNames[zoneTitle], "")) + }) } - }) + } + a.stripeMoveMenu(c, menu, i, at) // Move Earlier and Move Later swap the button with its neighbour in its own zone: the // button goes in front of the one before it, or in front of the one after the next. items := a.chrome.items[at] diff --git a/desktop/internal/workbench/drag.go b/desktop/internal/workbench/drag.go index 020d2c9f04..9d913367dc 100644 --- a/desktop/internal/workbench/drag.go +++ b/desktop/internal/workbench/drag.go @@ -126,14 +126,19 @@ func (a *App) toolAccept(source, _ gfx.ID) bool { if !d.active || d.item != item { button := a.chrome.rects[item] z := a.chrome.zoneOf(item) - side, _ := stripeForZone(z) + side, onStripe := stripeForZone(z) *d = dragState{ active: true, item: item, sourceZone: z, snappedStripe: side, grab: gfx.Point{X: point.X - button.X, Y: point.Y - button.Y}, } + if !onStripe { + // A title bar button starts away from both stripes; it snaps to one when the + // pointer reaches it. + d.phase = dragDetached + } } d.x, d.y, d.viewport = point.X, point.Y, a.viewport() - if d.sourceZone.surface() == surfaceStripes { + if a.chrome.allowed(d.item, zoneLeftTop) { d.phase, d.snappedStripe = dragPhaseAt(d.phase, d.snappedStripe, point, dragStripeRects(gfx.Rect{ Width: d.viewport.Width, Height: d.viewport.Height, })) @@ -167,21 +172,30 @@ func (a *App) endDrags() { } } -// draggingToolButton reports that a button of the tool stripes is being dragged, which is -// when the stripes show every zone as a place to drop it (see stripe). +// draggingToolButton reports that a button that may sit on the tool stripes is being dragged, +// which is when the stripes show every zone as a place to drop it (see stripe). func (a *App) draggingToolButton() bool { - return a.dnd.tool.Dragging() && a.drag.active && a.drag.sourceZone.surface() == surfaceStripes + return a.dnd.tool.Dragging() && a.drag.active && a.chrome.allowed(a.drag.item, zoneLeftTop) } // dragLocate finds where dropping item at point would put it. Tool buttons use their // snapped stripe or detached dock geometry; title and status items keep their existing -// bar-only targets. A point outside the window never produces a target. +// bar-only targets. A title bar button that may also sit on the stripes lands in the title +// bar while the pointer is over it and moves as a tool button everywhere else. A point +// outside the window never produces a target. func (a *App) dragLocate(item int, source zone, point gfx.Point, viewport gfx.Size, phase dragPhase, snapped stripeSide) (dragTarget, bool) { var target dragTarget if point.X < 0 || point.Y < 0 || point.X >= viewport.Width || point.Y >= viewport.Height { return target, false } - switch source.surface() { + surface := source.surface() + if a.chrome.catalog[item].stripes { + surface = surfaceStripes + if point.Y < titleBarHeight { + surface = surfaceTitle + } + } + switch surface { case surfaceTitle: if point.Y >= titleBarHeight { return target, false @@ -273,11 +287,12 @@ func (a *App) dragInsertion(item int, z zone, x, y float32) (string, gfx.Rect) { return before, gfx.Rect{X: position, Y: zr.Y + dragMarkInset, Width: dragMark, Height: zr.Height - 2*dragMarkInset} } -// paintDrag paints the gesture above the frame: stripe zones stay tinted, detached dock -// targets show their pane preview and localized title, and the insertion line marks the -// position in the target zone. A snapped stripe ghost stays in its button column, while a -// detached ghost follows the pointer with its original grab point. The source button stays -// where it is, dimmed (see chromeBox). +// paintDrag paints the gesture above the frame: the zones the button may go to stay tinted, +// detached dock targets show their pane preview and localized title, and the insertion line +// marks the position in the target zone. A snapped stripe ghost stays in its button column, +// while a detached ghost follows the pointer with its original grab point; a title bar button +// that may also sit on the stripes takes the title bar's ghost while the pointer is over the +// title bar. The source button stays where it is, dimmed (see chromeBox). func (a *App) paintDrag(canvas *gfx.Canvas) { d := &a.drag if !d.active { @@ -285,9 +300,8 @@ func (a *App) paintDrag(canvas *gfx.Canvas) { } canvas.PushLayer(dragLayer) defer canvas.PopLayer() - surface := d.sourceZone.surface() for z := range a.chrome.zoneRects { - if zone(z).surface() != surface { + if !a.chrome.allowed(d.item, zone(z)) { continue } tint := float32(dragZoneTint) @@ -298,14 +312,15 @@ func (a *App) paintDrag(canvas *gfx.Canvas) { canvas.Rounded(r.Inset(gfx.All(-dragZoneOutset)), dragZoneRadius, a.colors.Accent.WithAlpha(tint)) } } - if surface == surfaceStripes && d.phase == dragDetached && d.hasTarget { + if d.phase == dragDetached && d.hasTarget && d.target.zone.surface() == surfaceStripes { a.paintDetachedDropPreview(canvas, d.target) } if d.hasTarget { canvas.Rounded(d.target.mark, dragMark/2, a.colors.Accent) } - if surface == surfaceStripes { + overTitle := a.chrome.catalog[d.item].stripes && d.y < titleBarHeight + if a.chrome.allowed(d.item, zoneLeftTop) && !overTitle { if d.phase == dragDetached { a.paintDetachedToolGhost(canvas, d) } else { @@ -389,7 +404,8 @@ func (a *App) paintDetachedDropPreview(canvas *gfx.Canvas, target dragTarget) { } // paintLegacyDragGhost keeps title and status drags on their original below-right ghost, -// because those bars do not detach into the workbench. +// because those bars do not detach into the workbench. A title bar button that may also sit +// on the stripes takes it while the pointer is over the title bar. func (a *App) paintLegacyDragGhost(canvas *gfx.Canvas, d *dragState) { icon := a.chrome.catalog[d.item].icon text := a.dragGhostText(d.item) diff --git a/desktop/internal/workbench/logevents_test.go b/desktop/internal/workbench/logevents_test.go index 8f8cfab270..34ac764d13 100644 --- a/desktop/internal/workbench/logevents_test.go +++ b/desktop/internal/workbench/logevents_test.go @@ -70,6 +70,8 @@ func TestLogEventsMatchCatalog(t *testing.T) { {operationFailedLevel, operationFailedEvent, operationFailedFields("workbench_background_save", failure)}, {operationFailedLevel, operationFailedEvent, operationFailedFields("workbench_background_remove", failure)}, {core.LevelInfo, "app.action.performed", map[string]any{"action": "workspace.background.open", "surface": surfaceButton}}, + {core.LevelInfo, "app.action.performed", map[string]any{"action": "workspace.searchEverywhere.open", "surface": surfaceButton}}, + {core.LevelInfo, "app.action.performed", map[string]any{"action": "title.debug", "surface": surfaceButton}}, {core.LevelInfo, "app.action.performed", map[string]any{"action": "workspace.background.choose", "surface": surfaceButton}}, {core.LevelInfo, "app.action.performed", map[string]any{"action": "workspace.background.remove", "surface": surfaceButton}}, {core.LevelInfo, "app.action.performed", map[string]any{"action": "workspace.background.strength", "surface": surfaceButton}}, diff --git a/desktop/internal/workbench/title_run.go b/desktop/internal/workbench/title_run.go index 59672bfd5b..34f10a5745 100644 --- a/desktop/internal/workbench/title_run.go +++ b/desktop/internal/workbench/title_run.go @@ -163,13 +163,14 @@ func (a *App) titleRun(p *project) { a.titleStart(p, titleActionRun) } -// titleDebug is a press on the title bar's Debug button: it opens the Debug window and debugs -// the chosen configuration, or the current file under the selected adapter. +// titleDebug is a press on the Debug button, in the title bar or on the stripe the user moved +// it to: it opens the Debug window and debugs the chosen configuration, or the current file +// under the selected adapter. func (a *App) titleDebug(p *project) { if p == nil { return } - a.performed("title.debug", surfaceToolbar) + a.performed("title.debug", a.chromeSurface(catalogIndex[itemTitleDebug])) a.openToolWindow(itemDebug) a.titleStart(p, titleActionDebug) } diff --git a/desktop/internal/workbench/title_stripe_test.go b/desktop/internal/workbench/title_stripe_test.go new file mode 100644 index 0000000000..f3e562ede0 --- /dev/null +++ b/desktop/internal/workbench/title_stripe_test.go @@ -0,0 +1,227 @@ +package workbench + +import ( + "slices" + "testing" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" + "github.com/vivaui/viva/gfx" +) + +// moveChromeTo moves catalog item id to the end of zone z through the kernel, as a drop or the +// Move to submenu does, and paints the result. +func (h *harness) moveChromeTo(id string, z zone) { + h.t.Helper() + h.app.post(func(a *App) { a.reduceChrome(core.MoveChrome(id, zoneNames[z], "")) }) + h.settle() + if got := h.app.chrome.zoneOf(catalogIndex[id]); got != z { + h.t.Fatalf("%s sits in zone %v, want %v", id, got, z) + } +} + +// The Debug, Search and Settings buttons of the title bar drag onto the left and right tool +// stripes, where they are laid out as stripe buttons, and drag back into the title bar. The +// layout file keeps where they are. +func TestTitleButtonsDragOntoTheStripesAndBack(t *testing.T) { + h := newHarness(t, &testKernel{Client: core.NewClient()}) + h.open(t.TempDir()) + + right := h.app.chrome.zoneRects[zoneRightTop] + h.drag(center(h.button(itemTitleSettings)), gfx.Point{X: right.X + right.Width/2, Y: right.Y + right.Height - 2}) + h.settle() + if got := h.zoneItems(zoneRightTop); !slices.Equal(got, []string{itemBuild, itemNotifications, itemTitleSettings}) { + t.Fatalf("top right zone = %v, want the settings button after the notifications button", got) + } + if got := h.zoneItems(zoneTitle); slices.Contains(got, itemTitleSettings) { + t.Fatalf("title bar = %v still holds the settings button", got) + } + settings := h.button(itemTitleSettings) + notifications := h.button(itemNotifications) + if settings.Width != 30 || settings.Height != 30 || settings.X != notifications.X || settings.Y-notifications.Y != 40 { + t.Fatalf("the settings button is at %+v, want 30x30, 40 below the notifications button at %+v", settings, notifications) + } + + // The empty split group of the left stripe opens up while a title button is dragged, as it + // does for a stripe button, so the button can be dropped there. + from := center(h.button(itemTitleSearch)) + must := func(err error) { + t.Helper() + if err != nil { + t.Fatalf("drag: %v", err) + } + } + must(h.driver.Press(from.X, from.Y, gfx.PointerButtonPrimary)) + must(h.driver.Move(from.X, from.Y+2*dragThreshold)) + left := h.app.chrome.zoneRects[zoneLeftBottom] + if left.Height < chromeToolButton { + t.Fatalf("the empty left bottom zone is %v high while the search button is dragged, want at least a button", left.Height) + } + to := center(left) + must(h.driver.Move(to.X/2+from.X/2, to.Y/2+from.Y/2)) + must(h.driver.Move(to.X, to.Y)) + must(h.driver.Release(to.X, to.Y, gfx.PointerButtonPrimary)) + h.settle() + if got := h.zoneItems(zoneLeftBottom); !slices.Equal(got, []string{itemTitleSearch}) { + t.Fatalf("bottom left stripe zone = %v, want the search button", got) + } + var saved core.ChromeLayout + if _, err := h.store.Load(layoutFile, &saved); err != nil || + !slices.Contains(saved.Placements, core.Placement{ID: itemTitleSettings, Zone: core.ZoneRightTop}) || + !slices.Contains(saved.Placements, core.Placement{ID: itemTitleSearch, Zone: core.ZoneLeftBottom}) { + t.Fatalf("saved placements = %v, %v; want settings at the top right and search at the bottom left", saved.Placements, err) + } + + first := h.button(itemRunConfig) + h.drag(center(h.button(itemTitleSettings)), gfx.Point{X: first.X + 2, Y: first.Y + first.Height/2}) + h.settle() + if got := h.zoneItems(zoneTitle); len(got) == 0 || got[0] != itemTitleSettings { + t.Fatalf("title bar = %v, want the settings button back first", got) + } + if got := h.zoneItems(zoneRightTop); !slices.Equal(got, []string{itemBuild, itemNotifications}) { + t.Fatalf("top right zone = %v, want the settings button gone", got) + } + if settings := h.button(itemTitleSettings); settings.Y >= titleBarHeight { + t.Fatalf("the settings button is at %+v, want it back in the title bar", settings) + } +} + +// Run stays a title bar button: it does not drag onto a stripe and has no Move to menu. +func TestTitleRunStaysInTheTitleBar(t *testing.T) { + h := newHarness(t, &testKernel{Client: core.NewClient()}) + h.open(t.TempDir()) + + h.drag(center(h.button(itemTitleRun)), center(h.app.chrome.zoneRects[zoneLeftTop])) + h.settle() + if got := h.app.chrome.zoneOf(catalogIndex[itemTitleRun]); got != zoneTitle { + t.Fatalf("the run button moved to zone %v, want it to stay in the title bar", got) + } + h.rightClickAt(h.button(itemTitleRun)) + if h.hasPopupItem(h.shared("desktop.tools.moveTo")) { + t.Fatal("the run button offers Move to") + } +} + +// The menu of a title bar button that may sit on a stripe moves it onto one. On the stripe its +// menu moves it on or back to the title bar, but offers no Hide Entry: the button cannot be +// hidden there either. +func TestTitleButtonMenuMovesItOntoAStripeAndBack(t *testing.T) { + h := newHarness(t, &testKernel{Client: core.NewClient()}) + h.open(t.TempDir()) + + h.rightClickAt(h.button(itemTitleDebug)) + if h.hasPopupItem(h.shared("desktop.tools.moveToTitleBar")) { + t.Fatal("the menu of the debug button in the title bar offers Move to Title Bar") + } + h.clickNamed(h.shared("desktop.tools.moveTo")) + h.clickNamed(stripeZoneMoveText(h.app.language(), zoneBottomRight)) + h.settleChain() + if got := h.zoneItems(zoneBottomRight); !slices.Equal(got, []string{itemBackground, itemTitleDebug}) { + t.Fatalf("bottom right zone = %v, want the debug button after the background button", got) + } + + h.rightClickAt(h.button(itemTitleDebug)) + if h.hasPopupItem(h.shared("native.hideEntry")) { + t.Fatal("the menu of the debug button on a stripe offers Hide Entry") + } + if !h.hasPopupItem(h.shared("desktop.tools.moveTo")) { + t.Fatal("the menu of the debug button on a stripe offers no Move to") + } + h.click(center(h.popupHit(h.shared("desktop.tools.moveToTitleBar")))) + h.settleChain() + if got := h.zoneItems(zoneTitle); len(got) == 0 || got[len(got)-1] != itemTitleDebug { + t.Fatalf("title bar = %v, want the debug button back at the end", got) + } + if got := h.zoneItems(zoneBottomRight); !slices.Equal(got, []string{itemBackground}) { + t.Fatalf("bottom right zone = %v, want the debug button gone", got) + } +} + +// The settings button on a stripe opens the settings menu beside it, on the inner side, and +// takes the open look of a stripe button while the menu is open; a second press closes it. +func TestSettingsOnAStripeOpensItsMenuBesideIt(t *testing.T) { + h := newHarness(t, &testKernel{Client: core.NewClient()}) + h.open(t.TempDir()) + h.moveChromeTo(itemTitleSettings, zoneRightBottom) + + gear := h.button(itemTitleSettings) + h.click(center(gear)) + h.settle() + if !h.app.title.gearOpen { + t.Fatal("the settings button on a stripe did not open its menu") + } + for _, label := range []string{h.app.text.Title.Preferences, h.app.text.Title.Plugins, h.app.text.Title.LogsAndDiagnostics, h.app.text.Title.ThemeMenu, h.app.text.Title.Keymap} { + if !h.shows(label) { + t.Fatalf("the settings menu does not show %q", label) + } + } + row := h.hitLabeled(h.app.text.Title.Preferences) + if row.Right() > gear.X { + t.Fatalf("the Settings… row is at %+v, want it left of the button at %+v", row, gear) + } + + h.click(center(gear)) + h.settle() + if h.app.title.gearOpen { + t.Fatal("a second press on the settings button left its menu open") + } +} + +// Search and Debug do on a stripe what they do in the title bar, name themselves in the tip +// of a stripe button and log the press as one on a button rather than the toolbar. +func TestSearchAndDebugOnAStripeDoTheirWork(t *testing.T) { + h := newHarness(t, &testKernel{Client: core.NewClient()}) + logger := &treeRecordingLog{} + h.app.logSink = logger + h.open(t.TempDir()) + h.moveChromeTo(itemTitleSearch, zoneLeftTop) + h.moveChromeTo(itemTitleDebug, zoneLeftTop) + + keys := h.app.settings.Keymap.Label("search.everywhere") + tip := i18n.SharedFormat(h.app.language(), "desktop.tools.withShortcut", map[string]string{"name": h.app.text.Title.Search, "keys": keys}) + search := h.button(itemTitleSearch) + at := center(search) + if err := h.driver.Move(at.X, at.Y); err != nil { + t.Fatal(err) + } + h.settle() + tips := h.tooltips() + if len(tips) != 1 || tips[0].Value != tip || tips[0].Bounds.X < search.Right() { + t.Fatalf("resting on the search button on the left stripe shows the tips %+v, want only %q right of %+v", tips, tip, search) + } + + h.click(at) + h.settle() + if !h.app.everywhereView.open || h.driver.Snapshot().Focused != everywhereQueryID { + t.Fatal("the search button on a stripe did not open Search Everywhere with its query focused") + } + if err := h.driver.Key(gfx.KeyEscape, 0); err != nil { + t.Fatal(err) + } + h.settle() + + h.click(center(h.button(itemTitleDebug))) + h.settleChain() + if !h.app.chrome.isOpen(catalogIndex[itemDebug]) { + t.Fatal("the debug button on a stripe did not open the Debug tool window") + } + for _, action := range []string{"workspace.searchEverywhere.open", "title.debug"} { + if got := performedSurfaces(logger, action); !slices.Equal(got, []string{string(surfaceButton)}) { + t.Errorf("%s was logged from %v, want once from a button", action, got) + } + } +} + +// performedSurfaces is the surface of every logged performance of action, in order. +func performedSurfaces(log *treeRecordingLog, action string) []string { + log.mu.Lock() + defer log.mu.Unlock() + var surfaces []string + for _, event := range log.events { + if event.Event == "app.action.performed" && event.Fields["action"] == action { + surface, _ := event.Fields["surface"].(string) + surfaces = append(surfaces, surface) + } + } + return surfaces +} diff --git a/desktop/internal/workbench/visual_title_stripe_capture_test.go b/desktop/internal/workbench/visual_title_stripe_capture_test.go new file mode 100644 index 0000000000..1a65e92b9a --- /dev/null +++ b/desktop/internal/workbench/visual_title_stripe_capture_test.go @@ -0,0 +1,111 @@ +//go:build vivahead && lithevisual + +package workbench + +import ( + "os" + "path/filepath" + "testing" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/store" + "github.com/vivaui/viva/app" + "github.com/vivaui/viva/gfx" + "github.com/vivaui/viva/headless" +) + +// TestVisualTitleButtonsOnStripes captures the Debug, Search and Settings buttons of the title +// bar on the tool stripes: the default title bar, Settings being dragged to the end of the right +// stripe's top group, the three buttons on the stripes, the settings menu beside its button +// there, the Search tip on the stripe, the stripe menu of Debug and the title bar menu of +// Settings. Dark scenes are in Chinese, light ones in English. It needs only +// LITHE_VISUAL_OUTPUT_DIR. +func TestVisualTitleButtonsOnStripes(t *testing.T) { + out := os.Getenv("LITHE_VISUAL_OUTPUT_DIR") + if out == "" { + t.Skip("set LITHE_VISUAL_OUTPUT_DIR") + } + if err := os.MkdirAll(out, 0755); err != nil { + t.Fatal(err) + } + // onStripes moves Debug and Search to the end of the left stripe's top group and Settings to + // the end of the right stripe's top group, as drops there do. + onStripes := func(h *harness) { + h.app.post(func(a *App) { + a.reduceChrome(core.MoveChrome(itemTitleDebug, core.ZoneLeftTop, "")) + a.reduceChrome(core.MoveChrome(itemTitleSearch, core.ZoneLeftTop, "")) + a.reduceChrome(core.MoveChrome(itemTitleSettings, core.ZoneRightTop, "")) + }) + h.settle() + } + scenes := []struct { + id string + show func(*harness) + }{ + {"title-default", func(*harness) {}}, + {"settings-dragging", func(h *harness) { + target := h.app.chrome.zoneRects[zoneRightTop] + start, end := center(h.button(itemTitleSettings)), gfx.Point{X: target.X + target.Width/2, Y: target.Y + target.Height - 2} + if err := h.driver.Press(start.X, start.Y, gfx.PointerButtonPrimary); err != nil { + t.Fatal(err) + } + for i := 1; i <= 8; i++ { + f := float32(i) / 8 + if err := h.driver.Move(start.X+(end.X-start.X)*f, start.Y+(end.Y-start.Y)*f); err != nil { + t.Fatal(err) + } + } + h.settle() + }}, + {"buttons-on-stripes", onStripes}, + {"settings-menu-on-stripe", func(h *harness) { + onStripes(h) + h.click(center(h.button(itemTitleSettings))) + h.settle() + }}, + {"search-tip-on-stripe", func(h *harness) { + onStripes(h) + at := center(h.button(itemTitleSearch)) + if err := h.driver.Move(at.X, at.Y); err != nil { + t.Fatal(err) + } + h.settle() + }}, + {"debug-stripe-menu", func(h *harness) { + onStripes(h) + h.rightClickAt(h.button(itemTitleDebug)) + }}, + {"settings-title-menu", func(h *harness) { + h.rightClickAt(h.button(itemTitleSettings)) + h.clickNamed(h.shared("desktop.tools.moveTo")) + h.settle() + }}, + } + for _, look := range []struct{ theme, language string }{{"dark", "zh-Hans"}, {"light", "en-US"}} { + for _, scene := range scenes { + t.Run(scene.id+"-"+look.theme, func(t *testing.T) { + prefs := store.At(t.TempDir()) + if err := prefs.Save(settingsFile, map[string]string{"theme": look.theme}); err != nil { + t.Fatal(err) + } + var session *headless.Session + h := newHarnessWithDriver(t, Options{Kernel: &testKernel{Client: core.NewClient()}, Store: prefs, Languages: []string{look.language}}, func(config app.Config) (*app.Driver, func(), error) { + config.Width, config.Height = 1100, 680 + var err error + session, err = headless.Open(config, nil, headless.Options{}) + if err != nil { + return nil, nil, err + } + return session.Driver(), session.Close, nil + }) + root := t.TempDir() + writeTreeFiles(t, root, "src/main.txt", "notes.txt", "readme.txt") + h.openTree(t, root) + scene.show(h) + if err := session.Screenshot(filepath.Join(out, scene.id+"-"+look.theme+".png")); err != nil { + t.Fatal(err) + } + }) + } + } +} diff --git a/docs/assets/title-buttons-on-stripes/README.md b/docs/assets/title-buttons-on-stripes/README.md new file mode 100644 index 0000000000..8ecccdd2f7 --- /dev/null +++ b/docs/assets/title-buttons-on-stripes/README.md @@ -0,0 +1,19 @@ +# 标题栏调试、搜索、设置按钮可放到左右工具条测试截图 + +来自生产 Viva Page 的无头渲染,窗口 1100×680,使用隔离的临时项目和配置。深色使用中文、浅色使用英文。 +默认布局和改动前的 `main` 相同(三个按钮都在标题栏右上角),所以只有 `after/`。截图不代表 +macOS/Windows 原生窗口验收。 + +| 场景 | 深色中文 | 浅色英文 | +| --- | --- | --- | +| 默认布局:运行配置、运行、调试、搜索、设置都在标题栏右上角 | [截图](after/title-default-dark.png) | [截图](after/title-default-light.png) | +| 按住标题栏的设置按钮拖到右侧栏上方组末尾,还没松开:标题栏原位置变暗,工具条显示落点 | [截图](after/settings-dragging-dark.png) | [截图](after/settings-dragging-light.png) | +| 调试、搜索放到左侧栏上方组末尾,设置放到右侧栏上方组末尾:按工具条按钮排列,标题栏只剩运行配置和运行 | [截图](after/buttons-on-stripes-dark.png) | [截图](after/buttons-on-stripes-light.png) | +| 点工具条上的设置按钮:按钮呈打开状态,设置菜单在按钮内侧(左边)弹出,菜单项与标题栏里相同 | [截图](after/settings-menu-on-stripe-dark.png) | [截图](after/settings-menu-on-stripe-light.png) | +| 指针停在工具条上的搜索按钮:提示在内侧,仍带“搜索 + 快捷键” | [截图](after/search-tip-on-stripe-dark.png) | [截图](after/search-tip-on-stripe-light.png) | +| 右键工具条上的调试按钮:有“移到标题栏”“移动到”“前移/后移”,没有“隐藏” | [截图](after/debug-stripe-menu-dark.png) | [截图](after/debug-stripe-menu-light.png) | +| 右键标题栏的设置按钮,展开“移动到”:可移到六个工具条区 | [截图](after/settings-title-menu-dark.png) | [截图](after/settings-title-menu-light.png) | + +复验:设置 `LITHE_VISUAL_OUTPUT_DIR`,在 `desktop/` 下通过 `../scripts/desktop/desktop-go.sh test +-tags vivahead,lithevisual ./internal/workbench -run '^TestVisualTitleButtonsOnStripes$' +-count=1 -timeout 300s` 生成 `after/`。 diff --git a/docs/assets/title-buttons-on-stripes/after/buttons-on-stripes-dark.png b/docs/assets/title-buttons-on-stripes/after/buttons-on-stripes-dark.png new file mode 100644 index 0000000000..ddbc35cb91 Binary files /dev/null and b/docs/assets/title-buttons-on-stripes/after/buttons-on-stripes-dark.png differ diff --git a/docs/assets/title-buttons-on-stripes/after/buttons-on-stripes-light.png b/docs/assets/title-buttons-on-stripes/after/buttons-on-stripes-light.png new file mode 100644 index 0000000000..aff9570579 Binary files /dev/null and b/docs/assets/title-buttons-on-stripes/after/buttons-on-stripes-light.png differ diff --git a/docs/assets/title-buttons-on-stripes/after/debug-stripe-menu-dark.png b/docs/assets/title-buttons-on-stripes/after/debug-stripe-menu-dark.png new file mode 100644 index 0000000000..6e139eff4d Binary files /dev/null and b/docs/assets/title-buttons-on-stripes/after/debug-stripe-menu-dark.png differ diff --git a/docs/assets/title-buttons-on-stripes/after/debug-stripe-menu-light.png b/docs/assets/title-buttons-on-stripes/after/debug-stripe-menu-light.png new file mode 100644 index 0000000000..8e0d91904d Binary files /dev/null and b/docs/assets/title-buttons-on-stripes/after/debug-stripe-menu-light.png differ diff --git a/docs/assets/title-buttons-on-stripes/after/search-tip-on-stripe-dark.png b/docs/assets/title-buttons-on-stripes/after/search-tip-on-stripe-dark.png new file mode 100644 index 0000000000..f02a5b5680 Binary files /dev/null and b/docs/assets/title-buttons-on-stripes/after/search-tip-on-stripe-dark.png differ diff --git a/docs/assets/title-buttons-on-stripes/after/search-tip-on-stripe-light.png b/docs/assets/title-buttons-on-stripes/after/search-tip-on-stripe-light.png new file mode 100644 index 0000000000..8a478706e6 Binary files /dev/null and b/docs/assets/title-buttons-on-stripes/after/search-tip-on-stripe-light.png differ diff --git a/docs/assets/title-buttons-on-stripes/after/settings-dragging-dark.png b/docs/assets/title-buttons-on-stripes/after/settings-dragging-dark.png new file mode 100644 index 0000000000..81c263ad94 Binary files /dev/null and b/docs/assets/title-buttons-on-stripes/after/settings-dragging-dark.png differ diff --git a/docs/assets/title-buttons-on-stripes/after/settings-dragging-light.png b/docs/assets/title-buttons-on-stripes/after/settings-dragging-light.png new file mode 100644 index 0000000000..75357e4e85 Binary files /dev/null and b/docs/assets/title-buttons-on-stripes/after/settings-dragging-light.png differ diff --git a/docs/assets/title-buttons-on-stripes/after/settings-menu-on-stripe-dark.png b/docs/assets/title-buttons-on-stripes/after/settings-menu-on-stripe-dark.png new file mode 100644 index 0000000000..1ac8c36f91 Binary files /dev/null and b/docs/assets/title-buttons-on-stripes/after/settings-menu-on-stripe-dark.png differ diff --git a/docs/assets/title-buttons-on-stripes/after/settings-menu-on-stripe-light.png b/docs/assets/title-buttons-on-stripes/after/settings-menu-on-stripe-light.png new file mode 100644 index 0000000000..c53e889dc5 Binary files /dev/null and b/docs/assets/title-buttons-on-stripes/after/settings-menu-on-stripe-light.png differ diff --git a/docs/assets/title-buttons-on-stripes/after/settings-title-menu-dark.png b/docs/assets/title-buttons-on-stripes/after/settings-title-menu-dark.png new file mode 100644 index 0000000000..9fd7b1a2b8 Binary files /dev/null and b/docs/assets/title-buttons-on-stripes/after/settings-title-menu-dark.png differ diff --git a/docs/assets/title-buttons-on-stripes/after/settings-title-menu-light.png b/docs/assets/title-buttons-on-stripes/after/settings-title-menu-light.png new file mode 100644 index 0000000000..dad1924709 Binary files /dev/null and b/docs/assets/title-buttons-on-stripes/after/settings-title-menu-light.png differ diff --git a/docs/assets/title-buttons-on-stripes/after/title-default-dark.png b/docs/assets/title-buttons-on-stripes/after/title-default-dark.png new file mode 100644 index 0000000000..b2c9878a12 Binary files /dev/null and b/docs/assets/title-buttons-on-stripes/after/title-default-dark.png differ diff --git a/docs/assets/title-buttons-on-stripes/after/title-default-light.png b/docs/assets/title-buttons-on-stripes/after/title-default-light.png new file mode 100644 index 0000000000..adcbdc543d Binary files /dev/null and b/docs/assets/title-buttons-on-stripes/after/title-default-light.png differ diff --git a/shared/i18n/locales/en-US.json b/shared/i18n/locales/en-US.json index 880f3ff2e2..486b49531c 100644 --- a/shared/i18n/locales/en-US.json +++ b/shared/i18n/locales/en-US.json @@ -11302,6 +11302,7 @@ "desktop.title.runBusy": "The Run window is still running another operation. Wait for it to finish or stop it first.", "desktop.diff.keepWhitespace": "Do not ignore whitespace", "desktop.tools.moveTo": "Move to", + "desktop.tools.moveToTitleBar": "Move to Title Bar", "desktop.editorFind.find": "Find", "desktop.editorFind.replace": "Replace", "desktop.editorFind.replaceOne": "Replace current", diff --git a/shared/i18n/locales/zh-CN.json b/shared/i18n/locales/zh-CN.json index 9e5198f4b8..e4e9a7b15c 100644 --- a/shared/i18n/locales/zh-CN.json +++ b/shared/i18n/locales/zh-CN.json @@ -11302,6 +11302,7 @@ "desktop.title.runBusy": "运行窗口还在执行其他操作。请等它结束,或者先停止它。", "desktop.diff.keepWhitespace": "不忽略空白", "desktop.tools.moveTo": "移动到", + "desktop.tools.moveToTitleBar": "移到标题栏", "desktop.editorFind.find": "查找", "desktop.editorFind.replace": "替换", "desktop.editorFind.replaceOne": "替换当前", diff --git a/shared/i18n/messages.json b/shared/i18n/messages.json index c21db48a12..a90585e699 100644 --- a/shared/i18n/messages.json +++ b/shared/i18n/messages.json @@ -108012,6 +108012,13 @@ "desktop" ] }, + { + "id": "desktop.tools.moveToTitleBar", + "description": "Context menu item of a title bar button the user moved onto a tool stripe: moves it back to the title bar.", + "platforms": [ + "desktop" + ] + }, { "id": "desktop.editorFind.find", "description": "IDE editor essentials: editorFind.find", diff --git a/shared/platform-feature-matrix/features/viva-title-run-debug.json b/shared/platform-feature-matrix/features/viva-title-run-debug.json index ea1f63035d..f66e83d09b 100644 --- a/shared/platform-feature-matrix/features/viva-title-run-debug.json +++ b/shared/platform-feature-matrix/features/viva-title-run-debug.json @@ -49,5 +49,5 @@ }, "owner": "Run", "verification": "打开带构建提供者的项目(测试内联的合成 Build Provider 即可):标题栏下拉列出检测到的运行配置并记住所选项;运行按钮启动所选配置并打开运行窗口;调试按钮对声明了调试适配器的运行准备并启动调试会话、打开调试窗口,未声明时提示该配置不能调试;声明了公共调试类型的服务运行(合成提供者 + 另一个合成插件的 attach 适配器),调试时提供者收到 `launchOptions.debug`(选中的适配器、类型、本机端口),服务监听后适配器以 attach 连接该端口,在调试窗口停止后服务结束、端口释放;没有或有两个匹配适配器时提示原因且不请求提供者;停用、再启用适配器所在插件后,调试适配器列表随之更新;运行超过准备时限的服务不会被结束(测试把时限缩短到 5 秒);语言服务器就绪后才声明命令时,宿主等到声明再请求端口,从不声明时在时限内结束;准备失败时结束“准备中”并显示原因;当前文件没有可运行的入口时提示原因(有入口时的运行见 run-current-file-entrypoint);项目没有运行配置时点“编辑运行配置…”提示原因,有旧版或其他提供方的已保存配置时说明隐藏了几条。提供者运行准备失败时,运行控制台显示提供者输出的构建日志;未声明名称的运行,配置名就是目标名。单元测试覆盖等待配置读出后运行、没有配置时编辑入口的提示和隐藏条数、当前文件提示、无适配器提示、不经构建提供者启动的配置提示、提供者准备请求、按名称选择适配器和拒绝插件未安装的适配器、准备运行时转发提供者输出、未命名运行按目标命名,声明提供者进程但用命令读取模型和写文件的依赖命令,以及按配置类型连接调试服务运行(选择、拒绝、停止联动)。", - "notes": "Viva 标题栏按钮此前只有外观。运行忙碌时仅提示,不排队;当前文件运行由构建插件按文件找出入口(run-current-file-entrypoint);同包适配器的提供者调试暂不携带运行配置的启动选项;按配置类型连接的服务运行调试一个项目同时只有一个调试会话。macOS、Windows 原生窗口验收 pending。" + "notes": "Viva 标题栏按钮此前只有外观。运行忙碌时仅提示,不排队;当前文件运行由构建插件按文件找出入口(run-current-file-entrypoint);同包适配器的提供者调试暂不携带运行配置的启动选项;按配置类型连接的服务运行调试一个项目同时只有一个调试会话。调试按钮可拖到左右侧栏,功能照旧,运行和运行配置下拉只留在标题栏(见 workbench-tool-window-docking)。macOS、Windows 原生窗口验收 pending。" } diff --git a/shared/platform-feature-matrix/features/workbench-tool-window-docking.json b/shared/platform-feature-matrix/features/workbench-tool-window-docking.json index 3fbf6d3501..254460e2be 100644 --- a/shared/platform-feature-matrix/features/workbench-tool-window-docking.json +++ b/shared/platform-feature-matrix/features/workbench-tool-window-docking.json @@ -13,7 +13,8 @@ "desktop/internal/workbench/root.go", "desktop/internal/workbench/tabstrip.go", "desktop/internal/workbench/chrome_view.go", - "desktop/internal/workbench/chrome_menu_test.go" + "desktop/internal/workbench/chrome_menu_test.go", + "desktop/internal/workbench/title_stripe_test.go" ] }, "windows": { @@ -26,7 +27,8 @@ "desktop/internal/workbench/root.go", "desktop/internal/workbench/tabstrip.go", "desktop/internal/workbench/chrome_view.go", - "desktop/internal/workbench/chrome_menu_test.go" + "desktop/internal/workbench/chrome_menu_test.go", + "desktop/internal/workbench/title_stripe_test.go" ] }, "owner": "Workbench", @@ -60,5 +62,5 @@ "verificationStatus": "pending" } }, - "notes": "Viva:catalog.go 定义六个停靠区,dockdrag.go 处理拖动落点与遮罩,布局经 loadChrome 保存;组内排序和右键移动由 chrome_menu_test.go 覆盖;布局保存在全局 workbench-layout-v2.json,未按工作区分别恢复。 全页对照恢复活动侧栏蓝色与焦点相关的标签边框;项目渐变由根容器在子元素前绘制,不覆盖不透明工具面板。首次打开仅展开 Project,Git 按需打开,已有保存布局保持优先。像素回归 TestVisualWorkbenchGradientStaysBehindPanels 证明修复前失败、修复后通过;Windows 原生验收仍待执行。 侧栏按钮右键“隐藏入口”把按钮从侧栏收起,Core 布局状态记录 hidden 并保留原分区和位置;“…”按钮是目录里的 toolWindows 项,只在有隐藏入口时出现,默认排在左侧栏上方组末尾,和其他侧栏按钮一样可拖到任一侧栏分区、组内排序或用右键“移动到”,位置写入布局且没有隐藏入口时也保留;它的右键菜单不提供“隐藏入口”,手改布局把它标为隐藏时仍显示;列表在所在侧栏内侧弹出,上方组向下展开,下方两组向上展开;尺寸和间距与侧栏按钮一致、悬停显示名称,列出隐藏的工具窗口(图标、名称、快捷键,已打开的行高亮),点击行恢复按钮并打开窗口,行的右键“取消隐藏”只恢复按钮;隐藏按钮的窗口仍可由快捷键打开,此时“…”按钮高亮。TestHiddenStripeButtonIsListedUnderTheEllipsisAndComesBack、TestUnhidePutsTheButtonBackWithoutTouchingItsToolWindow、TestTheEllipsisButtonDragsToAnotherStripeZone、TestTheEllipsisButtonMenuMovesItButCannotHideIt、TestChromeStateShowsTheEllipsisOnlyWhileAButtonIsHidden、TestALayoutSavedBeforeTheEllipsisMovedPutsItAfterTheTopGroup 覆盖;旧布局里已删除的“更新”入口在加载时丢弃;macOS 与 Windows 实机验收待执行。" + "notes": "Viva:catalog.go 定义六个停靠区,dockdrag.go 处理拖动落点与遮罩,布局经 loadChrome 保存;组内排序和右键移动由 chrome_menu_test.go 覆盖;布局保存在全局 workbench-layout-v2.json,未按工作区分别恢复。 全页对照恢复活动侧栏蓝色与焦点相关的标签边框;项目渐变由根容器在子元素前绘制,不覆盖不透明工具面板。首次打开仅展开 Project,Git 按需打开,已有保存布局保持优先。像素回归 TestVisualWorkbenchGradientStaysBehindPanels 证明修复前失败、修复后通过;Windows 原生验收仍待执行。 侧栏按钮右键“隐藏入口”把按钮从侧栏收起,Core 布局状态记录 hidden 并保留原分区和位置;“…”按钮是目录里的 toolWindows 项,只在有隐藏入口时出现,默认排在左侧栏上方组末尾,和其他侧栏按钮一样可拖到任一侧栏分区、组内排序或用右键“移动到”,位置写入布局且没有隐藏入口时也保留;它的右键菜单不提供“隐藏入口”,手改布局把它标为隐藏时仍显示;列表在所在侧栏内侧弹出,上方组向下展开,下方两组向上展开;尺寸和间距与侧栏按钮一致、悬停显示名称,列出隐藏的工具窗口(图标、名称、快捷键,已打开的行高亮),点击行恢复按钮并打开窗口,行的右键“取消隐藏”只恢复按钮;隐藏按钮的窗口仍可由快捷键打开,此时“…”按钮高亮。TestHiddenStripeButtonIsListedUnderTheEllipsisAndComesBack、TestUnhidePutsTheButtonBackWithoutTouchingItsToolWindow、TestTheEllipsisButtonDragsToAnotherStripeZone、TestTheEllipsisButtonMenuMovesItButCannotHideIt、TestChromeStateShowsTheEllipsisOnlyWhileAButtonIsHidden、TestALayoutSavedBeforeTheEllipsisMovedPutsItAfterTheTopGroup 覆盖;旧布局里已删除的“更新”入口在加载时丢弃;标题栏的调试、搜索、设置按钮在目录里标 alsoOnToolStripes(Core 布局规则),可拖到六个侧栏分区、在侧栏内排序,也可拖回标题栏;右键在标题栏提供“移动到”,在侧栏提供“移到标题栏”“移动到”“前移/后移”,不提供“隐藏入口”;放到侧栏后功能与显示照旧:调试开始调试并打开 Debug 窗口,搜索打开全局搜索,设置在按钮内侧弹出设置菜单,仍带名称和快捷键提示,日志 surface 从 toolbar 变为 button;运行和运行配置只留在标题栏。title_stripe_test.go 覆盖,截图见 docs/assets/title-buttons-on-stripes;macOS 与 Windows 实机验收待执行。" }