Release v0.6.54: adjustable pencil smoothing and unsaved settings state

This commit is contained in:
agrynco committed 2026-11-06 14:46:53 +02:00
1 parent 727dc96908
commit 63b7b879a3
14 files changed
+318 -18

No files matched your search

+47
View File
@@ -83,6 +83,53 @@ int main(int argc, char **argv)
require(c.pencilCursor!=nullptr,"pencil drawing cursor loads");
require(c.freehand && !c.pointer && ks::toolCursor(c)==c.pencilCursor,
"new screenshot editor starts with the pencil tool");
{
require(GetDlgItem(window,41) && GetDlgItem(window,44),"smoothing slider and Apply to all exist");
auto adjust=[&](int value,int code=TB_THUMBPOSITION) {
SendDlgItemMessageW(window,41,TBM_SETPOS,TRUE,value);
SendMessageW(window,WM_HSCROLL,MAKEWPARAM(code,0),(LPARAM)GetDlgItem(window,41));
};
adjust(70); require(c.smoothing==70 && c.marks.empty(),"no selection changes default smoothing");
ks::Mark pencil{{40,80},{240,80},0}; pencil.freehand=true;
for(int i=0;i<=100;++i) pencil.points.push_back({40+i*2,80+(i%2?5:0)});
ks::Mark rectangle{{40,130},{240,210},0}; rectangle.shape=ks::ScreenshotShape::Rectangle;
c.marks={pencil,pencil,rectangle}; c.selected=0;
auto rawImage=ks::decodeImage(ks::screenshotClip(c.image->dc,320,240,c.marks)).bgra;
adjust(40,TB_THUMBTRACK); adjust(90,TB_THUMBTRACK); adjust(90,TB_ENDTRACK);
require(c.marks[0].smoothing==90 && c.marks[1].smoothing==0 && c.smoothing==70,
"selected stroke smoothing leaves other objects and default alone");
SendMessageW(window,WM_COMMAND,12,0);
require(c.marks[0].smoothing==0,"one undo reverses an entire slider drag");
SendMessageW(window,WM_COMMAND,18,0);
require(c.marks[0].smoothing==90,"redo restores smoothing amount and path");
c.selected=0; ks::syncLineOptions(window,c);
SendMessageW(window,WM_COMMAND,44,0);
require(c.marks[0].smoothing==90 && c.marks[1].smoothing==90 && c.smoothing==90 &&
c.marks[2].shape==ks::ScreenshotShape::Rectangle && c.marks[2].rawPoints.empty(),
"Apply to all updates pencil strokes and default without changing shapes");
require(ks::decodeImage(ks::screenshotClip(c.image->dc,320,240,c.marks)).bgra!=rawImage,
"PNG export uses the smoothed geometry");
SendMessageW(window,WM_COMMAND,12,0);
require(c.marks[0].smoothing==90 && c.marks[1].smoothing==0,"bulk smoothing is one undo step");
c.selected=0; adjust(0);
require(c.marks[0].points.size()==pencil.points.size() && c.marks[0].points[1].y==85,
"selected zero smoothing restores exact original path");
require(ks::decodeImage(ks::screenshotClip(c.image->dc,320,240,c.marks)).bgra==rawImage,
"restoring zero smoothing restores the exact original exported pixels");
c.marks.clear(); c.selected=-1; c.history=ks::ScreenshotHistory{};
adjust(75);
auto mouse=[&](UINT message,POINT p) {
int x=c.view.left+MulDiv(p.x,c.view.right-c.view.left,c.image->width);
int y=c.view.top+MulDiv(p.y,c.view.bottom-c.view.top,c.image->height);
SendMessageW(window,message,message==WM_LBUTTONUP?0:MK_LBUTTON,MAKELPARAM(x,y));
};
mouse(WM_LBUTTONDOWN,{40,90});
for(int i=1;i<=100;++i) mouse(WM_MOUSEMOVE,{40+i*2,90+LONG(std::lround(35*std::sin(i*.04)+3*std::sin(i*1.7)))});
mouse(WM_LBUTTONUP,{240,64});
require(c.marks.size()==1 && c.marks[0].freehand && c.marks[0].smoothing==75 && !c.marks[0].rawPoints.empty(),
"new curved pencil stroke uses toolbar default and retains original samples");
c.marks.clear(); c.selected=-1; c.history=ks::ScreenshotHistory{}; c.smoothing=25;
}
{
require(GetDlgItem(window,36)!=nullptr,"triangle has a dedicated toolbar button");
SendMessageW(window,WM_KEYDOWN,'G',0);