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
2fd94719
Unverified
Commit
2fd94719
authored
10 months ago
by
databasedav
Committed by
GitHub
10 months ago
Browse files
Options
Downloads
Patches
Plain Diff
add scroll disableability (#141)
* add scroll disableability * fmt
parent
88ea7326
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cosmic_edit.rs
+4
-0
4 additions, 0 deletions
src/cosmic_edit.rs
src/input.rs
+30
-20
30 additions, 20 deletions
src/input.rs
with
34 additions
and
20 deletions
src/cosmic_edit.rs
+
4
−
0
View file @
2fd94719
...
...
@@ -70,6 +70,10 @@ pub struct MaxLines(pub usize);
#[derive(Component,
Default)]
pub
struct
MaxChars
(
pub
usize
);
/// Buffer does not respond to scroll events
#[derive(Component,
Default)]
pub
struct
ScrollDisabled
;
/// A pointer to an entity with a [`CosmicEditBundle`], used to apply cosmic rendering to a UI
/// element.
///
...
...
This diff is collapsed.
Click to expand it.
src/input.rs
+
30
−
20
View file @
2fd94719
...
...
@@ -69,6 +69,7 @@ pub(crate) fn input_mouse(
Entity
,
&
XOffset
,
&
mut
Sprite
,
Option
<&
ScrollDisabled
>
,
)
>
,
node_q
:
Query
<
(
&
Node
,
&
GlobalTransform
,
&
CosmicSource
)
>
,
mut
font_system
:
ResMut
<
CosmicFontSystem
>
,
...
...
@@ -107,8 +108,15 @@ pub(crate) fn input_mouse(
return
;
};
if
let
Ok
((
mut
editor
,
sprite_transform
,
text_position
,
entity
,
x_offset
,
sprite
))
=
editor_q
.get_mut
(
active_editor_entity
)
if
let
Ok
((
mut
editor
,
sprite_transform
,
text_position
,
entity
,
x_offset
,
sprite
,
scroll_disabled
,
))
=
editor_q
.get_mut
(
active_editor_entity
)
{
let
buffer
=
editor
.with_buffer
(|
b
|
b
.clone
());
...
...
@@ -218,24 +226,26 @@ pub(crate) fn input_mouse(
return
;
}
for
ev
in
scroll_evr
.read
()
{
match
ev
.unit
{
MouseScrollUnit
::
Line
=>
{
editor
.action
(
&
mut
font_system
.0
,
Action
::
Scroll
{
lines
:
-
ev
.y
as
i32
,
},
);
}
MouseScrollUnit
::
Pixel
=>
{
let
line_height
=
buffer
.metrics
()
.line_height
;
editor
.action
(
&
mut
font_system
.0
,
Action
::
Scroll
{
lines
:
-
(
ev
.y
/
line_height
)
as
i32
,
},
);
if
scroll_disabled
.is_none
()
{
for
ev
in
scroll_evr
.read
()
{
match
ev
.unit
{
MouseScrollUnit
::
Line
=>
{
editor
.action
(
&
mut
font_system
.0
,
Action
::
Scroll
{
lines
:
-
ev
.y
as
i32
,
},
);
}
MouseScrollUnit
::
Pixel
=>
{
let
line_height
=
buffer
.metrics
()
.line_height
;
editor
.action
(
&
mut
font_system
.0
,
Action
::
Scroll
{
lines
:
-
(
ev
.y
/
line_height
)
as
i32
,
},
);
}
}
}
}
...
...
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