Add option to restrict color picker to window

This commit is contained in:
arch1t3cht 2022-07-18 20:20:24 +02:00
parent 238dbb386d
commit 2c296afdb8
4 changed files with 22 additions and 7 deletions

View File

@ -386,15 +386,21 @@ void ColorPickerScreenDropper::DropFromScreenXY(int x, int y) {
wxMemoryDC capdc(capture);
capdc.SetPen(*wxTRANSPARENT_PEN);
#ifndef __WXMAC__
wxWindow *superparent = GetParent();
while (superparent->GetParent() != nullptr) {
superparent = superparent->GetParent();
}
superparent->ScreenToClient(&x, &y);
std::unique_ptr<wxDC> screen;
wxWindowDC screen(superparent);
if (!OPT_GET("Tool/Color Picker/Restrict to Window")->GetBool()) {
screen = agi::make_unique<wxScreenDC>();
} else {
wxWindow *superparent = GetParent();
while (superparent->GetParent() != nullptr) {
superparent = superparent->GetParent();
}
superparent->ScreenToClient(&x, &y);
screen = agi::make_unique<wxWindowDC>(superparent);
}
capdc.StretchBlit(0, 0, resx * magnification, resy * magnification,
&screen, x - resx / 2, y - resy / 2, resx, resy);
screen.get(), x - resx / 2, y - resy / 2, resx, resy);
#else
// wxScreenDC doesn't work on recent versions of OS X so do it manually

View File

@ -573,6 +573,9 @@
"Maximized" : false,
"Skip Whitespace" : true
},
"Color Picker" : {
"Restrict to Window" : false
},
"Visual" : {
"Autohide": false
}

View File

@ -573,6 +573,9 @@
"Maximized" : false,
"Skip Whitespace" : true
},
"Color Picker" : {
"Restrict to Window" : false
},
"Visual" : {
"Autohide": false
}

View File

@ -228,6 +228,9 @@ void Interface(wxTreebook *book, Preferences *parent) {
auto tl_assistant = p->PageSizer(_("Translation Assistant"));
p->OptionAdd(tl_assistant, _("Skip over whitespace"), "Tool/Translation Assistant/Skip Whitespace");
auto color_picker = p->PageSizer(_("Color Picker"));
p->OptionAdd(color_picker, _("Restrict Screen Picker to Window"), "Tool/Color Picker/Restrict to Window");
p->SetSizerAndFit(p->sizer);
}