mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-02 20:08:12 +08:00
WIP: Part 2
This commit is contained in:
@@ -177,6 +177,7 @@ impl PreferencesDialogMessageHandler {
|
|||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
.selected_index(Some(preferences.selection_mode as u32))
|
.selected_index(Some(preferences.selection_mode as u32))
|
||||||
|
.auto_width(true)
|
||||||
.widget_instance();
|
.widget_instance();
|
||||||
let selection_mode = vec![
|
let selection_mode = vec![
|
||||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||||
@@ -266,6 +267,7 @@ impl PreferencesDialogMessageHandler {
|
|||||||
.on_update(move |_| PreferencesMessage::GraphWireStyle { style: GraphWireStyle::GridAligned }.into()),
|
.on_update(move |_| PreferencesMessage::GraphWireStyle { style: GraphWireStyle::GridAligned }.into()),
|
||||||
])
|
])
|
||||||
.selected_index(Some(preferences.graph_wire_style as u32))
|
.selected_index(Some(preferences.graph_wire_style as u32))
|
||||||
|
.auto_width(true)
|
||||||
.widget_instance();
|
.widget_instance();
|
||||||
let graph_wire_style = vec![
|
let graph_wire_style = vec![
|
||||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||||
|
|||||||
@@ -3486,7 +3486,6 @@ impl DocumentMessageHandler {
|
|||||||
.selected_index(blend_mode.and_then(|blend_mode| blend_mode.index_in_list_svg_subset()).map(|index| index as u32))
|
.selected_index(blend_mode.and_then(|blend_mode| blend_mode.index_in_list_svg_subset()).map(|index| index as u32))
|
||||||
.disabled(disabled)
|
.disabled(disabled)
|
||||||
.draw_icon(false)
|
.draw_icon(false)
|
||||||
.max_width(100)
|
|
||||||
.tooltip_label("Blend Mode")
|
.tooltip_label("Blend Mode")
|
||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||||
@@ -3508,7 +3507,6 @@ impl DocumentMessageHandler {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.on_commit(|_| DocumentMessage::AddTransaction.into())
|
.on_commit(|_| DocumentMessage::AddTransaction.into())
|
||||||
.max_width(100)
|
|
||||||
.tooltip_label("Opacity")
|
.tooltip_label("Opacity")
|
||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||||
@@ -3530,7 +3528,6 @@ impl DocumentMessageHandler {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.on_commit(|_| DocumentMessage::AddTransaction.into())
|
.on_commit(|_| DocumentMessage::AddTransaction.into())
|
||||||
.max_width(100)
|
|
||||||
.tooltip_label("Fill")
|
.tooltip_label("Fill")
|
||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
];
|
];
|
||||||
@@ -3946,6 +3943,7 @@ pub fn navigation_controls(ptz: &PTZ, navigation_handler: &NavigationMessageHand
|
|||||||
.min(0.000001)
|
.min(0.000001)
|
||||||
.max(1000000.)
|
.max(1000000.)
|
||||||
.tooltip_label(if node_graph { "Node Graph Zoom" } else { "Canvas Zoom" })
|
.tooltip_label(if node_graph { "Node Graph Zoom" } else { "Canvas Zoom" })
|
||||||
|
.min_width(80)
|
||||||
.on_update(|number_input: &NumberInput| {
|
.on_update(|number_input: &NumberInput| {
|
||||||
NavigationMessage::CanvasZoomSet {
|
NavigationMessage::CanvasZoomSet {
|
||||||
zoom_factor: number_input.value.unwrap() / 100.,
|
zoom_factor: number_input.value.unwrap() / 100.,
|
||||||
|
|||||||
@@ -186,10 +186,6 @@
|
|||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
> .radio-input button {
|
|
||||||
flex: 1 1 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
> .parameter-expose-button + .text-label ~ .number-input:last-child {
|
> .parameter-expose-button + .text-label ~ .number-input:last-child {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,9 @@
|
|||||||
class:disabled
|
class:disabled
|
||||||
class:narrow
|
class:narrow
|
||||||
class:flush
|
class:flush
|
||||||
|
class:auto-width={autoWidth}
|
||||||
style:min-width={minWidth > 0 ? `${minWidth}px` : undefined}
|
style:min-width={minWidth > 0 ? `${minWidth}px` : undefined}
|
||||||
|
style:max-width={maxWidth > 0 ? `${maxWidth}px` : undefined}
|
||||||
data-tooltip-label={tooltipLabel}
|
data-tooltip-label={tooltipLabel}
|
||||||
data-tooltip-description={tooltipDescription}
|
data-tooltip-description={tooltipDescription}
|
||||||
data-tooltip-shortcut={tooltipShortcut?.shortcut ? JSON.stringify(tooltipShortcut.shortcut) : undefined}
|
data-tooltip-shortcut={tooltipShortcut?.shortcut ? JSON.stringify(tooltipShortcut.shortcut) : undefined}
|
||||||
@@ -111,11 +113,16 @@
|
|||||||
.text-button-container {
|
.text-button-container {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex: 1 1 auto;
|
||||||
|
|
||||||
|
&:has(.auto-width) {
|
||||||
|
flex: 1 0 auto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-button {
|
.text-button {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 0 0 auto;
|
flex: 1 1 auto;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
@@ -131,6 +138,10 @@
|
|||||||
--button-text-color: var(--color-e-nearwhite);
|
--button-text-color: var(--color-e-nearwhite);
|
||||||
--widget-height: 24px;
|
--widget-height: 24px;
|
||||||
|
|
||||||
|
&.auto-width {
|
||||||
|
flex: 1 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
&.narrow.narrow {
|
&.narrow.narrow {
|
||||||
--widget-height: 20px;
|
--widget-height: 20px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@
|
|||||||
|
|
||||||
<LayoutRow
|
<LayoutRow
|
||||||
class="dropdown-input"
|
class="dropdown-input"
|
||||||
classes={{ narrow }}
|
classes={{ narrow, "auto-width": autoWidth }}
|
||||||
styles={{
|
styles={{
|
||||||
...(minWidth > 0 ? { "min-width": `${minWidth}px` } : {}),
|
...(minWidth > 0 ? { "min-width": `${minWidth}px` } : {}),
|
||||||
...(maxWidth > 0 ? { "max-width": `${maxWidth}px` } : {}),
|
...(maxWidth > 0 ? { "max-width": `${maxWidth}px` } : {}),
|
||||||
@@ -165,8 +165,13 @@
|
|||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.dropdown-input {
|
.dropdown-input {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
flex: 1 1 auto;
|
||||||
--widget-height: 24px;
|
--widget-height: 24px;
|
||||||
|
|
||||||
|
&.auto-width {
|
||||||
|
flex: 1 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
&.narrow.narrow {
|
&.narrow.narrow {
|
||||||
--widget-height: 20px;
|
--widget-height: 20px;
|
||||||
}
|
}
|
||||||
@@ -181,7 +186,9 @@
|
|||||||
.dropdown-label {
|
.dropdown-label {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
flex: 1 1 100%;
|
flex: 1 1 auto;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-icon {
|
.dropdown-icon {
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
<!-- 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
|
<LayoutRow
|
||||||
class={`field-input ${className}`}
|
class={`field-input ${className}`}
|
||||||
classes={{ disabled, narrow, monospace, ...classes }}
|
classes={{ disabled, narrow, monospace, "auto-width": autoWidth, ...classes }}
|
||||||
style={styleName}
|
style={styleName}
|
||||||
styles={{
|
styles={{
|
||||||
...styles,
|
...styles,
|
||||||
@@ -92,10 +92,10 @@
|
|||||||
{tooltipDescription}
|
{tooltipDescription}
|
||||||
{tooltipShortcut}
|
{tooltipShortcut}
|
||||||
>
|
>
|
||||||
|
|
||||||
{#if !textarea}
|
{#if !textarea}
|
||||||
{#if label}
|
{#if label}
|
||||||
<label for={`field-input-${id}`} on:pointerdown>{label}</label>
|
<label for={`field-input-${id}`} on:pointerdown>{label}</label>
|
||||||
|
<div class="after-label-spacer"></div>
|
||||||
{/if}
|
{/if}
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
@@ -139,12 +139,27 @@
|
|||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.field-input {
|
.field-input {
|
||||||
min-width: 80px;
|
|
||||||
height: auto;
|
height: auto;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
background: var(--color-1-nearblack);
|
background: var(--color-1-nearblack);
|
||||||
|
|
||||||
|
// This property seems likely to be supported soon in Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1832409
|
||||||
|
// Meanwhile, Firefox and Safari pre-26.2 (Dec 2025) assume the input text field is 30px wide, as set by `min-width: 30px` in FieldInput.svelte.
|
||||||
|
@supports (field-sizing: content) {
|
||||||
|
input[type="text"]:not(:focus).has-label {
|
||||||
|
field-sizing: content;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
width: auto;
|
||||||
|
min-width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
flex: 1 1 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&.narrow.narrow {
|
&.narrow.narrow {
|
||||||
--widget-height: 20px;
|
--widget-height: 20px;
|
||||||
}
|
}
|
||||||
@@ -157,14 +172,24 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
flex: 0 0 auto;
|
flex: 1 1 auto;
|
||||||
line-height: calc(var(--widget-height) - 6px);
|
line-height: calc(var(--widget-height) - 6px);
|
||||||
padding: 3px 0;
|
padding: 3px 0;
|
||||||
padding-right: 4px;
|
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|
||||||
|
// This keeps the label, when abbreviated by ellipsis, from touching the number value.
|
||||||
|
// This only shrinks after the label has shrunk to 0 (which is why this is a separate element, not margin or padding on the label or input).
|
||||||
|
+ .after-label-spacer {
|
||||||
|
width: 4px;
|
||||||
|
flex: 0 1 auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.auto-width label {
|
||||||
|
flex: 1 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:not(.disabled) label {
|
&:not(.disabled) label {
|
||||||
|
|||||||
@@ -27,7 +27,14 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<LayoutRow class="radio-input" classes={{ disabled, narrow, mixed }} styles={{ ...(minWidth > 0 ? { "min-width": `${minWidth}px` } : {}) }}>
|
<LayoutRow
|
||||||
|
class="radio-input"
|
||||||
|
classes={{ disabled, narrow, mixed, "auto-width": autoWidth }}
|
||||||
|
styles={{
|
||||||
|
...(minWidth > 0 ? { "min-width": `${minWidth}px` } : {}),
|
||||||
|
...(maxWidth > 0 ? { "max-width": `${maxWidth}px` } : {}),
|
||||||
|
}}
|
||||||
|
>
|
||||||
{#each entries as entry, index}
|
{#each entries as entry, index}
|
||||||
<button
|
<button
|
||||||
class:active={!mixed ? index === selectedIndex : undefined}
|
class:active={!mixed ? index === selectedIndex : undefined}
|
||||||
@@ -68,8 +75,7 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
// `min-width: fit-content` and `flex: 1 1 0` together allow us to occupy space such that we're always at least the content width,
|
// `min-width: fit-content` and `flex: 1 1 0` together allow us to occupy space such that we're always at least the content width,
|
||||||
// but if the container is set wider, we distribute the space evenly (so buttons with short and long labels would have equal widths).
|
// but if the container is set wider, we distribute the space evenly (so buttons with short and long labels would have equal widths).
|
||||||
min-width: fit-content;
|
flex: 1 1 100%;
|
||||||
flex: 1 1 0;
|
|
||||||
|
|
||||||
&:first-of-type {
|
&:first-of-type {
|
||||||
margin-left: 2px;
|
margin-left: 2px;
|
||||||
@@ -99,10 +105,15 @@
|
|||||||
.text-label {
|
.text-label {
|
||||||
margin: 0 8px;
|
margin: 0 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
flex: 0 0 auto;
|
flex: 0 1 auto;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.auto-width button .text-label {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
&:not(.disabled) button:not(.active):hover {
|
&:not(.disabled) button:not(.active):hover {
|
||||||
background: var(--color-6-lowergray);
|
background: var(--color-6-lowergray);
|
||||||
color: var(--color-f-white);
|
color: var(--color-f-white);
|
||||||
|
|||||||
Reference in New Issue
Block a user