Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2022-05-13 16:55:11 +0300
committerJulian Eisel <julian@blender.org>2022-05-13 18:55:52 +0300
commit8d43ee1b0823e6e5fae2fdceaee0a94d3d61f9b7 (patch)
treeaf808de0186cfb0a57ced1f5445317bb20bf3d84 /source/blender/editors/interface/interface.cc
parentc2d2cd1468cd89e7aaf7770a8b89be19a83490df (diff)
Fix T97518: All buttons with eyedropper highlight if one is hovered
Issue is that the operator acts on the active button, and also uses that in the poll. So the actually active button would affect the poll of a different button. For the superimposed icons we need to be able to execute these polls properly for non-active buttons. This enables temporarily overriding the active button for lookups via context. While a bit of a hack it makes sense conceptually. Reviewed By: Campbell Barton Maniphest Tasks: T97518 Differential Revision: https://developer.blender.org/D14880
Diffstat (limited to 'source/blender/editors/interface/interface.cc')
-rw-r--r--source/blender/editors/interface/interface.cc25
1 files changed, 21 insertions, 4 deletions
diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc
index b7098c26bcd..480044118f1 100644
--- a/source/blender/editors/interface/interface.cc
+++ b/source/blender/editors/interface/interface.cc
@@ -1861,15 +1861,32 @@ bool ui_but_context_poll_operator_ex(bContext *C,
const wmOperatorCallParams *optype_params)
{
bool result;
+ int old_but_flag = 0;
- if (but && but->context) {
- CTX_store_set(C, but->context);
+ if (but) {
+ old_but_flag = but->flag;
+
+ /* Temporarily make this button override the active one, in case the poll acts on the active
+ * button. */
+ const_cast<uiBut *>(but)->flag |= UI_BUT_ACTIVE_OVERRIDE;
+
+ if (but->context) {
+ CTX_store_set(C, but->context);
+ }
}
result = WM_operator_poll_context(C, optype_params->optype, optype_params->opcontext);
- if (but && but->context) {
- CTX_store_set(C, nullptr);
+ if (but) {
+ BLI_assert_msg((but->flag & ~UI_BUT_ACTIVE_OVERRIDE) ==
+ (old_but_flag & ~UI_BUT_ACTIVE_OVERRIDE),
+ "Operator polls shouldn't change button flags");
+
+ const_cast<uiBut *>(but)->flag = old_but_flag;
+
+ if (but->context) {
+ CTX_store_set(C, nullptr);
+ }
}
return result;