Project Pampa request: copy-paste for curve mapping widgets
Use C-c for copy, C-v for paste over the widget.
This commit is contained in:
@@ -4186,5 +4186,6 @@ void UI_reinit_font(void)
|
||||
void UI_exit(void)
|
||||
{
|
||||
ui_resources_free();
|
||||
ui_button_clipboard_free();
|
||||
}
|
||||
|
||||
|
||||
@@ -242,6 +242,11 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *userd
|
||||
static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiButtonActivateType type);
|
||||
static void button_timers_tooltip_remove(bContext *C, uiBut *but);
|
||||
|
||||
/* buttons clipboard */
|
||||
static ColorBand but_copypaste_coba = {0};
|
||||
static CurveMapping but_copypaste_curve = {0};
|
||||
static bool but_copypaste_curve_alive = false;
|
||||
|
||||
/* ******************** menu navigation helpers ************** */
|
||||
|
||||
/* assumes event type is MOUSEPAN */
|
||||
@@ -1324,7 +1329,6 @@ static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleB
|
||||
/* c = copy, v = paste */
|
||||
static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, char mode)
|
||||
{
|
||||
static ColorBand but_copypaste_coba = {0};
|
||||
char buf[UI_MAX_DRAW_STR + 1] = {0};
|
||||
|
||||
if (mode == 'v' && but->lock == TRUE) {
|
||||
@@ -1458,6 +1462,28 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
}
|
||||
}
|
||||
else if (but->type == BUT_CURVE) {
|
||||
if (mode == 'c') {
|
||||
if (but->poin == NULL)
|
||||
return;
|
||||
|
||||
but_copypaste_curve_alive = true;
|
||||
curvemapping_free_data(&but_copypaste_curve);
|
||||
curvemapping_copy_data(&but_copypaste_curve, (CurveMapping *) but->poin);
|
||||
}
|
||||
else {
|
||||
if (!but_copypaste_curve_alive)
|
||||
return;
|
||||
|
||||
if (!but->poin)
|
||||
but->poin = MEM_callocN(sizeof(CurveMapping), "curvemapping");
|
||||
|
||||
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
|
||||
curvemapping_free_data((CurveMapping *) but->poin);
|
||||
curvemapping_copy_data((CurveMapping *) but->poin, &but_copypaste_curve);
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
}
|
||||
}
|
||||
/* operator button (any type) */
|
||||
else if (but->optype) {
|
||||
if (mode == 'c') {
|
||||
@@ -7851,3 +7877,7 @@ bool UI_textbutton_activate_event(const bContext *C, ARegion *ar,
|
||||
}
|
||||
}
|
||||
|
||||
void ui_button_clipboard_free(void)
|
||||
{
|
||||
curvemapping_free_data(&but_copypaste_curve);
|
||||
}
|
||||
|
||||
@@ -523,6 +523,7 @@ extern void ui_button_active_free(const struct bContext *C, uiBut *but);
|
||||
extern bool ui_button_is_active(struct ARegion *ar);
|
||||
extern int ui_button_open_menu_direction(uiBut *but);
|
||||
extern void ui_button_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut *but, int restore);
|
||||
void ui_button_clipboard_free(void);
|
||||
|
||||
/* interface_widgets.c */
|
||||
void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3);
|
||||
|
||||
Reference in New Issue
Block a user