Ctrl-0 can now be used to just reset a single component of an array to

its default value instead of resetting the entire array
This commit is contained in:
Joshua Leung 2011-02-15 00:53:20 +00:00
parent d4ebace149
commit dab76a3ccf
3 changed files with 7 additions and 4 deletions

@ -1773,11 +1773,13 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
return 0;
}
void ui_set_but_default(bContext *C, uiBut *but)
void ui_set_but_default(bContext *C, uiBut *but, short all)
{
/* if there is a valid property that is editable... */
if (but->rnapoin.data && but->rnaprop && RNA_property_editable(&but->rnapoin, but->rnaprop)) {
if(RNA_property_reset(&but->rnapoin, but->rnaprop, -1)) {
int index = (all)? -1 : but->rnaindex;
if(RNA_property_reset(&but->rnapoin, but->rnaprop, index)) {
/* perform updates required for this property */
RNA_property_update(C, &but->rnapoin, but->rnaprop);
}

@ -4357,8 +4357,9 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
/* reset to default */
/* XXX hardcoded keymap check.... */
else if(ELEM(event->type, ZEROKEY, PAD0) && event->val == KM_PRESS) {
/* ctrl-0 = for arrays, only the active one gets done (vs whole array for just 0) */
if (!(ELEM3(but->type, HSVCIRCLE, HSVCUBE, HISTOGRAM)))
ui_set_but_default(C, but);
ui_set_but_default(C, but, !event->ctrl);
}
/* handle menu */
else if(event->type == RIGHTMOUSE && event->val == KM_PRESS) {

@ -364,7 +364,7 @@ extern void ui_convert_to_unit_alt_name(uiBut *but, char *str, int maxlen);
extern int ui_set_but_string(struct bContext *C, uiBut *but, const char *str);
extern int ui_get_but_string_max_length(uiBut *but);
extern void ui_set_but_default(struct bContext *C, uiBut *but);
extern void ui_set_but_default(struct bContext *C, uiBut *but, short all);
extern void ui_set_but_soft_range(uiBut *but, double value);