forked from 1b-agent/opencadstudio-upstream
Add a colour wheel for the viewport backgrounds
The Display page could only take a typed #RRGGBB, which is precise but no way to choose a colour by eye. The swatches are now buttons that open a wheel. The wheel does not replace the hex field, it sits beside it: typing an exact value stays the quickest way to reproduce a known colour. On submit it hands a hex string to the existing ModelSpaceBgChanged and friends rather than writing the config itself, so the two routes cannot drift apart on validation, persistence, or the MatchTheme fallback an empty field triggers. Also stops the Browser shipping in the default dock layout. It was added to the right edge, which shifted the block palette to index 1 and broke four dock tests that encode the existing arrangement. Those tests were right and the change was wrong: the earlier commit claimed to leave the layout alone. BROWSER now docks the panel on first use, so nobody's edges rearrange on upgrade for a panel they never asked for.
This commit is contained in:
6 files changed
+106
-53
No files matched your search
@@ -7068,6 +7068,39 @@ impl OpenCADStudio {
|
||||
Task::none()
|
||||
}
|
||||
|
||||
Message::BgPickerOpen(target) => {
|
||||
self.bg_picker = Some(target);
|
||||
Task::none()
|
||||
}
|
||||
|
||||
Message::BgPickerCancel => {
|
||||
self.bg_picker = None;
|
||||
Task::none()
|
||||
}
|
||||
|
||||
Message::BgPickerSubmit(color) => {
|
||||
// Hand the result to the same handler the typed hex field
|
||||
// uses, so the wheel and the field cannot drift apart on
|
||||
// validation, persistence or the MatchTheme fallback.
|
||||
let hex = crate::app::config::rgb_to_hex([
|
||||
(color.r * 255.0).round() as u8,
|
||||
(color.g * 255.0).round() as u8,
|
||||
(color.b * 255.0).round() as u8,
|
||||
]);
|
||||
match self.bg_picker.take() {
|
||||
Some(crate::app::BgTarget::Model) => {
|
||||
Task::done(Message::ModelSpaceBgChanged(hex))
|
||||
}
|
||||
Some(crate::app::BgTarget::Paper) => {
|
||||
Task::done(Message::PaperSpaceBgChanged(hex))
|
||||
}
|
||||
Some(crate::app::BgTarget::Desk) => {
|
||||
Task::done(Message::DeskSpaceBgChanged(hex))
|
||||
}
|
||||
None => Task::none(),
|
||||
}
|
||||
}
|
||||
|
||||
Message::ModelSpaceBgChanged(hex) => {
|
||||
self.model_bg_input = hex.clone();
|
||||
if hex.trim().is_empty() {
|
||||
|
||||
Reference in new issue
Block a user