Skip to content
Open
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
1 change: 1 addition & 0 deletions crates/rnote-ui/src/appwindow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ impl RnAppWindow {
// Anything that needs to be done right before showing the appwindow

self.refresh_ui();
imp.sidebar.get().activate_doc_settings_buttons();
}

fn setup_icon_theme(&self) {
Expand Down
62 changes: 59 additions & 3 deletions crates/rnote-ui/src/settingspanel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,7 @@ impl RnSettingsPanel {
}
));

imp.doc_show_format_borders_row.set_sensitive(false);
imp.doc_show_format_borders_row
.connect_active_notify(clone!(
#[weak]
Expand All @@ -860,13 +861,17 @@ impl RnSettingsPanel {
.sync_create()
.build();

imp.doc_format_border_color_button.set_sensitive(false);
imp.doc_format_border_color_button
.connect_rgba_notify(clone!(
#[weak(rename_to=settingspanel)]
self,
#[weak]
appwindow,
move |button| {
if !button.get_sensitive() {
return;
}
let format_border_color = button.rgba().into_compose_color();
let Some(canvas) = appwindow.active_tab_canvas() else {
return;
Expand All @@ -892,10 +897,14 @@ impl RnSettingsPanel {
}
));

imp.doc_background_color_button.set_sensitive(false);
imp.doc_background_color_button.connect_rgba_notify(clone!(
#[weak]
appwindow,
move |button| {
if !button.get_sensitive() {
return;
}
let background_color = button.rgba().into_compose_color();
let Some(canvas) = appwindow.active_tab_canvas() else {
return;
Expand All @@ -917,14 +926,18 @@ impl RnSettingsPanel {
}
));

imp.doc_document_layout_row.set_sensitive(false);
imp.doc_document_layout_row
.get()
.connect_selected_item_notify(clone!(
#[weak(rename_to=settings_panel)]
self,
#[weak]
appwindow,
move |_| {
move |row| {
if !row.get_sensitive() {
return;
}
let document_layout = settings_panel.document_layout();
let Some(canvas) = appwindow.active_tab_canvas() else {
return;
Expand All @@ -944,14 +957,18 @@ impl RnSettingsPanel {
}
));

imp.doc_background_patterns_row.set_sensitive(false);
imp.doc_background_patterns_row
.get()
.connect_selected_item_notify(clone!(
#[weak(rename_to=settings_panel)]
self,
#[weak]
appwindow,
move |_| {
move |row| {
if !row.get_sensitive() {
return;
}
let pattern = settings_panel.background_pattern();
let Some(canvas) = appwindow.active_tab_canvas() else {
return;
Expand Down Expand Up @@ -1030,11 +1047,15 @@ impl RnSettingsPanel {
}
));

imp.doc_background_pattern_color_button.set_sensitive(false);
imp.doc_background_pattern_color_button
.connect_rgba_notify(clone!(
#[weak]
appwindow,
move |button| {
if !button.get_sensitive() {
return;
}
let Some(canvas) = appwindow.active_tab_canvas() else {
return;
};
Expand All @@ -1058,6 +1079,8 @@ impl RnSettingsPanel {
}
));

imp.doc_background_pattern_width_unitentry
.set_sensitive(false);
imp.doc_background_pattern_width_unitentry
.get()
.connect_notify_local(
Expand All @@ -1066,6 +1089,9 @@ impl RnSettingsPanel {
#[weak]
appwindow,
move |unit_entry, _| {
if !unit_entry.get_sensitive() {
return;
}
let Some(canvas) = appwindow.active_tab_canvas() else {
return;
};
Expand All @@ -1092,6 +1118,8 @@ impl RnSettingsPanel {
),
);

imp.doc_background_pattern_height_unitentry
.set_sensitive(false);
imp.doc_background_pattern_height_unitentry
.get()
.connect_notify_local(
Expand All @@ -1100,6 +1128,9 @@ impl RnSettingsPanel {
#[weak]
appwindow,
move |unit_entry, _| {
if !unit_entry.get_sensitive() {
return;
}
let Some(canvas) = appwindow.active_tab_canvas() else {
return;
};
Expand Down Expand Up @@ -1144,12 +1175,17 @@ impl RnSettingsPanel {
}
));

imp.background_pattern_invert_color_button
.set_sensitive(false);
imp.background_pattern_invert_color_button
.get()
.connect_clicked(clone!(
#[weak]
appwindow,
move |_| {
move |button| {
if !button.get_sensitive() {
return;
}
let Some(canvas) = appwindow.active_tab_canvas() else {
return;
};
Expand Down Expand Up @@ -1184,6 +1220,26 @@ impl RnSettingsPanel {
));
}

// All relevant buttons are set as sensitive : false upon startup
// until the first tab is added. This way setting the correct values
// in the doc part of the settings won't send back a widget flag
// that modifies the store
pub fn activate_doc_settings_buttons(&self) {
let imp = self.imp();
imp.doc_show_format_borders_row.set_sensitive(true);
imp.doc_format_border_color_button.set_sensitive(true);
imp.doc_background_color_button.set_sensitive(true);
imp.doc_document_layout_row.set_sensitive(true);
imp.doc_background_patterns_row.set_sensitive(true);
imp.doc_background_pattern_color_button.set_sensitive(true);
imp.doc_background_pattern_width_unitentry
.set_sensitive(true);
imp.doc_background_pattern_height_unitentry
.set_sensitive(true);
imp.background_pattern_invert_color_button
.set_sensitive(true);
}

fn setup_shortcuts(&self, appwindow: &RnAppWindow) {
let imp = self.imp();
let penshortcut_stylus_button_primary_row = imp.penshortcut_stylus_button_primary_row.get();
Expand Down
6 changes: 6 additions & 0 deletions crates/rnote-ui/src/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,10 @@ impl RnSidebar {
}
));
}

pub(crate) fn activate_doc_settings_buttons(&self) {
let imp = self.imp();

imp.settings_panel.get().activate_doc_settings_buttons();
}
}