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
50eabf5a
Unverified
Commit
50eabf5a
authored
1 year ago
by
sam
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' into password
parents
e48b3aec
63c17ca3
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/lib.rs
+11
-5
11 additions, 5 deletions
src/lib.rs
src/render.rs
+15
-2
15 additions, 2 deletions
src/render.rs
with
26 additions
and
7 deletions
src/lib.rs
+
11
−
5
View file @
50eabf5a
...
@@ -21,7 +21,7 @@ use input::{input_kb, input_mouse, undo_redo, ClickTimer};
...
@@ -21,7 +21,7 @@ use input::{input_kb, input_mouse, undo_redo, ClickTimer};
use
input
::{
poll_wasm_paste
,
WasmPaste
,
WasmPasteAsyncChannel
};
use
input
::{
poll_wasm_paste
,
WasmPaste
,
WasmPasteAsyncChannel
};
use
render
::{
use
render
::{
blink_cursor
,
cosmic_edit_redraw_buffer
,
freeze_cursor_blink
,
hide_inactive_or_readonly_cursor
,
blink_cursor
,
cosmic_edit_redraw_buffer
,
freeze_cursor_blink
,
hide_inactive_or_readonly_cursor
,
on_scale_factor_change
,
CursorBlinkTimer
,
CursorVisibility
,
SwashCacheState
,
on_scale_factor_change
,
set_initial_scale
,
CursorBlinkTimer
,
CursorVisibility
,
SwashCacheState
,
};
};
#[cfg(feature
=
"multicam"
)]
#[cfg(feature
=
"multicam"
)]
...
@@ -73,6 +73,8 @@ pub enum CosmicTextPosition {
...
@@ -73,6 +73,8 @@ pub enum CosmicTextPosition {
pub
struct
CosmicTextChanged
(
pub
(
Entity
,
String
));
pub
struct
CosmicTextChanged
(
pub
(
Entity
,
String
));
// TODO docs
// TODO docs
const
DEFAULT_SCALE_PLACEHOLDER
:
f32
=
0.696969
;
#[derive(Clone,
Component)]
#[derive(Clone,
Component)]
pub
struct
CosmicMetrics
{
pub
struct
CosmicMetrics
{
pub
font_size
:
f32
,
pub
font_size
:
f32
,
...
@@ -85,7 +87,7 @@ impl Default for CosmicMetrics {
...
@@ -85,7 +87,7 @@ impl Default for CosmicMetrics {
Self
{
Self
{
font_size
:
12.
,
font_size
:
12.
,
line_height
:
12.
,
line_height
:
12.
,
scale_factor
:
1.
,
scale_factor
:
DEFAULT_SCALE_PLACEHOLDER
,
}
}
}
}
}
}
...
@@ -291,9 +293,13 @@ impl Plugin for CosmicEditPlugin {
...
@@ -291,9 +293,13 @@ impl Plugin for CosmicEditPlugin {
app
.add_systems
(
app
.add_systems
(
First
,
First
,
(
(
cosmic_editor_builder
,
set_initial_scale
,
placeholder_builder
,
(
on_scale_factor_change
,
cosmic_editor_builder
,
placeholder_builder
,
on_scale_factor_change
,
)
.after
(
set_initial_scale
),
render
::
cosmic_ui_to_canvas
,
render
::
cosmic_ui_to_canvas
,
render
::
cosmic_sprite_to_canvas
,
render
::
cosmic_sprite_to_canvas
,
),
),
...
...
This diff is collapsed.
Click to expand it.
src/render.rs
+
15
−
2
View file @
50eabf5a
...
@@ -2,7 +2,7 @@ use std::time::Duration;
...
@@ -2,7 +2,7 @@ use std::time::Duration;
use
bevy
::{
use
bevy
::{
asset
::
HandleId
,
asset
::
HandleId
,
prelude
::
*
,
prelude
::
*
;
render
::
render_resource
::
Extent3d
,
render
::
render_resource
::
Extent3d
,
window
::{
PrimaryWindow
,
WindowScaleFactorChanged
},
window
::{
PrimaryWindow
,
WindowScaleFactorChanged
},
};
};
...
@@ -12,7 +12,7 @@ use image::{imageops::FilterType, GenericImageView};
...
@@ -12,7 +12,7 @@ use image::{imageops::FilterType, GenericImageView};
use
crate
::{
use
crate
::{
get_text_size
,
get_x_offset_center
,
get_y_offset_center
,
CosmicAttrs
,
CosmicBackground
,
get_text_size
,
get_x_offset_center
,
get_y_offset_center
,
CosmicAttrs
,
CosmicBackground
,
CosmicCanvas
,
CosmicEditor
,
CosmicFontSystem
,
CosmicMetrics
,
CosmicMode
,
CosmicTextPosition
,
CosmicCanvas
,
CosmicEditor
,
CosmicFontSystem
,
CosmicMetrics
,
CosmicMode
,
CosmicTextPosition
,
FillColor
,
Focus
,
PasswordInput
,
Placeholder
,
ReadOnly
,
XOffset
,
FillColor
,
Focus
,
PasswordInput
,
Placeholder
,
ReadOnly
,
XOffset
,
DEFAULT_SCALE_PLACEHOLDER
};
};
#[derive(Resource)]
#[derive(Resource)]
...
@@ -452,6 +452,19 @@ pub(crate) fn hide_inactive_or_readonly_cursor(
...
@@ -452,6 +452,19 @@ pub(crate) fn hide_inactive_or_readonly_cursor(
}
}
}
}
pub
(
crate
)
fn
set_initial_scale
(
window_q
:
Query
<&
Window
,
With
<
PrimaryWindow
>>
,
mut
metrics_q
:
Query
<&
mut
CosmicMetrics
,
Added
<
CosmicMetrics
>>
,
)
{
let
scale
=
window_q
.single
()
.scale_factor
()
as
f32
;
for
mut
metrics
in
metrics_q
.iter_mut
()
{
if
metrics
.scale_factor
==
DEFAULT_SCALE_PLACEHOLDER
{
metrics
.scale_factor
=
scale
;
}
}
}
pub
(
crate
)
fn
on_scale_factor_change
(
pub
(
crate
)
fn
on_scale_factor_change
(
mut
scale_factor_changed
:
EventReader
<
WindowScaleFactorChanged
>
,
mut
scale_factor_changed
:
EventReader
<
WindowScaleFactorChanged
>
,
mut
cosmic_query
:
Query
<
(
&
mut
CosmicEditor
,
&
CosmicMetrics
,
&
mut
XOffset
)
>
,
mut
cosmic_query
:
Query
<
(
&
mut
CosmicEditor
,
&
CosmicMetrics
,
&
mut
XOffset
)
>
,
...
...
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