mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 00:34:25 +00:00
Layers header and panel controls take the scope's control size
BlendRows, LayerFilterBar, the scopes refresh button and the wide-angle Add constraint button no longer fix the small size, so they show at the size their scope gives (Md in a panel), as PhotoCraft's header controls do.
This commit is contained in:
@@ -16,7 +16,7 @@ use super::zones::{ScopeZoneEdit, ToneZone, ToneZones};
|
||||
use crate::scopes::{HistogramStatistics, histogram_statistics};
|
||||
use crate::ui::histogram::{ChannelColor, Histogram, HistogramData, LevelRange, PlotHeight, StaleMark};
|
||||
use craft_behavior::{ColumnWidth, EditEvents, IconId, Proposal};
|
||||
use craft_theme::{ControlSize, Mode};
|
||||
use craft_theme::Mode;
|
||||
use craft_ui::buttons::IconButton;
|
||||
use craft_ui::contract::{
|
||||
Bind, BodyCx, Entry, FieldLabelRole, Gap, NoValue, Outcome, Pattern, Props as _, Show as _, ShowContainer as _, SideLabel, ThemeScope, clicked,
|
||||
@@ -296,7 +296,7 @@ impl Pass<'_> {
|
||||
.show(ui, |ui, _| Select::new(words.channel_name.clone(), Bind::given(shown_key.to_owned()), &entries).show(ui))
|
||||
});
|
||||
picked = field.inner.and_then(|field| field.inner).and_then(|select| select.value().cloned());
|
||||
let button = IconButton::new(IconId::new("rotate_cw")).label(words.uncached_refresh.clone()).size(ControlSize::Sm).show(ui);
|
||||
let button = IconButton::new(IconId::new("rotate_cw")).label(words.uncached_refresh.clone()).show(ui);
|
||||
refresh = clicked(&button);
|
||||
});
|
||||
self.report.refresh |= refresh;
|
||||
|
||||
@@ -152,7 +152,7 @@ impl<'a> WideAnglePanel<'a> {
|
||||
}
|
||||
});
|
||||
}
|
||||
if clicked(&Button::new(words.add_constraint.clone()).size(ControlSize::Sm).id_salt("add").show(ui)) {
|
||||
if clicked(&Button::new(words.add_constraint.clone()).id_salt("add").show(ui)) {
|
||||
add = true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
mod stories;
|
||||
|
||||
use craft_behavior::{EditEvent, IconId, Mixed, SelectionChange};
|
||||
use craft_theme::{ControlSize, LabelColor};
|
||||
use craft_theme::LabelColor;
|
||||
use craft_ui::buttons::ToggleButton;
|
||||
use craft_ui::contract::{Bind, Entry, NoValue, Outcome, Props as _, Show as _, ShowContainer as _, Sizing};
|
||||
use craft_ui::layout_components::Row;
|
||||
@@ -672,7 +672,6 @@ impl<'a> LayerFilterBar<'a> {
|
||||
return LayerFilterOutput { response: ui.allocate_response(egui::Vec2::ZERO, egui::Sense::hover()), changed: false, edit: None };
|
||||
}
|
||||
let words = Env::of(ui).words::<LayerFilterWords>();
|
||||
let size = ControlSize::Sm;
|
||||
let mut edit = None;
|
||||
let row = Row::new().show(ui, |ui, cx| {
|
||||
let select_name = std::mem::replace(&mut cx.memory::<FindName>().select, focus_name);
|
||||
@@ -686,7 +685,7 @@ impl<'a> LayerFilterBar<'a> {
|
||||
}
|
||||
let types: Vec<Entry<FilterBy>> = offered.iter().copied().map(|by| Entry::new(by, type_label(by, &words).clone())).collect();
|
||||
// The type select fits its widest type, so the controls after it keep their room.
|
||||
let picked = Select::new(words.filter_type.clone(), Bind::given(next.by), &types).size(size).sizing(Sizing::Content).show(ui);
|
||||
let picked = Select::new(words.filter_type.clone(), Bind::given(next.by), &types).sizing(Sizing::Content).show(ui);
|
||||
if let Some(by) = picked.value() {
|
||||
next.by = *by;
|
||||
}
|
||||
@@ -701,12 +700,11 @@ impl<'a> LayerFilterBar<'a> {
|
||||
(FilterKind::Shape, "square", &words.shape),
|
||||
(FilterKind::SmartObject, "app_window", &words.smart_object),
|
||||
];
|
||||
toggles(ui, size, &kinds, FilterKind::name, &mut next.kinds);
|
||||
toggles(ui, &kinds, FilterKind::name, &mut next.kinds);
|
||||
}
|
||||
FilterBy::Name => {
|
||||
let mut field = TextField::search(words.search_layers.clone(), Bind::given(current.name.clone()))
|
||||
.placeholder(words.search.clone())
|
||||
.size(size);
|
||||
let mut field =
|
||||
TextField::search(words.search_layers.clone(), Bind::given(current.name.clone())).placeholder(words.search.clone());
|
||||
if focus_name || select_name {
|
||||
field = field.select_on_focus();
|
||||
}
|
||||
@@ -721,13 +719,13 @@ impl<'a> LayerFilterBar<'a> {
|
||||
FilterBy::Effect => {
|
||||
let effects: Vec<Entry<EffectKind>> =
|
||||
EffectKind::ALL.into_iter().map(|kind| Entry::new(kind, kind.label(&words).clone())).collect();
|
||||
let picked = Select::new(words.filter_effect.clone(), Bind::given(current.effect), &effects).size(size).show(ui);
|
||||
let picked = Select::new(words.filter_effect.clone(), Bind::given(current.effect), &effects).show(ui);
|
||||
if let Some(effect) = picked.value() {
|
||||
next.effect = *effect;
|
||||
}
|
||||
}
|
||||
FilterBy::Mode => {
|
||||
let picked = Select::new(words.blend_mode.clone(), Bind::given(current.mode.clone()), blend_modes).size(size).show(ui);
|
||||
let picked = Select::new(words.blend_mode.clone(), Bind::given(current.mode.clone()), blend_modes).show(ui);
|
||||
if let Some(mode) = picked.value() {
|
||||
next.mode.clone_from(mode);
|
||||
}
|
||||
@@ -735,7 +733,7 @@ impl<'a> LayerFilterBar<'a> {
|
||||
FilterBy::Attribute => {
|
||||
let attributes: Vec<Entry<LayerAttribute>> =
|
||||
LayerAttribute::ALL.into_iter().map(|attribute| Entry::new(attribute, attribute.label(&words).clone())).collect();
|
||||
let picked = Select::new(words.filter_attribute.clone(), Bind::given(current.attribute), &attributes).size(size).show(ui);
|
||||
let picked = Select::new(words.filter_attribute.clone(), Bind::given(current.attribute), &attributes).show(ui);
|
||||
if let Some(attribute) = picked.value() {
|
||||
next.attribute = *attribute;
|
||||
}
|
||||
@@ -746,7 +744,7 @@ impl<'a> LayerFilterBar<'a> {
|
||||
.chain(LabelColor::ALL.into_iter().map(Some))
|
||||
.map(|color| Entry::new(color, label_color_label(color, &list_words)))
|
||||
.collect();
|
||||
let picked = Select::new(words.filter_color.clone(), Bind::given(current.color), &colors).size(size).show(ui);
|
||||
let picked = Select::new(words.filter_color.clone(), Bind::given(current.color), &colors).show(ui);
|
||||
if let Some(color) = picked.value() {
|
||||
next.color = *color;
|
||||
}
|
||||
@@ -757,7 +755,7 @@ impl<'a> LayerFilterBar<'a> {
|
||||
(SmartKind::Missing, "unlink", &words.smart_missing),
|
||||
(SmartKind::Embedded, "file", &words.smart_embedded),
|
||||
];
|
||||
toggles(ui, size, &kinds, smart_salt, &mut next.smart);
|
||||
toggles(ui, &kinds, smart_salt, &mut next.smart);
|
||||
}
|
||||
// The selected layers pick the artboards; Group lists every group.
|
||||
FilterBy::Artboard | FilterBy::Group => {}
|
||||
@@ -797,15 +795,11 @@ const fn smart_salt(kind: SmartKind) -> &'static str {
|
||||
|
||||
/// One icon toggle button per `(value, icon, name)`, pressed while `on` holds the value; a toggle
|
||||
/// adds the value to `on` or takes it out.
|
||||
fn toggles<K: Copy + PartialEq>(ui: &mut Ui, size: ControlSize, buttons: &[(K, &'static str, &Label)], salt: fn(K) -> &'static str, on: &mut Vec<K>) {
|
||||
fn toggles<K: Copy + PartialEq>(ui: &mut Ui, buttons: &[(K, &'static str, &Label)], salt: fn(K) -> &'static str, on: &mut Vec<K>) {
|
||||
let shown = on.clone();
|
||||
for &(value, icon, name) in buttons {
|
||||
let toggled = ToggleButton::new(name.clone(), Bind::given(shown.contains(&value)))
|
||||
.icon(IconId::new(icon))
|
||||
.icon_only()
|
||||
.size(size)
|
||||
.id_salt(salt(value))
|
||||
.show(ui);
|
||||
let toggled =
|
||||
ToggleButton::new(name.clone(), Bind::given(shown.contains(&value))).icon(IconId::new(icon)).icon_only().id_salt(salt(value)).show(ui);
|
||||
match toggled.value() {
|
||||
Some(true) => on.push(value),
|
||||
Some(false) => on.retain(|held| *held != value),
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
mod stories;
|
||||
|
||||
use craft_behavior::{EditEvent, EditEvents, IconId};
|
||||
use craft_theme::ControlSize;
|
||||
use craft_ui::buttons::ToggleButton;
|
||||
use craft_ui::contract::{Bind, Entry, Gap, NoValue, Outcome, Props as _, RowAlign, Show as _, ShowContainer as _, SideLabel, Sizing, TooltipSpec};
|
||||
use craft_ui::form::Field;
|
||||
@@ -16,9 +15,6 @@ use egui::{Response, Ui};
|
||||
|
||||
use super::tree::{LayerProperties, LockKind};
|
||||
|
||||
/// The rows sit in a panel, so their controls take the small size.
|
||||
const SIZE: ControlSize = ControlSize::Sm;
|
||||
|
||||
/// An edit of the active layer's properties, which the app applies to every selected layer (the
|
||||
/// Background left out of a multi-layer change, as PhotoCraft).
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
@@ -143,7 +139,6 @@ impl<'a> BlendRows<'a> {
|
||||
let blend_name = words.blend_mode.clone();
|
||||
let picked = Select::new(blend_name.clone(), Bind::given(props.blend_key.clone()), blend_modes)
|
||||
.preview()
|
||||
.size(SIZE)
|
||||
.enabled(editable)
|
||||
.tooltip(TooltipSpec::new(blend_name).disabled_text(unavailable.clone()))
|
||||
.show(ui);
|
||||
@@ -174,7 +169,6 @@ impl<'a> BlendRows<'a> {
|
||||
let button = ToggleButton::new(name.clone(), Bind::given(held.get(kind) || included))
|
||||
.icon(IconId::new(icon))
|
||||
.icon_only()
|
||||
.size(SIZE)
|
||||
.enabled(live && reason.is_none())
|
||||
.tooltip(TooltipSpec::new(name).disabled_text(reason.map_or_else(|| no_layer.clone(), |reason| reason.clone())))
|
||||
.show(ui);
|
||||
@@ -201,7 +195,6 @@ fn percent_field(ui: &mut Ui, caption: &Label, value: f64, enabled: bool, reason
|
||||
.unit_kind(UnitKind::Percent)
|
||||
.popup_slider(0.0..=100.0)
|
||||
.scrub_by_label()
|
||||
.size(SIZE)
|
||||
.enabled(enabled)
|
||||
.tooltip(TooltipSpec::new(caption.clone()).disabled_text(reason.clone()))
|
||||
.show(ui);
|
||||
|
||||
Reference in New Issue
Block a user