Skip to content
Merged
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
4 changes: 4 additions & 0 deletions src/femtovg_area/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,8 @@ impl FemtoVGArea {
//trigger resize to reset
self.imp().resize(0, 0);
}

pub fn resize(&self, width: i32, height: i32) {
self.imp().resize(width, height);
}
}
20 changes: 18 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ enum AppInput {
ToggleToolbarsDisplay,
ToolSwitchShortcut(Tools),
ColorSwitchShortcut(u64),
ScaleFactorChanged,
}

#[derive(Debug)]
Expand Down Expand Up @@ -231,6 +232,11 @@ impl Component for App {
ui::toolbars::ColorButtons::Palette(index),
));
}
AppInput::ScaleFactorChanged => {
self.sketch_board
.sender()
.emit(SketchBoardInput::ScaleFactorChanged);
}
}
}

Expand Down Expand Up @@ -290,17 +296,27 @@ impl Component for App {
if APP_CONFIG.read().focus_toggles_toolbars() {
let motion_controller = gtk::EventControllerMotion::builder().build();
let sender_clone = sender.clone();
let sender_clone2 = sender.clone();

motion_controller.connect_enter(move |_, _, _| {
sender.input(AppInput::SetToolbarsDisplay(true));
sender_clone.input(AppInput::SetToolbarsDisplay(true));
});
motion_controller.connect_leave(move |_| {
sender_clone.input(AppInput::SetToolbarsDisplay(false));
sender_clone2.input(AppInput::SetToolbarsDisplay(false));
});

root.add_controller(motion_controller);
}

root.connect_map(move |r| {
let sender_clone3 = sender.clone();
if let Some(surface) = r.surface() {
surface.connect_notify_local(Some("scale-factor"), move |_, _| {
sender_clone3.input(AppInput::ScaleFactorChanged);
});
}
});

generate_profile_output!("app init end");

glib::idle_add_local_once(move || {
Expand Down
5 changes: 5 additions & 0 deletions src/sketch_board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub enum SketchBoardInput {
CommitEvent(TextEventMsg),
Refresh,
Exit,
ScaleFactorChanged,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -1116,6 +1117,10 @@ impl Component for SketchBoard {
self.handle_exit();
ToolUpdateResult::Unmodified
}
SketchBoardInput::ScaleFactorChanged => {
self.renderer.resize(0, 0);
Copy link
Member

Choose a reason for hiding this comment

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

this is 0,0?

Copy link
Member Author

Choose a reason for hiding this comment

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

resize(0,0) in femtovg_area/imp.rs will use the image width and height.

Copy link
Member

Choose a reason for hiding this comment

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

that behaviour could be more explicit, but okay ;)

ToolUpdateResult::Redraw
}
};

// println!(" Result={:?}", result);
Expand Down