REFEDIT session toolbar: definition name, working set count, REFSET

The right-edge toolbar of a REFEDIT session now shows the definition
being edited (REFEDITNAME) as an accent pill with the number of objects
in the working set, Add to / Remove from Working Set buttons with their
own icons (REFSET Add / Remove, straight to object selection), and
Save / Discard in a separate group below a rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ramox81andClaude Opus 5.5 committed 2026-10-14 10:51:22 +03:00
1 parent 592289f4fd
commit 74d65c26be
29 files changed
+218 -7

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke-linecap="round">
<rect x="1.8" y="8.8" width="13" height="13" rx="2" stroke="#e0e0e0" stroke-width="1.6" stroke-dasharray="3 2"/>
<path d="M17.8 2.6v8M13.8 6.6h8" stroke="#4a9eff" stroke-width="2.4"/>
</svg>

After

Width:  |  Height:  |  Size: 314 B

+4
View File
@@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke-linecap="round">
<rect x="1.8" y="6.8" width="13" height="13" rx="2" stroke="#e0e0e0" stroke-width="1.6" stroke-dasharray="3 2"/>
<path d="M13.8 4.6h8" stroke="#4a9eff" stroke-width="2.4"/>
</svg>

After

Width:  |  Height:  |  Size: 303 B

+3
View File
@@ -6471,6 +6471,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = حدد المرجع:
.reference-not-found = لم يتم العثور على المرجع.
.not-valid-reference = الكائن ليس مرجعًا صالحًا
+3
View File
@@ -6459,6 +6459,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = Изберете препратка:
.reference-not-found = Препратката не е намерена.
.not-valid-reference = Обектът не е валидна препратка
+3
View File
@@ -6456,6 +6456,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = Vyberte referenci:
.reference-not-found = Reference nebyla nalezena.
.not-valid-reference = Objekt není platná reference
+3
View File
@@ -6457,6 +6457,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = Referenz wählen:
.reference-not-found = Referenz nicht gefunden.
.not-valid-reference = Objekt ist keine gültige Referenz
+3
View File
@@ -6459,6 +6459,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = Επιλέξτε αναφορά:
.reference-not-found = Η αναφορά δεν βρέθηκε.
.not-valid-reference = Το αντικείμενο δεν είναι έγκυρη αναφορά
+3
View File
@@ -6458,6 +6458,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = Select reference:
.reference-not-found = Reference not found.
.not-valid-reference = Object is not a valid reference
+3
View File
@@ -6459,6 +6459,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = Seleccione la referencia:
.reference-not-found = No se encuentra la referencia.
.not-valid-reference = El objeto no es una referencia válida
+3
View File
@@ -6456,6 +6456,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = Valitse viittaus:
.reference-not-found = Viittausta ei löydy.
.not-valid-reference = Objekti ei ole kelvollinen viittaus
+3
View File
@@ -6459,6 +6459,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = Sélectionnez la référence :
.reference-not-found = Référence introuvable.
.not-valid-reference = L'objet n'est pas une référence valide
+3
View File
@@ -6447,6 +6447,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = संदर्भ चुनें:
.reference-not-found = संदर्भ नहीं मिला।
.not-valid-reference = ऑब्जेक्ट मान्य संदर्भ नहीं है
+3
View File
@@ -6443,6 +6443,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = Válassza ki a hivatkozást:
.reference-not-found = A hivatkozás nem található.
.not-valid-reference = Az objektum nem érvényes hivatkozás
+3
View File
@@ -6458,6 +6458,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = Selezionare il riferimento:
.reference-not-found = Riferimento non trovato.
.not-valid-reference = L'oggetto non è un riferimento valido
+3
View File
@@ -6447,6 +6447,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = 参照を選択:
.reference-not-found = 参照が見つかりません。
.not-valid-reference = オブジェクトは有効な参照ではありません
+3
View File
@@ -6458,6 +6458,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = 참조 선택:
.reference-not-found = 참조를 찾을 수 없습니다.
.not-valid-reference = 객체가 유효한 참조가 아닙니다
+3
View File
@@ -6459,6 +6459,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = ເລືອກການອ້າງອີງ:
.reference-not-found = ບໍ່ພົບການອ້າງອີງ.
.not-valid-reference = ວັດຖຸບໍ່ແມ່ນການອ້າງອີງທີ່ຖືກຕ້ອງ
+3
View File
@@ -6457,6 +6457,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = Selecteer referentie:
.reference-not-found = Referentie niet gevonden.
.not-valid-reference = Object is geen geldige referentie
+3
View File
@@ -6458,6 +6458,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = Wybierz odnośnik:
.reference-not-found = Nie znaleziono odnośnika.
.not-valid-reference = Obiekt nie jest prawidłowym odnośnikiem
+3
View File
@@ -6459,6 +6459,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = Selecione a referência:
.reference-not-found = Referência não encontrada.
.not-valid-reference = O objeto não é uma referência válida
+3
View File
@@ -6460,6 +6460,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = Выберите ссылку:
.reference-not-found = Ссылка не найдена.
.not-valid-reference = Объект не является допустимой ссылкой
+3
View File
@@ -6380,6 +6380,9 @@ view-background =
.select-image = Arka Plan Görüntüsü Seç
ref-edit =
.add-to-working-set = Çalışma Kümesine Ekle
.remove-from-working-set = Çalışma Kümesinden Çıkar
.toolbar-objects = nesne
.select-reference = Referans seçin:
.reference-not-found = Referans bulunamadı.
.not-valid-reference = Nesne geçerli bir referans değil
+3
View File
@@ -6442,6 +6442,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = 选择参照:
.reference-not-found = 找不到参照。
.not-valid-reference = 对象不是有效的参照
+3
View File
@@ -6454,6 +6454,9 @@ view-background =
.select-image = Select Background Image
ref-edit =
.add-to-working-set = Add to Working Set
.remove-from-working-set = Remove from Working Set
.toolbar-objects = objects
.select-reference = 選取參考:
.reference-not-found = 找不到參考。
.not-valid-reference = 物件不是有效的參考
+7 -2
View File
@@ -21,7 +21,7 @@ impl OpenCADStudio {
pub(super) fn dispatch_refedit(&mut self, cmd: &str, i: usize) -> Option<Task<Message>> {
match cmd {
"REFEDIT" | "-REFEDIT" => Some(self.start_refedit(i, cmd == "-REFEDIT")),
"REFSET" => {
"REFSET" | "REFSET_ADD" | "REFSET_REMOVE" => {
if self.tabs[i].refedit_session.is_none() {
self.command_line.push_error(crate::t!(NOT_CHECKED_OUT).as_ref());
return Some(Task::none());
@@ -30,7 +30,12 @@ impl OpenCADStudio {
crate::t!("Transfer objects between the RefEdit working set and host drawing...")
.as_ref(),
);
let command = RefSetCommand::new();
// The side toolbar's Add / Remove go straight to the selection.
let command = match cmd {
"REFSET_ADD" => RefSetCommand::selecting(true),
"REFSET_REMOVE" => RefSetCommand::selecting(false),
_ => RefSetCommand::new(),
};
use crate::command::CadCommand;
self.command_line.push_info(&command.prompt());
self.tabs[i].active_cmd = Some(Box::new(command));
+31 -3
View File
@@ -1687,9 +1687,18 @@ bg={bg_ms:.1}ms n={view_count}"
// In-place block edit (REFEDIT): right-edge toolbar with Save / Discard
// so the edit can be finished by clicking. (#136)
if tab.refedit_session.is_some() && !tab.is_start {
if let Some(tb) = crate::ui::side_toolbar::view(
&crate::modules::draw::modify::refedit::refedit_tools(),
if let (Some(session), false) = (tab.refedit_session.as_ref(), tab.is_start) {
use crate::modules::draw::modify::refedit::{refedit_set_tools, refedit_tools};
let set_tools = refedit_set_tools();
let close_tools = refedit_tools();
let header = crate::ui::side_toolbar::refedit_header(
&session.block_name,
refedit_working_set_count(session, &tab.scene),
);
if let Some(tb) = crate::ui::side_toolbar::view_sections(
Some(header),
&[&set_tools, &close_tools],
&|_| false,
) {
viewport_stack = viewport_stack.push(tb);
}
@@ -4183,3 +4192,22 @@ mod tests {
);
}
}
/// The objects in a REFEDIT session's working set: the checked-out copies and
/// objects added with REFSET still in it, and everything created in the
/// space since.
// ponytail: walks the document per frame while a session is open; keep a
// running count on the session if large drawings feel it.
fn refedit_working_set_count(
session: &crate::modules::draw::modify::refedit::RefEditSession,
scene: &crate::scene::Scene,
) -> usize {
let space = scene.current_layout_block_handle_pub();
scene
.document
.entities()
.filter(|entity| {
entity.common().owner_handle == space && session.in_working_set(entity.common().handle)
})
.count()
}
+2
View File
@@ -3,6 +3,8 @@
pub(super) fn message_attribute(source: &str) -> Option<(&'static str, &'static str)> {
match source {
"Add to Working Set" => Some(("ref-edit", "add-to-working-set")),
"Remove from Working Set" => Some(("ref-edit", "remove-from-working-set")),
"Select reference:" => Some(("ref-edit", "select-reference")),
"Reference not found." => Some(("ref-edit", "reference-not-found")),
"Object is not a valid reference" => Some(("ref-edit", "not-valid-reference")),
+28
View File
@@ -20,6 +20,25 @@ use std::collections::HashSet;
use crate::command::{CadCommand, CmdOption, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef};
/// Right-edge side-toolbar buttons that move objects into or out of the
/// working set while a REFEDIT session is active (REFSET Add / Remove).
pub fn refedit_set_tools() -> Vec<ToolDef> {
vec![
ToolDef {
id: "REFSET_ADD",
label: "Add to Working Set",
icon: IconKind::Svg(include_bytes!("../../../../assets/icons/refset_add.svg")),
event: ModuleEvent::Command("REFSET_ADD".to_string()),
},
ToolDef {
id: "REFSET_REMOVE",
label: "Remove from Working Set",
icon: IconKind::Svg(include_bytes!("../../../../assets/icons/refset_remove.svg")),
event: ModuleEvent::Command("REFSET_REMOVE".to_string()),
},
]
}
/// Right-edge side-toolbar buttons shown while a REFEDIT session is active:
/// save the in-place block edit, or discard it. (#136)
pub fn refedit_tools() -> Vec<ToolDef> {
@@ -479,6 +498,15 @@ impl RefSetCommand {
selected: Vec::new(),
}
}
/// Straight to `Select objects:` for Add (`add`) or Remove.
pub fn selecting(add: bool) -> Self {
Self {
add,
gathering: true,
selected: Vec::new(),
}
}
}
impl CadCommand for RefSetCommand {
+76 -2
View File
@@ -49,6 +49,53 @@ fn tip_panel(label: &'static str) -> Element<'static, Message> {
.into()
}
/// The REFEDIT session toolbar's head: the definition being edited as an
/// accent pill (REFEDITNAME) and how many objects the working set holds.
pub fn refedit_header(name: &str, count: usize) -> Element<'static, Message> {
// Long names are cut so the bar stays narrow; the full name is in the tip.
let short: String = if name.chars().count() > 7 {
format!("{}…", name.chars().take(6).collect::<String>())
} else {
name.to_string()
};
let pill = container(text(short).size(10))
.padding([1, 6])
.style(|theme: &Theme| {
let palette = theme.palette();
container::Style {
background: Some(Background::Color(palette.primary.base.color)),
border: Border {
radius: 8.0.into(),
..Default::default()
},
text_color: Some(palette.primary.base.text),
..Default::default()
}
});
let tip = container(text(name.to_string()).size(11)).padding([2, 6]).style(|theme: &Theme| {
let palette = theme.palette();
container::Style {
background: Some(Background::Color(palette.background.strong.color)),
border: Border {
color: palette.background.neutral.color,
width: 1.0,
radius: 3.0.into(),
},
text_color: Some(palette.background.strong.text),
..Default::default()
}
});
column![
tooltip(pill, tip, tooltip::Position::Left).gap(6),
text(format!("{} {}", count, crate::tr!("ref-edit", "toolbar-objects")))
.size(9)
.style(crate::ui::style::common::muted_style),
]
.spacing(2)
.align_x(iced::Center)
.into()
}
/// Build the floating right-edge vertical toolbar from `tools`, vertically
/// centred over the canvas. Returns `None` when `tools` is empty so the caller
/// can skip pushing an overlay.
@@ -61,12 +108,39 @@ pub fn view_with_active(
tools: &[ToolDef],
active: &dyn Fn(&str) -> bool,
) -> Option<Element<'static, Message>> {
if tools.is_empty() {
view_sections(None, &[tools], active)
}
/// As [`view_with_active`], with `header` on top and a rule between the
/// groups of tools.
pub fn view_sections(
header: Option<Element<'static, Message>>,
groups: &[&[ToolDef]],
active: &dyn Fn(&str) -> bool,
) -> Option<Element<'static, Message>> {
if groups.iter().all(|g| g.is_empty()) {
return None;
}
let mut col = column![].spacing(4).align_x(iced::Center);
for t in tools {
if let Some(header) = header {
col = col.push(header);
}
let tools = groups.iter().filter(|g| !g.is_empty()).enumerate().flat_map(|(group, tools)| {
tools.iter().enumerate().map(move |(k, t)| (group > 0 && k == 0, t))
});
for (starts_group, t) in tools {
if starts_group {
col = col.push(
container(iced::widget::Space::new())
.width(Length::Fixed(BTN_SIZE - 4.0))
.height(Length::Fixed(1.0))
.style(|theme: &Theme| container::Style {
background: Some(Background::Color(theme.palette().background.neutral.color)),
..Default::default()
}),
);
}
let on = active(t.id);
let btn = button(icon_el(t.icon))
.on_press(Message::RibbonToolClick {