Преглед на файлове

Merge pull request #52976 from KoBeWi/TBD

Rémi Verschelde преди 3 години
родител
ревизия
ea508ced9f
променени са 2 файла, в които са добавени 31 реда и са изтрити 1 реда
  1. 1 1
      doc/classes/TreeItem.xml
  2. 30 0
      editor/import/dynamicfont_import_settings.cpp

+ 1 - 1
doc/classes/TreeItem.xml

@@ -390,7 +390,7 @@
 			<argument index="0" name="column" type="int" />
 			<argument index="1" name="emit_signal" type="bool" default="true" />
 			<description>
-				Propagates this item's checked status to its children and parents for the given [code]column[/code]. It is possible to process the items affected by this method call by connecting to [signal Tree.check_propagated_to_item]. The order that the items affected will be processed is as follows: the item invoking this method, children of that item, and finally parents of that item. If [code]emit_signal[/code] is set to false, then [signal Tree.check_propagated_to_item] will not be emitted.
+				Propagates this item's checked status to its children and parents for the given [code]column[/code]. It is possible to process the items affected by this method call by connecting to [signal Tree.check_propagated_to_item]. The order that the items affected will be processed is as follows: the item invoking this method, children of that item, and finally parents of that item. If [code]emit_signal[/code] is [code]false[/code], then [signal Tree.check_propagated_to_item] will not be emitted.
 			</description>
 		</method>
 		<method name="remove_child">

+ 30 - 0
editor/import/dynamicfont_import_settings.cpp

@@ -427,6 +427,7 @@ void DynamicFontImportSettings::_add_glyph_range_item(int32_t p_start, int32_t p
 	for (int i = 0; i < pages; i++) {
 		TreeItem *item = glyph_tree->create_item(glyph_root);
 		ERR_FAIL_NULL(item);
+		item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
 		item->set_text(0, _pad_zeros(String::num_int64(start, 16)) + " - " + _pad_zeros(String::num_int64(start + page_size, 16)));
 		item->set_text(1, p_name);
 		item->set_metadata(0, Vector2i(start, start + page_size));
@@ -435,6 +436,7 @@ void DynamicFontImportSettings::_add_glyph_range_item(int32_t p_start, int32_t p
 	if (remain > 0) {
 		TreeItem *item = glyph_tree->create_item(glyph_root);
 		ERR_FAIL_NULL(item);
+		item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
 		item->set_text(0, _pad_zeros(String::num_int64(start, 16)) + " - " + _pad_zeros(String::num_int64(p_end, 16)));
 		item->set_text(1, p_name);
 		item->set_metadata(0, Vector2i(start, p_end));
@@ -656,6 +658,30 @@ void DynamicFontImportSettings::_glyph_selected() {
 		}
 	}
 	label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size()));
+
+	item = glyph_tree->get_selected();
+	ERR_FAIL_NULL(item);
+	Vector2i range = item->get_metadata(0);
+
+	int total_chars = range.y - range.x;
+	int selected_count = 0;
+	for (int i = range.x; i < range.y; i++) {
+		if (!font_main->has_char(i)) {
+			total_chars--;
+		}
+
+		if (selected_chars.has(i)) {
+			selected_count++;
+		}
+	}
+
+	if (selected_count == total_chars) {
+		item->set_checked(0, true);
+	} else if (selected_count > 0) {
+		item->set_indeterminate(0, true);
+	} else {
+		item->set_checked(0, false);
+	}
 }
 
 void DynamicFontImportSettings::_range_edited() {
@@ -760,6 +786,10 @@ void DynamicFontImportSettings::_range_update(int32_t p_start, int32_t p_end) {
 		}
 	}
 	_edit_range(p_start, p_end);
+
+	TreeItem *item = glyph_tree->get_selected();
+	ERR_FAIL_NULL(item);
+	item->set_checked(0, !all_selected);
 }
 
 /*************************************************************************/