Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Bevy Cosmic Edit
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Microhacks
Bevy Forks
Bevy Cosmic Edit
Commits
6404aaf1
Commit
6404aaf1
authored
1 year ago
by
sam edelsten
Browse files
Options
Downloads
Patches
Plain Diff
fix cursor blink on editors with transparency
parent
18c08a16
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib.rs
+8
-11
8 additions, 11 deletions
src/lib.rs
with
8 additions
and
11 deletions
src/lib.rs
+
8
−
11
View file @
6404aaf1
...
@@ -138,7 +138,6 @@ fn cosmic_editor_builder(
...
@@ -138,7 +138,6 @@ fn cosmic_editor_builder(
&
mut
CosmicEditor
,
&
mut
CosmicEditor
,
&
CosmicAttrs
,
&
CosmicAttrs
,
&
CosmicMetrics
,
&
CosmicMetrics
,
&
BackgroundColor
,
Option
<&
ReadOnly
>
,
Option
<&
ReadOnly
>
,
Option
<&
Node
>
,
Option
<&
Node
>
,
Option
<&
Sprite
>
,
Option
<&
Sprite
>
,
...
@@ -147,9 +146,7 @@ fn cosmic_editor_builder(
...
@@ -147,9 +146,7 @@ fn cosmic_editor_builder(
>
,
>
,
mut
font_system
:
ResMut
<
CosmicFontSystem
>
,
mut
font_system
:
ResMut
<
CosmicFontSystem
>
,
)
{
)
{
for
(
mut
editor
,
attrs
,
metrics
,
background_color
,
readonly
,
node
,
sprite
)
in
for
(
mut
editor
,
attrs
,
metrics
,
readonly
,
node
,
sprite
)
in
added_editors
.iter_mut
()
{
added_editors
.iter_mut
()
{
// keep old text if set
// keep old text if set
let
mut
text
=
editor
.get_text
();
let
mut
text
=
editor
.get_text
();
...
@@ -187,7 +184,7 @@ fn cosmic_editor_builder(
...
@@ -187,7 +184,7 @@ fn cosmic_editor_builder(
// hide cursor on readonly buffers
// hide cursor on readonly buffers
let
mut
cursor
=
editor
.0
.cursor
();
let
mut
cursor
=
editor
.0
.cursor
();
if
readonly
.is_some
()
{
if
readonly
.is_some
()
{
cursor
.color
=
Some
(
bevy_color_to_cosmic
(
background_color
.
0
));
cursor
.color
=
Some
(
cosmic_text
::
Color
::
rgba
(
0
,
0
,
0
,
0
));
}
}
editor
.0
.set_cursor
(
cursor
);
editor
.0
.set_cursor
(
cursor
);
}
}
...
@@ -1184,10 +1181,10 @@ fn blink_cursor(
...
@@ -1184,10 +1181,10 @@ fn blink_cursor(
mut
timer
:
Local
<
Option
<
Timer
>>
,
mut
timer
:
Local
<
Option
<
Timer
>>
,
time
:
Res
<
Time
>
,
time
:
Res
<
Time
>
,
active_editor
:
ResMut
<
ActiveEditor
>
,
active_editor
:
ResMut
<
ActiveEditor
>
,
mut
cosmic_editor_q
:
Query
<
(
&
mut
CosmicEditor
,
&
BackgroundColor
),
Without
<
ReadOnly
>>
,
mut
cosmic_editor_q
:
Query
<&
mut
CosmicEditor
,
Without
<
ReadOnly
>>
,
)
{
)
{
if
let
Some
(
e
)
=
active_editor
.entity
{
if
let
Some
(
e
)
=
active_editor
.entity
{
if
let
Ok
(
(
mut
editor
,
bg_color
)
)
=
cosmic_editor_q
.get_mut
(
e
)
{
if
let
Ok
(
mut
editor
)
=
cosmic_editor_q
.get_mut
(
e
)
{
let
timer
=
let
timer
=
timer
.get_or_insert_with
(||
Timer
::
from_seconds
(
0.53
,
TimerMode
::
Repeating
));
timer
.get_or_insert_with
(||
Timer
::
from_seconds
(
0.53
,
TimerMode
::
Repeating
));
...
@@ -1207,7 +1204,7 @@ fn blink_cursor(
...
@@ -1207,7 +1204,7 @@ fn blink_cursor(
let
new_color
=
if
*
visible
{
let
new_color
=
if
*
visible
{
None
None
}
else
{
}
else
{
Some
(
bevy_color_to_cosmic
(
bg_color
.
0
))
Some
(
cosmic_text
::
Color
::
rgba
(
0
,
0
,
0
,
0
))
};
};
cursor
.color
=
new_color
;
cursor
.color
=
new_color
;
editor
.0
.set_cursor
(
cursor
);
editor
.0
.set_cursor
(
cursor
);
...
@@ -1217,17 +1214,17 @@ fn blink_cursor(
...
@@ -1217,17 +1214,17 @@ fn blink_cursor(
}
}
fn
hide_inactive_cursor
(
fn
hide_inactive_cursor
(
mut
cosmic_editor_q
:
Query
<
(
Entity
,
&
mut
CosmicEditor
,
&
BackgroundColor
)
>
,
mut
cosmic_editor_q
:
Query
<
(
Entity
,
&
mut
CosmicEditor
)
>
,
active_editor
:
Res
<
ActiveEditor
>
,
active_editor
:
Res
<
ActiveEditor
>
,
)
{
)
{
if
!
active_editor
.is_changed
()
||
active_editor
.entity
.is_none
()
{
if
!
active_editor
.is_changed
()
||
active_editor
.entity
.is_none
()
{
return
;
return
;
}
}
for
(
e
,
mut
editor
,
bg_color
)
in
&
mut
cosmic_editor_q
.iter_mut
()
{
for
(
e
,
mut
editor
)
in
&
mut
cosmic_editor_q
.iter_mut
()
{
if
e
!=
active_editor
.entity
.unwrap
()
{
if
e
!=
active_editor
.entity
.unwrap
()
{
let
mut
cursor
=
editor
.0
.cursor
();
let
mut
cursor
=
editor
.0
.cursor
();
cursor
.color
=
Some
(
bevy_color_to_cosmic
(
bg_color
.
0
));
cursor
.color
=
Some
(
cosmic_text
::
Color
::
rgba
(
0
,
0
,
0
,
0
));
editor
.0
.set_cursor
(
cursor
);
editor
.0
.set_cursor
(
cursor
);
editor
.0
.buffer_mut
()
.set_redraw
(
true
);
editor
.0
.buffer_mut
()
.set_redraw
(
true
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment