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
155 changes: 97 additions & 58 deletions crates/rnote-ui/data/ui/penssidebar/shaperpage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@
</style>
</object>
</child>
<child>
<object class="GtkMenuButton" id="shaperextra_menubutton">
<property name="icon-name">misc-menu-symbolic</property>
<property name="direction">left</property>
<property name="tooltip_text" translatable="yes">Shaper Extra</property>
<property name="popover">shaperextra_popover</property>
<style>
<class name="flat" />
</style>
</object>
</child>
</object>
</child>
<child>
Expand Down Expand Up @@ -126,35 +137,6 @@
</object>
</child>

<!-- Highlighting -->
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Highlighting</property>
<child>
<object class="AdwSwitchRow" id="highlight_mode_row">
<property name="title" translatable="yes">Highlight-Mode</property>
<property name="subtitle" translatable="yes">Fade active color</property>
</object>
</child>
<child>
<object class="AdwSpinRow" id="highlight_opacity_row">
<property name="title" translatable="yes">Highlight-Opacity</property>
<property name="subtitle" translatable="yes">Modify the highlight opacity (%)</property>
<property name="adjustment">
<object class="GtkAdjustment">
<property name="lower">0</property>
<property name="upper">100</property>
<property name="value">50</property>
<property name="step-increment">1</property>
</object>
</property>
<property name="numeric">true</property>
<property name="digits">0</property>
</object>
</child>
</object>
</child>

<!-- Smooth options -->
<child>
<object class="AdwPreferencesGroup" id="smoothstyle_group">
Expand Down Expand Up @@ -234,41 +216,98 @@
</child>
</object>
</child>
</object>
</child>
</object>

<!-- Shaper Extra -->
<object class="GtkPopover" id="shaperextra_popover">
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<property name="margin-start">6</property>
<property name="margin-end">6</property>
<property name="spacing">12</property>
<property name="width-request">300</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Shaper Extra</property>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about a simple

Shape Configuration (2/2)

and adding a (1/2) on the first page.

Though at that point a next/previous page navigation makes more sense.

Maybe a nagivation view can work inside of the popover ? https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.7/class.NavigationView.html

<property name="hexpand">true</property>
<property name="halign">center</property>
<style>
<class name="title-3" />
</style>
</object>
</child>
<child>
<object class="GtkButton" id="shaperextra_popover_close_button">
<property name="icon-name">window-close-symbolic</property>
<style>
<class name="flat" />
<class name="circular" />
</style>
</object>
</child>
</object>
</child>

<!-- Highlighting -->
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Highlighting</property>
<child>
<object class="AdwSwitchRow" id="highlight_mode_row">
<property name="title" translatable="yes">Highlight-Mode</property>
<property name="subtitle" translatable="yes">Fade active color</property>
</object>
</child>
<child>
<object class="AdwSpinRow" id="highlight_opacity_row">
<property name="title" translatable="yes">Highlight-Opacity</property>
<property name="subtitle" translatable="yes">Modify the highlight opacity (%)</property>
<property name="adjustment">
<object class="GtkAdjustment">
<property name="lower">0</property>
<property name="upper">100</property>
<property name="value">50</property>
<property name="step-increment">1</property>
</object>
</property>
<property name="numeric">true</property>
<property name="digits">0</property>
</object>
</child>
</object>
</child>

<!-- Constraints -->
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Constraints</property>
<child>
<object class="GtkListBox">
<property name="width-request">300</property>
<property name="selection-mode">none</property>
<style>
<class name="content" />
<class name="medium" />
</style>
<child>
<object class="AdwSwitchRow" id="constraint_enabled_row">
<property name="title" translatable="yes">Enabled</property>
<property name="subtitle" translatable="yes">Hold Ctrl to temporarily enable/disable
<object class="AdwSwitchRow" id="constraint_enabled_row">
<property name="title" translatable="yes">Enabled</property>
<property name="subtitle" translatable="yes">Hold Ctrl to temporarily enable/disable
constraints when this switch is off/on</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="constraint_one_to_one_row">
<property name="title" translatable="yes">1:1</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="constraint_three_to_two_row">
<property name="title" translatable="yes">3:2</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="constraint_golden_row">
<property name="title" translatable="yes">Golden Ratio (1:1.618)</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="constraint_one_to_one_row">
<property name="title" translatable="yes">1:1</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="constraint_three_to_two_row">
<property name="title" translatable="yes">3:2</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="constraint_golden_row">
<property name="title" translatable="yes">Golden Ratio (1:1.618)</property>
</object>
</child>
</object>
Expand Down Expand Up @@ -319,4 +358,4 @@ constraints when this switch is off/on</property>
</child>
</object>
</template>
</interface>
</interface>
5 changes: 5 additions & 0 deletions crates/rnote-ui/src/appwindow/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,11 @@ impl RnAppWindow {
.shaper_page()
.shapeconfig_menubutton()
.set_direction(ArrowType::Right);
obj.overlays()
.penssidebar()
.shaper_page()
.shaperextra_menubutton()
.set_direction(ArrowType::Right);
obj.overlays()
.penssidebar()
.shaper_page()
Expand Down
143 changes: 82 additions & 61 deletions crates/rnote-ui/src/penssidebar/shaperpage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ mod imp {
#[template_child]
pub(crate) shaperstyle_rough_row: TemplateChild<adw::ActionRow>,
#[template_child]
pub(crate) highlight_mode_row: TemplateChild<adw::SwitchRow>,
#[template_child]
pub(crate) highlight_opacity_row: TemplateChild<adw::SpinRow>,
#[template_child]
pub(crate) smoothstyle_group: TemplateChild<adw::PreferencesGroup>,
#[template_child]
pub(crate) smoothstyle_line_cap_row: TemplateChild<adw::ComboRow>,
Expand All @@ -59,6 +55,17 @@ mod imp {
pub(crate) roughstyle_fillstyle_row: TemplateChild<adw::ComboRow>,
#[template_child]
pub(crate) roughstyle_hachure_angle_row: TemplateChild<adw::SpinRow>,

#[template_child]
pub(crate) shaperextra_menubutton: TemplateChild<MenuButton>,
#[template_child]
pub(crate) shaperextra_popover: TemplateChild<Popover>,
#[template_child]
pub(crate) shaperextra_popover_close_button: TemplateChild<Button>,
#[template_child]
pub(crate) highlight_mode_row: TemplateChild<adw::SwitchRow>,
#[template_child]
pub(crate) highlight_opacity_row: TemplateChild<adw::SpinRow>,
#[template_child]
pub(crate) constraint_enabled_row: TemplateChild<adw::SwitchRow>,
#[template_child]
Expand Down Expand Up @@ -124,6 +131,10 @@ impl RnShaperPage {
self.imp().shapeconfig_menubutton.get()
}

pub(crate) fn shaperextra_menubutton(&self) -> MenuButton {
self.imp().shaperextra_menubutton.get()
}

pub(crate) fn shapebuildertype_menubutton(&self) -> MenuButton {
self.imp().shapebuildertype_menubutton.get()
}
Expand Down Expand Up @@ -184,6 +195,7 @@ impl RnShaperPage {
pub(crate) fn init(&self, appwindow: &RnAppWindow) {
let imp = self.imp();
let shapeconfig_popover = imp.shapeconfig_popover.get();
let shaperextra_popover = imp.shaperextra_popover.get();
let shapebuildertype_popover = imp.shapebuildertype_popover.get();

// Popovers
Expand All @@ -195,6 +207,14 @@ impl RnShaperPage {
}
));

imp.shaperextra_popover_close_button.connect_clicked(clone!(
#[weak]
shaperextra_popover,
move |_| {
shaperextra_popover.popdown();
}
));

imp.shapebuildertype_popover_close_button
.connect_clicked(clone!(
#[weak]
Expand Down Expand Up @@ -301,33 +321,6 @@ impl RnShaperPage {
}
));

// Highlighter options
imp.highlight_mode_row.connect_active_notify(clone!(
#[weak]
appwindow,
move |row| {
appwindow
.engine_config()
.write()
.pens_config
.shaper_config
.highlight_mode = row.is_active();
}
));

imp.highlight_opacity_row.connect_changed(clone!(
#[weak]
appwindow,
move |row| {
appwindow
.engine_config()
.write()
.pens_config
.shaper_config
.highlight_opacity = row.value().round() / 100.0;
}
));

// Smooth style
// Line cap
imp.smoothstyle_line_cap_row
Expand Down Expand Up @@ -428,37 +421,33 @@ impl RnShaperPage {
}
));

// shape builder type
imp.shapebuildertype_picker.set_groups(
shape_builder_type_icons_get_groups(),
shape_builder_type_icons_to_display_name,
);
// Shaper extra
// Highlighter options
imp.highlight_mode_row.connect_active_notify(clone!(
#[weak]
appwindow,
move |row| {
appwindow
.engine_config()
.write()
.pens_config
.shaper_config
.highlight_mode = row.is_active();
}
));

imp.shapebuildertype_picker.connect_notify_local(
Some("picked"),
clone!(
#[weak(rename_to=shaperpage)]
self,
#[weak]
appwindow,
move |picker, _| {
if let Some(buildertype) = shaperpage.shapebuildertype()
&& let Some(icon_name) = picker.picked()
{
appwindow
.engine_config()
.write()
.pens_config
.shaper_config
.builder_type = buildertype;
shaperpage
.imp()
.shapebuildertype_menubutton
.set_icon_name(&icon_name);
}
}
),
);
imp.highlight_opacity_row.connect_changed(clone!(
#[weak]
appwindow,
move |row| {
appwindow
.engine_config()
.write()
.pens_config
.shaper_config
.highlight_opacity = row.value().round() / 100.0;
}
));

// Constraints
imp.constraint_enabled_row
Expand Down Expand Up @@ -560,6 +549,38 @@ impl RnShaperPage {
}
}
));

// shape builder type
imp.shapebuildertype_picker.set_groups(
shape_builder_type_icons_get_groups(),
shape_builder_type_icons_to_display_name,
);

imp.shapebuildertype_picker.connect_notify_local(
Some("picked"),
clone!(
#[weak(rename_to=shaperpage)]
self,
#[weak]
appwindow,
move |picker, _| {
if let Some(buildertype) = shaperpage.shapebuildertype()
&& let Some(icon_name) = picker.picked()
{
appwindow
.engine_config()
.write()
.pens_config
.shaper_config
.builder_type = buildertype;
shaperpage
.imp()
.shapebuildertype_menubutton
.set_icon_name(&icon_name);
}
}
),
);
}

pub(crate) fn refresh_ui(&self, appwindow: &RnAppWindow) {
Expand Down