Fix #107009: Setting Text Object Styles #107048
|
@ -363,7 +363,7 @@ class DATA_PT_font(CurveButtonsPanelText, Panel):
|
|||
if mode == 'EDIT_TEXT':
|
||||
layout.separator()
|
||||
|
||||
if text.is_selected == False :
|
||||
if not text.has_selection:
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(char, "use_bold", toggle=True)
|
||||
row.prop(char, "use_italic", toggle=True)
|
||||
|
|
|
@ -44,7 +44,7 @@ typedef struct EditFont {
|
|||
|
||||
/* Combined styles (#CharInfo.flag) for selected string. A flag will be
|
||||
* set only if ALL characters in the selected string have it. */
|
||||
int selected_flag;
|
||||
int select_char_info_flag;
|
||||
Campbell Barton
commented
Prefer this includes the term char_info or style, e.g. Prefer this includes the term char_info or style, e.g. `select_char_info_flag`
|
||||
|
||||
/**
|
||||
* ID data is older than edit-mode data.
|
||||
|
|
|
@ -1143,22 +1143,11 @@ static bool vfont_to_curve(Object *ob,
|
|||
if (ef && ef->selboxes) {
|
||||
/* Set combined style flags for the selected string. Start with all styles then
|
||||
* remove one if ANY characters do not have it. Break out if we've removed them all. */
|
||||
ef->selected_flag = CU_CHINFO_BOLD | CU_CHINFO_ITALIC | CU_CHINFO_UNDERLINE |
|
||||
ef->select_char_info_flag = CU_CHINFO_BOLD | CU_CHINFO_ITALIC | CU_CHINFO_UNDERLINE |
|
||||
CU_CHINFO_SMALLCAPS;
|
||||
for (int k = selstart; k <= selend && ef->selected_flag; k++) {
|
||||
for (int k = selstart; k <= selend && ef->select_char_info_flag; k++) {
|
||||
Campbell Barton
commented
Checking each flag isn't needed. Checking each flag isn't needed. `ef->selected_flag &= info->flag;` masks out flags as intended.
|
||||
info = &custrinfo[k];
|
||||
if (!(info->flag & CU_CHINFO_BOLD)) {
|
||||
ef->selected_flag &= ~CU_CHINFO_BOLD;
|
||||
}
|
||||
if (!(info->flag & CU_CHINFO_ITALIC)) {
|
||||
ef->selected_flag &= ~CU_CHINFO_ITALIC;
|
||||
}
|
||||
if (!(info->flag & CU_CHINFO_UNDERLINE)) {
|
||||
ef->selected_flag &= ~CU_CHINFO_UNDERLINE;
|
||||
}
|
||||
if (!(info->flag & CU_CHINFO_SMALLCAPS)) {
|
||||
ef->selected_flag &= ~CU_CHINFO_SMALLCAPS;
|
||||
}
|
||||
ef->select_char_info_flag &= info->flag;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -838,7 +838,7 @@ static bool rna_Curve_is_editmode_get(PointerRNA *ptr)
|
|||
}
|
||||
}
|
||||
|
||||
static bool rna_Curve_is_selected(PointerRNA *ptr)
|
||||
static bool rna_TextCurve_has_selection_get(PointerRNA *ptr)
|
||||
Campbell Barton
commented
The name is misleading, The name is misleading, `rna_TextCurve_has_selection` (RNA terms this a `TextCurve`).
|
||||
{
|
||||
Curve *cu = (Curve *)ptr->owner_id;
|
||||
if (cu->editfont != NULL)
|
||||
|
@ -1283,27 +1283,27 @@ static void rna_def_font(BlenderRNA *UNUSED(brna), StructRNA *srna)
|
|||
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
|
||||
|
||||
prop = RNA_def_property(srna, "select_is_underline", PROP_BOOLEAN, PROP_NONE);
|
||||
Harley marked this conversation as resolved
Outdated
Campbell Barton
commented
Generally Generally `is_/has_` ... etc are prefixes. `is_select_bold` ... etc.
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "editfont->selected_flag", CU_CHINFO_UNDERLINE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "editfont->select_char_info_flag", CU_CHINFO_UNDERLINE);
|
||||
RNA_def_property_ui_text(prop, "Selected Underline", "Whether the selected text is underlined");
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
|
||||
prop = RNA_def_property(srna, "select_is_bold", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "editfont->selected_flag", CU_CHINFO_BOLD);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "editfont->select_char_info_flag", CU_CHINFO_BOLD);
|
||||
RNA_def_property_ui_text(prop, "Selected Bold", "Whether the selected text is bold");
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
|
||||
prop = RNA_def_property(srna, "select_is_italic", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "editfont->selected_flag", CU_CHINFO_ITALIC);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "editfont->select_char_info_flag", CU_CHINFO_ITALIC);
|
||||
RNA_def_property_ui_text(prop, "Selected Italic", "Whether the selected text is italics");
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
|
||||
prop = RNA_def_property(srna, "select_is_smallcaps", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "editfont->selected_flag", CU_CHINFO_SMALLCAPS);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "editfont->select_char_info_flag", CU_CHINFO_SMALLCAPS);
|
||||
RNA_def_property_ui_text(prop, "Selected Smallcaps", "Whether the selected text is small caps");
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
|
||||
prop = RNA_def_property(srna, "is_selected", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_funcs(prop, "rna_Curve_is_selected", NULL);
|
||||
prop = RNA_def_property(srna, "has_selection", PROP_BOOLEAN, PROP_NONE);
|
||||
Campbell Barton
commented
Prefer Prefer `has_selection` as `is_selected` makes it seem it might be the object selection.
|
||||
RNA_def_property_boolean_funcs(prop, "rna_TextCurve_has_selection_get", NULL);
|
||||
RNA_def_property_ui_text(prop, "Text Selected", "Whether there is any text selected");
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
if not text.is_selected:
...