mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 14:28:12 +08:00
WIP: Part 1
This commit is contained in:
@@ -138,8 +138,12 @@ pub struct TextButton {
|
|||||||
pub narrow: bool,
|
pub narrow: bool,
|
||||||
|
|
||||||
// Sizing
|
// Sizing
|
||||||
|
#[serde(rename = "autoWidth")]
|
||||||
|
pub auto_width: bool,
|
||||||
#[serde(rename = "minWidth")]
|
#[serde(rename = "minWidth")]
|
||||||
pub min_width: u32,
|
pub min_width: u32,
|
||||||
|
#[serde(rename = "maxWidth")]
|
||||||
|
pub max_width: u32,
|
||||||
|
|
||||||
// Tooltips
|
// Tooltips
|
||||||
#[serde(rename = "tooltipLabel")]
|
#[serde(rename = "tooltipLabel")]
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ pub struct DropdownInput {
|
|||||||
pub interactive: bool,
|
pub interactive: bool,
|
||||||
|
|
||||||
// Sizing
|
// Sizing
|
||||||
|
#[serde(rename = "autoWidth")]
|
||||||
|
pub auto_width: bool,
|
||||||
#[serde(rename = "minWidth")]
|
#[serde(rename = "minWidth")]
|
||||||
pub min_width: u32,
|
pub min_width: u32,
|
||||||
#[serde(rename = "maxWidth")]
|
#[serde(rename = "maxWidth")]
|
||||||
@@ -189,6 +191,8 @@ pub struct NumberInput {
|
|||||||
pub unit_is_hidden_when_editing: bool,
|
pub unit_is_hidden_when_editing: bool,
|
||||||
|
|
||||||
// Sizing
|
// Sizing
|
||||||
|
#[serde(rename = "autoWidth")]
|
||||||
|
pub auto_width: bool,
|
||||||
#[serde(rename = "minWidth")]
|
#[serde(rename = "minWidth")]
|
||||||
pub min_width: u32,
|
pub min_width: u32,
|
||||||
#[serde(rename = "maxWidth")]
|
#[serde(rename = "maxWidth")]
|
||||||
@@ -309,8 +313,12 @@ pub struct RadioInput {
|
|||||||
pub narrow: bool,
|
pub narrow: bool,
|
||||||
|
|
||||||
// Sizing
|
// Sizing
|
||||||
|
#[serde(rename = "autoWidth")]
|
||||||
|
pub auto_width: bool,
|
||||||
#[serde(rename = "minWidth")]
|
#[serde(rename = "minWidth")]
|
||||||
pub min_width: u32,
|
pub min_width: u32,
|
||||||
|
#[serde(rename = "maxWidth")]
|
||||||
|
pub max_width: u32,
|
||||||
//
|
//
|
||||||
// Callbacks exists on the `RadioEntryData` children, not this parent `RadioInput`
|
// Callbacks exists on the `RadioEntryData` children, not this parent `RadioInput`
|
||||||
}
|
}
|
||||||
@@ -399,6 +407,8 @@ pub struct TextInput {
|
|||||||
pub centered: bool,
|
pub centered: bool,
|
||||||
|
|
||||||
// Sizing
|
// Sizing
|
||||||
|
#[serde(rename = "autoWidth")]
|
||||||
|
pub auto_width: bool,
|
||||||
#[serde(rename = "minWidth")]
|
#[serde(rename = "minWidth")]
|
||||||
pub min_width: u32,
|
pub min_width: u32,
|
||||||
#[serde(rename = "maxWidth")]
|
#[serde(rename = "maxWidth")]
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ pub struct TextLabel {
|
|||||||
pub table_align: bool,
|
pub table_align: bool,
|
||||||
|
|
||||||
// Sizing
|
// Sizing
|
||||||
|
#[serde(rename = "autoWidth")]
|
||||||
|
pub auto_width: bool,
|
||||||
#[serde(rename = "minWidth")]
|
#[serde(rename = "minWidth")]
|
||||||
pub min_width: u32,
|
pub min_width: u32,
|
||||||
#[serde(rename = "maxWidth")]
|
#[serde(rename = "maxWidth")]
|
||||||
|
|||||||
@@ -700,7 +700,7 @@
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
||||||
.widget-span:first-child {
|
.widget-span:first-child {
|
||||||
flex: 1 1 auto;
|
flex: 1 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:not(:has(*)) {
|
&:not(:has(*)) {
|
||||||
|
|||||||
@@ -174,7 +174,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
> .text-label:first-of-type {
|
> .text-label:first-of-type {
|
||||||
flex: 0 0 25%;
|
flex: 0 0 20%;
|
||||||
margin-left: 16px;
|
margin-left: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -337,6 +337,7 @@
|
|||||||
.widget-span.row {
|
.widget-span.row {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
overflow: hidden;
|
||||||
min-height: var(--row-height);
|
min-height: var(--row-height);
|
||||||
--row-height: 32px;
|
--row-height: 32px;
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,9 @@
|
|||||||
export let flush = false;
|
export let flush = false;
|
||||||
export let narrow = false;
|
export let narrow = false;
|
||||||
// Sizing
|
// Sizing
|
||||||
|
export let autoWidth = false;
|
||||||
export let minWidth = 0;
|
export let minWidth = 0;
|
||||||
|
export let maxWidth = 0;
|
||||||
// Tooltips
|
// Tooltips
|
||||||
export let tooltipLabel: string | undefined = undefined;
|
export let tooltipLabel: string | undefined = undefined;
|
||||||
export let tooltipDescription: string | undefined = undefined;
|
export let tooltipDescription: string | undefined = undefined;
|
||||||
@@ -107,15 +109,15 @@
|
|||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.text-button-container {
|
.text-button-container {
|
||||||
display: flex;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-button {
|
.text-button {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex: 0 0 auto;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex: 0 0 auto;
|
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
height: var(--widget-height);
|
height: var(--widget-height);
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
export let virtualScrolling = false;
|
export let virtualScrolling = false;
|
||||||
export let interactive = true;
|
export let interactive = true;
|
||||||
// Sizing
|
// Sizing
|
||||||
|
export let autoWidth = false;
|
||||||
export let minWidth = 0;
|
export let minWidth = 0;
|
||||||
export let maxWidth = 0;
|
export let maxWidth = 0;
|
||||||
// Tooltips
|
// Tooltips
|
||||||
|
|||||||
@@ -25,6 +25,9 @@
|
|||||||
export let monospace = false;
|
export let monospace = false;
|
||||||
export let narrow = false;
|
export let narrow = false;
|
||||||
export let textarea = false;
|
export let textarea = false;
|
||||||
|
export let autoWidth = false;
|
||||||
|
export let minWidth = 0;
|
||||||
|
export let maxWidth = 0;
|
||||||
export let tooltipLabel: string | undefined = undefined;
|
export let tooltipLabel: string | undefined = undefined;
|
||||||
export let tooltipDescription: string | undefined = undefined;
|
export let tooltipDescription: string | undefined = undefined;
|
||||||
export let tooltipShortcut: ActionShortcut | undefined = undefined;
|
export let tooltipShortcut: ActionShortcut | undefined = undefined;
|
||||||
@@ -76,8 +79,24 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- This is a base component, extended by others like NumberInput and TextInput. It should not be used directly. -->
|
<!-- This is a base component, extended by others like NumberInput and TextInput. It should not be used directly. -->
|
||||||
<LayoutRow class={`field-input ${className}`} classes={{ disabled, narrow, monospace, ...classes }} style={styleName} {styles} {tooltipLabel} {tooltipDescription} {tooltipShortcut}>
|
<LayoutRow
|
||||||
|
class={`field-input ${className}`}
|
||||||
|
classes={{ disabled, narrow, monospace, ...classes }}
|
||||||
|
style={styleName}
|
||||||
|
styles={{
|
||||||
|
...styles,
|
||||||
|
...(minWidth > 0 ? { "min-width": `${minWidth}px` } : {}),
|
||||||
|
...(maxWidth > 0 ? { "max-width": `${maxWidth}px` } : {}),
|
||||||
|
}}
|
||||||
|
{tooltipLabel}
|
||||||
|
{tooltipDescription}
|
||||||
|
{tooltipShortcut}
|
||||||
|
>
|
||||||
|
|
||||||
{#if !textarea}
|
{#if !textarea}
|
||||||
|
{#if label}
|
||||||
|
<label for={`field-input-${id}`} on:pointerdown>{label}</label>
|
||||||
|
{/if}
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
class:has-label={label}
|
class:has-label={label}
|
||||||
@@ -115,9 +134,6 @@
|
|||||||
on:contextmenu={(e) => hideContextMenu && e.preventDefault()}
|
on:contextmenu={(e) => hideContextMenu && e.preventDefault()}
|
||||||
></textarea>
|
></textarea>
|
||||||
{/if}
|
{/if}
|
||||||
{#if label}
|
|
||||||
<label for={`field-input-${id}`} on:pointerdown>{label}</label>
|
|
||||||
{/if}
|
|
||||||
<slot />
|
<slot />
|
||||||
</LayoutRow>
|
</LayoutRow>
|
||||||
|
|
||||||
@@ -128,7 +144,6 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
background: var(--color-1-nearblack);
|
background: var(--color-1-nearblack);
|
||||||
flex-direction: row-reverse;
|
|
||||||
|
|
||||||
&.narrow.narrow {
|
&.narrow.narrow {
|
||||||
--widget-height: 20px;
|
--widget-height: 20px;
|
||||||
@@ -182,13 +197,13 @@
|
|||||||
|
|
||||||
&:focus {
|
&:focus {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
|
||||||
& + label {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
label:has(+ input:focus) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
textarea {
|
textarea {
|
||||||
min-height: calc((var(--widget-height) - 6px) * 3);
|
min-height: calc((var(--widget-height) - 6px) * 3);
|
||||||
margin: 3px;
|
margin: 3px;
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
export let unitIsHiddenWhenEditing = true;
|
export let unitIsHiddenWhenEditing = true;
|
||||||
|
|
||||||
// Sizing
|
// Sizing
|
||||||
|
export let autoWidth = false;
|
||||||
export let minWidth = 0;
|
export let minWidth = 0;
|
||||||
export let maxWidth = 0;
|
export let maxWidth = 0;
|
||||||
// Tooltips
|
// Tooltips
|
||||||
@@ -101,11 +102,6 @@
|
|||||||
|
|
||||||
$: watchValue(value, unit);
|
$: watchValue(value, unit);
|
||||||
$: sliderStepValue = isInteger ? (step === undefined ? 1 : step) : "any";
|
$: sliderStepValue = isInteger ? (step === undefined ? 1 : step) : "any";
|
||||||
$: styles = {
|
|
||||||
...(minWidth > 0 ? { "min-width": `${minWidth}px` } : {}),
|
|
||||||
...(maxWidth > 0 ? { "max-width": `${maxWidth}px` } : {}),
|
|
||||||
...(mode === "Range" ? { "--progress-factor": Math.min(Math.max((rangeSliderValueAsRendered - rangeMin) / (rangeMax - rangeMin), 0), 1) } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Keep track of the Shift and Ctrl key being held down.
|
// Keep track of the Shift and Ctrl key being held down.
|
||||||
const trackShiftAndCtrl = (e: KeyboardEvent | MouseEvent) => {
|
const trackShiftAndCtrl = (e: KeyboardEvent | MouseEvent) => {
|
||||||
@@ -775,7 +771,12 @@
|
|||||||
{tooltipLabel}
|
{tooltipLabel}
|
||||||
{tooltipDescription}
|
{tooltipDescription}
|
||||||
{tooltipShortcut}
|
{tooltipShortcut}
|
||||||
{styles}
|
styles={{
|
||||||
|
...(mode === "Range" ? { "--progress-factor": Math.min(Math.max((rangeSliderValueAsRendered - rangeMin) / (rangeMax - rangeMin), 0), 1) } : {}),
|
||||||
|
}}
|
||||||
|
{autoWidth}
|
||||||
|
{minWidth}
|
||||||
|
{maxWidth}
|
||||||
hideContextMenu={true}
|
hideContextMenu={true}
|
||||||
spellcheck={false}
|
spellcheck={false}
|
||||||
bind:this={self}
|
bind:this={self}
|
||||||
|
|||||||
@@ -15,7 +15,9 @@
|
|||||||
// Styling
|
// Styling
|
||||||
export let narrow = false;
|
export let narrow = false;
|
||||||
// Sizing
|
// Sizing
|
||||||
|
export let autoWidth = false;
|
||||||
export let minWidth = 0;
|
export let minWidth = 0;
|
||||||
|
export let maxWidth = 0;
|
||||||
|
|
||||||
$: mixed = selectedIndex === undefined && !disabled;
|
$: mixed = selectedIndex === undefined && !disabled;
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
export let narrow = false;
|
export let narrow = false;
|
||||||
export let centered = false;
|
export let centered = false;
|
||||||
// Sizing
|
// Sizing
|
||||||
|
export let autoWidth = false;
|
||||||
export let minWidth = 0;
|
export let minWidth = 0;
|
||||||
export let maxWidth = 0;
|
export let maxWidth = 0;
|
||||||
// Tooltips
|
// Tooltips
|
||||||
@@ -73,10 +74,6 @@
|
|||||||
<FieldInput
|
<FieldInput
|
||||||
class={`text-input ${className}`.trim()}
|
class={`text-input ${className}`.trim()}
|
||||||
classes={{ centered, ...classes }}
|
classes={{ centered, ...classes }}
|
||||||
styles={{
|
|
||||||
...(minWidth > 0 ? { "min-width": `${minWidth}px` } : {}),
|
|
||||||
...(maxWidth > 0 ? { "max-width": `${maxWidth}px` } : {}),
|
|
||||||
}}
|
|
||||||
{value}
|
{value}
|
||||||
on:value
|
on:value
|
||||||
on:textFocused={onTextFocused}
|
on:textFocused={onTextFocused}
|
||||||
@@ -90,6 +87,9 @@
|
|||||||
{tooltipDescription}
|
{tooltipDescription}
|
||||||
{tooltipShortcut}
|
{tooltipShortcut}
|
||||||
{placeholder}
|
{placeholder}
|
||||||
|
{autoWidth}
|
||||||
|
{minWidth}
|
||||||
|
{maxWidth}
|
||||||
bind:this={self}
|
bind:this={self}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
export let centerAlign = false;
|
export let centerAlign = false;
|
||||||
export let tableAlign = false;
|
export let tableAlign = false;
|
||||||
// Sizing
|
// Sizing
|
||||||
|
export let autoWidth = false;
|
||||||
export let minWidth = 0;
|
export let minWidth = 0;
|
||||||
export let maxWidth = 0;
|
export let maxWidth = 0;
|
||||||
export let minWidthCharacters = 0;
|
export let minWidthCharacters = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user