Fix #35991: show warning message to when trying to edit driven values in number buttons.

This commit is contained in:
Brecht Van Lommel
2013-07-03 20:37:07 +00:00
parent 7eed4d5c4f
commit 42f6136da8
3 changed files with 65 additions and 19 deletions

View File

@@ -5317,7 +5317,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
/* this should become disabled button .. */
if (but->lock == true) {
if (but->lockstr) {
BKE_report(NULL, RPT_WARNING, but->lockstr);
WM_report(C, RPT_INFO, but->lockstr);
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
@@ -5740,6 +5740,10 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
ui_numedit_end(but, data);
if (but->flag & UI_BUT_DRIVEN)
WM_report(C, RPT_INFO, "Can't edit driven number value, see graph editor for the driver setup.");
if (ui_is_a_warp_but(but)) {
#ifdef USE_CONT_MOUSE_CORRECT

View File

@@ -178,6 +178,14 @@ void WM_event_add_notifier(const struct bContext *C, unsigned int type, void *r
void WM_main_add_notifier(unsigned int type, void *reference);
void WM_main_remove_notifier_reference(const void *reference);
/* reports */
void WM_report(const struct bContext *C, ReportType type, const char *message);
void WM_reportf(const struct bContext *C, ReportType type, const char *format, ...)
#ifdef __GNUC__
__attribute__ ((format(printf, 3, 4)))
#endif
;
void wm_event_add(struct wmWindow *win, const struct wmEvent *event_to_add);
/* at maximum, every timestep seconds it triggers event_type events */

View File

@@ -43,6 +43,7 @@
#include "GHOST_C-api.h"
#include "BLI_blenlib.h"
#include "BLI_dynstr.h"
#include "BLI_utildefines.h"
#include "BLI_math.h"
@@ -533,6 +534,56 @@ void WM_event_print(const wmEvent *event)
#endif /* NDEBUG */
static void wm_add_reports(const bContext *C, ReportList *reports)
{
/* if the caller owns them, handle this */
if (reports->list.first && (reports->flag & RPT_OP_HOLD) == 0) {
wmWindowManager *wm = CTX_wm_manager(C);
ReportList *wm_reports = CTX_wm_reports(C);
ReportTimerInfo *rti;
/* add reports to the global list, otherwise they are not seen */
BLI_movelisttolist(&wm_reports->list, &reports->list);
/* After adding reports to the global list, reset the report timer. */
WM_event_remove_timer(wm, NULL, wm_reports->reporttimer);
/* Records time since last report was added */
wm_reports->reporttimer = WM_event_add_timer(wm, CTX_wm_window(C), TIMERREPORT, 0.05);
rti = MEM_callocN(sizeof(ReportTimerInfo), "ReportTimerInfo");
wm_reports->reporttimer->customdata = rti;
}
}
void WM_report(const bContext *C, ReportType type, const char *message)
{
ReportList reports;
BKE_reports_init(&reports, RPT_STORE);
BKE_report(&reports, type, message);
wm_add_reports(C, &reports);
BKE_reports_clear(&reports);
}
void WM_reportf(const bContext *C, ReportType type, const char *format, ...)
{
DynStr *ds;
va_list args;
ds = BLI_dynstr_new();
va_start(args, format);
BLI_dynstr_vappendf(ds, format, args);
va_end(args);
WM_report(C, type, BLI_dynstr_get_cstring(ds));
BLI_dynstr_free(ds);
}
/* (caller_owns_reports == TRUE) when called from python */
static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int caller_owns_reports)
{
@@ -575,24 +626,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int cal
}
/* if the caller owns them, handle this */
if (op->reports->list.first && (op->reports->flag & RPT_OP_HOLD) == 0) {
wmWindowManager *wm = CTX_wm_manager(C);
ReportList *wm_reports = CTX_wm_reports(C);
ReportTimerInfo *rti;
/* add reports to the global list, otherwise they are not seen */
BLI_movelisttolist(&wm_reports->list, &op->reports->list);
/* After adding reports to the global list, reset the report timer. */
WM_event_remove_timer(wm, NULL, wm_reports->reporttimer);
/* Records time since last report was added */
wm_reports->reporttimer = WM_event_add_timer(wm, CTX_wm_window(C), TIMERREPORT, 0.05);
rti = MEM_callocN(sizeof(ReportTimerInfo), "ReportTimerInfo");
wm_reports->reporttimer->customdata = rti;
}
wm_add_reports(C, op->reports);
}
/* this function is mainly to check that the rules for freeing