mirror of
https://github.com/storytold/craft-libs.git
synced 2026-12-01 10:48:15 +01:00
Parts whose popup is open show open, faces included
The toggling part's result carries Flags::OPEN while its popup shows, so a gallery's More face and a split button's arrow draw the pressed plate the open state counts as. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e3614bb25b
commit
693ce7da8f
3 files changed
+10
-5
No files matched your search
@@ -81,10 +81,8 @@ impl CxCore<'_> {
|
||||
flags |= Flags::FOCUS_VISIBLE;
|
||||
}
|
||||
}
|
||||
// A part whose popup is open (a split button's arrow while its menu shows) shows open, as a control does.
|
||||
if self.toggles.iter().any(|toggle| toggle.part == part && toggle.open) {
|
||||
flags |= Flags::OPEN;
|
||||
}
|
||||
// A part whose popup is open (`Flags::OPEN`: a split button's arrow while its menu shows) shows pressed, as a
|
||||
// control does.
|
||||
let pressed = result.pressed();
|
||||
let state = if !self.looks_enabled() || result.inactive {
|
||||
craft_theme::State::Disabled
|
||||
|
||||
@@ -142,6 +142,12 @@ pub(crate) fn drive_toggles(core: &mut CxCore<'_>, overlays: bool, name: &str) {
|
||||
}
|
||||
for toggle in &mut toggles {
|
||||
toggle.open = toggle.handle(owner).is_open_in(core);
|
||||
// The part shows its popup open (`Flags::OPEN`, drawn pressed), whether it paints itself or as a face.
|
||||
if toggle.open
|
||||
&& let Some(result) = core.results.get_mut(&(toggle.part.key, toggle.part.index))
|
||||
{
|
||||
result.flags |= crate::style::Flags::OPEN;
|
||||
}
|
||||
}
|
||||
core.toggles = toggles;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,8 @@ pub(crate) fn part_state(result: &crate::primitives::PartResult, enabled: bool,
|
||||
flags |= Flags::FOCUS_VISIBLE;
|
||||
}
|
||||
}
|
||||
let pressed = result.pressed();
|
||||
// A part whose popup is open (`Flags::OPEN`) shows the press it counts as.
|
||||
let pressed = result.pressed() || flags.contains(Flags::OPEN);
|
||||
let state = if !enabled || result.inactive {
|
||||
State::Disabled
|
||||
} else if pressed {
|
||||
|
||||
Reference in new issue
Block a user