# web/pane (vanilla.js 0.4.0)

> https://vanillapunch.com/docs/vanilla.js/0.4.0/api/web/pane/

화면 분할 패널(Pane) 클래스.

## PaneStyle

스타일 및 요소 생성 유틸리티.

예제: 테마 스타일이 적용된 단추 만들기

```js
import { PaneStyle, PaneTheme } from "./build/vanilla.js";

const button = PaneStyle.create("button", "button", { text: "OK", accent: true });
PaneStyle.apply(button, { margin: "8px" });
document.body.appendChild(button);
console.log(button.style.margin, PaneTheme.color.accent);
```

- `static apply(el, styles)` (static, since 0.0.10): 엘리먼트에 여러 스타일을 한꺼번에 적용한다. (엘리먼트나 스타일이 없으면 아무것도 하지 않는다)
  - `el` HTMLElement: 스타일을 적용할 엘리먼트.
  - `styles` Object: 적용할 CSS 속성 이름과 값. (camelCase)
- `static create(tagName, preset = "", options = {})` (static, since 0.0.10): 스타일 프리셋이 적용된 엘리먼트를 만든다.
  - `tagName` string: 만들 태그 이름.
  - `preset` string: 프리셋 이름. ("panel", "toolbar", "button", "input", "textarea", "text", 빈 글이면 공통 스타일만)
  - `options` Object: { id, text, style, type, placeholder, accent, warning }. (accent 나 warning 이 참인 단추는 그 색 바탕)
  - returns HTMLElement: 만든 엘리먼트.

## Pane

화면 분할 패널(Pane) 클래스.

예제: 좌우로 나누고 부모 요소에 붙이기

```js
import { Pane } from "./build/vanilla.js";

const rootPane = new Pane({ direction: "horizontal" });
const leftPane = new Pane({ size: 200, minSize: 100 });
const rightPane = new Pane({ size: "flex" });
rootPane.addPane(leftPane);
rootPane.addPane(rightPane);
rootPane.attachTo(document.body);
console.log(leftPane.getInitialSize(), rightPane.isFlex(), leftPane.getMinSize());
```

- `constructor(options = {})` (constructor, since 0.0.10): 생성.
  - `options` { direction?: string, size?: number | string, minSize?: number, maxSize?: number, isResizable?: boolean, resizableEdges?: { top: boolean, bottom: boolean, left: boolean, right: boolean } }: 나누는 방향(horizontal 이나 vertical), 처음 크기(픽셀, 1 이하의 비율, 퍼센트 글, flex), 가장 작고 큰 크기, 조절 가능 여부와 가장자리.
- `addPane(pane)` (method, since 0.0.10): 자식 추가.
  - `pane` Pane: 자식으로 붙일 패널. (앞 자식과의 사이에 리사이저가 생긴다)
- `updateLayout(x, y, w, h)` (method, since 0.0.10): 레이아웃 엔진
  - `x` number: 왼쪽 자리. (픽셀)
  - `y` number: 위쪽 자리. (픽셀)
  - `w` number: 너비. (픽셀)
  - `h` number: 높이. (픽셀)
- `resetLayout()` (method, since 0.0.10): 레이아웃 초기화 (드래그한 크기 삭제)
- `refresh()` (method, since 0.0.10): 부모 요소의 크기로 다시 배치. (부모가 없으면 아무것도 하지 않는다)
- `attachTo(p)` (method, since 0.0.10): 부모 요소에 붙이기. (창 크기가 바뀔 때마다 다시 배치한다)
  - `p` HTMLElement: 붙일 부모 요소.
- `setVisible(isVisible)` (method, since 0.3.2): 보이기 / 숨기기. (숨긴 패널은 자리를 차지하지 않고, 맞닿은 리사이저도 숨는다)
  - `isVisible` boolean: 보이면 참, 숨기면 거짓.
- `isVisible()` (method, since 0.3.2): 보이는지 반환.
  - returns boolean: 보이면 참.
- `isFlex()` (method, since 0.0.10): 남는 자리를 나눠 갖는지 반환. (처음 크기가 0 이면 참)
  - returns boolean: 남는 자리를 나눠 가지면 참.
- `getInitialSize()` (method, since 0.0.10): 처음 크기 반환. (1 이하이면 부모에 대한 비율, 넘으면 픽셀)
  - returns number: 처음 크기. (1 이하이면 부모에 대한 비율, 넘으면 픽셀)
- `getFixedSize()` (method, since 0.0.10): 정해진 크기 반환. (끌어서 정했거나 처음 크기가 픽셀이면 그 값, 아니면 0)
  - returns number: 정해진 크기. (픽셀, 정해진 것이 없으면 0)
- `setFixedSize(s)` (method, since 0.0.10): 정해진 크기 설정. (픽셀)
  - `s` number: 정해 둘 크기. (픽셀)
- `getMinSize()` (method, since 0.0.10): 가장 작은 크기 반환. (픽셀)
  - returns number: 가장 작은 크기. (픽셀)
- `getMaxSize()` (method, since 0.0.10): 가장 큰 크기 반환. (픽셀)
  - returns number: 가장 큰 크기. (픽셀)
- `getContainer()` (method, since 0.0.10): 컨테이너 요소 반환.
  - returns HTMLElement: 컨테이너 요소.
- `setCallback(c)` (method, since 0.0.10): 배치가 바뀔 때마다 부를 함수 설정.
  - `c` Function | null: 배치가 바뀔 때마다 부를 함수.
- `isResizable()` (method, since 0.0.10): 크기를 조절할 수 있는지 반환.
  - returns boolean: 크기를 조절할 수 있으면 참.
- `getResizableEdges()` (method, since 0.0.10): 조절할 수 있는 가장자리 반환. ({ top, right, bottom, left })
  - returns { top: boolean, bottom: boolean, left: boolean, right: boolean }: 조절할 수 있는 가장자리.

## PaneTheme (enum)

테마 상수 정의.

- `color` = `{ background: "#1e1e1e", panel: "#252526", toolbar: "#2d2d30", border: "#444", text: "#ccc", textDim: "#aaaaaa", accent: "#0e639c", accentHover: "#1177bb", warning: "#d97706", warningHover: "#f59e0b", error: "#f44336", success: "#4CAF50", inputBg: "#3c3c3c", resizer: "#333", resizerHover: "#007acc" }`: 색. (CSS 색 글)
- `size` = `{ resizer: 5 }`: 크기. (픽셀)
- `font` = `{ family: "sans-serif", mono: "\"Consolas\", monospace", size: "13px", sizeSmall: "12px" }`: 글꼴과 글 크기.
