forked from 1b-agent/opencadstudio-upstream
Merge pull request #1778 from ramox81/codex/refedit-toolbar
REFEDIT session toolbar: definition name, working set count and REFSET buttons
This commit is contained in:
commit
dec3ba2743
29 files changed
+218
-7
No files matched your search
@@ -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
@@ -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()
|
||||
}
|
||||
Reference in new issue
Block a user