Brush smoothing factor added to settings
This commit is contained in:
parent
533d54be82
commit
24b2be60e5
7 changed files with 20 additions and 3 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ nlohmann::json GlobalConfig::get_config_json(const InputManager& input) const {
|
|||
#endif
|
||||
|
||||
json tablet;
|
||||
tablet["brushPressureSmoothingFactor"] = tabletOptions.brushPressureSmoothingFactor;
|
||||
tablet["pressureAffectsBrushWidth"] = tabletOptions.pressureAffectsBrushWidth;
|
||||
tablet["middleClickButton"] = tabletOptions.middleClickButton;
|
||||
tablet["rightClickButton"] = tabletOptions.rightClickButton;
|
||||
|
|
@ -136,6 +137,7 @@ void GlobalConfig::set_config_json(InputManager& input, const nlohmann::json& j,
|
|||
#endif
|
||||
try{j.at("antialiasing").get_to(antialiasing);} catch(...) {}
|
||||
|
||||
try{j.at("tablet").at("brushPressureSmoothingFactor").get_to(tabletOptions.brushPressureSmoothingFactor);} catch(...) {}
|
||||
try{j.at("tablet").at("pressureAffectsBrushWidth").get_to(tabletOptions.pressureAffectsBrushWidth);} catch(...) {}
|
||||
try{j.at("tablet").at("middleClickButton").get_to(tabletOptions.middleClickButton);} catch(...) {}
|
||||
try{j.at("tablet").at("rightClickButton").get_to(tabletOptions.rightClickButton);} catch(...) {}
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ class GlobalConfig {
|
|||
bool ignoreMouseMovementWhenPenInProximity = false;
|
||||
bool disableTouchWhenPenInProximity = false;
|
||||
float brushMinimumSize = 0.0f;
|
||||
float brushPressureSmoothingFactor = 0.707f;
|
||||
bool zoomWhilePenDownAndButtonHeld = true;
|
||||
} tabletOptions;
|
||||
|
||||
|
|
|
|||
|
|
@ -942,6 +942,7 @@ void FileSelectScreen::settings_view() {
|
|||
checkbox_boolean_field(gui, "disable touch when pen in proximity", "Disable touch when pen in proximity", &main.conf.tabletOptions.disableTouchWhenPenInProximity);
|
||||
checkbox_boolean_field(gui, "make all tools share same size", "Make all tools share size", &main.toolConfig.globalConf.useGlobalRelativeWidth);
|
||||
slider_scalar_field(gui, "tablet brush minimum size", "Brush relative minimum size", &main.conf.tabletOptions.brushMinimumSize, 0.0f, 1.0f, {.decimalPrecision = 3});
|
||||
slider_scalar_field(gui, "tablet brush pressure smoothing factor", "Brush pressure smoothing factor", &main.conf.tabletOptions.brushPressureSmoothingFactor, 0.0f, 1.0f, {.decimalPrecision = 3});
|
||||
checkbox_boolean_field(gui, "pen pressure width", "Pen pressure affects brush size", &main.conf.tabletOptions.pressureAffectsBrushWidth);
|
||||
#ifndef __ANDROID__
|
||||
checkbox_boolean_field(gui, "use mobile UI", "Use mobile UI (requires restart)", &main.conf.mobileUI);
|
||||
|
|
|
|||
|
|
@ -1593,6 +1593,7 @@ void Toolbar::general_settings_inner_gui() {
|
|||
input_scalar_field<uint8_t>(gui, "middle click", "Middle click pen button", &main.conf.tabletOptions.middleClickButton, 1, 255);
|
||||
input_scalar_field<uint8_t>(gui, "right click", "Right click pen button", &main.conf.tabletOptions.rightClickButton, 1, 255);
|
||||
slider_scalar_field(gui, "tablet brush minimum size", "Brush relative minimum size", &main.conf.tabletOptions.brushMinimumSize, 0.0f, 1.0f, {.decimalPrecision = 3});
|
||||
slider_scalar_field(gui, "tablet brush pressure smoothing factor", "Brush pressure smoothing factor", &main.conf.tabletOptions.brushPressureSmoothingFactor, 0.0f, 1.0f, {.decimalPrecision = 3});
|
||||
checkbox_boolean_field(gui, "tablet zoom with button method", "Zoom when pen touching tablet and pen button assigned to middle click is held", &main.conf.tabletOptions.zoomWhilePenDownAndButtonHeld);
|
||||
#ifdef _WIN32
|
||||
checkbox_boolean_field(gui, "mouse ignore when pen proximity", "Ignore mouse movement when pen in proximity", &main.conf.tabletOptions.ignoreMouseMovementWhenPenInProximity);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue