Skip to content

Commit 638eaea

Browse files
authored
allow disabling rgb bindings (#818)
1 parent 1f95ef1 commit 638eaea

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

pad/editor/src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,6 +1727,13 @@ pub fn Editor<'a>(
17271727
let input: HtmlSelectElement = event.target().unwrap().dyn_into().unwrap();
17281728
set_gayness(input.value().as_str().into());
17291729
};
1730+
let toggle_rgb_bindings = move |_| {
1731+
set_timeout(
1732+
move || get_state.get().refresh_code(),
1733+
Duration::from_millis(0),
1734+
);
1735+
set_rgb_bindings(!get_rgb_bindings());
1736+
};
17301737
set_font_name(&get_font_name());
17311738
set_font_size(&get_font_size());
17321739

@@ -1992,6 +1999,14 @@ pub fn Editor<'a>(
19921999
</option>
19932000
</select>
19942001
</div>
2002+
<div title="Color constant [r g b] bindings according to their value">
2003+
"RGB bindings:"
2004+
<input
2005+
type="checkbox"
2006+
checked=get_rgb_bindings
2007+
on:change=toggle_rgb_bindings
2008+
/>
2009+
</div>
19952010
<div title="Show line values to the right of the code">
19962011
"Show values:"
19972012
<input
@@ -2437,6 +2452,9 @@ fn binding_class(name: &str, docs: &BindingDocs) -> &'static str {
24372452
}
24382453

24392454
fn binding_style(docs: &BindingDocs) -> String {
2455+
if !get_rgb_bindings() {
2456+
return String::new();
2457+
}
24402458
if let BindingDocsKind::Constant(Some(val)) = &docs.kind {
24412459
if let Ok(nums) = val.as_nums(&IgnoreError, "") {
24422460
if let [r, g, b] = *nums {

pad/editor/src/utils.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,6 +1629,13 @@ pub fn set_gayness(gayness: Gayness) {
16291629
_ = window().location().reload();
16301630
}
16311631

1632+
pub fn get_rgb_bindings() -> bool {
1633+
get_local_var("rgb-bindings", || true)
1634+
}
1635+
pub fn set_rgb_bindings(rgb_bindings: bool) {
1636+
set_local_var("rgb-bindings", rgb_bindings);
1637+
}
1638+
16321639
fn update_style() {
16331640
let font_name = get_font_name();
16341641
let font_size = get_font_size();

0 commit comments

Comments
 (0)