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
@@ -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 |
@@ -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 |
@@ -6484,6 +6484,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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 = الكائن ليس مرجعًا صالحًا
|
.not-valid-reference = الكائن ليس مرجعًا صالحًا
|
||||||
|
|||||||
@@ -6472,6 +6472,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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 = Обектът не е валидна препратка
|
.not-valid-reference = Обектът не е валидна препратка
|
||||||
|
|||||||
@@ -6469,6 +6469,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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:
|
.select-reference = Vyberte referenci:
|
||||||
.reference-not-found = Reference nebyla nalezena.
|
.reference-not-found = Reference nebyla nalezena.
|
||||||
.not-valid-reference = Objekt není platná reference
|
.not-valid-reference = Objekt není platná reference
|
||||||
|
|||||||
@@ -6470,6 +6470,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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:
|
.select-reference = Referenz wählen:
|
||||||
.reference-not-found = Referenz nicht gefunden.
|
.reference-not-found = Referenz nicht gefunden.
|
||||||
.not-valid-reference = Objekt ist keine gültige Referenz
|
.not-valid-reference = Objekt ist keine gültige Referenz
|
||||||
|
|||||||
@@ -6472,6 +6472,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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 = Το αντικείμενο δεν είναι έγκυρη αναφορά
|
.not-valid-reference = Το αντικείμενο δεν είναι έγκυρη αναφορά
|
||||||
|
|||||||
@@ -6471,6 +6471,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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:
|
.select-reference = Select reference:
|
||||||
.reference-not-found = Reference not found.
|
.reference-not-found = Reference not found.
|
||||||
.not-valid-reference = Object is not a valid reference
|
.not-valid-reference = Object is not a valid reference
|
||||||
|
|||||||
@@ -6472,6 +6472,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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:
|
.select-reference = Seleccione la referencia:
|
||||||
.reference-not-found = No se encuentra la referencia.
|
.reference-not-found = No se encuentra la referencia.
|
||||||
.not-valid-reference = El objeto no es una referencia válida
|
.not-valid-reference = El objeto no es una referencia válida
|
||||||
|
|||||||
@@ -6469,6 +6469,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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:
|
.select-reference = Valitse viittaus:
|
||||||
.reference-not-found = Viittausta ei löydy.
|
.reference-not-found = Viittausta ei löydy.
|
||||||
.not-valid-reference = Objekti ei ole kelvollinen viittaus
|
.not-valid-reference = Objekti ei ole kelvollinen viittaus
|
||||||
|
|||||||
@@ -6472,6 +6472,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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 :
|
.select-reference = Sélectionnez la référence :
|
||||||
.reference-not-found = Référence introuvable.
|
.reference-not-found = Référence introuvable.
|
||||||
.not-valid-reference = L'objet n'est pas une référence valide
|
.not-valid-reference = L'objet n'est pas une référence valide
|
||||||
|
|||||||
@@ -6460,6 +6460,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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 = ऑब्जेक्ट मान्य संदर्भ नहीं है
|
.not-valid-reference = ऑब्जेक्ट मान्य संदर्भ नहीं है
|
||||||
|
|||||||
@@ -6456,6 +6456,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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:
|
.select-reference = Válassza ki a hivatkozást:
|
||||||
.reference-not-found = A hivatkozás nem található.
|
.reference-not-found = A hivatkozás nem található.
|
||||||
.not-valid-reference = Az objektum nem érvényes hivatkozás
|
.not-valid-reference = Az objektum nem érvényes hivatkozás
|
||||||
|
|||||||
@@ -6471,6 +6471,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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:
|
.select-reference = Selezionare il riferimento:
|
||||||
.reference-not-found = Riferimento non trovato.
|
.reference-not-found = Riferimento non trovato.
|
||||||
.not-valid-reference = L'oggetto non è un riferimento valido
|
.not-valid-reference = L'oggetto non è un riferimento valido
|
||||||
|
|||||||
@@ -6460,6 +6460,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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 = オブジェクトは有効な参照ではありません
|
.not-valid-reference = オブジェクトは有効な参照ではありません
|
||||||
|
|||||||
@@ -6471,6 +6471,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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 = 객체가 유효한 참조가 아닙니다
|
.not-valid-reference = 객체가 유효한 참조가 아닙니다
|
||||||
|
|||||||
@@ -6472,6 +6472,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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 = ວັດຖຸບໍ່ແມ່ນການອ້າງອີງທີ່ຖືກຕ້ອງ
|
.not-valid-reference = ວັດຖຸບໍ່ແມ່ນການອ້າງອີງທີ່ຖືກຕ້ອງ
|
||||||
|
|||||||
@@ -6470,6 +6470,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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:
|
.select-reference = Selecteer referentie:
|
||||||
.reference-not-found = Referentie niet gevonden.
|
.reference-not-found = Referentie niet gevonden.
|
||||||
.not-valid-reference = Object is geen geldige referentie
|
.not-valid-reference = Object is geen geldige referentie
|
||||||
|
|||||||
@@ -6471,6 +6471,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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:
|
.select-reference = Wybierz odnośnik:
|
||||||
.reference-not-found = Nie znaleziono odnośnika.
|
.reference-not-found = Nie znaleziono odnośnika.
|
||||||
.not-valid-reference = Obiekt nie jest prawidłowym odnośnikiem
|
.not-valid-reference = Obiekt nie jest prawidłowym odnośnikiem
|
||||||
|
|||||||
@@ -6472,6 +6472,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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:
|
.select-reference = Selecione a referência:
|
||||||
.reference-not-found = Referência não encontrada.
|
.reference-not-found = Referência não encontrada.
|
||||||
.not-valid-reference = O objeto não é uma referência válida
|
.not-valid-reference = O objeto não é uma referência válida
|
||||||
|
|||||||
@@ -6473,6 +6473,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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 = Объект не является допустимой ссылкой
|
.not-valid-reference = Объект не является допустимой ссылкой
|
||||||
|
|||||||
@@ -6393,6 +6393,9 @@ view-background =
|
|||||||
.select-image = Arka Plan Görüntüsü Seç
|
.select-image = Arka Plan Görüntüsü Seç
|
||||||
|
|
||||||
ref-edit =
|
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:
|
.select-reference = Referans seçin:
|
||||||
.reference-not-found = Referans bulunamadı.
|
.reference-not-found = Referans bulunamadı.
|
||||||
.not-valid-reference = Nesne geçerli bir referans değil
|
.not-valid-reference = Nesne geçerli bir referans değil
|
||||||
|
|||||||
@@ -6455,6 +6455,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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 = 对象不是有效的参照
|
.not-valid-reference = 对象不是有效的参照
|
||||||
|
|||||||
@@ -6467,6 +6467,9 @@ view-background =
|
|||||||
.select-image = Select Background Image
|
.select-image = Select Background Image
|
||||||
|
|
||||||
ref-edit =
|
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 = 物件不是有效的參考
|
.not-valid-reference = 物件不是有效的參考
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ impl OpenCADStudio {
|
|||||||
pub(super) fn dispatch_refedit(&mut self, cmd: &str, i: usize) -> Option<Task<Message>> {
|
pub(super) fn dispatch_refedit(&mut self, cmd: &str, i: usize) -> Option<Task<Message>> {
|
||||||
match cmd {
|
match cmd {
|
||||||
"REFEDIT" | "-REFEDIT" => Some(self.start_refedit(i, cmd == "-REFEDIT")),
|
"REFEDIT" | "-REFEDIT" => Some(self.start_refedit(i, cmd == "-REFEDIT")),
|
||||||
"REFSET" => {
|
"REFSET" | "REFSET_ADD" | "REFSET_REMOVE" => {
|
||||||
if self.tabs[i].refedit_session.is_none() {
|
if self.tabs[i].refedit_session.is_none() {
|
||||||
self.command_line.push_error(crate::t!(NOT_CHECKED_OUT).as_ref());
|
self.command_line.push_error(crate::t!(NOT_CHECKED_OUT).as_ref());
|
||||||
return Some(Task::none());
|
return Some(Task::none());
|
||||||
@@ -30,7 +30,12 @@ impl OpenCADStudio {
|
|||||||
crate::t!("Transfer objects between the RefEdit working set and host drawing...")
|
crate::t!("Transfer objects between the RefEdit working set and host drawing...")
|
||||||
.as_ref(),
|
.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;
|
use crate::command::CadCommand;
|
||||||
self.command_line.push_info(&command.prompt());
|
self.command_line.push_info(&command.prompt());
|
||||||
self.tabs[i].active_cmd = Some(Box::new(command));
|
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
|
// In-place block edit (REFEDIT): right-edge toolbar with Save / Discard
|
||||||
// so the edit can be finished by clicking. (#136)
|
// so the edit can be finished by clicking. (#136)
|
||||||
if tab.refedit_session.is_some() && !tab.is_start {
|
if let (Some(session), false) = (tab.refedit_session.as_ref(), tab.is_start) {
|
||||||
if let Some(tb) = crate::ui::side_toolbar::view(
|
use crate::modules::draw::modify::refedit::{refedit_set_tools, refedit_tools};
|
||||||
&crate::modules::draw::modify::refedit::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);
|
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()
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
pub(super) fn message_attribute(source: &str) -> Option<(&'static str, &'static str)> {
|
pub(super) fn message_attribute(source: &str) -> Option<(&'static str, &'static str)> {
|
||||||
match source {
|
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")),
|
"Select reference:" => Some(("ref-edit", "select-reference")),
|
||||||
"Reference not found." => Some(("ref-edit", "reference-not-found")),
|
"Reference not found." => Some(("ref-edit", "reference-not-found")),
|
||||||
"Object is not a valid reference" => Some(("ref-edit", "not-valid-reference")),
|
"Object is not a valid reference" => Some(("ref-edit", "not-valid-reference")),
|
||||||
|
|||||||
@@ -20,6 +20,25 @@ use std::collections::HashSet;
|
|||||||
use crate::command::{CadCommand, CmdOption, CmdResult};
|
use crate::command::{CadCommand, CmdOption, CmdResult};
|
||||||
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
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:
|
/// Right-edge side-toolbar buttons shown while a REFEDIT session is active:
|
||||||
/// save the in-place block edit, or discard it. (#136)
|
/// save the in-place block edit, or discard it. (#136)
|
||||||
pub fn refedit_tools() -> Vec<ToolDef> {
|
pub fn refedit_tools() -> Vec<ToolDef> {
|
||||||
@@ -479,6 +498,15 @@ impl RefSetCommand {
|
|||||||
selected: Vec::new(),
|
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 {
|
impl CadCommand for RefSetCommand {
|
||||||
|
|||||||
+76
-2
@@ -49,6 +49,53 @@ fn tip_panel(label: &'static str) -> Element<'static, Message> {
|
|||||||
.into()
|
.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
|
/// Build the floating right-edge vertical toolbar from `tools`, vertically
|
||||||
/// centred over the canvas. Returns `None` when `tools` is empty so the caller
|
/// centred over the canvas. Returns `None` when `tools` is empty so the caller
|
||||||
/// can skip pushing an overlay.
|
/// can skip pushing an overlay.
|
||||||
@@ -61,12 +108,39 @@ pub fn view_with_active(
|
|||||||
tools: &[ToolDef],
|
tools: &[ToolDef],
|
||||||
active: &dyn Fn(&str) -> bool,
|
active: &dyn Fn(&str) -> bool,
|
||||||
) -> Option<Element<'static, Message>> {
|
) -> 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;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut col = column![].spacing(4).align_x(iced::Center);
|
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 on = active(t.id);
|
||||||
let btn = button(icon_el(t.icon))
|
let btn = button(icon_el(t.icon))
|
||||||
.on_press(Message::RibbonToolClick {
|
.on_press(Message::RibbonToolClick {
|
||||||
|
|||||||
Reference in new issue
Block a user