Brush smoothing factor added to settings

This commit is contained in:
Yousef Khadadeh 2026-05-16 20:40:23 +03:00
parent 533d54be82
commit 24b2be60e5
7 changed files with 20 additions and 3 deletions

View file

@ -30,7 +30,6 @@
#include "../../GUIStuff/ElementHelpers/CheckBoxHelpers.hpp"
#define MINIMUM_DISTANCE_TO_NEXT_POINT 0.002f
#define SMOOTH_FACTOR 0.707f
#define DRAW_MINIMUM_LIMIT 1.0f
BrushTool::BrushTool(DrawingProgram& initDrawP):
@ -171,7 +170,7 @@ void BrushTool::input_mouse_motion_callback(const InputManager::MouseMotionCallb
}
}
smooth_out_points(SMOOTH_FACTOR);
smooth_out_points(drawP.world.main.conf.tabletOptions.brushPressureSmoothingFactor);
containerPtr->send_comp_update(drawP, false);
containerPtr->commit_update(drawP);
}
@ -190,7 +189,7 @@ void BrushTool::input_pen_axis_callback(const InputManager::PenAxisCallbackArgs&
auto& brushPoints = *brushStroke.d.points;
float width = toolConfig.get_relative_width_stroke_size(drawP, containerPtr->coords.inverseScale).first.value() * penWidth;
brushPoints.back().width = std::max(brushPoints.back().width, width);
smooth_out_points(SMOOTH_FACTOR);
smooth_out_points(drawP.world.main.conf.tabletOptions.brushPressureSmoothingFactor);
containerPtr->send_comp_update(drawP, false);
containerPtr->commit_update(drawP);
}

View file

@ -69,6 +69,7 @@ void TextBoxTool::input_mouse_button_on_canvas_callback(const InputManager::Mous
objInfoBeingEdited = drawP.layerMan.add_component_to_layer_being_edited(newContainer);
}
else if(!button.down && objInfoBeingEdited) {
make_sure_textbox_is_big();
auto editTool = std::make_unique<EditTool>(drawP);
editTool->edit_start(objInfoBeingEdited, false);
drawP.toolToSwitchToAfterUpdate = std::move(editTool);
@ -96,6 +97,16 @@ void TextBoxTool::input_mouse_motion_callback(const InputManager::MouseMotionCal
}
}
void TextBoxTool::make_sure_textbox_is_big() {
if(objInfoBeingEdited) {
const Vector2f TEXTBOX_MINIMUM_DIMENSIONS{200.0f, 100.0f};
NetworkingObjects::NetObjOwnerPtr<CanvasComponentContainer>& containerPtr = objInfoBeingEdited->obj;
TextBoxCanvasComponent& textBox = static_cast<TextBoxCanvasComponent&>(containerPtr->get_comp());
if(vec_distance(textBox.d.p1, textBox.d.p2) < 20.0f)
textBox.d.p2 = textBox.d.p1 + TEXTBOX_MINIMUM_DIMENSIONS;
}
}
void TextBoxTool::erase_component(CanvasComponentContainer::ObjInfo* erasedComp) {
if(objInfoBeingEdited == erasedComp)
objInfoBeingEdited = nullptr;
@ -119,6 +130,7 @@ bool TextBoxTool::prevent_undo_or_redo() {
void TextBoxTool::commit() {
if(objInfoBeingEdited) {
NetworkingObjects::NetObjOwnerPtr<CanvasComponentContainer>& containerPtr = objInfoBeingEdited->obj;
make_sure_textbox_is_big();
containerPtr->commit_update(drawP);
containerPtr->send_comp_update(drawP, true);
drawP.layerMan.add_undo_place_component(objInfoBeingEdited);

View file

@ -39,6 +39,7 @@ class TextBoxTool : public DrawingProgramToolBase {
virtual void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion) override;
private:
void commit();
void make_sure_textbox_is_big();
Vector2f startAt;
Vector2f endAt;