web/pane
화면 분할 패널. (원본 web/pane.js 의 PaneTheme, PaneStyle, Pane)
- 원본은 도구(파티클 에디터 같은)의 창 구성을 DOM 으로 짓는다. 가로나 세로로 나눈 패널, 고정, 비율, flex 크기, 최소와 최대, 끌어서 크기를 바꾸는 리사이저, 숨기기, 끌어서 바꾼 크기 지우기, 배치 콜백, 그리고 같은 테마 색의 요소를 짓는 PaneStyle 프리셋(panel, toolbar, button, input, textarea, text)이다.
- 웹은 원본처럼 DOM 요소로 짓는다. (pane/dompane.rs)
- 데스크탑은 DOM 이 없어 엔진 노드로 같은 일을 한다. 컨테이너는 노드이고 내용은 그 자식 노드다. 리사이저는 끌 수 있는 노드이고 테마 색으로 그린다. (pane/nodepane.rs)
- 크기 셈(calculate_pane_layout)과 끌기 셈(calculate_resized_size)은 두 플랫폼이 같은 함수를 쓴다. (원본 updateLayout, onMouseMove)
- 원본과 다른 점:
- PaneTheme 은 원본의 묶음(color, size, font)을 이름 앞머리로 편 연관 상수다. (PaneTheme.color.background → PaneTheme::COLOR_BACKGROUND, PaneTheme.size.resizer → PaneTheme::SIZE_RESIZER, PaneTheme.font.sizeSmall → PaneTheme::FONT_SIZE_SMALL) 줄인 이름은 풀었다. (color.inputBg → COLOR_INPUT_BACKGROUND, font.mono → FONT_MONOSPACE) SIZE_RESIZER 는 픽셀 수(f64)다.
- Pane 의 옵션은 PaneOptions 다. 크기는 PaneSize 다. (Flex, Fixed(픽셀), Ratio(0~1 비율)) 원본은 숫자 하나로 0 이나 "flex" 는 flex, 1 이하는 비율, 1 을 넘으면 픽셀로 읽는다. ("50%" 는 Ratio(0.5)) 그래서 get_initial_size 는 PaneSize 를 돌려준다.
- PaneStyle::create 의 옵션은 PaneStyleOptions 다. 빈 글은 원본의 빈 값처럼 넣지 않는다. 원본 options.type 은 element_type 이다. (type 은 러스트 예약어)
Screen split pane. (PaneTheme, PaneStyle, Pane of the original web/pane.js)
- The original builds the window layout of tools (such as the particle editor) with the DOM. Panes split horizontally or vertically, fixed, ratio and flex sizes, minimum and maximum, resizers that change size by dragging, hiding, clearing dragged sizes, layout callbacks, and PaneStyle presets (panel, toolbar, button, input, textarea, text) that build elements with the same theme colors.
- The web builds them with DOM elements as in the original. (pane/dompane.rs)
- Desktop has no DOM, so engine nodes do the same work. Containers are nodes and contents are their child nodes. Resizers are draggable nodes drawn with theme colors. (pane/nodepane.rs)
- Size calculation (calculate_pane_layout) and drag calculation (calculate_resized_size) use the same functions on both platforms. (the original updateLayout, onMouseMove)
- Differences from the original:
- PaneTheme is associated constants that flatten the original groups (color, size, font) with name prefixes. (PaneTheme.color.background → PaneTheme::COLOR_BACKGROUND, PaneTheme.size.resizer → PaneTheme::SIZE_RESIZER, PaneTheme.font.sizeSmall → PaneTheme::FONT_SIZE_SMALL) Abbreviated names were spelled out. (color.inputBg → COLOR_INPUT_BACKGROUND, font.mono → FONT_MONOSPACE) SIZE_RESIZER is a pixel count (f64).
- Pane options are PaneOptions. Sizes are PaneSize. (Flex, Fixed(pixels), Ratio(0~1 ratio)) The original reads a single number: 0 or "flex" as flex, 1 or less as a ratio, above 1 as pixels. ("50%" is Ratio(0.5)) So get_initial_size returns a PaneSize.
- PaneStyle::create options are PaneStyleOptions. Empty strings are not applied, like empty values in the original. The original options.type is element_type. (type is a Rust reserved word)
PaneResizeCallbacktype
패널 크기가 다시 놓일 때 부르는 콜백. (원본 setCallback)
Callback called when the pane sizes are laid out again. (original setCallback)
pub type PaneResizeCallback = Box<dyn FnMut()>PaneThemestruct
테마 상수. (원본 PaneTheme)
Theme constants. (original PaneTheme)
use vanilla::{Color, PaneTheme};
let border_bottom = format!("1px solid {}", PaneTheme::COLOR_BORDER);
assert_eq!(border_bottom, "1px solid #444");
assert_eq!(Color::from(PaneTheme::COLOR_PANEL), Color::from("#252526"));
assert_eq!(PaneTheme::SIZE_RESIZER, 5.0);
assert_eq!(PaneTheme::FONT_SIZE, "13px");바탕 색. (원본 color.background, 패널 컨테이너와 textarea 프리셋의 바탕)
Background color. (original color.background, background of the pane container and the textarea preset)
반환Returns&'static str
panel 프리셋의 바탕 색. (원본 color.panel)
Background color of the panel preset. (original color.panel)
반환Returns&'static str
toolbar 프리셋의 바탕 색. (원본 color.toolbar)
Background color of the toolbar preset. (original color.toolbar)
반환Returns&'static str
테두리 색. (원본 color.border, toolbar 프리셋의 아래 테두리)
Border color. (original color.border, bottom border of the toolbar preset)
반환Returns&'static str
글 색. (원본 color.text)
Text color. (original color.text)
반환Returns&'static str
흐린 글 색. (원본 color.textDim)
Dim text color. (original color.textDim)
반환Returns&'static str
강조 색. (원본 color.accent, accent 단추의 바탕)
Accent color. (original color.accent, background of accent buttons)
반환Returns&'static str
강조 색에 올려 두었을 때의 색. (원본 color.accentHover)
Color when hovering over the accent color. (original color.accentHover)
반환Returns&'static str
경고 색에 올려 두었을 때의 색. (원본 color.warningHover)
Color when hovering over the warning color. (original color.warningHover)
반환Returns&'static str
오류 색. (원본 color.error)
Error color. (original color.error)
반환Returns&'static str
성공 색. (원본 color.success)
Success color. (original color.success)
반환Returns&'static str
입력 칸의 바탕 색. (원본 color.inputBg, input 프리셋)
Background color of input boxes. (original color.inputBg, input preset)
반환Returns&'static str
리사이저 색. (원본 color.resizer, 단추의 기본 바탕과 입력 칸의 테두리에도 쓴다)
Resizer color. (original color.resizer, also used for the default button background and input box borders)
반환Returns&'static str
리사이저에 올려 두거나 끄는 동안의 색. (원본 color.resizerHover)
Color while hovering over or dragging a resizer. (original color.resizerHover)
반환Returns&'static str
글꼴. (원본 font.family)
Font family. (original font.family)
반환Returns&'static str
고정폭 글꼴. (원본 font.mono, textarea 프리셋)
Monospace font. (original font.mono, textarea preset)
반환Returns&'static str
글 크기. (원본 font.size)
Font size. (original font.size)
반환Returns&'static str
작은 글 크기. (원본 font.sizeSmall)
Small font size. (original font.sizeSmall)
반환Returns&'static str
PaneStyleOptionsstruct traits Clone, Copy, Debug, Default
PaneStyle::create 옵션. (원본 options: { id, text, style, type, placeholder, accent, warning })
PaneStyle::create options. (original options: { id, text, style, type, placeholder, accent, warning })
use vanilla::PaneStyleOptions;
let options = PaneStyleOptions { id: "saveButton", text: "Save", accent: true, style: &[("margin", "4px")], ..Default::default() };
assert_eq!(options.style, &[("margin", "4px")]);
assert_eq!(options.element_type, "");
assert_eq!(options.placeholder, "");
assert!(!options.warning);요소 id. (빈 글이면 넣지 않는다, 데스크탑은 노드 이름이고 비면 태그 이름)
Element id. (not set if empty, on desktop it is the node name, the tag name if empty)
반환Returns&'a str
글. (원본 innerText, 빈 글이면 넣지 않는다)
Text. (original innerText, not set if empty)
반환Returns&'a str
덧붙이는 스타일. ((CSS 속성 이름, 값) 목록, 프리셋 스타일 뒤에 넣는다)
Additional styles. (list of (CSS property name, value), applied after the preset styles)
반환Returns&'a [(&'a str, &'a str)]
요소의 type. (원본 options.type, 빈 글이면 넣지 않는다, 데스크탑은 쓰지 않는다)
Element type. (original options.type, not set if empty, not used on desktop)
반환Returns&'a str
안내 글. (웹은 요소의 placeholder 이고 빈 글이면 넣지 않는다, 데스크탑은 input 과 textarea 의 입력 필드에 넣는다)
Placeholder text. (the element's placeholder on the web, not set if empty, on desktop it goes into the input field of input and textarea)
반환Returns&'a str
button 프리셋의 바탕을 COLOR_ACCENT 로.
Sets the button preset background to COLOR_ACCENT.
반환Returnsbool
button 프리셋의 바탕을 COLOR_WARNING 으로. (accent 보다 앞선다)
Sets the button preset background to COLOR_WARNING. (takes precedence over accent)
반환Returnsbool
PaneResizableEdgesstruct traits Clone, Copy, Debug, PartialEq, Eq, Default
리사이저로 끌 수 있는 가장자리. (원본 resizableEdges)
Edges that can be dragged with a resizer. (original resizableEdges)
use vanilla::{PaneOptions, PaneResizableEdges};
let options = PaneOptions { resizable_edges: PaneResizableEdges { left: false, ..Default::default() }, ..Default::default() };
assert!(options.resizable_edges.top && options.resizable_edges.bottom && options.resizable_edges.right);
assert!(!options.resizable_edges.left);위 가장자리. (세로로 나눈 부모에서 앞 형제와의 리사이저)
Top edge. (the resizer with the previous sibling in a vertically split parent)
반환Returnsbool
아래 가장자리. (세로로 나눈 부모에서 뒤 형제와의 리사이저)
Bottom edge. (the resizer with the next sibling in a vertically split parent)
반환Returnsbool
왼쪽 가장자리. (가로로 나눈 부모에서 앞 형제와의 리사이저)
Left edge. (the resizer with the previous sibling in a horizontally split parent)
반환Returnsbool
오른쪽 가장자리. (가로로 나눈 부모에서 뒤 형제와의 리사이저)
Right edge. (the resizer with the next sibling in a horizontally split parent)
반환Returnsbool
PaneOptionsstruct traits Clone, Copy, Debug, Default
Pane 생성 옵션. (원본 options: { direction, size, minSize, maxSize, isResizable, resizableEdges })
Pane creation options. (original options: { direction, size, minSize, maxSize, isResizable, resizableEdges })
use vanilla::{PaneDirection, PaneOptions, PaneSize};
let list_options = PaneOptions { size: PaneSize::Fixed(240.0), min_size: 170.0, ..Default::default() };
let tool_options = PaneOptions { direction: PaneDirection::Vertical, size: PaneSize::Ratio(0.25), is_resizable: false, ..Default::default() };
assert_eq!(list_options.direction, PaneDirection::Horizontal);
assert_eq!(list_options.max_size, f64::MAX);
assert!(list_options.is_resizable);
assert_eq!(tool_options.min_size, 50.0);자식을 놓는 방향. (기본 Horizontal)
Direction to lay out children. (default Horizontal)
반환ReturnsPaneDirection
처음 크기. (부모의 나누는 방향 쪽 길이, 기본 Flex)
Initial size. (length along the parent's split direction, default Flex)
반환ReturnsPaneSize
가장 큰 크기. (픽셀, 기본 f64::MAX)
Maximum size. (pixels, default f64::MAX)
반환Returnsf64
리사이저로 끌 수 있는지. (기본 true, 부모와 맞닿은 두 형제가 모두 true 여야 그 사이 리사이저가 끌린다)
Whether it can be dragged with a resizer. (default true, the resizer between two adjacent siblings can be dragged only if the parent and both siblings are true)
반환Returnsbool
리사이저로 끌 수 있는 가장자리. (기본 네 쪽 모두)
Edges that can be dragged with a resizer. (default all four)
반환ReturnsPaneResizableEdges
ClassicScrollbarMetricsstruct traits Clone, Copy, Debug, PartialEq
자리를 차지하는 스크롤 막대(클래식 막대)의 치수. (크롬과 같게, DIP)
Metrics of a space-taking scroll bar (classic scroll bar). (same as Chrome, DIP)
use vanilla::web::pane::{self, ClassicScrollbarMetrics};
let metrics = ClassicScrollbarMetrics { thickness: 15.0, button_length: 18.0, thumb_thickness: 9.0, thumb_cross_offset: 3.0, thumb_minimum_length: 17.0, thumb_length_inset: 0.0 };
assert_eq!(pane::calculate_classic_thumb_span(&metrics, 200.0, 200.0, 800.0, 0.0), Some((18.0, 41.0)));
assert_eq!(pane::calculate_classic_thumb_span(&metrics, 200.0, 200.0, 800.0, 600.0), Some((141.0, 41.0)));
assert_eq!(pane::calculate_classic_thumb_span(&metrics, 200.0, 200.0, 200.0, 0.0), None);막대 두께. (내용 상자에서 이만큼 덜어 낸다)
Bar thickness. (this much is taken from the content box)
반환Returnsf64
양끝 단추 길이. (썸은 그 사이에서 움직인다, 없으면 0)
Length of the buttons at both ends. (the thumb moves between them, 0 if none)
반환Returnsf64
막대 안쪽에서 썸까지. (막대의 가로지르는 쪽)
From the inside of the bar to the thumb. (across the bar)
반환Returnsf64
썸이 움직이는 칸의 가장 짧은 썸 길이.
Shortest thumb length in the track the thumb moves in.
반환Returnsf64
그린 썸이 칸 끝에서 떨어지는 만큼.
How far the drawn thumb stays from the ends of the track.
반환Returnsf64
함수Functions
이 플랫폼의 크롬이 쓰는 클래식 스크롤 막대 치수. (얹는 막대면 None)
- 윈도우, 리눅스: 크롬은 Fluent 막대를 자리를 차지하는 막대로 쓴다. (native_theme_features.cc 의 IsFluentScrollbarEnabled 가 IS_WIN, IS_LINUX 에서 참, 얹는 막대 기능 kOverlayScrollbar 는 두 운영체제에서 꺼져 있다) 두께 15, 단추 18, 썸 9 와 가장 짧은 길이 17 (native_theme_fluent.h, .cc). scrollbar-width: thin 은 크롬 ScrollbarThemeAura 처럼 2/3 배다.
- 맥: 크롬은 시스템 설정(스크롤 막대 보기)을 NSScroller.preferredScrollerStyle 로 읽어(os_settings_provider_mac.mm) 얹는 막대면 자리를 차지하지 않는다. 클래식이면 scrollbar_theme_mac.cc 의 legacy 값(두께 15, 얇으면 11, 가장 짧은 썸 칸 20, 16)이고 썸은 native_theme_mac.mm 처럼 둘레를 3 (막대 쪽은 테두리 1 더) 줄여 그린다.
- 웹: 브라우저가 놓은 막대 두께(overflow: scroll 인 요소의 offsetWidth - clientWidth)를 읽는다. 0 이면 얹는 막대다.
Classic scroll bar metrics used by Chrome on this platform. (None for overlay scroll bars)
- Windows, Linux: Chrome uses the Fluent scroll bar as a space-taking scroll bar. (IsFluentScrollbarEnabled in native_theme_features.cc is true on IS_WIN, IS_LINUX, and the overlay scroll bar feature kOverlayScrollbar is off on both operating systems) Thickness 15, buttons 18, thumb 9 and minimum length 17 (native_theme_fluent.h, .cc). scrollbar-width: thin is 2/3 times, like Chrome ScrollbarThemeAura.
- Mac: Chrome reads the system setting (Show scroll bars) with NSScroller.preferredScrollerStyle (os_settings_provider_mac.mm), and overlay scroll bars take no space. If classic, the legacy values of scrollbar_theme_mac.cc apply (thickness 15, 11 if thin, minimum thumb track 20, 16), and the thumb is drawn shrunk by 3 all around (1 more for the border on the bar side) like native_theme_mac.mm.
- Web: reads the bar thickness laid out by the browser (offsetWidth - clientWidth of an element with overflow: scroll). 0 means an overlay scroll bar.
- is_thinbool
- CSS scrollbar-width 가 thin 인지.Whether CSS scrollbar-width is thin.
반환ReturnsOption<ClassicScrollbarMetrics> 클래식 막대의 치수. (얹는 막대면 None)Metrics of the classic scroll bar. (None for overlay scroll bars)
pub fn calculate_classic_thumb_span(metrics: &ClassicScrollbarMetrics, track_length: f64, viewport_length: f64, extent_length: f64, offset: f64) -> Option<(f64, f64)>#클래식 막대의 썸 자리. ((썸 시작, 썸 길이), 막대 길이 방향의 자리, 막대 시작이 0. 넘치지 않거나 썸 칸이 없으면 None)
- 크롬 ScrollbarTheme 처럼 썸 칸은 양끝 단추 사이이고, 썸 길이는 칸 x 보이는 비율(가장 짧은 길이까지)이다.
Thumb position of the classic scroll bar. ((thumb start, thumb length), positions along the bar length, the bar start is 0. None if not overflowing or there is no thumb track)
- Like Chrome ScrollbarTheme, the thumb track is between the buttons at both ends, and the thumb length is track x visible ratio (down to the minimum length).
- metrics&ClassicScrollbarMetrics
- 막대 치수. (read_classic_scrollbar_metrics)Bar metrics. (read_classic_scrollbar_metrics)
- track_lengthf64
- 막대 길이.Bar length.
- viewport_lengthf64
- 보이는 내용의 길이.Length of the visible content.
- extent_lengthf64
- 내용 전체의 길이.Length of the whole content.
- offsetf64
- 굴려 넘긴 만큼.Scrolled amount.
반환ReturnsOption<(f64, f64)> (썸 시작, 썸 길이). 내용이 0.5 를 넘게 넘치지 않거나, 썸 칸이 가장 짧은 썸 길이보다 짧거나, 보이는 길이가 0 이하면 None.(thumb start, thumb length). None if the content does not overflow by more than 0.5, the thumb track is shorter than the minimum thumb length, or the visible length is 0 or less.
PaneDirectionenum traits Clone, Copy, Debug, Default, PartialEq, Eq
나누는 방향. (원본 "horizontal" | "vertical")
Split direction. (original "horizontal" | "vertical")
| 이름Name | 설명Description |
|---|---|
Horizontal | 자식을 왼쪽에서 오른쪽으로 놓는다.Places children from left to right. |
Vertical | 자식을 위에서 아래로 놓는다.Places children from top to bottom. |
PaneSizeenum traits Clone, Copy, Debug, Default, PartialEq
처음 크기. (부모의 나누는 방향 쪽 길이)
Initial size. (length along the parent's split direction)
| 이름Name | 값Value | 설명Description |
|---|---|---|
Flex | 고정 크기 형제들이 쓰고 남은 자리를 flex 형제끼리 똑같이 나눈다. (원본 0, "flex")The space left over by fixed size siblings is split equally among flex siblings. (original 0, "flex") | |
Fixed | Fixed(f64) | 픽셀. (원본 1 을 넘는 숫자)Pixels. (original numbers greater than 1) |
Ratio | Ratio(f64) | 리사이저를 뺀 부모 길이에 곱하는 비율. (원본 1 이하 숫자, "50%")Ratio multiplied by the parent length minus the resizers. (original numbers at most 1, "50%") |