Improve change stroke color performance

This commit is contained in:
Yousef Khadadeh 2026-05-18 20:33:06 +03:00
parent 04e9180fe8
commit a13c96ce0a
2 changed files with 11 additions and 2 deletions

View file

@ -187,10 +187,10 @@ void DrawingProgramSelection::update_selection_stroke_color() {
if(c->obj->get_comp().get_stroke_color() != std::nullopt) {
strokeColorChangeData.oldColorData.emplace(c->obj.get_net_id(), c->obj->get_comp().get_stroke_color().value());
c->obj->get_comp().change_stroke_color(strokeColorChangeData.newColor);
c->obj->commit_update_dont_invalidate_cache(drawP); // Object isn't in the cache since it's selected
c->obj->send_comp_update(drawP, false);
c->obj->send_comp_update(drawP, false); // Might be deselected, so make sure to send update before its deselected
}
}
commitChangeColorUpdate = true;
strokeColorChangeData.oldColor = strokeColorChangeData.newColor;
}
}
@ -480,6 +480,13 @@ void DrawingProgramSelection::commit_transform_selection() {
}
void DrawingProgramSelection::update() {
if(commitChangeColorUpdate) {
for(auto& c : selectedSet) {
if(c->obj->get_comp().get_stroke_color() != std::nullopt)
c->obj->commit_update_dont_invalidate_cache(drawP); // Object isn't in the cache since it's selected
}
commitChangeColorUpdate = false;
}
}
void DrawingProgramSelection::input_key_callback_modify_selection(const InputManager::KeyCallbackArgs& key) {

View file

@ -56,6 +56,8 @@ class DrawingProgramSelection {
void input_mouse_button_on_canvas_callback_modify_selection(const InputManager::MouseButtonCallbackArgs& button);
void input_mouse_motion_callback_modify_selection(const InputManager::MouseMotionCallbackArgs& motion);
private:
bool commitChangeColorUpdate = false;
void phone_bottom_toolbar_gui(PhoneDrawingProgramScreen& t);
void translate_key(unsigned keyPressed, bool pressed);
bool mouse_collided_with_selection_aabb();