User Interface: Ctrl+C over a menu copies the py command

also use bools rather then ints
This commit is contained in:
2013-12-05 17:26:03 +11:00
parent 8003f0606d
commit 6976866d5a
10 changed files with 37 additions and 27 deletions

View File

@@ -3972,7 +3972,7 @@ void uiButGetStrInfo(bContext *C, uiBut *but, ...)
const char *tc1, *tc2;
tc1 = strstr(but->str, "%t");
tc2 = strstr(but->str, "|"); /* XXX For some reason strchr seems to not work here? */
tc2 = strstr(but->str, UI_SEP_CHAR_S);
if (tc2 && (!tc1 || tc1 > tc2))
tc1 = tc2;

View File

@@ -60,6 +60,7 @@
#include "BKE_context.h"
#include "BKE_idprop.h"
#include "BKE_report.h"
#include "BKE_screen.h"
#include "BKE_texture.h"
#include "BKE_tracking.h"
#include "BKE_unit.h"
@@ -1556,6 +1557,15 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
MEM_freeN(str);
}
}
/* menu (any type) */
else if (ELEM(but->type, MENU, PULLDOWN)) {
MenuType *mt = uiButGetMenuType(but);
if (mt) {
char str[32 + sizeof(mt->idname)];
BLI_snprintf(str, sizeof(str), "bpy.ops.wm.call_menu(name=\"%s\")", mt->idname);
WM_clipboard_text_set(str, 0);
}
}
}
/* ************************ password text ******************************

View File

@@ -1128,7 +1128,7 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar)
retval = WM_UI_HANDLER_CONTINUE;
for (block = ar->uiblocks.last; block; block = block->prev) {
int inside = 0, inside_header = 0, inside_scale = 0;
bool inside = false, inside_header = false, inside_scale = false;
mx = event->x;
my = event->y;
@@ -1145,24 +1145,24 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar)
/* clicked at panel header? */
if (pa->flag & PNL_CLOSEDX) {
if (block->rect.xmin <= mx && block->rect.xmin + PNL_HEADER >= mx)
inside_header = 1;
inside_header = true;
}
else if (block->rect.xmin > mx || block->rect.xmax < mx) {
/* outside left/right side */
}
else if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my)) {
inside_header = 1;
inside_header = true;
}
else if (!(pa->flag & PNL_CLOSEDY)) {
/* open panel */
if (pa->control & UI_PNL_SCALE) {
if (block->rect.xmax - PNL_HEADER <= mx)
if (block->rect.ymin + PNL_HEADER >= my)
inside_scale = 1;
inside_scale = true;
}
if (block->rect.xmin <= mx && block->rect.xmax >= mx)
if (block->rect.ymin <= my && block->rect.ymax + PNL_HEADER >= my)
inside = 1;
inside = true;
}
/* XXX hardcoded key warning */

View File

@@ -1144,7 +1144,7 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
/* wake up animtimer */
if (win->screen->animtimer)
WM_event_timer_sleep(wm, win, win->screen->animtimer, 0);
WM_event_timer_sleep(wm, win, win->screen->animtimer, false);
}
if (G.debug & G_DEBUG_EVENTS) {
@@ -1423,7 +1423,7 @@ void ED_screen_set(bContext *C, bScreen *sc)
/* we put timer to sleep, so screen_exit has to think there's no timer */
oldscreen->animtimer = NULL;
if (wt)
WM_event_timer_sleep(wm, win, wt, 1);
WM_event_timer_sleep(wm, win, wt, true);
ED_screen_exit(C, win, oldscreen);
oldscreen->animtimer = wt;

View File

@@ -75,7 +75,7 @@ void WM_init_state_normal_set(void);
void WM_init_native_pixels(bool do_it);
void WM_init (struct bContext *C, int argc, const char **argv);
void WM_exit_ext (struct bContext *C, const short do_python);
void WM_exit_ext (struct bContext *C, const bool do_python);
void WM_exit (struct bContext *C) ATTR_NORETURN;
@@ -164,7 +164,7 @@ struct wmEventHandler *WM_event_add_dropbox_handler(ListBase *handlers, ListBase
/* mouse */
void WM_event_add_mousemove(struct bContext *C);
int WM_modal_tweak_exit(const struct wmEvent *event, int tweak_event);
bool WM_modal_tweak_exit(const struct wmEvent *event, int tweak_event);
/* notifiers */
void WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference);
@@ -182,7 +182,7 @@ void wm_event_init_from_window(struct wmWindow *win, struct wmEvent *event);
/* at maximum, every timestep seconds it triggers event_type events */
struct wmTimer *WM_event_add_timer(struct wmWindowManager *wm, struct wmWindow *win, int event_type, double timestep);
void WM_event_remove_timer(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer);
void WM_event_timer_sleep(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer, int dosleep);
void WM_event_timer_sleep(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer, bool do_sleep);
/* operator api, default callbacks */
/* invoke callback, uses enum property named "type" */
@@ -379,13 +379,13 @@ enum {
struct wmJob *WM_jobs_get(struct wmWindowManager *wm, struct wmWindow *win, void *owner, const char *name, int flag, int job_type);
int WM_jobs_test(struct wmWindowManager *wm, void *owner, int job_type);
bool WM_jobs_test(struct wmWindowManager *wm, void *owner, int job_type);
float WM_jobs_progress(struct wmWindowManager *wm, void *owner);
char *WM_jobs_name(struct wmWindowManager *wm, void *owner);
void *WM_jobs_customdata(struct wmWindowManager *wm, void *owner);
void *WM_jobs_customdata_from_type(struct wmWindowManager *wm, int job_type);
int WM_jobs_is_running(struct wmJob *);
bool WM_jobs_is_running(struct wmJob *);
void *WM_jobs_customdata_get(struct wmJob *);
void WM_jobs_customdata_set(struct wmJob *, void *customdata, void (*free)(void *));
void WM_jobs_timer(struct wmJob *, double timestep, unsigned int note, unsigned int endnote);
@@ -402,14 +402,14 @@ void WM_jobs_kill_all(struct wmWindowManager *wm);
void WM_jobs_kill_all_except(struct wmWindowManager *wm, void *owner);
void WM_jobs_kill_type(struct wmWindowManager *wm, void *owner, int job_type);
int WM_jobs_has_running(struct wmWindowManager *wm);
bool WM_jobs_has_running(struct wmWindowManager *wm);
void WM_job_main_thread_lock_acquire(struct wmJob *job);
void WM_job_main_thread_lock_release(struct wmJob *job);
/* clipboard */
char *WM_clipboard_text_get(int selection);
void WM_clipboard_text_set(char *buf, int selection);
char *WM_clipboard_text_get(bool selection);
void WM_clipboard_text_set(const char *buf, bool selection);
/* progress */
void WM_progress_set(struct wmWindow *win, float progress);
@@ -421,7 +421,7 @@ void WM_redraw_windows(struct bContext *C);
void WM_main_playanim(int argc, const char **argv);
/* debugging only, convenience function to write on crash */
int write_crash_blend(void);
bool write_crash_blend(void);
#ifdef __cplusplus
}

View File

@@ -2584,7 +2584,7 @@ void WM_event_add_mousemove(bContext *C)
/* for modal callbacks, check configuration for how to interpret exit with tweaks */
int WM_modal_tweak_exit(const wmEvent *event, int tweak_event)
bool WM_modal_tweak_exit(const wmEvent *event, int tweak_event)
{
/* if the release-confirm userpref setting is enabled,
* tweak events can be canceled when mouse is released

View File

@@ -832,7 +832,7 @@ static ImBuf *blend_file_thumb(Scene *scene, bScreen *screen, int **thumb_pt)
}
/* easy access from gdb */
int write_crash_blend(void)
bool write_crash_blend(void)
{
char path[FILE_MAX];
int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on crash file */

View File

@@ -382,7 +382,7 @@ static void wait_for_console_key(void)
/* called in creator.c even... tsk, split this! */
/* note, doesnt run exit() call WM_exit() for that */
void WM_exit_ext(bContext *C, const short do_python)
void WM_exit_ext(bContext *C, const bool do_python)
{
wmWindowManager *wm = C ? CTX_wm_manager(C) : NULL;

View File

@@ -222,7 +222,7 @@ wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *
}
/* returns true if job runs, for UI (progress) indicators */
int WM_jobs_test(wmWindowManager *wm, void *owner, int job_type)
bool WM_jobs_test(wmWindowManager *wm, void *owner, int job_type)
{
wmJob *wm_job;
@@ -280,7 +280,7 @@ void *WM_jobs_customdata_from_type(wmWindowManager *wm, int job_type)
return NULL;
}
int WM_jobs_is_running(wmJob *wm_job)
bool WM_jobs_is_running(wmJob *wm_job)
{
return wm_job->running;
}
@@ -649,7 +649,7 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
}
}
int WM_jobs_has_running(wmWindowManager *wm)
bool WM_jobs_has_running(wmWindowManager *wm)
{
wmJob *wm_job;

View File

@@ -1137,7 +1137,7 @@ void wm_ghost_exit(void)
/* **************** timer ********************** */
/* to (de)activate running timers temporary */
void WM_event_timer_sleep(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer, int dosleep)
void WM_event_timer_sleep(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer, bool do_sleep)
{
wmTimer *wt;
@@ -1146,7 +1146,7 @@ void WM_event_timer_sleep(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *t
break;
if (wt)
wt->sleep = dosleep;
wt->sleep = do_sleep;
}
wmTimer *WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)
@@ -1199,7 +1199,7 @@ void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *
/* ******************* clipboard **************** */
char *WM_clipboard_text_get(int selection)
char *WM_clipboard_text_get(bool selection)
{
char *p, *p2, *buf, *newbuf;
@@ -1224,7 +1224,7 @@ char *WM_clipboard_text_get(int selection)
return newbuf;
}
void WM_clipboard_text_set(char *buf, int selection)
void WM_clipboard_text_set(const char *buf, bool selection)
{
if (!G.background) {
#ifdef _WIN32