-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crop module gets orientation proxy support #17888
base: master
Are you sure you want to change the base?
Crop module gets orientation proxy support #17888
Conversation
Note: no support for the lighttable "actions on selections" button and not planned from my side. |
ecc457d
to
6f00a40
Compare
We must call gui_changed() at the end of gui_update() to ensure a new history if parameters changed, UI symptoms possible were subtly wrong slider soft min/max. While checking some minor cleanup - g->cropping should be _grab_region_t instead of int and be initialized as that - deduplicate updating sliders in _update_sliders_and_limit()
2de7071
to
12e3a19
Compare
While developing an image in darkroom we might have set a cropping area, this commit implements functionality to keep the cropped area if we change orientation via the flip module. Three parts in the codebase required additions without changing existing code. 1. `dt_develop_t` got two additions in cropping proxy, `struct dt_iop_module_t *flip_handler` points to the crop module and is setup there. We can't use `exposer` as the proxy because that is dynamically set in pixelpipe code only if enabled and we want to change crop parameters even if crop is disabled. `void (*flip_callback)` is the callback function changing crop parameters, defined in crop. 2. Orientation module uses the `flip_callback(self, orientation)` requesting changes in crop. 3. In crop we have `_crop_handle_flip()` as proxy `flip_callback` with proper logs about action. - It gets the data from self `dt_iop_crop_params_t`, - does the requested action, - updates gui from parameters - adds a new history stack entry (respecting the current `crop->enabled` status).
12e3a19
to
b1f0ad2
Compare
if(!p) return; | ||
|
||
// we avoid action if default or fully symmetrical | ||
const gboolean no_action = (p->cx == 1.f - p->ch) && (p->cy == 1.f - p->cw); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
This is not testing for "full symmetry". ;-)
Also, some layouts that don't need adjustment under flipping do need to be rotated and vice versa. So if you want to do more than only avoid adjusting no-crops, you'll have to do a full before-after comparison, i.e.
const float ocx = p->cx, ocy = p->cy, ocw = p->cw, och = p->ch;
if(mode == ORIENTATION_FLIP_HORIZONTALLY) {p->cx = 1.f-ocw; p->cw = 1.f-ocx;}
else if(mode == ORIENTATION_FLIP_VERTICALLY) {p->cy = 1.f-och; p->ch = 1.f-ocy;}
else if(mode == ORIENTATION_ROTATE_CW_90_DEG) {p->cx = 1.f-och; p->ch = ocw; p->cw = 1.f-ocy; p->cy = ocx;}
else if(mode == ORIENTATION_ROTATE_CCW_90_DEG) {p->cx = ocy; p->cy = 1.f-ocw; p->cw = och; p->ch = 1.f-ocx;}
and skip the last two lines if all of p->cx vs ocx etc are sigma close enough (since these are calculated values, rather than constants like 0 or 1, you could get mismatches on 1/4 == 1 - 3/4 if someone types in 25% everywhere).
While developing an image in darkroom we might have set a cropping area, this commit implements functionality to keep the cropped area if we change orientation via the flip module.
Three parts in the codebase required additions without changing existing code so not expecting stability regressions.
dt_develop_t
got two additions in cropping proxy,struct dt_iop_module_t *flip_handler
points to the crop module and is setup there. We can't useexposer
as the proxy because that is dynamically set in pixelpipe code only if enabled and we want to change crop parameters even if currently disabled.void (*flip_callback)
is the callback function changing crop parameters, defined in crop.Orientation module uses the
flip_callback(self, orientation)
requesting changes in crop.In crop we have
_crop_handle_flip()
as proxyflip_callback
with proper logs about action.dt_iop_crop_params_t
,crop->enabled
status.Finally worked on this, various pending issues:
Fixes #17631 #17498 #14788 #11614