Add DocumentMode groundwork with MaskMode and Q toggle#4001
Add DocumentMode groundwork with MaskMode and Q toggle#4001krVatsal wants to merge 1 commit intoGraphiteEditor:masterfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new DocumentMode enum, including a MaskMode variant, and integrates it into the DocumentMessageHandler to allow toggling and setting the document mode. The review feedback suggests ensuring UI consistency by triggering PortfolioMessage::UpdateDocumentWidgets when the mode changes and recommends uncommenting and updating the fmt::Display implementation for DocumentMode to avoid leaving dead code.
| DocumentMessage::ToggleDocumentMode => { | ||
| self.document_mode = match self.document_mode { | ||
| DocumentMode::MaskMode => DocumentMode::DesignMode, | ||
| _ => DocumentMode::MaskMode, | ||
| }; | ||
| } | ||
| DocumentMessage::SetDocumentMode { document_mode } => { | ||
| self.document_mode = document_mode; | ||
| } |
There was a problem hiding this comment.
When changing the document_mode, it is important to notify the frontend so that any UI elements (like the status bar or document bar) can refresh their state. Even if no UI currently displays this mode, adding PortfolioMessage::UpdateDocumentWidgets ensures consistency with how other document-level states (like render mode or snapping) are handled.
DocumentMessage::ToggleDocumentMode => {
self.document_mode = match self.document_mode {
DocumentMode::MaskMode => DocumentMode::DesignMode,
_ => DocumentMode::MaskMode,
};
responses.add(PortfolioMessage::UpdateDocumentWidgets);
}
DocumentMessage::SetDocumentMode { document_mode } => {
if self.document_mode != document_mode {
self.document_mode = document_mode;
responses.add(PortfolioMessage::UpdateDocumentWidgets);
}
}| // impl fmt::Display for DocumentMode { | ||
| // fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| // match self { | ||
| // DocumentMode::DesignMode => write!(f, "Design Mode"), | ||
| // DocumentMode::SelectMode => write!(f, "Select Mode"), | ||
| // DocumentMode::GuideMode => write!(f, "Guide Mode"), | ||
| // DocumentMode::MaskMode => write!(f, "Mask Mode"), | ||
| // } | ||
| // } | ||
| // } |
There was a problem hiding this comment.
The Display implementation for DocumentMode is currently commented out. Since the enum is now active and being used for groundwork, it is better to enable this implementation and ensure it includes the new MaskMode variant. This avoids leaving dead code in the repository.
| // impl fmt::Display for DocumentMode { | |
| // fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | |
| // match self { | |
| // DocumentMode::DesignMode => write!(f, "Design Mode"), | |
| // DocumentMode::SelectMode => write!(f, "Select Mode"), | |
| // DocumentMode::GuideMode => write!(f, "Guide Mode"), | |
| // DocumentMode::MaskMode => write!(f, "Mask Mode"), | |
| // } | |
| // } | |
| // } | |
| impl fmt::Display for DocumentMode { | |
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | |
| match self { | |
| DocumentMode::DesignMode => write!(f, "Design Mode"), | |
| DocumentMode::SelectMode => write!(f, "Select Mode"), | |
| DocumentMode::GuideMode => write!(f, "Guide Mode"), | |
| DocumentMode::MaskMode => write!(f, "Mask Mode"), | |
| } | |
| } | |
| } |
This PR implements the early groundwork for Document Mode as planned for community bonding / week 1 in Marquee Selection Masking.
It introduces MaskMode and wires a keyboard toggle, while intentionally avoiding rendering or visual feature work.
What this PR changes?
Scope and intent