mirror of
https://github.com/storytold/texturecraft.git
synced 2026-11-18 05:49:21 +00:00
7a780244d9
Preserve the shared-catalog integration and saved review repairs. Reject saved path commits during quick-mask editing, hide the unavailable 2D brush cursor, and reduce dirty-tile selection work. Keep the Selection test fixture in its own module.
84 lines
2.7 KiB
Rust
84 lines
2.7 KiB
Rust
//! Selection cases for the tool availability tests
|
|
|
|
use texturecraft_engine::Tool;
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub(super) enum Selection {
|
|
PaintContent,
|
|
FillContent,
|
|
PaintMask,
|
|
FillMask,
|
|
FolderMask,
|
|
InstanceOwnMask,
|
|
PaintSublayer,
|
|
PaintSublayerInMask,
|
|
PaintSublayerInFill,
|
|
PathSublayer,
|
|
FilterInPaint,
|
|
FilterInFill,
|
|
FilterInMask,
|
|
FillEffectInPaint,
|
|
GeneratorInFillMask,
|
|
FolderContent,
|
|
InstanceOfPaint,
|
|
InstanceOfFill,
|
|
Nothing,
|
|
QuickMaskOverPaint,
|
|
QuickMaskOverFill,
|
|
QuickMaskOverNothing,
|
|
}
|
|
|
|
impl Selection {
|
|
pub(super) const ALL: [Selection; 22] = [
|
|
Selection::PaintContent,
|
|
Selection::FillContent,
|
|
Selection::PaintMask,
|
|
Selection::FillMask,
|
|
Selection::FolderMask,
|
|
Selection::InstanceOwnMask,
|
|
Selection::PaintSublayer,
|
|
Selection::PaintSublayerInMask,
|
|
Selection::PaintSublayerInFill,
|
|
Selection::PathSublayer,
|
|
Selection::FilterInPaint,
|
|
Selection::FilterInFill,
|
|
Selection::FilterInMask,
|
|
Selection::FillEffectInPaint,
|
|
Selection::GeneratorInFillMask,
|
|
Selection::FolderContent,
|
|
Selection::InstanceOfPaint,
|
|
Selection::InstanceOfFill,
|
|
Selection::Nothing,
|
|
Selection::QuickMaskOverPaint,
|
|
Selection::QuickMaskOverFill,
|
|
Selection::QuickMaskOverNothing,
|
|
];
|
|
|
|
/// Whether the shelf offers `tool` for this selection
|
|
pub(super) fn offers(self, tool: Tool) -> bool {
|
|
let reads_content = matches!(tool, Tool::Smudge | Tool::Clone);
|
|
match tool {
|
|
Tool::ColorPicker => true,
|
|
Tool::GeometryMask => !matches!(self, Selection::Nothing | Selection::QuickMaskOverNothing),
|
|
_ => match self {
|
|
Selection::PaintContent | Selection::PaintSublayer => true,
|
|
Selection::PaintSublayerInFill => tool != Tool::Path,
|
|
Selection::PaintMask | Selection::FillMask | Selection::FolderMask | Selection::InstanceOwnMask | Selection::PaintSublayerInMask => {
|
|
!reads_content
|
|
}
|
|
Selection::PathSublayer => tool == Tool::Path,
|
|
Selection::QuickMaskOverPaint | Selection::QuickMaskOverFill | Selection::QuickMaskOverNothing => tool != Tool::Path,
|
|
_ => false,
|
|
},
|
|
}
|
|
}
|
|
|
|
/// Greyed in the shelf, but scripts still paint here: below the effect, or the instance's source
|
|
pub(super) fn scripts_still_paint(self) -> bool {
|
|
matches!(
|
|
self,
|
|
Selection::FilterInPaint | Selection::FillEffectInPaint | Selection::FilterInMask | Selection::GeneratorInFillMask | Selection::InstanceOfPaint
|
|
)
|
|
}
|
|
}
|