From 55af00b237b4c609dbb22e117e1299ffcf376554 Mon Sep 17 00:00:00 2001 From: piexel Date: Thu, 26 Nov 2026 13:25:52 +0100 Subject: [PATCH] Show the views in tool windows on the left - Stripe toggles a Views window and a Contents window, as IntelliJ's tool windows - Views lists every view by group; a double click keeps its tab - Contents holds the shown view's own lists under Views, half the column - Remember which windows are open - Objects get a castle icon apart from the 3D world's box --- studio/src/renderer/src/studio/MapStudio.tsx | 10 +- studio/src/renderer/src/studio/ViewList.tsx | 177 ++++++++++++------- 2 files changed, 123 insertions(+), 64 deletions(-) diff --git a/studio/src/renderer/src/studio/MapStudio.tsx b/studio/src/renderer/src/studio/MapStudio.tsx index b236aca27..9e4677855 100644 --- a/studio/src/renderer/src/studio/MapStudio.tsx +++ b/studio/src/renderer/src/studio/MapStudio.tsx @@ -152,6 +152,14 @@ export function MapStudio({ client, world, theme, onOpenPack, onDisconnect }: Ma useServerEvents(client, setPlayers, setUsage, tell, setConnected, packReloaded) const openView = useCallback((viewId: string) => setWorkbench((current) => showView(current, viewId, entryViews.has(viewId))), [entryViews]) + const keepView = useCallback( + (viewId: string) => + setWorkbench((current) => { + const shown = showView(current, viewId, false) + return keepTab(shown, focusedTab(shown).id) + }), + [] + ) const commands = useCommandRegistry() const recent = useRecentTabs(setWorkbench) @@ -232,7 +240,7 @@ export function MapStudio({ client, world, theme, onOpenPack, onDisconnect }: Ma )} - + showsMapOf(tab.viewId)} /> diff --git a/studio/src/renderer/src/studio/ViewList.tsx b/studio/src/renderer/src/studio/ViewList.tsx index e2a9144c7..7798e5b18 100644 --- a/studio/src/renderer/src/studio/ViewList.tsx +++ b/studio/src/renderer/src/studio/ViewList.tsx @@ -1,21 +1,20 @@ -import { DropdownMenu } from 'radix-ui' import { useState } from 'react' import { AudioWaveform, Box, + Castle, Boxes, Droplets, Fish, Flower2, - Gauge, Gem, - Globe, HardDrive, ImageIcon, Layers, + LayoutGrid, + ListTree, Map, MountainSnow, - Package, Palette, Pickaxe, Pyramid, @@ -30,6 +29,8 @@ import { type LucideIcon } from 'lucide-react' import { Kbd } from '@/components/ui/kbd' +import { ScrollArea } from '@/components/ui/scroll-area' +import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' import { cn } from '@/lib/utils' import type { ViewInfo } from '../bridge/types' import { viewShortcutId } from './shortcuts' @@ -54,22 +55,19 @@ const VIEW_ICONS: Record = { savedWorld: HardDrive, 'iris:terrain/palettes': Palette, 'iris:decorant/decorators': Flower2, - 'iris:objects': Package, + 'iris:objects': Castle, 'iris:objects/procedural': Workflow, noise: AudioWaveform, imageMaps: ImageIcon, pregen: Zap } -const GROUP_ICONS: Record = { - WORLD: Globe, - BIOME_LAYERS: Layers, - DIAGNOSTICS: Gauge, - PACK: AudioWaveform, - BLOCKS: Boxes -} const FALLBACK_ICON: LucideIcon = Shapes +/** Inset, because the stripe scrolls and so clips anything drawn outside its buttons. */ +const STRIPE_BUTTON = 'flex size-[30px] shrink-0 items-center justify-center rounded-lg outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset' +const GROUP_LABEL = 'truncate px-2 pt-2 pb-1 text-[11px] font-semibold text-muted-foreground' +const OPEN_WINDOWS_KEY = 'studio.leftToolWindows' -/** The icon a view has on its tabs and in its group's list. */ +/** The icon a view has on its tabs and in the list of views. */ export function ViewIcon({ viewId, className }: { viewId: string; className: string }): React.JSX.Element { const Icon = VIEW_ICONS[viewId] ?? FALLBACK_ICON return @@ -79,29 +77,92 @@ interface ViewListProps { views: ViewInfo[] /** The view of the focused tab. */ current: string - onSelect(view: string): void - /** Receives the element the shown view fills with its own lists, beside the stripe. */ + onOpen(view: string): void + /** Opens a view in a tab of its own that the next view opened does not reuse. */ + onKeep(view: string): void + /** Receives the element the shown view fills with its own lists, while the window holding them is open. */ slotRef(element: HTMLElement | null): void } /** - * The views the server offers, as one button for each of their groups on the window's edge with the group's name under - * it, each opening the list of its views; beside it the island the focused tab's view fills with its own lists, which - * is not there for a view without any (IntelliJ's tool window stripe with its names shown). + * The tool windows on the window's left edge, as IntelliJ has them: the list of every view, and under it the lists of + * the view that is shown, each opened and closed from its icon on the stripe and both sharing the column when open. */ -export function ViewList({ views, current, onSelect, slotRef }: ViewListProps): React.JSX.Element { +export function ViewList({ views, current, onOpen, onKeep, slotRef }: ViewListProps): React.JSX.Element { + const [open, toggle] = useOpenWindows() + const currentLabel = views.find((view) => view.id === current)?.label ?? current return ( <> -