Spreadsheet: Dataset region for spreadsheet editor
This patch adds a left aligned sidebar to the spreadsheet editor. This Sidebar can be used to navigate the geometry component types and attribute domains. It also provides a quick overview of domain sizes. It replaces the two dropdowns in the regions header. Next step will be to add the domain cycling shortcut using the CTRL + mouse wheel. Reviewer: Dalai Felinto (dfelinto), Julian Eisel (Severin), Hans Goudey (HooglyBoogly). Differential Revision: https://developer.blender.org/D11046
This commit is contained in:
@@ -2105,8 +2105,10 @@ void UI_region_message_subscribe(ARegion *region, struct wmMsgBus *mbus)
|
||||
int ui_but_is_pushed_ex(uiBut *but, double *value)
|
||||
{
|
||||
int is_push = 0;
|
||||
|
||||
if (but->bit) {
|
||||
if (but->pushed_state_func) {
|
||||
return but->pushed_state_func(but, but->pushed_state_arg);
|
||||
}
|
||||
else if (but->bit) {
|
||||
const bool state = !ELEM(
|
||||
but->type, UI_BTYPE_TOGGLE_N, UI_BTYPE_ICON_TOGGLE_N, UI_BTYPE_CHECKBOX_N);
|
||||
int lvalue;
|
||||
@@ -2253,7 +2255,6 @@ void ui_but_v3_get(uiBut *but, float vec[3])
|
||||
}
|
||||
else if (but->pointype == UI_BUT_POIN_CHAR) {
|
||||
const char *cp = (char *)but->poin;
|
||||
|
||||
vec[0] = ((float)cp[0]) / 255.0f;
|
||||
vec[1] = ((float)cp[1]) / 255.0f;
|
||||
vec[2] = ((float)cp[2]) / 255.0f;
|
||||
@@ -3903,6 +3904,10 @@ static void ui_but_alloc_info(const eButType type,
|
||||
alloc_size = sizeof(uiButCurveProfile);
|
||||
alloc_str = "uiButCurveProfile";
|
||||
break;
|
||||
case UI_BTYPE_DATASETROW:
|
||||
alloc_size = sizeof(uiButDatasetRow);
|
||||
alloc_str = "uiButDatasetRow";
|
||||
break;
|
||||
default:
|
||||
alloc_size = sizeof(uiBut);
|
||||
alloc_str = "uiBut";
|
||||
@@ -4100,6 +4105,7 @@ static uiBut *ui_def_but(uiBlock *block,
|
||||
UI_BTYPE_BUT_MENU,
|
||||
UI_BTYPE_SEARCH_MENU,
|
||||
UI_BTYPE_PROGRESS_BAR,
|
||||
UI_BTYPE_DATASETROW,
|
||||
UI_BTYPE_POPOVER)) {
|
||||
but->drawflag |= (UI_BUT_TEXT_LEFT | UI_BUT_ICON_LEFT);
|
||||
}
|
||||
@@ -6336,10 +6342,11 @@ void UI_but_func_tooltip_set(uiBut *but, uiButToolTipFunc func, void *argN)
|
||||
but->tip_argN = argN;
|
||||
}
|
||||
|
||||
void UI_but_func_pushed_state_set(uiBut *but, uiButPushedStateFunc func, void *arg)
|
||||
void UI_but_func_pushed_state_set(uiBut *but, uiButPushedStateFunc func, const void *arg)
|
||||
{
|
||||
but->pushed_state_func = func;
|
||||
but->pushed_state_arg = arg;
|
||||
ui_but_update(but);
|
||||
}
|
||||
|
||||
uiBut *uiDefBlockBut(uiBlock *block,
|
||||
@@ -6824,6 +6831,56 @@ uiBut *uiDefSearchButO_ptr(uiBlock *block,
|
||||
return but;
|
||||
}
|
||||
|
||||
void UI_but_datasetrow_indentation_set(uiBut *but, int indentation)
|
||||
{
|
||||
uiButDatasetRow *but_dataset = (uiButDatasetRow *)but;
|
||||
BLI_assert(but->type == UI_BTYPE_DATASETROW);
|
||||
|
||||
but_dataset->indentation = indentation;
|
||||
BLI_assert(indentation >= 0);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a hint to the button which draws right aligned, grayed out and never clipped.
|
||||
*/
|
||||
void UI_but_hint_drawstr_set(uiBut *but, const char *string)
|
||||
{
|
||||
ui_but_add_shortcut(but, string, false);
|
||||
}
|
||||
|
||||
void UI_but_datasetrow_component_set(uiBut *but, uint8_t geometry_component_type)
|
||||
{
|
||||
uiButDatasetRow *but_dataset_row = (uiButDatasetRow *)but;
|
||||
BLI_assert(but->type == UI_BTYPE_DATASETROW);
|
||||
|
||||
but_dataset_row->geometry_component_type = geometry_component_type;
|
||||
}
|
||||
|
||||
void UI_but_datasetrow_domain_set(uiBut *but, uint8_t attribute_domain)
|
||||
{
|
||||
uiButDatasetRow *but_dataset_row = (uiButDatasetRow *)but;
|
||||
BLI_assert(but->type == UI_BTYPE_DATASETROW);
|
||||
|
||||
but_dataset_row->attribute_domain = attribute_domain;
|
||||
}
|
||||
|
||||
uint8_t UI_but_datasetrow_component_get(uiBut *but)
|
||||
{
|
||||
uiButDatasetRow *but_dataset_row = (uiButDatasetRow *)but;
|
||||
BLI_assert(but->type == UI_BTYPE_DATASETROW);
|
||||
|
||||
return but_dataset_row->geometry_component_type;
|
||||
}
|
||||
|
||||
uint8_t UI_but_datasetrow_domain_get(uiBut *but)
|
||||
{
|
||||
uiButDatasetRow *but_dataset_row = (uiButDatasetRow *)but;
|
||||
BLI_assert(but->type == UI_BTYPE_DATASETROW);
|
||||
|
||||
return but_dataset_row->attribute_domain;
|
||||
}
|
||||
|
||||
void UI_but_node_link_set(uiBut *but, bNodeSocket *socket, const float draw_color[4])
|
||||
{
|
||||
but->flag |= UI_BUT_NODE_LINK;
|
||||
|
||||
@@ -1461,12 +1461,9 @@ static bool ui_drag_toggle_but_is_supported(const uiBut *but)
|
||||
|
||||
/* Button pushed state to compare if other buttons match. Can be more
|
||||
* then just true or false for toggle buttons with more than 2 states. */
|
||||
static int ui_drag_toggle_but_pushed_state(bContext *C, uiBut *but)
|
||||
static int ui_drag_toggle_but_pushed_state(uiBut *but)
|
||||
{
|
||||
if (but->rnapoin.data == NULL && but->poin == NULL && but->icon) {
|
||||
if (but->pushed_state_func) {
|
||||
return but->pushed_state_func(C, but->pushed_state_arg);
|
||||
}
|
||||
/* Assume icon identifies a unique state, for buttons that
|
||||
* work through functions callbacks and don't have an boolean
|
||||
* value that indicates the state. */
|
||||
@@ -1513,7 +1510,7 @@ static bool ui_drag_toggle_set_xy_xy(
|
||||
/* execute the button */
|
||||
if (ui_drag_toggle_but_is_supported(but)) {
|
||||
/* is it pressed? */
|
||||
const int pushed_state_but = ui_drag_toggle_but_pushed_state(C, but);
|
||||
const int pushed_state_but = ui_drag_toggle_but_pushed_state(but);
|
||||
if (pushed_state_but != pushed_state) {
|
||||
UI_but_execute(C, region, but);
|
||||
if (do_check) {
|
||||
@@ -1943,7 +1940,7 @@ static bool ui_but_drag_init(bContext *C,
|
||||
* typically 'button_activate_exit()' handles this */
|
||||
ui_apply_but_autokey(C, but);
|
||||
|
||||
drag_info->pushed_state = ui_drag_toggle_but_pushed_state(C, but);
|
||||
drag_info->pushed_state = ui_drag_toggle_but_pushed_state(but);
|
||||
drag_info->but_cent_start[0] = BLI_rctf_cent_x(&but->rect);
|
||||
drag_info->but_cent_start[1] = BLI_rctf_cent_y(&but->rect);
|
||||
copy_v2_v2_int(drag_info->xy_init, &event->x);
|
||||
@@ -2187,6 +2184,9 @@ static void ui_apply_but(
|
||||
case UI_BTYPE_LISTROW:
|
||||
ui_apply_but_ROW(C, block, but, data);
|
||||
break;
|
||||
case UI_BTYPE_DATASETROW:
|
||||
ui_apply_but_ROW(C, block, but, data);
|
||||
break;
|
||||
case UI_BTYPE_TAB:
|
||||
ui_apply_but_TAB(C, but, data);
|
||||
break;
|
||||
@@ -7851,6 +7851,9 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
|
||||
case UI_BTYPE_LABEL:
|
||||
case UI_BTYPE_IMAGE:
|
||||
case UI_BTYPE_PROGRESS_BAR:
|
||||
case UI_BTYPE_DATASETROW:
|
||||
retval = ui_do_but_TOG(C, but, data, event);
|
||||
break;
|
||||
case UI_BTYPE_NODE_SOCKET:
|
||||
retval = ui_do_but_EXIT(C, but, data, event);
|
||||
break;
|
||||
|
||||
@@ -279,7 +279,7 @@ struct uiBut {
|
||||
float *editvec;
|
||||
|
||||
uiButPushedStateFunc pushed_state_func;
|
||||
void *pushed_state_arg;
|
||||
const void *pushed_state_arg;
|
||||
|
||||
/* pointer back */
|
||||
uiBlock *block;
|
||||
@@ -350,6 +350,15 @@ typedef struct uiButProgressbar {
|
||||
float progress;
|
||||
} uiButProgressbar;
|
||||
|
||||
/** Derived struct for #UI_BTYPE_DATASETROW. */
|
||||
typedef struct uiButDatasetRow {
|
||||
uiBut but;
|
||||
|
||||
uint8_t geometry_component_type;
|
||||
uint8_t attribute_domain;
|
||||
int indentation;
|
||||
} uiButDatasetRow;
|
||||
|
||||
/** Derived struct for #UI_BTYPE_HSVCUBE. */
|
||||
typedef struct uiButHSVCube {
|
||||
uiBut but;
|
||||
|
||||
@@ -67,7 +67,8 @@ bool ui_but_is_toggle(const uiBut *but)
|
||||
UI_BTYPE_TOGGLE_N,
|
||||
UI_BTYPE_CHECKBOX,
|
||||
UI_BTYPE_CHECKBOX_N,
|
||||
UI_BTYPE_ROW);
|
||||
UI_BTYPE_ROW,
|
||||
UI_BTYPE_DATASETROW);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -113,6 +113,7 @@ typedef enum {
|
||||
UI_WTYPE_LISTITEM,
|
||||
UI_WTYPE_PROGRESSBAR,
|
||||
UI_WTYPE_NODESOCKET,
|
||||
UI_WTYPE_DATASETROW,
|
||||
} uiWidgetTypeEnum;
|
||||
|
||||
/* Button state argument shares bits with 'uiBut.flag'.
|
||||
@@ -3697,6 +3698,28 @@ static void widget_progressbar(
|
||||
rect->xmax += (BLI_rcti_size_x(&rect_prog) / 2);
|
||||
}
|
||||
|
||||
static void widget_datasetrow(
|
||||
uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int UNUSED(roundboxalign))
|
||||
{
|
||||
uiButDatasetRow *but_componentrow = (uiButDatasetRow *)but;
|
||||
uiWidgetBase wtb;
|
||||
widget_init(&wtb);
|
||||
|
||||
/* no outline */
|
||||
wtb.draw_outline = false;
|
||||
const float rad = wcol->roundness * U.widget_unit;
|
||||
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
|
||||
|
||||
if ((state & UI_ACTIVE) || (state & UI_SELECT)) {
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
}
|
||||
|
||||
BLI_rcti_resize(rect,
|
||||
BLI_rcti_size_x(rect) - UI_UNIT_X * but_componentrow->indentation,
|
||||
BLI_rcti_size_y(rect));
|
||||
BLI_rcti_translate(rect, 0.5f * UI_UNIT_X * but_componentrow->indentation, 0);
|
||||
}
|
||||
|
||||
static void widget_nodesocket(
|
||||
uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign))
|
||||
{
|
||||
@@ -4469,6 +4492,10 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
|
||||
wt.custom = widget_progressbar;
|
||||
break;
|
||||
|
||||
case UI_WTYPE_DATASETROW:
|
||||
wt.custom = widget_datasetrow;
|
||||
break;
|
||||
|
||||
case UI_WTYPE_NODESOCKET:
|
||||
wt.custom = widget_nodesocket;
|
||||
break;
|
||||
@@ -4792,6 +4819,11 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu
|
||||
fstyle = &style->widgetlabel;
|
||||
break;
|
||||
|
||||
case UI_BTYPE_DATASETROW:
|
||||
wt = widget_type(UI_WTYPE_DATASETROW);
|
||||
fstyle = &style->widgetlabel;
|
||||
break;
|
||||
|
||||
case UI_BTYPE_SCROLL:
|
||||
wt = widget_type(UI_WTYPE_SCROLL);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user