mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-03 01:38:11 +08:00
Minor Tooling and UI Improvements (#1314)
* [wip]fix: disable fill and gradient tools on bmp images - aims to fix #1161 * [wip]fix: disable gradient tool for bmp images * fix: disable gradient tool for bitmap images - fixes https://github.com/GraphiteEditor/Graphite/issues/1161 * [wip]fix: disable menu bar elements if no open document * [WIP]feat: render certain menubar elements if document is open * fix: conditional menu bar rendering fixes - update menu bar on certain document actions - fix menu bar order on rendering all elements * refactor: change conditional menu elements property - use existing 'disabled' property * feat: render menu dropdown items conditionally * fix: revert formatter whitespace changes * refactor: improve variable naming and message usage - name menu bar bool flag better - use SendLayout message and remove unneeded calls
This commit is contained in:
@@ -7,6 +7,7 @@ use crate::messages::tool::utility_types::{EventToMessageMap, Fsm, ToolActionHan
|
||||
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
|
||||
|
||||
use document_legacy::intersection::Quad;
|
||||
use document_legacy::layers::layer_layer::CachedOutputData;
|
||||
use document_legacy::layers::style::Fill;
|
||||
|
||||
use glam::DVec2;
|
||||
@@ -103,6 +104,17 @@ impl Fsm for FillToolFsmState {
|
||||
let quad = Quad::from_box([mouse_pos - tolerance, mouse_pos + tolerance]);
|
||||
|
||||
if let Some(path) = document.document_legacy.intersects_quad_root(quad, render_data).last() {
|
||||
let is_bitmap = document
|
||||
.document_legacy
|
||||
.layer(path)
|
||||
.ok()
|
||||
.and_then(|layer| layer.as_layer().ok())
|
||||
.map_or(false, |layer| matches!(layer.cached_output_data, CachedOutputData::BlobURL(_) | CachedOutputData::SurfaceId(_)));
|
||||
|
||||
if is_bitmap {
|
||||
return self;
|
||||
}
|
||||
|
||||
let color = match lmb_or_rmb {
|
||||
LeftPointerDown => global_tool_data.primary_color,
|
||||
RightPointerDown => global_tool_data.secondary_color,
|
||||
|
||||
@@ -11,6 +11,7 @@ use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
|
||||
|
||||
use document_legacy::intersection::Quad;
|
||||
use document_legacy::layers::layer_info::Layer;
|
||||
use document_legacy::layers::layer_layer::CachedOutputData;
|
||||
use document_legacy::layers::style::{Fill, Gradient, GradientType, PathStyle, RenderData, Stroke};
|
||||
use document_legacy::LayerId;
|
||||
use document_legacy::Operation;
|
||||
@@ -420,9 +421,6 @@ impl Fsm for GradientToolFsmState {
|
||||
}
|
||||
|
||||
for path in document.selected_visible_layers() {
|
||||
if !document.document_legacy.multiply_transforms(path).unwrap().inverse().is_finite() {
|
||||
continue;
|
||||
}
|
||||
let layer = document.document_legacy.layer(path).unwrap();
|
||||
|
||||
if let Ok(Fill::Gradient(gradient)) = layer.style().map(|style| style.fill()) {
|
||||
@@ -568,7 +566,18 @@ impl Fsm for GradientToolFsmState {
|
||||
let quad = Quad::from_box([input.mouse.position - tolerance, input.mouse.position + tolerance]);
|
||||
let intersection = document.document_legacy.intersects_quad_root(quad, render_data).pop();
|
||||
|
||||
// the intersection is the layer where the gradient is being applied
|
||||
if let Some(intersection) = intersection {
|
||||
let is_bitmap = document
|
||||
.document_legacy
|
||||
.layer(&intersection)
|
||||
.ok()
|
||||
.and_then(|layer| layer.as_layer().ok())
|
||||
.map_or(false, |layer| matches!(layer.cached_output_data, CachedOutputData::BlobURL(_) | CachedOutputData::SurfaceId(_)));
|
||||
if is_bitmap {
|
||||
return self;
|
||||
}
|
||||
|
||||
if !document.selected_layers_contains(&intersection) {
|
||||
let replacement_selected_layers = vec![intersection.clone()];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user