Fix #107009: Setting Text Object Styles #107048

Merged
Harley Acheson merged 5 commits from Harley/blender:CurveStyles into main 2023-04-18 21:24:48 +02:00
Member

This allows toggling of text styles of selected text and at the current
mouse cursor position if nothing is selected.


Investigating this bug report and examining the code of GSoC student Yash Dabhade (yashdabhade), I think this PR is all we actually need for text style changes to work in a more logical way.

The current issue is that we have buttons that reliably show if the character at the cursor position is bold, italics, etc. However clicking these buttons doesn't do what users would expect, as they don't change the style of any selected text. They only change the style flags at the mouse position so any new text entered will use that style. We also have a "Text" menu with items to "Toggle Bold", etc. However these only work on the selected text and will NOT change the style for new text added. So we have two very different style-changing options that work in unexpected ways. This PR just makes them both work the same.

So for the text menu items, if anything is selected it will continue to work as today. But if nothing it selected it won't just error out but will instead set that style for following text:

TextStyles2.gif.gif

For the text style buttons, they show the same information as now, but clicking them will change the style for following text if nothing is selected. But if anything is selected it will change it:

TextStyles1.gif.gif

This allows toggling of text styles of selected text and at the current mouse cursor position if nothing is selected. --- Investigating this bug report and examining the code of GSoC student Yash Dabhade (yashdabhade), I think this PR is all we actually need for text style changes to work in a more logical way. The current issue is that we have buttons that reliably show if the character at the cursor position is bold, italics, etc. However clicking these buttons doesn't do what users would expect, as they don't change the style of any selected text. They only change the style flags at the mouse position so any new text entered will use that style. We also have a "Text" menu with items to "Toggle Bold", etc. However these only work on the selected text and will NOT change the style for new text added. So we have two very different style-changing options that work in unexpected ways. This PR just makes them both work the same. So for the text menu items, if anything is selected it will continue to work as today. But if nothing it selected it won't just error out but will instead set that style for following text: ![TextStyles2.gif.gif](/attachments/0e773fa7-a147-4ee4-9513-f9af53c8885e) For the text style buttons, they show the same information as now, but clicking them will change the style for following text if nothing is selected. But if anything is selected it will change it: ![TextStyles1.gif.gif](/attachments/2f9cb8da-ba66-4781-aef2-ff419ee30cea)
Harley Acheson added 1 commit 2023-04-17 19:38:06 +02:00
9193530568 Fix #107009: Setting Text Object Styles
This allows toggling of text styles of selected text and at the current
mouse cursor position if nothing is selected.
Harley Acheson requested review from Campbell Barton 2023-04-17 19:39:30 +02:00
Harley Acheson added this to the User Interface project 2023-04-17 19:53:42 +02:00

While this is an improvement on the current state, the buttons can take the selected state into account (so a selection with mixed state doesn't show as bold) - this is how most word processors work.

The original patch from yashdabhade implemented this and I think it's worth following this logic.


As a intermediate change this seems OK, but I think it would be best to implement style buttons that follow the entire selection.

While this is an improvement on the current state, the buttons can take the selected state into account (so a selection with mixed state doesn't show as bold) - this is how most word processors work. The original patch from yashdabhade implemented this and I think it's worth following this logic. ---- As a intermediate change this seems OK, but I think it would be best to implement style buttons that follow the entire selection.
Harley Acheson changed title from Fix #107009: Setting Text Object Styles to WIP: Fix #107009: Setting Text Object Styles 2023-04-18 02:03:06 +02:00
Harley Acheson added 1 commit 2023-04-18 03:46:18 +02:00
Author
Member

@ideasman42 - Now properly showing the combined styles of the selected text. Will only consider a portion as bold if every character is bold, etc.

@ideasman42 - Now properly showing the combined styles of the selected text. Will only consider a portion as bold if every character is bold, etc.
Campbell Barton requested changes 2023-04-18 04:32:17 +02:00
@ -368,3 +366,1 @@
row.prop(char, "use_italic", toggle=True)
row.prop(char, "use_underline", toggle=True)
row.prop(char, "use_small_caps", toggle=True)
if text.is_selected == False :

if not text.is_selected: ...

`if not text.is_selected:` ...
@ -44,1 +44,4 @@
/* 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;

Prefer this includes the term char_info or style, e.g. select_char_info_flag

Prefer this includes the term char_info or style, e.g. `select_char_info_flag`
@ -1144,0 +1145,4 @@
* 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 |
CU_CHINFO_SMALLCAPS;
for (int k = selstart; k <= selend && ef->selected_flag; k++) {

Checking each flag isn't needed. ef->selected_flag &= info->flag; masks out flags as intended.

Checking each flag isn't needed. `ef->selected_flag &= info->flag;` masks out flags as intended.
@ -838,6 +838,15 @@ static bool rna_Curve_is_editmode_get(PointerRNA *ptr)
}
}
static bool rna_Curve_is_selected(PointerRNA *ptr)

The name is misleading, rna_TextCurve_has_selection (RNA terms this a TextCurve).

The name is misleading, `rna_TextCurve_has_selection` (RNA terms this a `TextCurve`).
@ -1275,0 +1302,4 @@
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);

Prefer has_selection as is_selected makes it seem it might be the object selection.

Prefer `has_selection` as `is_selected` makes it seem it might be the object selection.
Harley Acheson added 1 commit 2023-04-18 06:02:39 +02:00
Harley Acheson changed title from WIP: Fix #107009: Setting Text Object Styles to Fix #107009: Setting Text Object Styles 2023-04-18 06:03:03 +02:00
Campbell Barton approved these changes 2023-04-18 09:31:36 +02:00
Campbell Barton left a comment
Owner

Approving with minor request.

Approving with minor request.
@ -1273,2 +1282,4 @@
RNA_def_property_ui_text(prop, "Fast Editing", "Don't fill polygons while editing");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
prop = RNA_def_property(srna, "select_is_underline", PROP_BOOLEAN, PROP_NONE);

Generally is_/has_ ... etc are prefixes. is_select_bold ... etc.

Generally `is_/has_` ... etc are prefixes. `is_select_bold` ... etc.
Harley marked this conversation as resolved
Harley Acheson added 1 commit 2023-04-18 20:10:43 +02:00
Harley Acheson added 1 commit 2023-04-18 20:41:20 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
c489e12840
Merge branch 'main' into CurveStyles
Author
Member

@blender-bot build

@blender-bot build
Harley Acheson merged commit f7ba61d3a6 into main 2023-04-18 21:24:48 +02:00
Harley Acheson deleted branch CurveStyles 2023-04-18 21:24:49 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#107048
No description provided.