Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to text line #654

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions pygame_gui/core/drawable_shapes/drawable_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,10 @@ def finalise_text(self, state_str,
def apply_active_text_changes(self):
"""
Updates the shape surface with any changes to the text surface. Useful when we've made
small edits to the text surface
small edits to the text surface.

This may be bugged.

"""
if self.text_box_layout is not None:
for state_id, state in self.states.items():
Expand Down Expand Up @@ -684,7 +687,10 @@ def set_text_alpha(self, alpha: int):
"""
self.text_box_layout.set_alpha(alpha)
self.redraw_state(self.active_state.state_id, add_text=False)
self.finalise_text(self.active_state.state_id, only_text_changed=True)
self.finalise_text(self.active_state.state_id,
self.active_state.state_id + "_text",
self.active_state.state_id + '_text_shadow',
only_text_changed=False)

def redraw_active_state_no_text(self):
"""
Expand All @@ -699,7 +705,10 @@ def finalise_text_onto_active_state(self):
to lose by recreating the text from scratch.
"""
self.redraw_state(self.active_state.state_id, add_text=False)
self.finalise_text(self.active_state.state_id, only_text_changed=True)
self.finalise_text(self.active_state.state_id,
self.active_state.state_id + "_text",
self.active_state.state_id + '_text_shadow',
only_text_changed=False)

def insert_text(self, text: str, layout_index: int, parser: Optional[HTMLParser] = None):
"""
Expand All @@ -722,7 +731,7 @@ def toggle_text_cursor(self):
"""
if self.text_box_layout is not None:
self.text_box_layout.toggle_cursor()
self.apply_active_text_changes()
self.finalise_text_onto_active_state()
self.active_state.has_fresh_surface = True

def redraw_state(self, state_str: str, add_text: bool = True):
Expand Down
1 change: 0 additions & 1 deletion pygame_gui/elements/ui_text_entry_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ def update(self, time_delta: float):
if self.drawable_shape is not None:
self.drawable_shape.text_box_layout.set_cursor_position(self.edit_position)
self.drawable_shape.toggle_text_cursor()
self.drawable_shape.apply_active_text_changes()

if self.cursor_blink_delay_after_moving_acc > self.cursor_blink_delay_after_moving:
if self.blink_cursor_time_acc >= self.blink_cursor_time:
Expand Down
Loading