Skip to content

Commit

Permalink
Apply image scale operations to multiple cells (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiolo committed Dec 20, 2022
1 parent 178a1c3 commit f83d726
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions src/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,32 @@ struct Document {
selected.HomeEnd(this, dc, k == A_HOME || k == A_CHOME);
return nullptr;


case A_IMAGESCP:
case A_IMAGESCF: {
long v = 0;
loopallcellssel(c, true) {
if(c->text.image) {
if(!v) {
v = wxGetNumberFromUser(
_(L"Please enter the percentage you want the image scaled by:"), L"%",
_(L"Image Resize"), 50, 5, 400, sys->frame);
if (v < 0) return nullptr;
}
auto sc = v / 100.0;
if (k == A_IMAGESCP) {
c->text.image->BitmapScale(sc);
} else {
c->text.image->DisplayScale(sc);
}
c->ResetLayout();
}
}
Refresh();
return nullptr;
}


case A_IMAGESCN: {
loopallcellssel(c, true)
if (c->text.image) {
Expand Down Expand Up @@ -1579,24 +1605,6 @@ struct Document {
return CopyImageToClipboard(c);
}

case A_IMAGESCP:
case A_IMAGESCF: {
if (!c->text.image) return _(L"No image in this cell.");
long v = wxGetNumberFromUser(
_(L"Please enter the percentage you want the image scaled by:"), L"%",
_(L"Image Resize"), 50, 5, 400, sys->frame);
if (v < 0) return nullptr;
auto sc = v / 100.0;
if (k == A_IMAGESCP) {
c->text.image->BitmapScale(sc);
} else {
c->text.image->DisplayScale(sc);
}
c->ResetLayout();
Refresh();
return nullptr;
}

case A_ENTERGRID:
if (!c->grid) Action(dc, A_NEWGRID);
selected = Selection(c->grid, 0, 0, 1, 1);
Expand Down

0 comments on commit f83d726

Please sign in to comment.