Cleanup: strip trailing space from interface files
This commit is contained in:
@@ -85,7 +85,7 @@
|
||||
|
||||
/**
|
||||
* a full doc with API notes can be found in 'blender/doc/guides/interface_API.txt'
|
||||
*
|
||||
*
|
||||
* `uiBlahBlah()` external function.
|
||||
* `ui_blah_blah()` internal function.
|
||||
*/
|
||||
@@ -290,7 +290,7 @@ void ui_block_bounds_calc(uiBlock *block)
|
||||
{
|
||||
uiBut *bt;
|
||||
int xof;
|
||||
|
||||
|
||||
if (BLI_listbase_is_empty(&block->buttons)) {
|
||||
if (block->panel) {
|
||||
block->rect.xmin = 0.0; block->rect.xmax = block->panel->sizex;
|
||||
@@ -298,13 +298,13 @@ void ui_block_bounds_calc(uiBlock *block)
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
BLI_rctf_init_minmax(&block->rect);
|
||||
|
||||
for (bt = block->buttons.first; bt; bt = bt->next) {
|
||||
BLI_rctf_union(&block->rect, &bt->rect);
|
||||
}
|
||||
|
||||
|
||||
block->rect.xmin -= block->bounds;
|
||||
block->rect.ymin -= block->bounds;
|
||||
block->rect.xmax += block->bounds;
|
||||
@@ -313,7 +313,7 @@ void ui_block_bounds_calc(uiBlock *block)
|
||||
|
||||
block->rect.xmax = block->rect.xmin + max_ff(BLI_rctf_size_x(&block->rect), block->minbounds);
|
||||
|
||||
/* hardcoded exception... but that one is annoying with larger safety */
|
||||
/* hardcoded exception... but that one is annoying with larger safety */
|
||||
bt = block->buttons.first;
|
||||
if (bt && STREQLEN(bt->str, "ERROR", 5)) xof = 10;
|
||||
else xof = 40;
|
||||
@@ -329,7 +329,7 @@ static void ui_block_bounds_calc_centered(wmWindow *window, uiBlock *block)
|
||||
int xmax, ymax;
|
||||
int startx, starty;
|
||||
int width, height;
|
||||
|
||||
|
||||
/* note: this is used for the splash where window bounds event has not been
|
||||
* updated by ghost, get the window bounds from ghost directly */
|
||||
|
||||
@@ -337,18 +337,18 @@ static void ui_block_bounds_calc_centered(wmWindow *window, uiBlock *block)
|
||||
ymax = WM_window_pixels_y(window);
|
||||
|
||||
ui_block_bounds_calc(block);
|
||||
|
||||
|
||||
width = BLI_rctf_size_x(&block->rect);
|
||||
height = BLI_rctf_size_y(&block->rect);
|
||||
|
||||
|
||||
startx = (xmax * 0.5f) - (width * 0.5f);
|
||||
starty = (ymax * 0.5f) - (height * 0.5f);
|
||||
|
||||
|
||||
ui_block_translate(block, startx - block->rect.xmin, starty - block->rect.ymin);
|
||||
|
||||
|
||||
/* now recompute bounds and safety */
|
||||
ui_block_bounds_calc(block);
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void ui_block_bounds_calc_centered_pie(uiBlock *block)
|
||||
@@ -378,7 +378,7 @@ static void ui_block_bounds_calc_popup(
|
||||
|
||||
/* compute mouse position with user defined offset */
|
||||
ui_block_bounds_calc(block);
|
||||
|
||||
|
||||
xmax = WM_window_pixels_x(window);
|
||||
ymax = WM_window_pixels_y(window);
|
||||
|
||||
@@ -436,7 +436,7 @@ void UI_block_bounds_set_normal(uiBlock *block, int addval)
|
||||
{
|
||||
if (block == NULL)
|
||||
return;
|
||||
|
||||
|
||||
block->bounds = addval;
|
||||
block->bounds_type = UI_BLOCK_BOUNDS;
|
||||
}
|
||||
@@ -511,12 +511,12 @@ static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines, int das
|
||||
rcti rect;
|
||||
|
||||
if (line->from == NULL || line->to == NULL) return;
|
||||
|
||||
|
||||
rect.xmin = BLI_rctf_cent_x(&line->from->rect);
|
||||
rect.ymin = BLI_rctf_cent_y(&line->from->rect);
|
||||
rect.xmax = BLI_rctf_cent_x(&line->to->rect);
|
||||
rect.ymax = BLI_rctf_cent_y(&line->to->rect);
|
||||
|
||||
|
||||
if (dashInactiveLines)
|
||||
UI_ThemeColor(TH_GRID);
|
||||
else if (line->flag & UI_SELECT)
|
||||
@@ -629,12 +629,12 @@ static void ui_but_update_linklines(uiBlock *block, uiBut *oldbut, uiBut *newbut
|
||||
{
|
||||
uiLinkLine *line;
|
||||
uiBut *but;
|
||||
|
||||
|
||||
/* if active button is UI_BTYPE_LINK */
|
||||
if (newbut->type == UI_BTYPE_LINK && newbut->link) {
|
||||
|
||||
|
||||
SWAP(uiLink *, oldbut->link, newbut->link);
|
||||
|
||||
|
||||
for (line = oldbut->link->lines.first; line; line = line->next) {
|
||||
if (line->to == newbut)
|
||||
line->to = oldbut;
|
||||
@@ -642,7 +642,7 @@ static void ui_but_update_linklines(uiBlock *block, uiBut *oldbut, uiBut *newbut
|
||||
line->from = oldbut;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* check all other button links */
|
||||
for (but = block->buttons.first; but; but = but->next) {
|
||||
if (but != newbut && but->type == UI_BTYPE_LINK && but->link) {
|
||||
@@ -811,7 +811,7 @@ bool UI_but_active_only(const bContext *C, ARegion *ar, uiBlock *block, uiBut *b
|
||||
uiBlock *oldblock;
|
||||
uiBut *oldbut;
|
||||
bool activate = false, found = false, isactive = false;
|
||||
|
||||
|
||||
oldblock = block->oldblock;
|
||||
if (!oldblock) {
|
||||
activate = true;
|
||||
@@ -834,7 +834,7 @@ bool UI_but_active_only(const bContext *C, ARegion *ar, uiBlock *block, uiBut *b
|
||||
ui_but_free(C, but);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1038,27 +1038,27 @@ static bool ui_but_event_property_operator_string(
|
||||
"WM_OT_context_cycle_array",
|
||||
"WM_OT_context_menu_enum",
|
||||
NULL
|
||||
};
|
||||
};
|
||||
const size_t num_ops = sizeof(ctx_toggle_opnames) / sizeof(const char *);
|
||||
|
||||
|
||||
bool found = false;
|
||||
|
||||
|
||||
/* this version is only for finding hotkeys for properties (which get set via context using operators) */
|
||||
if (but->rnaprop) {
|
||||
/* to avoid massive slowdowns on property panels, for now, we only check the
|
||||
/* to avoid massive slowdowns on property panels, for now, we only check the
|
||||
* hotkeys for Editor / Scene settings...
|
||||
*
|
||||
* TODO: userpref settings?
|
||||
*/
|
||||
// TODO: value (for enum stuff)?
|
||||
char *data_path = NULL;
|
||||
|
||||
|
||||
if (but->rnapoin.id.data) {
|
||||
ID *id = but->rnapoin.id.data;
|
||||
|
||||
|
||||
if (GS(id->name) == ID_SCR) {
|
||||
/* screen/editor property
|
||||
* NOTE: in most cases, there is actually no info for backwards tracing
|
||||
/* screen/editor property
|
||||
* NOTE: in most cases, there is actually no info for backwards tracing
|
||||
* how to get back to ID from the editor data we may be dealing with
|
||||
*/
|
||||
if (RNA_struct_is_a(but->rnapoin.type, &RNA_Space)) {
|
||||
@@ -1079,7 +1079,7 @@ static bool ui_but_event_property_operator_string(
|
||||
}
|
||||
else if (GS(id->name) == ID_SCE) {
|
||||
if (RNA_struct_is_a(but->rnapoin.type, &RNA_ToolSettings)) {
|
||||
/* toolsettings property
|
||||
/* toolsettings property
|
||||
* NOTE: toolsettings is usually accessed directly (i.e. not through scene)
|
||||
*/
|
||||
data_path = RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop);
|
||||
@@ -1087,7 +1087,7 @@ static bool ui_but_event_property_operator_string(
|
||||
else {
|
||||
/* scene property */
|
||||
char *path = RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop);
|
||||
|
||||
|
||||
if (path) {
|
||||
data_path = BLI_sprintfN("scene.%s", path);
|
||||
MEM_freeN(path);
|
||||
@@ -1103,23 +1103,23 @@ static bool ui_but_event_property_operator_string(
|
||||
else {
|
||||
//puts("other id");
|
||||
}
|
||||
|
||||
|
||||
//printf("prop shortcut: '%s' (%s)\n", RNA_property_identifier(but->rnaprop), data_path);
|
||||
}
|
||||
|
||||
|
||||
/* we have a datapath! */
|
||||
if (data_path) {
|
||||
size_t i;
|
||||
|
||||
|
||||
/* create a property to host the "datapath" property we're sending to the operators */
|
||||
IDProperty *prop_path;
|
||||
IDProperty *prop_path_value;
|
||||
|
||||
|
||||
IDPropertyTemplate val = {0};
|
||||
prop_path = IDP_New(IDP_GROUP, &val, __func__);
|
||||
prop_path_value = IDP_NewString(data_path, "data_path", strlen(data_path) + 1);
|
||||
IDP_AddToGroup(prop_path, prop_path_value);
|
||||
|
||||
|
||||
/* check each until one works... */
|
||||
for (i = 0; (i < num_ops) && (ctx_toggle_opnames[i]); i++) {
|
||||
if (WM_key_event_operator_string(
|
||||
@@ -1130,14 +1130,14 @@ static bool ui_but_event_property_operator_string(
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* cleanup */
|
||||
IDP_FreeProperty(prop_path);
|
||||
MEM_freeN(prop_path);
|
||||
MEM_freeN(data_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
@@ -1294,7 +1294,7 @@ void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2], int r_x
|
||||
if (block->flag & UI_BLOCK_LOOP) {
|
||||
ui_menu_block_set_keymaps(C, block);
|
||||
}
|
||||
|
||||
|
||||
/* after keymaps! */
|
||||
switch (block->bounds_type) {
|
||||
case UI_BLOCK_BOUNDS_NONE:
|
||||
@@ -1342,12 +1342,12 @@ void ui_fontscale(short *points, float aspect)
|
||||
{
|
||||
if (aspect < 0.9f || aspect > 1.1f) {
|
||||
float pointsf = *points;
|
||||
|
||||
|
||||
/* for some reason scaling fonts goes too fast compared to widget size */
|
||||
/* XXX not true anymore? (ton) */
|
||||
//aspect = sqrt(aspect);
|
||||
pointsf /= aspect;
|
||||
|
||||
|
||||
if (aspect > 1.0f)
|
||||
*points = ceilf(pointsf);
|
||||
else
|
||||
@@ -1373,7 +1373,7 @@ void UI_block_draw(const bContext *C, uiBlock *block)
|
||||
uiBut *but;
|
||||
rcti rect;
|
||||
int multisample_enabled;
|
||||
|
||||
|
||||
/* get menu region or area region */
|
||||
ar = CTX_wm_menu(C);
|
||||
if (!ar)
|
||||
@@ -1389,16 +1389,16 @@ void UI_block_draw(const bContext *C, uiBlock *block)
|
||||
|
||||
/* we set this only once */
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
|
||||
/* scale fonts */
|
||||
ui_fontscale(&style.paneltitle.points, block->aspect);
|
||||
ui_fontscale(&style.grouplabel.points, block->aspect);
|
||||
ui_fontscale(&style.widgetlabel.points, block->aspect);
|
||||
ui_fontscale(&style.widget.points, block->aspect);
|
||||
|
||||
|
||||
/* scale block min/max to rect */
|
||||
ui_but_to_pixelrect(&rect, ar, block, NULL);
|
||||
|
||||
|
||||
/* pixel space for AA widgets */
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
@@ -1407,7 +1407,7 @@ void UI_block_draw(const bContext *C, uiBlock *block)
|
||||
glLoadIdentity();
|
||||
|
||||
wmOrtho2_region_pixelspace(ar);
|
||||
|
||||
|
||||
/* back */
|
||||
if (block->flag & UI_BLOCK_RADIAL)
|
||||
ui_draw_pie_center(block);
|
||||
@@ -1420,14 +1420,14 @@ void UI_block_draw(const bContext *C, uiBlock *block)
|
||||
for (but = block->buttons.first; but; but = but->next) {
|
||||
if (!(but->flag & (UI_HIDDEN | UI_SCROLLED))) {
|
||||
ui_but_to_pixelrect(&rect, ar, block, but);
|
||||
|
||||
|
||||
/* XXX: figure out why invalid coordinates happen when closing render window */
|
||||
/* and material preview is redrawn in main window (temp fix for bug #23848) */
|
||||
if (rect.xmin < rect.xmax && rect.ymin < rect.ymax)
|
||||
ui_draw_but(C, ar, &style, but, &rect);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* restore matrix */
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
@@ -1436,7 +1436,7 @@ void UI_block_draw(const bContext *C, uiBlock *block)
|
||||
|
||||
if (multisample_enabled)
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
|
||||
|
||||
ui_draw_links(block);
|
||||
}
|
||||
|
||||
@@ -1524,7 +1524,7 @@ static void ui_but_update_select_flag(uiBut *but, double *value)
|
||||
static uiBut *ui_linkline_find_inlink(uiBlock *block, void *poin)
|
||||
{
|
||||
uiBut *but;
|
||||
|
||||
|
||||
but = block->buttons.first;
|
||||
while (but) {
|
||||
if (but->type == UI_BTYPE_INLINK) {
|
||||
@@ -1538,7 +1538,7 @@ static uiBut *ui_linkline_find_inlink(uiBlock *block, void *poin)
|
||||
static void ui_linkline_add(ListBase *listb, uiBut *but, uiBut *bt, short deactive)
|
||||
{
|
||||
uiLinkLine *line;
|
||||
|
||||
|
||||
line = MEM_callocN(sizeof(uiLinkLine), "linkline");
|
||||
BLI_addtail(listb, line);
|
||||
line->from = but;
|
||||
@@ -1557,12 +1557,12 @@ void UI_block_links_compose(uiBlock *block)
|
||||
uiLink *link;
|
||||
void ***ppoin;
|
||||
int a;
|
||||
|
||||
|
||||
but = block->buttons.first;
|
||||
while (but) {
|
||||
if (but->type == UI_BTYPE_LINK) {
|
||||
link = but->link;
|
||||
|
||||
|
||||
/* for all pointers in the array */
|
||||
if (link) {
|
||||
if (link->ppoin) {
|
||||
@@ -1620,14 +1620,14 @@ void ui_linkline_remove(uiLinkLine *line, uiBut *but)
|
||||
{
|
||||
uiLink *link;
|
||||
int a, b;
|
||||
|
||||
|
||||
BLI_remlink(&but->link->lines, line);
|
||||
|
||||
link = line->from->link;
|
||||
|
||||
/* are there more pointers allowed? */
|
||||
if (link->ppoin) {
|
||||
|
||||
|
||||
if (*(link->totlink) == 1) {
|
||||
*(link->totlink) = 0;
|
||||
MEM_freeN(*(link->ppoin));
|
||||
@@ -1753,10 +1753,10 @@ bool ui_but_is_float(const uiBut *but)
|
||||
{
|
||||
if (but->pointype == UI_BUT_POIN_FLOAT && but->poin)
|
||||
return true;
|
||||
|
||||
|
||||
if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_FLOAT)
|
||||
return true;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1787,7 +1787,7 @@ bool ui_but_is_unit(const uiBut *but)
|
||||
if (ui_but_is_unit_radians_ex(unit, unit_type))
|
||||
return false;
|
||||
#endif
|
||||
|
||||
|
||||
/* for now disable time unit conversion */
|
||||
if (unit_type == PROP_UNIT_TIME)
|
||||
return false;
|
||||
@@ -1969,7 +1969,7 @@ void ui_but_value_set(uiBut *but, double value)
|
||||
if (fval >= -0.00001f && fval <= 0.00001f) fval = 0.0f; /* prevent negative zero */
|
||||
value = fval;
|
||||
}
|
||||
|
||||
|
||||
/* then set value with possible edit override */
|
||||
if (but->editval)
|
||||
value = *but->editval = value;
|
||||
@@ -2098,11 +2098,11 @@ void ui_but_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen)
|
||||
UnitSettings *unit = but->block->unit;
|
||||
int unit_type = UI_but_unit_type_get(but);
|
||||
char *orig_str;
|
||||
|
||||
|
||||
orig_str = BLI_strdup(str);
|
||||
|
||||
|
||||
bUnit_ToUnitAltName(str, maxlen, orig_str, unit->system, RNA_SUBTYPE_UNIT_VALUE(unit_type));
|
||||
|
||||
|
||||
MEM_freeN(orig_str);
|
||||
}
|
||||
}
|
||||
@@ -2448,7 +2448,7 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
|
||||
else {
|
||||
ptr = but->rnasearchpoin;
|
||||
prop = but->rnasearchprop;
|
||||
|
||||
|
||||
if (prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr))
|
||||
RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr);
|
||||
|
||||
@@ -2739,7 +2739,7 @@ void UI_block_free(const bContext *C, uiBlock *block)
|
||||
|
||||
BLI_freelistN(&block->saferct);
|
||||
BLI_freelistN(&block->color_pickers.list);
|
||||
|
||||
|
||||
MEM_freeN(block);
|
||||
}
|
||||
|
||||
@@ -2747,7 +2747,7 @@ void UI_block_free(const bContext *C, uiBlock *block)
|
||||
void UI_blocklist_free(const bContext *C, ListBase *lb)
|
||||
{
|
||||
uiBlock *block;
|
||||
|
||||
|
||||
while ((block = BLI_pophead(lb))) {
|
||||
UI_block_free(C, block);
|
||||
}
|
||||
@@ -2759,7 +2759,7 @@ void UI_blocklist_free_inactive(const bContext *C, ListBase *lb)
|
||||
|
||||
for (block = lb->first; block; block = nextblock) {
|
||||
nextblock = block->next;
|
||||
|
||||
|
||||
if (!block->handle) {
|
||||
if (!block->active) {
|
||||
BLI_remlink(lb, block);
|
||||
@@ -2871,9 +2871,9 @@ void ui_but_update_ex(uiBut *but, const bool validate)
|
||||
/* if something changed in the button */
|
||||
double value = UI_BUT_VALUE_UNSET;
|
||||
// float okwidth; // UNUSED
|
||||
|
||||
|
||||
ui_but_update_select_flag(but, &value);
|
||||
|
||||
|
||||
/* only update soft range while not editing */
|
||||
if (!(but->editval || but->editstr || but->editvec)) {
|
||||
if ((but->rnaprop != NULL) ||
|
||||
@@ -2902,7 +2902,7 @@ void ui_but_update_ex(uiBut *but, const bool validate)
|
||||
but->hardmin <= but->hardmax);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_ICON_TOGGLE:
|
||||
case UI_BTYPE_ICON_TOGGLE_N:
|
||||
if (!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) {
|
||||
@@ -2910,16 +2910,16 @@ void ui_but_update_ex(uiBut *but, const bool validate)
|
||||
else but->iconadd = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
/* quiet warnings for unhandled types */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* safety is 4 to enable small number buttons (like 'users') */
|
||||
// okwidth = -4 + (BLI_rcti_size_x(&but->rect)); // UNUSED
|
||||
|
||||
|
||||
/* name: */
|
||||
switch (but->type) {
|
||||
|
||||
@@ -3007,7 +3007,7 @@ void ui_but_update_ex(uiBut *but, const bool validate)
|
||||
else {
|
||||
BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case UI_BTYPE_TEXT:
|
||||
@@ -3019,7 +3019,7 @@ void ui_but_update_ex(uiBut *but, const bool validate)
|
||||
BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, str);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_KEY_EVENT:
|
||||
{
|
||||
const char *str;
|
||||
@@ -3066,13 +3066,13 @@ void ui_but_update_ex(uiBut *but, const bool validate)
|
||||
default:
|
||||
BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* if we are doing text editing, this will override the drawstr */
|
||||
if (but->editstr)
|
||||
but->drawstr[0] = '\0';
|
||||
|
||||
|
||||
/* text clipping moved to widget drawing code itself */
|
||||
}
|
||||
|
||||
@@ -3155,7 +3155,7 @@ static uiBut *ui_def_but(
|
||||
int slen;
|
||||
|
||||
BLI_assert(width >= 0 && height >= 0);
|
||||
|
||||
|
||||
/* we could do some more error checks here */
|
||||
if ((type & BUTTYPE) == UI_BTYPE_LABEL) {
|
||||
BLI_assert((poin != NULL || min != 0.0f || max != 0.0f || (a1 == 0.0f && a2 != 0.0f) || (a1 != 0.0f && a1 != 1.0f)) == false);
|
||||
@@ -3210,7 +3210,7 @@ static uiBut *ui_def_but(
|
||||
but->funcN = block->funcN;
|
||||
if (block->func_argN)
|
||||
but->func_argN = MEM_dupallocN(block->func_argN);
|
||||
|
||||
|
||||
but->pos = -1; /* cursor invisible */
|
||||
|
||||
if (ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER)) { /* add a space to name */
|
||||
@@ -3263,7 +3263,7 @@ static uiBut *ui_def_but(
|
||||
}
|
||||
|
||||
BLI_addtail(&block->buttons, but);
|
||||
|
||||
|
||||
if (block->curlayout)
|
||||
ui_layout_add_but(block->curlayout, but);
|
||||
|
||||
@@ -3552,7 +3552,7 @@ static uiBut *ui_def_but_rna(
|
||||
if (icon) {
|
||||
ui_def_but_icon(but, icon, UI_HAS_ICON);
|
||||
}
|
||||
|
||||
|
||||
if ((type == UI_BTYPE_MENU) && (but->dt == UI_EMBOSS_PULLDOWN)) {
|
||||
but->flag |= UI_BUT_ICON_SUBMENU;
|
||||
}
|
||||
@@ -3629,7 +3629,7 @@ uiBut *uiDefBut(uiBlock *block, int type, int retval, const char *str, int x, in
|
||||
uiBut *but = ui_def_but(block, type, retval, str, x, y, width, height, poin, min, max, a1, a2, tip);
|
||||
|
||||
ui_but_update(but);
|
||||
|
||||
|
||||
return but;
|
||||
}
|
||||
|
||||
@@ -3671,7 +3671,7 @@ struct AutoComplete {
|
||||
AutoComplete *UI_autocomplete_begin(const char *startname, size_t maxlen)
|
||||
{
|
||||
AutoComplete *autocpl;
|
||||
|
||||
|
||||
autocpl = MEM_callocN(sizeof(AutoComplete), "AutoComplete");
|
||||
autocpl->maxlen = maxlen;
|
||||
autocpl->matches = 0;
|
||||
@@ -3712,7 +3712,7 @@ void UI_autocomplete_update_name(AutoComplete *autocpl, const char *name)
|
||||
}
|
||||
|
||||
int UI_autocomplete_end(AutoComplete *autocpl, char *autoname)
|
||||
{
|
||||
{
|
||||
int match = AUTOCOMPLETE_NO_MATCH;
|
||||
if (autocpl->truncate[0]) {
|
||||
if (autocpl->matches == 1) {
|
||||
@@ -3970,7 +3970,7 @@ uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int o
|
||||
uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip)
|
||||
{
|
||||
wmOperatorType *ot = WM_operatortype_find(opname, 0);
|
||||
if (str && str[0] == '\0')
|
||||
if (str && str[0] == '\0')
|
||||
return uiDefIconButO_ptr(block, type, ot, opcontext, icon, x, y, width, height, tip);
|
||||
return uiDefIconTextButO_ptr(block, type, ot, opcontext, icon, str, x, y, width, height, tip);
|
||||
}
|
||||
@@ -3980,9 +3980,9 @@ uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcon
|
||||
void UI_but_link_set(uiBut *but, void **poin, void ***ppoin, short *tot, int from, int to)
|
||||
{
|
||||
uiLink *link;
|
||||
|
||||
|
||||
link = but->link = MEM_callocN(sizeof(uiLink), "new uilink");
|
||||
|
||||
|
||||
link->poin = poin;
|
||||
link->ppoin = ppoin;
|
||||
link->totlink = tot;
|
||||
@@ -3996,11 +3996,11 @@ int UI_blocklist_min_y_get(ListBase *lb)
|
||||
{
|
||||
uiBlock *block;
|
||||
int min = 0;
|
||||
|
||||
|
||||
for (block = lb->first; block; block = block->next)
|
||||
if (block == lb->first || block->rect.ymin < min)
|
||||
min = block->rect.ymin;
|
||||
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
@@ -4019,7 +4019,7 @@ void UI_block_order_flip(uiBlock *block)
|
||||
return;
|
||||
else if (block->flag & UI_BLOCK_NO_FLIP)
|
||||
return;
|
||||
|
||||
|
||||
for (but = block->buttons.first; but; but = but->next) {
|
||||
if (but->drawflag & UI_BUT_ALIGN) return;
|
||||
if (but->rect.ymin < miny) miny = but->rect.ymin;
|
||||
@@ -4168,8 +4168,8 @@ void UI_but_unit_type_set(uiBut *but, const int unit_type)
|
||||
int UI_but_unit_type_get(const uiBut *but)
|
||||
{
|
||||
int ownUnit = (int)but->unit_type;
|
||||
|
||||
/* own unit define always takes precedence over RNA provided, allowing for overriding
|
||||
|
||||
/* own unit define always takes precedence over RNA provided, allowing for overriding
|
||||
* default value provided in RNA in a few special cases (i.e. Active Keyframe in Graph Edit)
|
||||
*/
|
||||
/* XXX: this doesn't allow clearing unit completely, though the same could be said for icons */
|
||||
@@ -4331,7 +4331,7 @@ uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int ic
|
||||
uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip)
|
||||
{
|
||||
uiBut *but = ui_def_but(block, UI_BTYPE_BLOCK, 0, str, x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip);
|
||||
|
||||
|
||||
/* XXX temp, old menu calls pass on icon arrow, which is now UI_BUT_ICON_SUBMENU flag */
|
||||
if (icon != ICON_RIGHTARROW_THIN) {
|
||||
ui_def_but_icon(but, icon, 0);
|
||||
@@ -4342,7 +4342,7 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg,
|
||||
|
||||
but->block_create_func = func;
|
||||
ui_but_update(but);
|
||||
|
||||
|
||||
return but;
|
||||
}
|
||||
|
||||
@@ -4350,14 +4350,14 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg,
|
||||
uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, int x, int y, short width, short height, const char *tip)
|
||||
{
|
||||
uiBut *but = ui_def_but(block, UI_BTYPE_BLOCK, retval, "", x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip);
|
||||
|
||||
|
||||
ui_def_but_icon(but, icon, UI_HAS_ICON);
|
||||
|
||||
but->drawflag |= UI_BUT_ICON_LEFT;
|
||||
|
||||
|
||||
but->block_create_func = func;
|
||||
ui_but_update(but);
|
||||
|
||||
|
||||
return but;
|
||||
}
|
||||
|
||||
@@ -4384,13 +4384,13 @@ uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x, in
|
||||
uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x, int y, short width, short height, float a1, float a2, const char *tip)
|
||||
{
|
||||
uiBut *but = ui_def_but(block, UI_BTYPE_SEARCH_MENU, retval, "", x, y, width, height, arg, 0.0, maxlen, a1, a2, tip);
|
||||
|
||||
|
||||
ui_def_but_icon(but, icon, UI_HAS_ICON);
|
||||
|
||||
but->drawflag |= UI_BUT_ICON_LEFT | UI_BUT_TEXT_LEFT;
|
||||
|
||||
|
||||
ui_but_update(but);
|
||||
|
||||
|
||||
return but;
|
||||
}
|
||||
|
||||
@@ -4414,7 +4414,7 @@ void UI_but_func_search_set(
|
||||
but->search_create_func = search_create_func;
|
||||
but->search_func = search_func;
|
||||
but->search_arg = arg;
|
||||
|
||||
|
||||
if (bfunc) {
|
||||
#ifdef DEBUG
|
||||
if (but->func) {
|
||||
@@ -4424,7 +4424,7 @@ void UI_but_func_search_set(
|
||||
#endif
|
||||
UI_but_func_set(but, bfunc, arg, active);
|
||||
}
|
||||
|
||||
|
||||
/* search buttons show red-alert if item doesn't exist, not for menus */
|
||||
if (0 == (but->block->flag & UI_BLOCK_LOOP)) {
|
||||
/* skip empty buttons, not all buttons need input, we only show invalid */
|
||||
@@ -4522,14 +4522,14 @@ uiBut *uiDefSearchButO_ptr(
|
||||
void UI_but_focus_on_enter_event(wmWindow *win, uiBut *but)
|
||||
{
|
||||
wmEvent event;
|
||||
|
||||
|
||||
wm_event_init_from_window(win, &event);
|
||||
|
||||
event.type = EVT_BUT_OPEN;
|
||||
event.val = KM_PRESS;
|
||||
event.customdata = but;
|
||||
event.customdatafree = false;
|
||||
|
||||
|
||||
wm_event_add(win, &event);
|
||||
}
|
||||
|
||||
@@ -4653,7 +4653,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
|
||||
PointerRNA *ptr = NULL;
|
||||
PropertyRNA *prop = NULL;
|
||||
int value = 0;
|
||||
|
||||
|
||||
/* get the enum property... */
|
||||
if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) {
|
||||
/* enum property */
|
||||
@@ -4664,8 +4664,8 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
|
||||
else if (but->optype) {
|
||||
PointerRNA *opptr = UI_but_operator_ptr_get(but);
|
||||
wmOperatorType *ot = but->optype;
|
||||
|
||||
/* if the default property of the operator is enum and it is set,
|
||||
|
||||
/* if the default property of the operator is enum and it is set,
|
||||
* fetch the tooltip of the selected value so that "Snap" and "Mirror"
|
||||
* operator menus in the Anim Editors will show tooltips for the different
|
||||
* operations instead of the meaningless generic operator tooltip
|
||||
@@ -4678,12 +4678,12 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* get strings from matching enum item */
|
||||
if (ptr && prop) {
|
||||
if (!item) {
|
||||
int i;
|
||||
|
||||
|
||||
RNA_property_enum_items_gettexted(C, ptr, prop, &items, &totitems, &free_items);
|
||||
for (i = 0, item = items; i < totitems; i++, item++) {
|
||||
if (item->identifier[0] && item->value == value)
|
||||
|
||||
@@ -487,7 +487,7 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
|
||||
{
|
||||
uiBut *prev, *but = NULL, *next;
|
||||
int flag = 0, cols = 0, rows = 0;
|
||||
|
||||
|
||||
/* auto align */
|
||||
|
||||
for (but = first; but && but->alignnr == nr; but = but->next) {
|
||||
@@ -498,7 +498,7 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
|
||||
}
|
||||
|
||||
/* rows == 0: 1 row, cols == 0: 1 column */
|
||||
|
||||
|
||||
/* note; how it uses 'flag' in loop below (either set it, or OR it) is confusing */
|
||||
for (but = first, prev = NULL; but && but->alignnr == nr; prev = but, but = but->next) {
|
||||
next = but->next;
|
||||
@@ -507,13 +507,13 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
|
||||
|
||||
/* clear old flag */
|
||||
but->drawflag &= ~UI_BUT_ALIGN;
|
||||
|
||||
|
||||
if (flag == 0) { /* first case */
|
||||
if (next) {
|
||||
if (buts_are_horiz(but, next)) {
|
||||
if (rows == 0)
|
||||
flag = UI_BUT_ALIGN_RIGHT;
|
||||
else
|
||||
else
|
||||
flag = UI_BUT_ALIGN_DOWN | UI_BUT_ALIGN_RIGHT;
|
||||
}
|
||||
else {
|
||||
@@ -560,14 +560,14 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
|
||||
flag |= UI_BUT_ALIGN_TOP;
|
||||
}
|
||||
else { /* next button switches to new row */
|
||||
|
||||
|
||||
if (prev && buts_are_horiz(prev, but))
|
||||
flag |= UI_BUT_ALIGN_LEFT;
|
||||
else {
|
||||
flag &= ~UI_BUT_ALIGN_LEFT;
|
||||
flag |= UI_BUT_ALIGN_TOP;
|
||||
}
|
||||
|
||||
|
||||
if ((flag & UI_BUT_ALIGN_TOP) == 0) { /* still top row */
|
||||
if (prev) {
|
||||
if (next && buts_are_horiz(but, next))
|
||||
@@ -577,16 +577,16 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
|
||||
flag = UI_BUT_ALIGN_DOWN | UI_BUT_ALIGN_LEFT;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
flag |= UI_BUT_ALIGN_DOWN;
|
||||
}
|
||||
else
|
||||
else
|
||||
flag |= UI_BUT_ALIGN_TOP;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
but->drawflag |= flag;
|
||||
|
||||
|
||||
/* merge coordinates */
|
||||
if (prev) {
|
||||
/* simple cases */
|
||||
@@ -609,7 +609,7 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
|
||||
/* the previous button is a single one in its row */
|
||||
but->rect.ymax = (prev->rect.ymin + but->rect.ymax) / 2.0f;
|
||||
prev->rect.ymin = but->rect.ymax;
|
||||
|
||||
|
||||
but->rect.xmin = prev->rect.xmin;
|
||||
if (next && buts_are_horiz(but, next) == 0)
|
||||
but->rect.xmax = prev->rect.xmax;
|
||||
|
||||
@@ -71,26 +71,26 @@ void ui_but_anim_flag(uiBut *but, float cfra)
|
||||
FCurve *fcu;
|
||||
bool driven;
|
||||
bool special;
|
||||
|
||||
|
||||
but->flag &= ~(UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN);
|
||||
|
||||
|
||||
/* NOTE: "special" is reserved for special F-Curves stored on the animation data
|
||||
* itself (which are used to animate properties of the animation data).
|
||||
* We count those as "animated" too for now
|
||||
*/
|
||||
fcu = ui_but_get_fcurve(but, &adt, &act, &driven, &special);
|
||||
|
||||
|
||||
if (fcu) {
|
||||
if (!driven) {
|
||||
but->flag |= UI_BUT_ANIMATED;
|
||||
|
||||
/* T41525 - When the active action is a NLA strip being edited,
|
||||
|
||||
/* T41525 - When the active action is a NLA strip being edited,
|
||||
* we need to correct the frame number to "look inside" the
|
||||
* remapped action
|
||||
*/
|
||||
if (adt)
|
||||
cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP);
|
||||
|
||||
|
||||
if (fcurve_frame_has_keyframe(fcu, cfra, 0))
|
||||
but->flag |= UI_BUT_ANIMATED_KEY;
|
||||
}
|
||||
@@ -109,9 +109,9 @@ bool ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen)
|
||||
FCurve *fcu;
|
||||
ChannelDriver *driver;
|
||||
bool driven, special;
|
||||
|
||||
|
||||
fcu = ui_but_get_fcurve(but, NULL, NULL, &driven, &special);
|
||||
|
||||
|
||||
if (fcu && driven) {
|
||||
driver = fcu->driver;
|
||||
|
||||
@@ -136,20 +136,20 @@ bool ui_but_anim_expression_set(uiBut *but, const char *str)
|
||||
|
||||
if (fcu && driven) {
|
||||
driver = fcu->driver;
|
||||
|
||||
|
||||
if (driver && (driver->type == DRIVER_TYPE_PYTHON)) {
|
||||
BLI_strncpy_utf8(driver->expression, str, sizeof(driver->expression));
|
||||
|
||||
|
||||
/* tag driver as needing to be recompiled */
|
||||
driver->flag |= DRIVER_FLAG_RECOMPILE;
|
||||
|
||||
|
||||
/* clear invalid flags which may prevent this from working */
|
||||
driver->flag &= ~DRIVER_FLAG_INVALID;
|
||||
fcu->flag &= ~FCURVE_DISABLED;
|
||||
|
||||
|
||||
/* this notifier should update the Graph Editor and trigger depsgraph refresh? */
|
||||
WM_event_add_notifier(but->block->evil_C, NC_ANIMATION | ND_KEYFRAME, NULL);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -165,14 +165,14 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str)
|
||||
FCurve *fcu;
|
||||
char *path;
|
||||
bool ok = false;
|
||||
|
||||
|
||||
/* button must have RNA-pointer to a numeric-capable property */
|
||||
if (ELEM(NULL, but->rnapoin.data, but->rnaprop)) {
|
||||
if (G.debug & G_DEBUG)
|
||||
printf("ERROR: create expression failed - button has no RNA info attached\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (RNA_property_array_check(but->rnaprop) != 0) {
|
||||
if (but->rnaindex == -1) {
|
||||
if (G.debug & G_DEBUG)
|
||||
@@ -180,7 +180,7 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* make sure we have animdata for this */
|
||||
/* FIXME: until materials can be handled by depsgraph, don't allow drivers to be created for them */
|
||||
id = (ID *)but->rnapoin.id.data;
|
||||
@@ -189,18 +189,18 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str)
|
||||
printf("ERROR: create expression failed - invalid data-block for adding drivers (%p)\n", id);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* get path */
|
||||
path = RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop);
|
||||
if (path == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* create driver */
|
||||
fcu = verify_driver_fcurve(id, path, but->rnaindex, 1);
|
||||
if (fcu) {
|
||||
ChannelDriver *driver = fcu->driver;
|
||||
|
||||
|
||||
if (driver) {
|
||||
/* set type of driver */
|
||||
driver->type = DRIVER_TYPE_PYTHON;
|
||||
@@ -216,9 +216,9 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str)
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MEM_freeN(path);
|
||||
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -231,16 +231,16 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
|
||||
bool special;
|
||||
|
||||
fcu = ui_but_get_fcurve(but, NULL, &action, &driven, &special);
|
||||
|
||||
|
||||
if (fcu == NULL)
|
||||
return;
|
||||
|
||||
|
||||
if (special) {
|
||||
/* NLA Strip property */
|
||||
if (IS_AUTOKEY_ON(scene)) {
|
||||
ReportList *reports = CTX_wm_reports(C);
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
|
||||
|
||||
insert_keyframe_direct(reports, but->rnapoin, but->rnaprop, fcu, cfra, ts->keyframe_type, 0);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
}
|
||||
@@ -252,29 +252,29 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
|
||||
if (IS_AUTOKEY_ON(scene)) {
|
||||
ReportList *reports = CTX_wm_reports(C);
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
|
||||
|
||||
insert_keyframe_direct(reports, but->rnapoin, but->rnaprop, fcu, cfra, ts->keyframe_type, INSERTKEY_DRIVER);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
id = but->rnapoin.id.data;
|
||||
|
||||
|
||||
/* TODO: this should probably respect the keyingset only option for anim */
|
||||
if (autokeyframe_cfra_can_key(scene, id)) {
|
||||
ReportList *reports = CTX_wm_reports(C);
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
short flag = ANIM_get_keyframing_flags(scene, 1);
|
||||
|
||||
|
||||
fcu->flag &= ~FCURVE_SELECTED;
|
||||
|
||||
|
||||
/* Note: We use but->rnaindex instead of fcu->array_index,
|
||||
* because a button may control all items of an array at once.
|
||||
* E.g., color wheels (see T42567). */
|
||||
BLI_assert((fcu->array_index == but->rnaindex) || (but->rnaindex == -1));
|
||||
insert_keyframe(reports, id, action, ((fcu->grp) ? (fcu->grp->name) : (NULL)),
|
||||
fcu->rna_path, but->rnaindex, cfra, ts->keyframe_type, flag);
|
||||
|
||||
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ void UI_draw_roundbox_corner_set(int type)
|
||||
* if this is undone, it's not that big a deal, only makes curves edges
|
||||
* square for the */
|
||||
roundboxtype = type;
|
||||
|
||||
|
||||
}
|
||||
|
||||
int UI_draw_roundbox_corner_get(void)
|
||||
@@ -84,7 +84,7 @@ void UI_draw_roundbox_gl_mode(int mode, float minx, float miny, float maxx, floa
|
||||
float vec[7][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
|
||||
{0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
|
||||
int a;
|
||||
|
||||
|
||||
/* mult */
|
||||
for (a = 0; a < 7; a++) {
|
||||
mul_v2_fl(vec[a], rad);
|
||||
@@ -103,7 +103,7 @@ void UI_draw_roundbox_gl_mode(int mode, float minx, float miny, float maxx, floa
|
||||
else {
|
||||
glVertex2f(maxx, miny);
|
||||
}
|
||||
|
||||
|
||||
/* corner right-top */
|
||||
if (roundboxtype & UI_CNR_TOP_RIGHT) {
|
||||
glVertex2f(maxx, maxy - rad);
|
||||
@@ -115,7 +115,7 @@ void UI_draw_roundbox_gl_mode(int mode, float minx, float miny, float maxx, floa
|
||||
else {
|
||||
glVertex2f(maxx, maxy);
|
||||
}
|
||||
|
||||
|
||||
/* corner left-top */
|
||||
if (roundboxtype & UI_CNR_TOP_LEFT) {
|
||||
glVertex2f(minx + rad, maxy);
|
||||
@@ -127,7 +127,7 @@ void UI_draw_roundbox_gl_mode(int mode, float minx, float miny, float maxx, floa
|
||||
else {
|
||||
glVertex2f(minx, maxy);
|
||||
}
|
||||
|
||||
|
||||
/* corner left-bottom */
|
||||
if (roundboxtype & UI_CNR_BOTTOM_LEFT) {
|
||||
glVertex2f(minx, miny + rad);
|
||||
@@ -139,7 +139,7 @@ void UI_draw_roundbox_gl_mode(int mode, float minx, float miny, float maxx, floa
|
||||
else {
|
||||
glVertex2f(minx, miny);
|
||||
}
|
||||
|
||||
|
||||
glEnd();
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ void UI_draw_roundbox_shade_x(
|
||||
const float idiv = 1.0f / div;
|
||||
float coltop[3], coldown[3], color[4];
|
||||
int a;
|
||||
|
||||
|
||||
/* mult */
|
||||
for (a = 0; a < 7; a++) {
|
||||
mul_v2_fl(vec[a], rad);
|
||||
@@ -185,15 +185,15 @@ void UI_draw_roundbox_shade_x(
|
||||
|
||||
/* start with corner right-bottom */
|
||||
if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
|
||||
|
||||
|
||||
round_box_shade_col(coltop, coldown, 0.0);
|
||||
glVertex2f(maxx - rad, miny);
|
||||
|
||||
|
||||
for (a = 0; a < 7; a++) {
|
||||
round_box_shade_col(coltop, coldown, vec[a][1] * idiv);
|
||||
glVertex2f(maxx - rad + vec[a][0], miny + vec[a][1]);
|
||||
}
|
||||
|
||||
|
||||
round_box_shade_col(coltop, coldown, rad * idiv);
|
||||
glVertex2f(maxx, miny + rad);
|
||||
}
|
||||
@@ -201,13 +201,13 @@ void UI_draw_roundbox_shade_x(
|
||||
round_box_shade_col(coltop, coldown, 0.0);
|
||||
glVertex2f(maxx, miny);
|
||||
}
|
||||
|
||||
|
||||
/* corner right-top */
|
||||
if (roundboxtype & UI_CNR_TOP_RIGHT) {
|
||||
|
||||
|
||||
round_box_shade_col(coltop, coldown, (div - rad) * idiv);
|
||||
glVertex2f(maxx, maxy - rad);
|
||||
|
||||
|
||||
for (a = 0; a < 7; a++) {
|
||||
round_box_shade_col(coltop, coldown, (div - rad + vec[a][1]) * idiv);
|
||||
glVertex2f(maxx - vec[a][1], maxy - rad + vec[a][0]);
|
||||
@@ -219,18 +219,18 @@ void UI_draw_roundbox_shade_x(
|
||||
round_box_shade_col(coltop, coldown, 1.0);
|
||||
glVertex2f(maxx, maxy);
|
||||
}
|
||||
|
||||
|
||||
/* corner left-top */
|
||||
if (roundboxtype & UI_CNR_TOP_LEFT) {
|
||||
|
||||
|
||||
round_box_shade_col(coltop, coldown, 1.0);
|
||||
glVertex2f(minx + rad, maxy);
|
||||
|
||||
|
||||
for (a = 0; a < 7; a++) {
|
||||
round_box_shade_col(coltop, coldown, (div - vec[a][1]) * idiv);
|
||||
glVertex2f(minx + rad - vec[a][0], maxy - vec[a][1]);
|
||||
}
|
||||
|
||||
|
||||
round_box_shade_col(coltop, coldown, (div - rad) * idiv);
|
||||
glVertex2f(minx, maxy - rad);
|
||||
}
|
||||
@@ -238,18 +238,18 @@ void UI_draw_roundbox_shade_x(
|
||||
round_box_shade_col(coltop, coldown, 1.0);
|
||||
glVertex2f(minx, maxy);
|
||||
}
|
||||
|
||||
|
||||
/* corner left-bottom */
|
||||
if (roundboxtype & UI_CNR_BOTTOM_LEFT) {
|
||||
|
||||
|
||||
round_box_shade_col(coltop, coldown, rad * idiv);
|
||||
glVertex2f(minx, miny + rad);
|
||||
|
||||
|
||||
for (a = 0; a < 7; a++) {
|
||||
round_box_shade_col(coltop, coldown, (rad - vec[a][1]) * idiv);
|
||||
glVertex2f(minx + vec[a][1], miny + rad - vec[a][0]);
|
||||
}
|
||||
|
||||
|
||||
round_box_shade_col(coltop, coldown, 0.0);
|
||||
glVertex2f(minx + rad, miny);
|
||||
}
|
||||
@@ -257,7 +257,7 @@ void UI_draw_roundbox_shade_x(
|
||||
round_box_shade_col(coltop, coldown, 0.0);
|
||||
glVertex2f(minx, miny);
|
||||
}
|
||||
|
||||
|
||||
glEnd();
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ void UI_draw_roundbox_shade_y(
|
||||
const float idiv = 1.0f / div;
|
||||
float colLeft[3], colRight[3], color[4];
|
||||
int a;
|
||||
|
||||
|
||||
/* mult */
|
||||
for (a = 0; a < 7; a++) {
|
||||
mul_v2_fl(vec[a], rad);
|
||||
@@ -295,12 +295,12 @@ void UI_draw_roundbox_shade_y(
|
||||
if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
|
||||
round_box_shade_col(colLeft, colRight, 0.0);
|
||||
glVertex2f(maxx - rad, miny);
|
||||
|
||||
|
||||
for (a = 0; a < 7; a++) {
|
||||
round_box_shade_col(colLeft, colRight, vec[a][0] * idiv);
|
||||
glVertex2f(maxx - rad + vec[a][0], miny + vec[a][1]);
|
||||
}
|
||||
|
||||
|
||||
round_box_shade_col(colLeft, colRight, rad * idiv);
|
||||
glVertex2f(maxx, miny + rad);
|
||||
}
|
||||
@@ -308,14 +308,14 @@ void UI_draw_roundbox_shade_y(
|
||||
round_box_shade_col(colLeft, colRight, 0.0);
|
||||
glVertex2f(maxx, miny);
|
||||
}
|
||||
|
||||
|
||||
/* corner right-top */
|
||||
if (roundboxtype & UI_CNR_TOP_RIGHT) {
|
||||
round_box_shade_col(colLeft, colRight, 0.0);
|
||||
glVertex2f(maxx, maxy - rad);
|
||||
|
||||
|
||||
for (a = 0; a < 7; a++) {
|
||||
|
||||
|
||||
round_box_shade_col(colLeft, colRight, (div - rad - vec[a][0]) * idiv);
|
||||
glVertex2f(maxx - vec[a][1], maxy - rad + vec[a][0]);
|
||||
}
|
||||
@@ -326,17 +326,17 @@ void UI_draw_roundbox_shade_y(
|
||||
round_box_shade_col(colLeft, colRight, 0.0);
|
||||
glVertex2f(maxx, maxy);
|
||||
}
|
||||
|
||||
|
||||
/* corner left-top */
|
||||
if (roundboxtype & UI_CNR_TOP_LEFT) {
|
||||
round_box_shade_col(colLeft, colRight, (div - rad) * idiv);
|
||||
glVertex2f(minx + rad, maxy);
|
||||
|
||||
|
||||
for (a = 0; a < 7; a++) {
|
||||
round_box_shade_col(colLeft, colRight, (div - rad + vec[a][0]) * idiv);
|
||||
glVertex2f(minx + rad - vec[a][0], maxy - vec[a][1]);
|
||||
}
|
||||
|
||||
|
||||
round_box_shade_col(colLeft, colRight, 1.0);
|
||||
glVertex2f(minx, maxy - rad);
|
||||
}
|
||||
@@ -344,17 +344,17 @@ void UI_draw_roundbox_shade_y(
|
||||
round_box_shade_col(colLeft, colRight, 1.0);
|
||||
glVertex2f(minx, maxy);
|
||||
}
|
||||
|
||||
|
||||
/* corner left-bottom */
|
||||
if (roundboxtype & UI_CNR_BOTTOM_LEFT) {
|
||||
round_box_shade_col(colLeft, colRight, 1.0);
|
||||
glVertex2f(minx, miny + rad);
|
||||
|
||||
|
||||
for (a = 0; a < 7; a++) {
|
||||
round_box_shade_col(colLeft, colRight, (vec[a][0]) * idiv);
|
||||
glVertex2f(minx + vec[a][1], miny + rad - vec[a][0]);
|
||||
}
|
||||
|
||||
|
||||
round_box_shade_col(colLeft, colRight, 1.0);
|
||||
glVertex2f(minx + rad, miny);
|
||||
}
|
||||
@@ -362,7 +362,7 @@ void UI_draw_roundbox_shade_y(
|
||||
round_box_shade_col(colLeft, colRight, 1.0);
|
||||
glVertex2f(minx, miny);
|
||||
}
|
||||
|
||||
|
||||
glEnd();
|
||||
}
|
||||
|
||||
@@ -370,14 +370,14 @@ void UI_draw_roundbox_shade_y(
|
||||
void UI_draw_roundbox_unfilled(float minx, float miny, float maxx, float maxy, float rad)
|
||||
{
|
||||
float color[4];
|
||||
|
||||
|
||||
if (roundboxtype & UI_RB_ALPHA) {
|
||||
glGetFloatv(GL_CURRENT_COLOR, color);
|
||||
color[3] = 0.5;
|
||||
glColor4fv(color);
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
|
||||
|
||||
/* set antialias line */
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glEnable(GL_BLEND);
|
||||
@@ -411,10 +411,10 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
|
||||
ImBuf *ibuf = (ImBuf *)but->poin;
|
||||
|
||||
if (!ibuf) return;
|
||||
|
||||
|
||||
int w = BLI_rcti_size_x(rect);
|
||||
int h = BLI_rcti_size_y(rect);
|
||||
|
||||
|
||||
/* scissor doesn't seem to be doing the right thing...? */
|
||||
#if 0
|
||||
//glColor4f(1.0, 0.f, 0.f, 1.f);
|
||||
@@ -425,26 +425,26 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
|
||||
glGetIntegerv(GL_SCISSOR_BOX, scissor);
|
||||
glScissor(ar->winrct.xmin + rect->xmin, ar->winrct.ymin + rect->ymin, w, h);
|
||||
#endif
|
||||
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glColor4f(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
|
||||
if (w != ibuf->x || h != ibuf->y) {
|
||||
float facx = (float)w / (float)ibuf->x;
|
||||
float facy = (float)h / (float)ibuf->y;
|
||||
glPixelZoom(facx, facy);
|
||||
}
|
||||
glaDrawPixelsAuto((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, ibuf->rect);
|
||||
|
||||
|
||||
glPixelZoom(1.0f, 1.0f);
|
||||
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
|
||||
#if 0
|
||||
// restore scissortest
|
||||
glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -559,17 +559,17 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
|
||||
Histogram *hist = (Histogram *)but->poin;
|
||||
int res = hist->x_resolution;
|
||||
const bool is_line = (hist->flag & HISTO_FLAG_LINE) != 0;
|
||||
|
||||
|
||||
rctf rect = {
|
||||
.xmin = (float)recti->xmin + 1,
|
||||
.xmax = (float)recti->xmax - 1,
|
||||
.ymin = (float)recti->ymin + 1,
|
||||
.ymax = (float)recti->ymax - 1
|
||||
};
|
||||
|
||||
|
||||
float w = BLI_rctf_size_x(&rect);
|
||||
float h = BLI_rctf_size_y(&rect) * hist->ymax;
|
||||
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
@@ -598,7 +598,7 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
|
||||
fdrawline(rect.xmin, rect.ymin + fac * h, rect.xmax, rect.ymin + fac * h);
|
||||
fdrawline(rect.xmin + fac * w, rect.ymin, rect.xmin + fac * w, rect.ymax);
|
||||
}
|
||||
|
||||
|
||||
if (hist->mode == HISTO_MODE_LUMA) {
|
||||
histogram_draw_one(1.0, 1.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_luma, res, is_line);
|
||||
}
|
||||
@@ -613,7 +613,7 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
|
||||
if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_B)
|
||||
histogram_draw_one(0.0, 0.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_b, res, is_line);
|
||||
}
|
||||
|
||||
|
||||
/* outline */
|
||||
draw_scope_end(&rect, scissor);
|
||||
}
|
||||
@@ -628,9 +628,9 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
||||
float colorsycc[3][3] = {{1, 0, 1}, {1, 1, 0}, {0, 1, 1}};
|
||||
float colors_alpha[3][3], colorsycc_alpha[3][3]; /* colors pre multiplied by alpha for speed up */
|
||||
float min, max;
|
||||
|
||||
|
||||
if (scopes == NULL) return;
|
||||
|
||||
|
||||
rctf rect = {
|
||||
.xmin = (float)recti->xmin + 1,
|
||||
.xmax = (float)recti->xmax - 1,
|
||||
@@ -644,10 +644,10 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
||||
float h = BLI_rctf_size_y(&rect) * scopes->wavefrm_yfac;
|
||||
float yofs = rect.ymin + (BLI_rctf_size_y(&rect) - h) / 2.0f;
|
||||
float w3 = w / 3.0f;
|
||||
|
||||
|
||||
/* log scale for alpha */
|
||||
float alpha = scopes->wavefrm_alpha * scopes->wavefrm_alpha;
|
||||
|
||||
|
||||
unit_m3(colors);
|
||||
|
||||
for (int c = 0; c < 3; c++) {
|
||||
@@ -689,7 +689,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
||||
fdrawline(rect.xmin + i * w3, rect.ymin, rect.xmin + i * w3, rect.ymax);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* separate min max zone on the right */
|
||||
fdrawline(rect.xmin + w, rect.ymin, rect.xmin + w, rect.ymax);
|
||||
/* 16-235-240 level in case of ITU-R BT601/709 */
|
||||
@@ -705,7 +705,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
||||
fdrawline(rect.xmin, yofs + h * 0.075f, rect.xmax + 1, yofs + h * 0.075f);
|
||||
|
||||
if (scopes->ok && scopes->waveform_1 != NULL) {
|
||||
|
||||
|
||||
/* LUMA (1 channel) */
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glColor3f(alpha, alpha, alpha);
|
||||
@@ -714,10 +714,10 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
||||
if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) {
|
||||
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
|
||||
glTranslatef(rect.xmin, yofs, 0.f);
|
||||
glScalef(w, h, 0.f);
|
||||
glVertexPointer(2, GL_FLOAT, 0, scopes->waveform_1);
|
||||
@@ -810,7 +810,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* outline */
|
||||
draw_scope_end(&rect, scissor);
|
||||
}
|
||||
@@ -885,20 +885,20 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
|
||||
const float colors[6][3] = {
|
||||
{0.75, 0.0, 0.0}, {0.75, 0.75, 0.0}, {0.0, 0.75, 0.0},
|
||||
{0.0, 0.75, 0.75}, {0.0, 0.0, 0.75}, {0.75, 0.0, 0.75}};
|
||||
|
||||
|
||||
rctf rect = {
|
||||
.xmin = (float)recti->xmin + 1,
|
||||
.xmax = (float)recti->xmax - 1,
|
||||
.ymin = (float)recti->ymin + 1,
|
||||
.ymax = (float)recti->ymax - 1
|
||||
};
|
||||
|
||||
|
||||
float w = BLI_rctf_size_x(&rect);
|
||||
float h = BLI_rctf_size_y(&rect);
|
||||
float centerx = rect.xmin + w / 2;
|
||||
float centery = rect.ymin + h / 2;
|
||||
float diam = (w < h) ? w : h;
|
||||
|
||||
|
||||
float alpha = scopes->vecscope_alpha * scopes->vecscope_alpha * scopes->vecscope_alpha;
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
@@ -915,7 +915,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
|
||||
ar->winrct.ymin + (rect.ymin - 1),
|
||||
(rect.xmax + 1) - (rect.xmin - 1),
|
||||
(rect.ymax + 1) - (rect.ymin - 1));
|
||||
|
||||
|
||||
glColor4f(1.f, 1.f, 1.f, 0.08f);
|
||||
/* draw grid elements */
|
||||
/* cross */
|
||||
@@ -939,7 +939,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
|
||||
/* saturation points */
|
||||
for (int i = 0; i < 6; i++)
|
||||
vectorscope_draw_target(centerx, centery, diam, colors[i]);
|
||||
|
||||
|
||||
if (scopes->ok && scopes->vecscope != NULL) {
|
||||
/* pixel point cloud */
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
@@ -954,7 +954,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
|
||||
glVertexPointer(2, GL_FLOAT, 0, scopes->vecscope);
|
||||
glPointSize(1.0);
|
||||
glDrawArrays(GL_POINTS, 0, scopes->waveform_tot);
|
||||
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glPopMatrix();
|
||||
}
|
||||
@@ -1117,16 +1117,16 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
|
||||
|
||||
v1[1] = y1 + sizey_solid;
|
||||
v2[1] = rect->ymax;
|
||||
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
for (int a = 0; a <= sizex; a++) {
|
||||
float pos = ((float)a) / sizex;
|
||||
BKE_colorband_evaluate(coba, pos, colf);
|
||||
if (display)
|
||||
IMB_colormanagement_scene_linear_to_display_v3(colf, display);
|
||||
|
||||
|
||||
v1[0] = v2[0] = x1 + a;
|
||||
|
||||
|
||||
glColor4fv(colf);
|
||||
glVertex2fv(v1);
|
||||
glVertex2fv(v2);
|
||||
@@ -1157,7 +1157,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
|
||||
/* layer: box outline */
|
||||
glColor4f(0.0, 0.0, 0.0, 1.0);
|
||||
fdrawbox(x1, y1, x1 + sizex, rect->ymax);
|
||||
|
||||
|
||||
/* layer: box outline */
|
||||
glEnable(GL_BLEND);
|
||||
glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
|
||||
@@ -1165,7 +1165,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 0.25f);
|
||||
fdrawline(x1, y1 - 1, x1 + sizex, y1 - 1);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
|
||||
/* layer: draw handles */
|
||||
for (int a = 0; a < coba->tot; a++, cbd++) {
|
||||
if (a != coba->cur) {
|
||||
@@ -1187,16 +1187,16 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
|
||||
static GLuint displist = 0;
|
||||
float diffuse[3] = {1.0f, 1.0f, 1.0f};
|
||||
float size;
|
||||
|
||||
|
||||
/* backdrop */
|
||||
glColor3ubv((unsigned char *)wcol->inner);
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
UI_draw_roundbox_gl_mode(GL_POLYGON, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f);
|
||||
|
||||
|
||||
/* sphere color */
|
||||
glCullFace(GL_BACK);
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
|
||||
/* setup lights */
|
||||
GPULightData light = {0};
|
||||
light.type = GPU_LIGHT_SUN;
|
||||
@@ -1215,7 +1215,7 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
|
||||
/* transform to button */
|
||||
glPushMatrix();
|
||||
glTranslatef(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect), 0.0f);
|
||||
|
||||
|
||||
if (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect))
|
||||
size = BLI_rcti_size_x(rect) / 200.f;
|
||||
else
|
||||
@@ -1228,13 +1228,13 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
|
||||
|
||||
displist = glGenLists(1);
|
||||
glNewList(displist, GL_COMPILE);
|
||||
|
||||
|
||||
qobj = gluNewQuadric();
|
||||
gluQuadricDrawStyle(qobj, GLU_FILL);
|
||||
GPU_basic_shader_bind(GPU_basic_shader_bound_options());
|
||||
gluSphere(qobj, 100.0, 32, 24);
|
||||
gluDeleteQuadric(qobj);
|
||||
|
||||
|
||||
glEndList();
|
||||
}
|
||||
|
||||
@@ -1244,7 +1244,7 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
|
||||
GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
|
||||
GPU_default_lights();
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
|
||||
/* AA circle */
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
@@ -1271,7 +1271,7 @@ static void ui_draw_but_curve_grid(const rcti *rect, float zoomx, float zoomy, f
|
||||
glVertex2f(fx, rect->ymax);
|
||||
fx += dx;
|
||||
}
|
||||
|
||||
|
||||
float dy = step * zoomy;
|
||||
float fy = rect->ymin + zoomy * (-offsy);
|
||||
if (fy > rect->ymin) fy -= dy * (floorf(fy - rect->ymin));
|
||||
@@ -1281,7 +1281,7 @@ static void ui_draw_but_curve_grid(const rcti *rect, float zoomx, float zoomy, f
|
||||
fy += dy;
|
||||
}
|
||||
glEnd();
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void gl_shaded_color(unsigned char *col, int shade)
|
||||
@@ -1324,7 +1324,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
|
||||
float zoomy = (BLI_rcti_size_y(rect) - 2.0f) / BLI_rctf_size_y(&cumap->curr);
|
||||
float offsx = cumap->curr.xmin - (1.0f / zoomx);
|
||||
float offsy = cumap->curr.ymin - (1.0f / zoomy);
|
||||
|
||||
|
||||
glLineWidth(1.0f);
|
||||
|
||||
/* backdrop */
|
||||
@@ -1407,7 +1407,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
|
||||
else if (cumap->cur == 3) {
|
||||
float lum = IMB_colormanagement_get_luminance(cumap->sample);
|
||||
glColor3ub(240, 240, 240);
|
||||
|
||||
|
||||
glVertex2f(rect->xmin + zoomx * (lum - offsx), rect->ymin);
|
||||
glVertex2f(rect->xmin + zoomx * (lum - offsx), rect->ymax);
|
||||
}
|
||||
@@ -1418,7 +1418,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
|
||||
glColor3ub(100, 240, 100);
|
||||
else
|
||||
glColor3ub(100, 100, 240);
|
||||
|
||||
|
||||
glVertex2f(rect->xmin + zoomx * (cumap->sample[cumap->cur] - offsx), rect->ymin);
|
||||
glVertex2f(rect->xmin + zoomx * (cumap->sample[cumap->cur] - offsx), rect->ymax);
|
||||
}
|
||||
@@ -1430,7 +1430,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glEnable(GL_BLEND);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
|
||||
|
||||
if (cuma->table == NULL)
|
||||
curvemapping_changed(cumap, false);
|
||||
|
||||
@@ -1477,7 +1477,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
|
||||
glVertex2f(fx, fy);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
|
||||
/* restore scissortest */
|
||||
glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
|
||||
|
||||
@@ -1609,7 +1609,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
|
||||
void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *recti)
|
||||
{
|
||||
static const float size = 5.0f;
|
||||
|
||||
|
||||
/* 16 values of sin function */
|
||||
const float si[16] = {
|
||||
0.00000000f, 0.39435585f, 0.72479278f, 0.93775213f,
|
||||
@@ -1624,12 +1624,12 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
|
||||
-0.99486932f, -0.87434661f, -0.61210598f, -0.25065253f,
|
||||
0.15142777f, 0.52896401f, 0.82076344f, 0.97952994f,
|
||||
};
|
||||
|
||||
|
||||
GLint scissor[4];
|
||||
|
||||
|
||||
/* need scissor test, can draw outside of boundary */
|
||||
glGetIntegerv(GL_VIEWPORT, scissor);
|
||||
|
||||
|
||||
rcti scissor_new = {
|
||||
.xmin = ar->winrct.xmin + recti->xmin,
|
||||
.ymin = ar->winrct.ymin + recti->ymin,
|
||||
@@ -1642,18 +1642,18 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
|
||||
scissor_new.ymin,
|
||||
BLI_rcti_size_x(&scissor_new),
|
||||
BLI_rcti_size_y(&scissor_new));
|
||||
|
||||
|
||||
glColor4ubv(but->col);
|
||||
|
||||
|
||||
float x = 0.5f * (recti->xmin + recti->xmax);
|
||||
float y = 0.5f * (recti->ymin + recti->ymax);
|
||||
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBegin(GL_POLYGON);
|
||||
for (int a = 0; a < 16; a++)
|
||||
glVertex2f(x + size * si[a], y + size * co[a]);
|
||||
glEnd();
|
||||
|
||||
|
||||
glColor4ub(0, 0, 0, 150);
|
||||
glLineWidth(1);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
@@ -1663,7 +1663,7 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
|
||||
glEnd();
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
|
||||
/* restore scissortest */
|
||||
glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
|
||||
}
|
||||
@@ -1680,7 +1680,7 @@ static void ui_shadowbox(float minx, float miny, float maxx, float maxy, float s
|
||||
glColor4ub(0, 0, 0, 0);
|
||||
glVertex2f(maxx + shadsize, maxy - 0.75f * shadsize);
|
||||
glVertex2f(maxx + shadsize, miny);
|
||||
|
||||
|
||||
/* corner shape */
|
||||
glColor4ub(0, 0, 0, alpha);
|
||||
glVertex2f(maxx, miny);
|
||||
@@ -1688,7 +1688,7 @@ static void ui_shadowbox(float minx, float miny, float maxx, float maxy, float s
|
||||
glVertex2f(maxx + shadsize, miny);
|
||||
glVertex2f(maxx + 0.7f * shadsize, miny - 0.7f * shadsize);
|
||||
glVertex2f(maxx, miny - shadsize);
|
||||
|
||||
|
||||
/* bottom quad */
|
||||
glColor4ub(0, 0, 0, alpha);
|
||||
glVertex2f(minx + 0.3f * shadsize, miny);
|
||||
@@ -1701,16 +1701,16 @@ static void ui_shadowbox(float minx, float miny, float maxx, float maxy, float s
|
||||
void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, float maxy)
|
||||
{
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
/* accumulated outline boxes to make shade not linear, is more pleasant */
|
||||
ui_shadowbox(minx, miny, maxx, maxy, 11.0, (20 * alpha) >> 8);
|
||||
ui_shadowbox(minx, miny, maxx, maxy, 7.0, (40 * alpha) >> 8);
|
||||
ui_shadowbox(minx, miny, maxx, maxy, 5.0, (80 * alpha) >> 8);
|
||||
|
||||
|
||||
glEnd();
|
||||
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
@@ -1718,7 +1718,7 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx,
|
||||
void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int UNUSED(select))
|
||||
{
|
||||
float rad;
|
||||
|
||||
|
||||
if (radius > (BLI_rctf_size_y(rct) - 10.0f) / 2.0f)
|
||||
rad = (BLI_rctf_size_y(rct) - 10.0f) / 2.0f;
|
||||
else
|
||||
@@ -1734,7 +1734,7 @@ void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha
|
||||
{
|
||||
a = i * aspect;
|
||||
}
|
||||
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
const float dalpha = alpha * 2.0f / 255.0f;
|
||||
@@ -1743,16 +1743,16 @@ void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha
|
||||
/* alpha ranges from 2 to 20 or so */
|
||||
glColor4f(0.0f, 0.0f, 0.0f, calpha);
|
||||
calpha += dalpha;
|
||||
|
||||
|
||||
UI_draw_roundbox_gl_mode(GL_POLYGON, rct->xmin - a, rct->ymin - a, rct->xmax + a, rct->ymax - 10.0f + a, rad + a);
|
||||
}
|
||||
|
||||
|
||||
/* outline emphasis */
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glColor4ub(0, 0, 0, 100);
|
||||
UI_draw_roundbox_gl_mode(GL_LINE_LOOP, rct->xmin - 0.5f, rct->ymin - 0.5f, rct->xmax + 0.5f, rct->ymax + 0.5f, radius + 0.5f);
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Contributor(s): Blender Foundation
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
@@ -296,7 +296,7 @@ typedef struct uiHandleButtonData {
|
||||
|
||||
/* tooltip */
|
||||
unsigned int tooltip_force : 1;
|
||||
|
||||
|
||||
/* auto open */
|
||||
bool used_mouse;
|
||||
wmTimer *autoopentimer;
|
||||
@@ -338,7 +338,7 @@ typedef struct uiHandleButtonData {
|
||||
/* menu open (watch UI_screen_free_active_but) */
|
||||
uiPopupBlockHandle *menu;
|
||||
int menuretval;
|
||||
|
||||
|
||||
/* search box (watch UI_screen_free_active_but) */
|
||||
ARegion *searchbox;
|
||||
#ifdef USE_KEYNAV_LIMIT
|
||||
@@ -365,14 +365,14 @@ typedef struct uiAfterFunc {
|
||||
uiButHandleFunc func;
|
||||
void *func_arg1;
|
||||
void *func_arg2;
|
||||
|
||||
|
||||
uiButHandleNFunc funcN;
|
||||
void *func_argN;
|
||||
|
||||
uiButHandleRenameFunc rename_func;
|
||||
void *rename_arg1;
|
||||
void *rename_orig;
|
||||
|
||||
|
||||
uiBlockHandleFunc handle_func;
|
||||
void *handle_func_arg;
|
||||
int retval;
|
||||
@@ -459,18 +459,18 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val)
|
||||
}
|
||||
else {
|
||||
lastdy += dy;
|
||||
|
||||
|
||||
if (ABS(lastdy) > (int)UI_UNIT_Y) {
|
||||
if (U.uiflag2 & USER_TRACKPAD_NATURAL)
|
||||
dy = -dy;
|
||||
|
||||
|
||||
*val = KM_PRESS;
|
||||
|
||||
|
||||
if (dy > 0)
|
||||
*type = WHEELUPMOUSE;
|
||||
else
|
||||
*type = WHEELDOWNMOUSE;
|
||||
|
||||
|
||||
lastdy = 0;
|
||||
}
|
||||
}
|
||||
@@ -512,7 +512,7 @@ static uiBut *ui_but_next(uiBut *but)
|
||||
static uiBut *ui_but_first(uiBlock *block)
|
||||
{
|
||||
uiBut *but;
|
||||
|
||||
|
||||
but = block->buttons.first;
|
||||
while (but) {
|
||||
if (ui_but_is_editable(but)) return but;
|
||||
@@ -524,7 +524,7 @@ static uiBut *ui_but_first(uiBlock *block)
|
||||
static uiBut *ui_but_last(uiBlock *block)
|
||||
{
|
||||
uiBut *but;
|
||||
|
||||
|
||||
but = block->buttons.last;
|
||||
while (but) {
|
||||
if (ui_but_is_editable(but)) return but;
|
||||
@@ -581,7 +581,7 @@ static void ui_mouse_scale_warp(
|
||||
float *r_mx, float *r_my, const bool shift)
|
||||
{
|
||||
const float fac = ui_mouse_scale_warp_factor(shift);
|
||||
|
||||
|
||||
/* slow down the mouse, this is fairly picky */
|
||||
*r_mx = (data->dragstartx * (1.0f - fac) + mx * fac);
|
||||
*r_my = (data->dragstarty * (1.0f - fac) + my * fac);
|
||||
@@ -695,7 +695,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
|
||||
after->butm_func_arg = block->butm_func_arg;
|
||||
after->a2 = but->a2;
|
||||
}
|
||||
|
||||
|
||||
if (block->handle)
|
||||
after->popup_op = block->handle->popup_op;
|
||||
|
||||
@@ -784,7 +784,7 @@ static void ui_apply_but_funcs_after(bContext *C)
|
||||
|
||||
if (after.popup_op)
|
||||
popup_check(C, after.popup_op);
|
||||
|
||||
|
||||
if (after.opptr) {
|
||||
/* free in advance to avoid leak on exit */
|
||||
opptr = *after.opptr;
|
||||
@@ -811,17 +811,17 @@ static void ui_apply_but_funcs_after(bContext *C)
|
||||
after.funcN(C, after.func_argN, after.func_arg2);
|
||||
if (after.func_argN)
|
||||
MEM_freeN(after.func_argN);
|
||||
|
||||
|
||||
if (after.handle_func)
|
||||
after.handle_func(C, after.handle_func_arg, after.retval);
|
||||
if (after.butm_func)
|
||||
after.butm_func(C, after.butm_func_arg, after.a2);
|
||||
|
||||
|
||||
if (after.rename_func)
|
||||
after.rename_func(C, after.rename_arg1, after.rename_orig);
|
||||
if (after.rename_orig)
|
||||
MEM_freeN(after.rename_orig);
|
||||
|
||||
|
||||
if (after.undostr[0])
|
||||
ED_undo_push(C, after.undostr);
|
||||
}
|
||||
@@ -859,32 +859,32 @@ static void ui_apply_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||
{
|
||||
double value;
|
||||
int w, lvalue, push;
|
||||
|
||||
|
||||
value = ui_but_value_get(but);
|
||||
lvalue = (int)value;
|
||||
|
||||
|
||||
if (but->bit) {
|
||||
w = UI_BITBUT_TEST(lvalue, but->bitnr);
|
||||
if (w) lvalue = UI_BITBUT_CLR(lvalue, but->bitnr);
|
||||
else lvalue = UI_BITBUT_SET(lvalue, but->bitnr);
|
||||
|
||||
|
||||
ui_but_value_set(but, (double)lvalue);
|
||||
if (but->type == UI_BTYPE_ICON_TOGGLE || but->type == UI_BTYPE_ICON_TOGGLE_N) {
|
||||
ui_but_update_edited(but);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
if (value == 0.0) push = 1;
|
||||
else push = 0;
|
||||
|
||||
|
||||
if (ELEM(but->type, UI_BTYPE_TOGGLE_N, UI_BTYPE_ICON_TOGGLE_N, UI_BTYPE_CHECKBOX_N)) push = !push;
|
||||
ui_but_value_set(but, (double)push);
|
||||
if (but->type == UI_BTYPE_ICON_TOGGLE || but->type == UI_BTYPE_ICON_TOGGLE_N) {
|
||||
ui_but_update_edited(but);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ui_apply_but_func(C, but);
|
||||
|
||||
data->retval = but->retval;
|
||||
@@ -1669,11 +1669,11 @@ static bool ui_but_contains_point_px_icon(uiBut *but, ARegion *ar, const wmEvent
|
||||
{
|
||||
rcti rect;
|
||||
int x = event->x, y = event->y;
|
||||
|
||||
|
||||
ui_window_to_block(ar, but->block, &x, &y);
|
||||
|
||||
|
||||
BLI_rcti_rctf_copy(&rect, &but->rect);
|
||||
|
||||
|
||||
if (but->imb || but->type == UI_BTYPE_COLOR) {
|
||||
/* use button size itself */
|
||||
}
|
||||
@@ -1685,7 +1685,7 @@ static bool ui_but_contains_point_px_icon(uiBut *but, ARegion *ar, const wmEvent
|
||||
rect.xmin += delta / 2;
|
||||
rect.xmax -= delta / 2;
|
||||
}
|
||||
|
||||
|
||||
return BLI_rcti_isect_pt(&rect, x, y);
|
||||
}
|
||||
|
||||
@@ -1776,7 +1776,7 @@ static bool ui_but_drag_init(
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1793,15 +1793,15 @@ static void ui_linkline_remove_active(uiBlock *block)
|
||||
if (but->type == UI_BTYPE_LINK && but->link) {
|
||||
for (line = but->link->lines.first; line; line = nline) {
|
||||
nline = line->next;
|
||||
|
||||
|
||||
if (line->flag & UI_SELECT) {
|
||||
BLI_remlink(&but->link->lines, line);
|
||||
|
||||
|
||||
link = line->from->link;
|
||||
|
||||
|
||||
/* are there more pointers allowed? */
|
||||
if (link->ppoin) {
|
||||
|
||||
|
||||
if (*(link->totlink) == 1) {
|
||||
*(link->totlink) = 0;
|
||||
MEM_freeN(*(link->ppoin));
|
||||
@@ -1810,7 +1810,7 @@ static void ui_linkline_remove_active(uiBlock *block)
|
||||
else {
|
||||
b = 0;
|
||||
for (a = 0; a < (*(link->totlink)); a++) {
|
||||
|
||||
|
||||
if ((*(link->ppoin))[a] != line->to->poin) {
|
||||
(*(link->ppoin))[b] = (*(link->ppoin))[a];
|
||||
b++;
|
||||
@@ -1822,7 +1822,7 @@ static void ui_linkline_remove_active(uiBlock *block)
|
||||
else {
|
||||
*(link->poin) = NULL;
|
||||
}
|
||||
|
||||
|
||||
MEM_freeN(line);
|
||||
}
|
||||
}
|
||||
@@ -1835,7 +1835,7 @@ static uiLinkLine *ui_but_find_link(uiBut *from, uiBut *to)
|
||||
{
|
||||
uiLinkLine *line;
|
||||
uiLink *link;
|
||||
|
||||
|
||||
link = from->link;
|
||||
if (link) {
|
||||
for (line = link->lines.first; line; line = line->next) {
|
||||
@@ -1861,7 +1861,7 @@ static void ui_but_smart_controller_add(bContext *C, uiBut *from, uiBut *to)
|
||||
uiLink *link = from->link;
|
||||
|
||||
PointerRNA props_ptr, object_ptr;
|
||||
|
||||
|
||||
if (link->ppoin)
|
||||
sens_from_links = (bController ***)(link->ppoin);
|
||||
else return;
|
||||
@@ -1890,10 +1890,10 @@ static void ui_but_smart_controller_add(bContext *C, uiBut *from, uiBut *to)
|
||||
|
||||
/* only works if the sensor and the actuator are from the same object */
|
||||
if (!act_iter) return;
|
||||
|
||||
|
||||
/* in case the linked controller is not the active one */
|
||||
RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr);
|
||||
|
||||
|
||||
WM_operator_properties_create(&props_ptr, "LOGIC_OT_controller_add");
|
||||
RNA_string_set(&props_ptr, "object", ob->id.name + 2);
|
||||
|
||||
@@ -1932,7 +1932,7 @@ static void ui_but_link_add(bContext *C, uiBut *from, uiBut *to)
|
||||
uiLinkLine *line;
|
||||
void **oldppoin;
|
||||
int a;
|
||||
|
||||
|
||||
if ((line = ui_but_find_link(from, to))) {
|
||||
line->flag |= UI_SELECT;
|
||||
ui_linkline_remove_active(from->block);
|
||||
@@ -1953,27 +1953,27 @@ static void ui_but_link_add(bContext *C, uiBut *from, uiBut *to)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
link = from->link;
|
||||
|
||||
|
||||
/* are there more pointers allowed? */
|
||||
if (link->ppoin) {
|
||||
oldppoin = *(link->ppoin);
|
||||
|
||||
|
||||
(*(link->totlink))++;
|
||||
*(link->ppoin) = MEM_callocN(*(link->totlink) * sizeof(void *), "new link");
|
||||
|
||||
|
||||
for (a = 0; a < (*(link->totlink)) - 1; a++) {
|
||||
(*(link->ppoin))[a] = oldppoin[a];
|
||||
}
|
||||
(*(link->ppoin))[a] = to->poin;
|
||||
|
||||
|
||||
if (oldppoin) MEM_freeN(oldppoin);
|
||||
}
|
||||
else {
|
||||
*(link->poin) = to->poin;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1981,7 +1981,7 @@ static void ui_apply_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||
{
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
uiBut *bt;
|
||||
|
||||
|
||||
for (bt = but->block->buttons.first; bt; bt = bt->next) {
|
||||
if (ui_but_contains_point_px(ar, bt, but->linkto[0] + ar->winrct.xmin, but->linkto[1] + ar->winrct.ymin) )
|
||||
break;
|
||||
@@ -1989,7 +1989,7 @@ static void ui_apply_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||
if (bt && bt != but) {
|
||||
if (!ELEM(bt->type, UI_BTYPE_LINK, UI_BTYPE_INLINK) || !ELEM(but->type, UI_BTYPE_LINK, UI_BTYPE_INLINK))
|
||||
return;
|
||||
|
||||
|
||||
if (but->type == UI_BTYPE_LINK) ui_but_link_add(C, but, bt);
|
||||
else ui_but_link_add(C, bt, but);
|
||||
|
||||
@@ -2208,13 +2208,13 @@ static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleB
|
||||
{
|
||||
wmDrag *wmd;
|
||||
ListBase *drags = event->customdata; /* drop event type has listbase customdata by default */
|
||||
|
||||
|
||||
for (wmd = drags->first; wmd; wmd = wmd->next) {
|
||||
if (wmd->type == WM_DRAG_ID) {
|
||||
/* align these types with UI_but_active_drop_name */
|
||||
if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
|
||||
ID *id = (ID *)wmd->poin;
|
||||
|
||||
|
||||
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
|
||||
|
||||
ui_textedit_string_set(but, data, id->name + 2);
|
||||
@@ -2228,7 +2228,7 @@ static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleB
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* ******************* copy and paste ******************** */
|
||||
@@ -2266,7 +2266,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
|
||||
|
||||
/* numeric value */
|
||||
if (ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER)) {
|
||||
|
||||
|
||||
if (but->poin == NULL && but->rnapoin.data == NULL) {
|
||||
/* pass */
|
||||
}
|
||||
@@ -2369,7 +2369,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
|
||||
/* RGB triple */
|
||||
else if (but->type == UI_BTYPE_COLOR) {
|
||||
float rgba[4];
|
||||
|
||||
|
||||
if (but->poin == NULL && but->rnapoin.data == NULL) {
|
||||
/* pass */
|
||||
}
|
||||
@@ -2380,7 +2380,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
|
||||
rgba[3] = RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3);
|
||||
else
|
||||
rgba[3] = 1.0f;
|
||||
|
||||
|
||||
ui_but_v3_get(but, rgba);
|
||||
/* convert to linear color to do compatible copy between gamma and non-gamma */
|
||||
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
|
||||
@@ -2388,7 +2388,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
|
||||
|
||||
BLI_snprintf(buf_copy, sizeof(buf_copy), "[%f, %f, %f, %f]", rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
WM_clipboard_text_set(buf_copy, 0);
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
if (sscanf(buf_paste, "[%f, %f, %f, %f]", &rgba[0], &rgba[1], &rgba[2], &rgba[3]) == 4) {
|
||||
@@ -2530,7 +2530,7 @@ static int ui_text_position_from_hidden(uiBut *but, int pos)
|
||||
|
||||
for (i = 0, strpos = butstr; i < pos; i++)
|
||||
strpos = BLI_str_find_next_char_utf8(strpos, NULL);
|
||||
|
||||
|
||||
return (strpos - butstr);
|
||||
}
|
||||
|
||||
@@ -2628,7 +2628,7 @@ static bool ui_textedit_delete_selection(uiBut *but, uiHandleButtonData *data)
|
||||
memmove(str + but->selsta, str + but->selend, (len - but->selend) + 1);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
|
||||
but->pos = but->selend = but->selsta;
|
||||
return changed;
|
||||
}
|
||||
@@ -2659,7 +2659,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
|
||||
|
||||
if (fstyle->kerning == 1) /* for BLF_width */
|
||||
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
||||
|
||||
|
||||
ui_but_text_password_hide(password_str, but, false);
|
||||
|
||||
if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
|
||||
@@ -2669,13 +2669,13 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
|
||||
}
|
||||
/* but this extra .05 makes clicks inbetween characters feel nicer */
|
||||
startx += ((UI_TEXT_MARGIN_X + 0.05f) * U.widget_unit) / aspect;
|
||||
|
||||
|
||||
/* mouse dragged outside the widget to the left */
|
||||
if (x < startx) {
|
||||
int i = but->ofs;
|
||||
|
||||
str_last = &str[but->ofs];
|
||||
|
||||
|
||||
while (i > 0) {
|
||||
if (BLI_str_cursor_step_prev_utf8(str, but->ofs, &i)) {
|
||||
/* 0.25 == scale factor for less sensitivity */
|
||||
@@ -2697,7 +2697,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
|
||||
/* keep track of previous distance from the cursor to the char */
|
||||
float cdist, cdist_prev = 0.0f;
|
||||
short pos_prev;
|
||||
|
||||
|
||||
str_last = &str[strlen(str)];
|
||||
|
||||
but->pos = pos_prev = ((str_last - str) - but->ofs);
|
||||
@@ -2730,10 +2730,10 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
|
||||
but->pos += but->ofs;
|
||||
if (but->pos < 0) but->pos = 0;
|
||||
}
|
||||
|
||||
|
||||
if (fstyle->kerning == 1)
|
||||
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
||||
|
||||
|
||||
ui_but_text_password_hide(password_str, but, true);
|
||||
|
||||
fstyle->points = fstyle_points_prev;
|
||||
@@ -2969,7 +2969,7 @@ static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const in
|
||||
char *pbuf;
|
||||
bool changed = false;
|
||||
int buf_len;
|
||||
|
||||
|
||||
/* paste */
|
||||
if (mode == UI_TEXTEDIT_PASTE) {
|
||||
/* extract the first line from the clipboard */
|
||||
@@ -2996,7 +2996,7 @@ static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const in
|
||||
BLI_strncpy(buf, data->str + but->selsta, sellen + 1);
|
||||
WM_clipboard_text_set(buf, 0);
|
||||
MEM_freeN(buf);
|
||||
|
||||
|
||||
/* for cut only, delete the selection afterwards */
|
||||
if (mode == UI_TEXTEDIT_CUT) {
|
||||
if ((but->selend - but->selsta) > 0) {
|
||||
@@ -3152,7 +3152,7 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||
printf("%s: invalid utf8 - stripped chars %d\n", __func__, strip);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (data->searchbox) {
|
||||
if (data->cancel == false) {
|
||||
if ((ui_searchbox_apply(but, data->searchbox) == false) &&
|
||||
@@ -3168,11 +3168,11 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||
ui_searchbox_free(C, data->searchbox);
|
||||
data->searchbox = NULL;
|
||||
}
|
||||
|
||||
|
||||
but->editstr = NULL;
|
||||
but->pos = -1;
|
||||
}
|
||||
|
||||
|
||||
WM_cursor_modal_restore(win);
|
||||
|
||||
#ifdef WITH_INPUT_IME
|
||||
@@ -3269,7 +3269,7 @@ static void ui_do_but_textedit(
|
||||
ui_searchbox_event(C, data->searchbox, but, event);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case RIGHTMOUSE:
|
||||
case ESCKEY:
|
||||
@@ -3289,7 +3289,7 @@ static void ui_do_but_textedit(
|
||||
case LEFTMOUSE:
|
||||
{
|
||||
bool had_selection = but->selsta != but->selend;
|
||||
|
||||
|
||||
/* exit on LMB only on RELEASE for searchbox, to mimic other popups, and allow multiple menu levels */
|
||||
if (data->searchbox)
|
||||
inbox = ui_searchbox_inside(data->searchbox, event->x, event->y);
|
||||
@@ -3319,7 +3319,7 @@ static void ui_do_but_textedit(
|
||||
retval = WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* only select a word in button if there was no selection before */
|
||||
if (event->val == KM_DBL_CLICK && had_selection == false) {
|
||||
ui_textedit_move(but, data, STRCUR_DIR_PREV, false, STRCUR_JUMP_DELIM);
|
||||
@@ -3416,7 +3416,7 @@ static void ui_do_but_textedit(
|
||||
event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE);
|
||||
retval = WM_UI_HANDLER_BREAK;
|
||||
break;
|
||||
|
||||
|
||||
case AKEY:
|
||||
|
||||
/* Ctrl + A: Select all */
|
||||
@@ -3494,7 +3494,7 @@ static void ui_do_but_textedit(
|
||||
}
|
||||
|
||||
retval = WM_UI_HANDLER_BREAK;
|
||||
|
||||
|
||||
}
|
||||
/* textbutton with this flag: do live update (e.g. for search buttons) */
|
||||
if (but->flag & UI_BUT_TEXTEDIT_UPDATE) {
|
||||
@@ -3530,7 +3530,7 @@ static void ui_do_but_textedit(
|
||||
ui_but_update_edited(but);
|
||||
}
|
||||
but->changed = true;
|
||||
|
||||
|
||||
if (data->searchbox)
|
||||
ui_searchbox_update(C, data->searchbox, but, true); /* true = reset */
|
||||
}
|
||||
@@ -3716,7 +3716,7 @@ int ui_but_menu_direction(uiBut *but)
|
||||
|
||||
if (data && data->menu)
|
||||
return data->menu->direction;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3808,7 +3808,7 @@ static int ui_do_but_HOTKEYEVT(
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* always set */
|
||||
but->modifier_key = 0;
|
||||
if (event->shift) but->modifier_key |= KM_SHIFT;
|
||||
@@ -3818,15 +3818,15 @@ static int ui_do_but_HOTKEYEVT(
|
||||
|
||||
ui_but_update(but);
|
||||
ED_region_tag_redraw(data->region);
|
||||
|
||||
|
||||
if (event->val == KM_PRESS) {
|
||||
if (ISHOTKEY(event->type)) {
|
||||
|
||||
|
||||
if (WM_key_event_string(event->type, false)[0])
|
||||
ui_but_value_set(but, event->type);
|
||||
else
|
||||
data->cancel = true;
|
||||
|
||||
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
@@ -3837,10 +3837,10 @@ static int ui_do_but_HOTKEYEVT(
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WM_UI_HANDLER_CONTINUE;
|
||||
}
|
||||
|
||||
@@ -4028,13 +4028,13 @@ static int ui_do_but_EXIT(
|
||||
bContext *C, uiBut *but,
|
||||
uiHandleButtonData *data, const wmEvent *event)
|
||||
{
|
||||
|
||||
|
||||
if (data->state == BUTTON_STATE_HIGHLIGHT) {
|
||||
|
||||
/* first handle click on icondrag type button */
|
||||
if (event->type == LEFTMOUSE && but->dragpoin) {
|
||||
if (ui_but_contains_point_px_icon(but, data->region, event)) {
|
||||
|
||||
|
||||
/* tell the button to wait and keep checking further events to
|
||||
* see if it should start dragging */
|
||||
button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
|
||||
@@ -4063,25 +4063,25 @@ static int ui_do_but_EXIT(
|
||||
}
|
||||
}
|
||||
else if (data->state == BUTTON_STATE_WAIT_DRAG) {
|
||||
|
||||
|
||||
/* this function also ends state */
|
||||
if (ui_but_drag_init(C, but, data, event)) {
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
|
||||
/* If the mouse has been pressed and released, getting to
|
||||
* this point without triggering a drag, then clear the
|
||||
|
||||
/* If the mouse has been pressed and released, getting to
|
||||
* this point without triggering a drag, then clear the
|
||||
* drag state for this button and continue to pass on the event */
|
||||
if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
return WM_UI_HANDLER_CONTINUE;
|
||||
}
|
||||
|
||||
/* while waiting for a drag to be triggered, always block
|
||||
|
||||
/* while waiting for a drag to be triggered, always block
|
||||
* other events from getting handled */
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
|
||||
|
||||
return WM_UI_HANDLER_CONTINUE;
|
||||
}
|
||||
|
||||
@@ -4095,7 +4095,7 @@ static float ui_numedit_apply_snapf(
|
||||
}
|
||||
else {
|
||||
float fac = 1.0f;
|
||||
|
||||
|
||||
if (ui_but_is_unit(but)) {
|
||||
UnitSettings *unit = but->block->unit;
|
||||
int unit_type = RNA_SUBTYPE_UNIT_VALUE(UI_but_unit_type_get(but));
|
||||
@@ -4143,7 +4143,7 @@ static float ui_numedit_apply_snapf(
|
||||
else {
|
||||
BLI_assert(0);
|
||||
}
|
||||
|
||||
|
||||
if (fac != 1.0f)
|
||||
tempf *= fac;
|
||||
}
|
||||
@@ -4288,7 +4288,7 @@ static bool ui_numedit_but_NUM(
|
||||
}
|
||||
|
||||
data->dragf += (((float)(mx - data->draglastx)) / deler) * non_linear_scale;
|
||||
|
||||
|
||||
CLAMP(data->dragf, 0.0f, 1.0f);
|
||||
data->draglastx = mx;
|
||||
tempf = (softmin + data->dragf * softrange);
|
||||
@@ -4301,7 +4301,7 @@ static bool ui_numedit_but_NUM(
|
||||
|
||||
CLAMP(temp, softmin, softmax);
|
||||
lvalue = (int)data->value;
|
||||
|
||||
|
||||
if (temp != lvalue) {
|
||||
data->dragchange = true;
|
||||
data->value = (double)temp;
|
||||
@@ -4342,11 +4342,11 @@ static int ui_do_but_NUM(
|
||||
|
||||
if (data->state == BUTTON_STATE_HIGHLIGHT) {
|
||||
int type = event->type, val = event->val;
|
||||
|
||||
|
||||
if (type == MOUSEPAN) {
|
||||
ui_pan_to_scroll(event, &type, &val);
|
||||
}
|
||||
|
||||
|
||||
/* XXX hardcoded keymap check.... */
|
||||
if (type == MOUSEPAN && event->alt)
|
||||
retval = WM_UI_HANDLER_BREAK; /* allow accumulating values, otherwise scrolling gets preference */
|
||||
@@ -4382,7 +4382,7 @@ static int ui_do_but_NUM(
|
||||
copy_v2_v2_int(data->multi_data.drag_start, &event->x);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (data->state == BUTTON_STATE_NUM_EDITING) {
|
||||
if (event->type == ESCKEY || event->type == RIGHTMOUSE) {
|
||||
@@ -4443,7 +4443,7 @@ static int ui_do_but_NUM(
|
||||
ui_do_but_textedit_select(C, block, but, data, event);
|
||||
retval = WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
|
||||
|
||||
if (click) {
|
||||
/* we can click on the side arrows to increment/decrement,
|
||||
* or click inside to edit the value directly */
|
||||
@@ -4509,7 +4509,7 @@ static int ui_do_but_NUM(
|
||||
|
||||
retval = WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
|
||||
|
||||
data->draglastx = mx;
|
||||
data->draglasty = my;
|
||||
|
||||
@@ -4758,13 +4758,13 @@ static int ui_do_but_SLI(
|
||||
/* nudge slider to the left or right */
|
||||
float f, tempf, softmin, softmax, softrange;
|
||||
int temp;
|
||||
|
||||
|
||||
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
|
||||
|
||||
|
||||
softmin = but->softmin;
|
||||
softmax = but->softmax;
|
||||
softrange = softmax - softmin;
|
||||
|
||||
|
||||
tempf = data->value;
|
||||
temp = (int)data->value;
|
||||
|
||||
@@ -4777,13 +4777,13 @@ static int ui_do_but_SLI(
|
||||
{
|
||||
f = (float)(mx - but->rect.xmin) / (BLI_rctf_size_x(&but->rect));
|
||||
}
|
||||
|
||||
|
||||
f = softmin + f * softrange;
|
||||
|
||||
|
||||
if (!ui_but_is_float(but)) {
|
||||
if (f < temp) temp--;
|
||||
else temp++;
|
||||
|
||||
|
||||
if (temp >= softmin && temp <= softmax)
|
||||
data->value = temp;
|
||||
else
|
||||
@@ -4792,13 +4792,13 @@ static int ui_do_but_SLI(
|
||||
else {
|
||||
if (f < tempf) tempf -= 0.01f;
|
||||
else tempf += 0.01f;
|
||||
|
||||
|
||||
if (tempf >= softmin && tempf <= softmax)
|
||||
data->value = tempf;
|
||||
else
|
||||
data->cancel = true;
|
||||
}
|
||||
|
||||
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
retval = WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
@@ -4811,7 +4811,7 @@ static int ui_do_but_SLI(
|
||||
|
||||
data->draglastx = mx;
|
||||
data->draglasty = my;
|
||||
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -4822,7 +4822,7 @@ static int ui_do_but_SCROLL(
|
||||
int mx, my /*, click = 0 */;
|
||||
int retval = WM_UI_HANDLER_CONTINUE;
|
||||
bool horizontal = (BLI_rctf_size_x(&but->rect) > BLI_rctf_size_y(&but->rect));
|
||||
|
||||
|
||||
mx = event->x;
|
||||
my = event->y;
|
||||
ui_window_to_block(data->region, block, &mx, &my);
|
||||
@@ -4868,7 +4868,7 @@ static int ui_do_but_SCROLL(
|
||||
|
||||
retval = WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -4951,9 +4951,9 @@ static int ui_do_but_BLOCK(
|
||||
bContext *C, uiBut *but,
|
||||
uiHandleButtonData *data, const wmEvent *event)
|
||||
{
|
||||
|
||||
|
||||
if (data->state == BUTTON_STATE_HIGHLIGHT) {
|
||||
|
||||
|
||||
/* first handle click on icondrag type button */
|
||||
if (event->type == LEFTMOUSE && but->dragpoin && event->val == KM_PRESS) {
|
||||
if (ui_but_contains_point_px_icon(but, data->region, event)) {
|
||||
@@ -5010,19 +5010,19 @@ static int ui_do_but_BLOCK(
|
||||
}
|
||||
}
|
||||
else if (data->state == BUTTON_STATE_WAIT_DRAG) {
|
||||
|
||||
|
||||
/* this function also ends state */
|
||||
if (ui_but_drag_init(C, but, data, event)) {
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
|
||||
|
||||
/* outside icon quit, not needed if drag activated */
|
||||
if (0 == ui_but_contains_point_px_icon(but, data->region, event)) {
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
data->cancel = true;
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
|
||||
|
||||
if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
|
||||
button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
@@ -5041,7 +5041,7 @@ static bool ui_numedit_but_UNITVEC(
|
||||
float dx, dy, rad, radsq, mrad, *fp;
|
||||
int mdx, mdy;
|
||||
bool changed = true;
|
||||
|
||||
|
||||
/* button is presumed square */
|
||||
/* if mouse moves outside of sphere, it does negative normal */
|
||||
|
||||
@@ -5051,21 +5051,21 @@ static bool ui_numedit_but_UNITVEC(
|
||||
fp = data->origvec;
|
||||
rad = BLI_rctf_size_x(&but->rect);
|
||||
radsq = rad * rad;
|
||||
|
||||
|
||||
if (fp[2] > 0.0f) {
|
||||
mdx = (rad * fp[0]);
|
||||
mdy = (rad * fp[1]);
|
||||
}
|
||||
else if (fp[2] > -1.0f) {
|
||||
mrad = rad / sqrtf(fp[0] * fp[0] + fp[1] * fp[1]);
|
||||
|
||||
|
||||
mdx = 2.0f * mrad * fp[0] - (rad * fp[0]);
|
||||
mdy = 2.0f * mrad * fp[1] - (rad * fp[1]);
|
||||
}
|
||||
else {
|
||||
mdx = mdy = 0;
|
||||
}
|
||||
|
||||
|
||||
dx = (float)(mx + mdx - data->dragstartx);
|
||||
dy = (float)(my + mdy - data->dragstarty);
|
||||
|
||||
@@ -5077,12 +5077,12 @@ static bool ui_numedit_but_UNITVEC(
|
||||
fp[2] = sqrtf(radsq - dx * dx - dy * dy);
|
||||
}
|
||||
else { /* outer circle */
|
||||
|
||||
|
||||
mrad = rad / sqrtf(mrad); // veclen
|
||||
|
||||
|
||||
dx *= (2.0f * mrad - 1.0f);
|
||||
dy *= (2.0f * mrad - 1.0f);
|
||||
|
||||
|
||||
mrad = dx * dx + dy * dy;
|
||||
if (mrad < radsq) {
|
||||
fp[0] = dx;
|
||||
@@ -5281,7 +5281,7 @@ static int ui_do_but_UNITVEC(
|
||||
/* also do drag the first time */
|
||||
if (ui_numedit_but_UNITVEC(but, data, mx, my, snap))
|
||||
ui_numedit_apply(C, block, but, data);
|
||||
|
||||
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
}
|
||||
@@ -5299,7 +5299,7 @@ static int ui_do_but_UNITVEC(
|
||||
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
|
||||
|
||||
return WM_UI_HANDLER_CONTINUE;
|
||||
}
|
||||
|
||||
@@ -5370,30 +5370,30 @@ static bool ui_numedit_but_HSVCUBE(
|
||||
ui_block_cm_to_display_space_v3(but->block, rgb);
|
||||
|
||||
ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsv);
|
||||
|
||||
|
||||
/* only apply the delta motion, not absolute */
|
||||
if (shift) {
|
||||
rcti rect_i;
|
||||
float xpos, ypos, hsvo[3];
|
||||
|
||||
|
||||
BLI_rcti_rctf_copy(&rect_i, &but->rect);
|
||||
|
||||
|
||||
/* calculate original hsv again */
|
||||
copy_v3_v3(rgb, data->origvec);
|
||||
if (use_display_colorspace)
|
||||
ui_block_cm_to_display_space_v3(but->block, rgb);
|
||||
|
||||
|
||||
copy_v3_v3(hsvo, hsv);
|
||||
|
||||
ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsvo);
|
||||
|
||||
|
||||
/* and original position */
|
||||
ui_hsvcube_pos_from_vals(but, &rect_i, hsvo, &xpos, &ypos);
|
||||
|
||||
|
||||
mx_fl = xpos - (data->dragstartx - mx_fl);
|
||||
my_fl = ypos - (data->dragstarty - my_fl);
|
||||
}
|
||||
|
||||
|
||||
/* relative position within box */
|
||||
x = ((float)mx_fl - but->rect.xmin) / BLI_rctf_size_x(&but->rect);
|
||||
y = ((float)my_fl - but->rect.ymin) / BLI_rctf_size_y(&but->rect);
|
||||
@@ -5510,10 +5510,10 @@ static void ui_ndofedit_but_HSVCUBE(
|
||||
case UI_GRAD_V_ALT:
|
||||
case UI_GRAD_L_ALT:
|
||||
/* vertical 'value' strip */
|
||||
|
||||
|
||||
/* exception only for value strip - use the range set in but->min/max */
|
||||
hsv[2] += ndof->rvec[0] * sensitivity;
|
||||
|
||||
|
||||
CLAMP(hsv[2], but->softmin, but->softmax);
|
||||
break;
|
||||
default:
|
||||
@@ -5563,19 +5563,19 @@ static int ui_do_but_HSVCUBE(
|
||||
/* also do drag the first time */
|
||||
if (ui_numedit_but_HSVCUBE(but, data, mx, my, snap, event->shift != 0))
|
||||
ui_numedit_apply(C, block, but, data);
|
||||
|
||||
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
#ifdef WITH_INPUT_NDOF
|
||||
else if (event->type == NDOF_MOTION) {
|
||||
const wmNDOFMotionData *ndof = event->customdata;
|
||||
const enum eSnapType snap = ui_event_to_snap(event);
|
||||
|
||||
|
||||
ui_ndofedit_but_HSVCUBE(but, data, ndof, snap, event->shift != 0);
|
||||
|
||||
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
ui_apply_but(C, but->block, but, data, true);
|
||||
|
||||
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
#endif /* WITH_INPUT_NDOF */
|
||||
@@ -5583,9 +5583,9 @@ static int ui_do_but_HSVCUBE(
|
||||
else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) {
|
||||
if (ELEM(but->a1, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) {
|
||||
int len;
|
||||
|
||||
|
||||
/* reset only value */
|
||||
|
||||
|
||||
len = RNA_property_array_length(&but->rnapoin, but->rnaprop);
|
||||
if (ELEM(len, 3, 4)) {
|
||||
float rgb[3], def_hsv[3];
|
||||
@@ -5601,10 +5601,10 @@ static int ui_do_but_HSVCUBE(
|
||||
|
||||
def_hsv[0] = hsv[0];
|
||||
def_hsv[1] = hsv[1];
|
||||
|
||||
|
||||
ui_color_picker_to_rgb_HSVCUBE_v(but, def_hsv, rgb);
|
||||
ui_but_v3_set(but, rgb);
|
||||
|
||||
|
||||
RNA_property_update(C, &but->rnapoin, but->rnaprop);
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
@@ -5630,7 +5630,7 @@ static int ui_do_but_HSVCUBE(
|
||||
else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
}
|
||||
|
||||
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
|
||||
@@ -5651,7 +5651,7 @@ static bool ui_numedit_but_HSVCIRCLE(
|
||||
bool use_display_colorspace = ui_but_is_colorpicker_display_space(but);
|
||||
|
||||
ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift);
|
||||
|
||||
|
||||
#ifdef USE_CONT_MOUSE_CORRECT
|
||||
if (ui_but_is_cursor_warp(but)) {
|
||||
/* OK but can go outside bounds */
|
||||
@@ -5691,7 +5691,7 @@ static bool ui_numedit_but_HSVCIRCLE(
|
||||
/* only apply the delta motion, not absolute */
|
||||
if (shift) {
|
||||
float xpos, ypos, hsvo[3], rgbo[3];
|
||||
|
||||
|
||||
/* calculate original hsv again */
|
||||
copy_v3_v3(hsvo, hsv);
|
||||
copy_v3_v3(rgbo, data->origvec);
|
||||
@@ -5705,9 +5705,9 @@ static bool ui_numedit_but_HSVCIRCLE(
|
||||
|
||||
mx_fl = xpos - (data->dragstartx - mx_fl);
|
||||
my_fl = ypos - (data->dragstarty - my_fl);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
ui_hsvcircle_vals_from_pos(hsv, hsv + 1, &rect, mx_fl, my_fl);
|
||||
|
||||
if ((but->flag & UI_BUT_COLOR_CUBIC) && (U.color_picker_type == USER_CP_CIRCLE_HSV))
|
||||
@@ -5727,10 +5727,10 @@ static bool ui_numedit_but_HSVCIRCLE(
|
||||
ui_block_cm_to_scene_linear_v3(but->block, rgb);
|
||||
|
||||
ui_but_v3_set(but, rgb);
|
||||
|
||||
|
||||
data->draglastx = mx;
|
||||
data->draglasty = my;
|
||||
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
@@ -5746,28 +5746,28 @@ static void ui_ndofedit_but_HSVCIRCLE(
|
||||
float rgb[3];
|
||||
float phi, r /*, sqr */ /* UNUSED */, v[2];
|
||||
float sensitivity = (shift ? 0.06f : 0.3f) * ndof->dt;
|
||||
|
||||
|
||||
ui_but_v3_get(but, rgb);
|
||||
if (use_display_colorspace)
|
||||
ui_block_cm_to_display_space_v3(but->block, rgb);
|
||||
ui_rgb_to_color_picker_compat_v(rgb, hsv);
|
||||
|
||||
|
||||
/* Convert current color on hue/sat disc to circular coordinates phi, r */
|
||||
phi = fmodf(hsv[0] + 0.25f, 1.0f) * -2.0f * (float)M_PI;
|
||||
r = hsv[1];
|
||||
/* sqr = r > 0.0f ? sqrtf(r) : 1; */ /* UNUSED */
|
||||
|
||||
|
||||
/* Convert to 2d vectors */
|
||||
v[0] = r * cosf(phi);
|
||||
v[1] = r * sinf(phi);
|
||||
|
||||
|
||||
/* Use ndof device y and x rotation to move the vector in 2d space */
|
||||
v[0] += ndof->rvec[2] * sensitivity;
|
||||
v[1] += ndof->rvec[0] * sensitivity;
|
||||
|
||||
/* convert back to polar coords on circle */
|
||||
phi = atan2f(v[0], v[1]) / (2.0f * (float)M_PI) + 0.5f;
|
||||
|
||||
|
||||
/* use ndof Y rotation to additionally rotate hue */
|
||||
phi += ndof->rvec[1] * sensitivity * 0.5f;
|
||||
r = len_v2(v);
|
||||
@@ -5795,14 +5795,14 @@ static void ui_ndofedit_but_HSVCIRCLE(
|
||||
hsv_clamp_v(hsv, FLT_MAX);
|
||||
|
||||
ui_color_picker_to_rgb_v(hsv, data->vec);
|
||||
|
||||
|
||||
if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (data->vec[0] || data->vec[1] || data->vec[2])) {
|
||||
normalize_v3_length(data->vec, but->a2);
|
||||
}
|
||||
|
||||
if (use_display_colorspace)
|
||||
ui_block_cm_to_scene_linear_v3(but->block, data->vec);
|
||||
|
||||
|
||||
ui_but_v3_set(but, data->vec);
|
||||
}
|
||||
#endif /* WITH_INPUT_NDOF */
|
||||
@@ -5817,7 +5817,7 @@ static int ui_do_but_HSVCIRCLE(
|
||||
mx = event->x;
|
||||
my = event->y;
|
||||
ui_window_to_block(data->region, block, &mx, &my);
|
||||
|
||||
|
||||
if (data->state == BUTTON_STATE_HIGHLIGHT) {
|
||||
if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
|
||||
const enum eSnapType snap = ui_event_to_snap(event);
|
||||
@@ -5826,52 +5826,52 @@ static int ui_do_but_HSVCIRCLE(
|
||||
data->draglastx = mx;
|
||||
data->draglasty = my;
|
||||
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
|
||||
|
||||
|
||||
/* also do drag the first time */
|
||||
if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, snap, event->shift != 0))
|
||||
ui_numedit_apply(C, block, but, data);
|
||||
|
||||
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
#ifdef WITH_INPUT_NDOF
|
||||
else if (event->type == NDOF_MOTION) {
|
||||
const enum eSnapType snap = ui_event_to_snap(event);
|
||||
const wmNDOFMotionData *ndof = event->customdata;
|
||||
|
||||
|
||||
ui_ndofedit_but_HSVCIRCLE(but, data, ndof, snap, event->shift != 0);
|
||||
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
ui_apply_but(C, but->block, but, data, true);
|
||||
|
||||
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
#endif /* WITH_INPUT_NDOF */
|
||||
/* XXX hardcoded keymap check.... */
|
||||
else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) {
|
||||
int len;
|
||||
|
||||
|
||||
/* reset only saturation */
|
||||
|
||||
|
||||
len = RNA_property_array_length(&but->rnapoin, but->rnaprop);
|
||||
if (len >= 3) {
|
||||
float rgb[3], def_hsv[3];
|
||||
float *def;
|
||||
def = MEM_callocN(sizeof(float) * len, "reset_defaults - float");
|
||||
|
||||
|
||||
RNA_property_float_get_default_array(&but->rnapoin, but->rnaprop, def);
|
||||
ui_color_picker_to_rgb_v(def, def_hsv);
|
||||
|
||||
|
||||
ui_but_v3_get(but, rgb);
|
||||
ui_rgb_to_color_picker_compat_v(rgb, hsv);
|
||||
|
||||
|
||||
def_hsv[0] = hsv[0];
|
||||
def_hsv[2] = hsv[2];
|
||||
|
||||
hsv_to_rgb_v(def_hsv, rgb);
|
||||
ui_but_v3_set(but, rgb);
|
||||
|
||||
|
||||
RNA_property_update(C, &but->rnapoin, but->rnaprop);
|
||||
|
||||
|
||||
MEM_freeN(def);
|
||||
}
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
@@ -5910,7 +5910,7 @@ static int ui_do_but_HSVCIRCLE(
|
||||
}
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
|
||||
|
||||
return WM_UI_HANDLER_CONTINUE;
|
||||
}
|
||||
|
||||
@@ -5929,10 +5929,10 @@ static bool ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int m
|
||||
dx = ((float)(mx - data->draglastx)) / BLI_rctf_size_x(&but->rect);
|
||||
data->dragcbd->pos += dx;
|
||||
CLAMP(data->dragcbd->pos, 0.0f, 1.0f);
|
||||
|
||||
|
||||
BKE_colorband_update_sort(data->coba);
|
||||
data->dragcbd = data->coba->data + data->coba->cur; /* because qsort */
|
||||
|
||||
|
||||
data->draglastx = mx;
|
||||
changed = true;
|
||||
|
||||
@@ -5979,7 +5979,7 @@ static int ui_do_but_COLORBAND(
|
||||
mindist = xco;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
data->dragcbd = coba->data + coba->cur;
|
||||
data->dragfstart = data->dragcbd->pos;
|
||||
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
|
||||
@@ -6033,10 +6033,10 @@ static bool ui_numedit_but_CURVE(
|
||||
dragx = data->draglastx;
|
||||
dragy = data->draglasty;
|
||||
ui_window_to_block(data->region, block, &dragx, &dragy);
|
||||
|
||||
|
||||
zoomx = BLI_rctf_size_x(&but->rect) / BLI_rctf_size_x(&cumap->curr);
|
||||
zoomy = BLI_rctf_size_y(&but->rect) / BLI_rctf_size_y(&cumap->curr);
|
||||
|
||||
|
||||
if (snap) {
|
||||
float d[2];
|
||||
|
||||
@@ -6075,7 +6075,7 @@ static bool ui_numedit_but_CURVE(
|
||||
}
|
||||
|
||||
curvemapping_changed(cumap, false);
|
||||
|
||||
|
||||
if (moved_point) {
|
||||
data->draglastx = evtx;
|
||||
data->draglasty = evty;
|
||||
@@ -6099,7 +6099,7 @@ static bool ui_numedit_but_CURVE(
|
||||
else {
|
||||
fx = (mx - dragx) / zoomx;
|
||||
fy = (my - dragy) / zoomy;
|
||||
|
||||
|
||||
/* clamp for clip */
|
||||
if (cumap->flag & CUMA_DO_CLIP) {
|
||||
if (cumap->curr.xmin - fx < cumap->clipr.xmin)
|
||||
@@ -6116,7 +6116,7 @@ static bool ui_numedit_but_CURVE(
|
||||
cumap->curr.ymin -= fy;
|
||||
cumap->curr.xmax -= fx;
|
||||
cumap->curr.ymax -= fy;
|
||||
|
||||
|
||||
data->draglastx = evtx;
|
||||
data->draglasty = evty;
|
||||
|
||||
@@ -6137,7 +6137,7 @@ static int ui_do_but_CURVE(
|
||||
mx = event->x;
|
||||
my = event->y;
|
||||
ui_window_to_block(data->region, block, &mx, &my);
|
||||
|
||||
|
||||
if (data->state == BUTTON_STATE_HIGHLIGHT) {
|
||||
if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
|
||||
CurveMapping *cumap = (CurveMapping *)but->poin;
|
||||
@@ -6150,7 +6150,7 @@ static int ui_do_but_CURVE(
|
||||
if (event->ctrl) {
|
||||
float f_xy[2];
|
||||
BLI_rctf_transform_pt_v(&cumap->curr, &but->rect, f_xy, m_xy);
|
||||
|
||||
|
||||
curvemap_insert(cuma, f_xy[0], f_xy[1]);
|
||||
curvemapping_changed(cumap, false);
|
||||
changed = true;
|
||||
@@ -6172,7 +6172,7 @@ static int ui_do_but_CURVE(
|
||||
int i;
|
||||
float f_xy[2], f_xy_prev[2];
|
||||
|
||||
/* if the click didn't select anything, check if it's clicked on the
|
||||
/* if the click didn't select anything, check if it's clicked on the
|
||||
* curve itself, and if so, add a point */
|
||||
cmp = cuma->table;
|
||||
|
||||
@@ -6193,10 +6193,10 @@ static int ui_do_but_CURVE(
|
||||
curvemapping_changed(cumap, false);
|
||||
|
||||
changed = true;
|
||||
|
||||
|
||||
/* reset cmp back to the curve points again, rather than drawing segments */
|
||||
cmp = cuma->curve;
|
||||
|
||||
|
||||
/* find newly added point and make it 'sel' */
|
||||
for (a = 0; a < cuma->totpoint; a++) {
|
||||
if (cmp[a].x == f_xy[0]) {
|
||||
@@ -6227,7 +6227,7 @@ static int ui_do_but_CURVE(
|
||||
}
|
||||
|
||||
data->dragsel = sel;
|
||||
|
||||
|
||||
data->dragstartx = event->x;
|
||||
data->dragstarty = event->y;
|
||||
data->draglastx = event->x;
|
||||
@@ -6240,7 +6240,7 @@ static int ui_do_but_CURVE(
|
||||
else if (data->state == BUTTON_STATE_NUM_EDITING) {
|
||||
if (event->type == MOUSEMOVE) {
|
||||
if (event->x != data->draglastx || event->y != data->draglasty) {
|
||||
|
||||
|
||||
if (ui_numedit_but_CURVE(block, but, data, event->x, event->y, event->ctrl != 0, event->shift != 0))
|
||||
ui_numedit_apply(C, block, but, data);
|
||||
}
|
||||
@@ -6301,11 +6301,11 @@ static int ui_do_but_HISTOGRAM(
|
||||
uiHandleButtonData *data, const wmEvent *event)
|
||||
{
|
||||
int mx, my;
|
||||
|
||||
|
||||
mx = event->x;
|
||||
my = event->y;
|
||||
ui_window_to_block(data->region, block, &mx, &my);
|
||||
|
||||
|
||||
if (data->state == BUTTON_STATE_HIGHLIGHT) {
|
||||
if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
|
||||
data->dragstartx = mx;
|
||||
@@ -6313,18 +6313,18 @@ static int ui_do_but_HISTOGRAM(
|
||||
data->draglastx = mx;
|
||||
data->draglasty = my;
|
||||
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
|
||||
|
||||
|
||||
/* also do drag the first time */
|
||||
if (ui_numedit_but_HISTOGRAM(but, data, mx, my))
|
||||
ui_numedit_apply(C, block, but, data);
|
||||
|
||||
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
/* XXX hardcoded keymap check.... */
|
||||
else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) {
|
||||
Histogram *hist = (Histogram *)but->poin;
|
||||
hist->ymax = 1.f;
|
||||
|
||||
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
@@ -6348,7 +6348,7 @@ static int ui_do_but_HISTOGRAM(
|
||||
}
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
|
||||
|
||||
return WM_UI_HANDLER_CONTINUE;
|
||||
}
|
||||
|
||||
@@ -6430,7 +6430,7 @@ static int ui_do_but_WAVEFORM(
|
||||
static int ui_do_but_LINK(
|
||||
bContext *C, uiBut *but,
|
||||
uiHandleButtonData *data, const wmEvent *event)
|
||||
{
|
||||
{
|
||||
VECCOPY2D(but->linkto, event->mval);
|
||||
|
||||
if (data->state == BUTTON_STATE_HIGHLIGHT) {
|
||||
@@ -6444,7 +6444,7 @@ static int ui_do_but_LINK(
|
||||
}
|
||||
}
|
||||
else if (data->state == BUTTON_STATE_WAIT_RELEASE) {
|
||||
|
||||
|
||||
if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
|
||||
if (!(but->flag & UI_SELECT))
|
||||
data->cancel = true;
|
||||
@@ -6452,7 +6452,7 @@ static int ui_do_but_LINK(
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WM_UI_HANDLER_CONTINUE;
|
||||
}
|
||||
|
||||
@@ -6548,7 +6548,7 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
|
||||
char shortcut_str[128];
|
||||
|
||||
IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
|
||||
|
||||
|
||||
/* complex code to change name of button */
|
||||
if (WM_key_event_operator_string(
|
||||
C, but->optype->idname, but->opcontext, prop, true,
|
||||
@@ -6579,18 +6579,18 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg)
|
||||
BLI_assert(kmi != NULL);
|
||||
|
||||
RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr);
|
||||
|
||||
|
||||
block = UI_block_begin(C, ar, "_popup", UI_EMBOSS);
|
||||
UI_block_func_handle_set(block, but_shortcut_name_func, but);
|
||||
UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT);
|
||||
UI_block_direction_set(block, UI_DIR_CENTER_Y);
|
||||
|
||||
|
||||
layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style);
|
||||
|
||||
|
||||
uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
|
||||
|
||||
|
||||
UI_block_bounds_set_popup(block, 6, -50, 26);
|
||||
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
@@ -6610,7 +6610,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
|
||||
uiStyle *style = UI_style_get_dpi();
|
||||
IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
|
||||
int kmi_id;
|
||||
|
||||
|
||||
/* XXX this guess_opname can potentially return a different keymap than being found on adding later... */
|
||||
km = WM_keymap_guess_opname(C, but->optype->idname);
|
||||
kmi = WM_keymap_add_item(km, but->optype->idname, AKEY, KM_PRESS, 0, 0);
|
||||
@@ -6636,7 +6636,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
|
||||
layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style);
|
||||
|
||||
uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
|
||||
|
||||
|
||||
UI_block_bounds_set_popup(block, 6, -50, 26);
|
||||
|
||||
#ifdef USE_KEYMAP_ADD_HACK
|
||||
@@ -6685,7 +6685,7 @@ static void remove_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
|
||||
BLI_assert(kmi != NULL);
|
||||
|
||||
WM_keymap_remove_item(km, kmi);
|
||||
|
||||
|
||||
but_shortcut_name_func(C, but, 0);
|
||||
}
|
||||
|
||||
@@ -6775,7 +6775,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
|
||||
if (but->type == UI_BTYPE_IMAGE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* highly unlikely getting the label ever fails */
|
||||
UI_but_string_info_get(C, but, &label, NULL);
|
||||
|
||||
@@ -6806,7 +6806,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
|
||||
/* determine if we can key a single component of an array */
|
||||
is_array = RNA_property_array_length(&but->rnapoin, but->rnaprop) != 0;
|
||||
is_array_component = (is_array && but->rnaindex != -1);
|
||||
|
||||
|
||||
/* Keyframes */
|
||||
if (but->flag & UI_BUT_ANIMATED_KEY) {
|
||||
/* replace/delete keyfraemes */
|
||||
@@ -6826,11 +6826,11 @@ static bool ui_but_menu(bContext *C, uiBut *but)
|
||||
uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Keyframe"),
|
||||
ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 1);
|
||||
}
|
||||
|
||||
|
||||
/* keyframe settings */
|
||||
uiItemS(layout);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if (but->flag & UI_BUT_DRIVEN) {
|
||||
/* pass */
|
||||
@@ -6847,7 +6847,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
|
||||
ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((but->flag & UI_BUT_ANIMATED) && (but->rnapoin.type != &RNA_NlaStrip)) {
|
||||
if (is_array_component) {
|
||||
uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"),
|
||||
@@ -6890,13 +6890,13 @@ static bool ui_but_menu(bContext *C, uiBut *but)
|
||||
uiItemS(layout);
|
||||
|
||||
if (is_array_component) {
|
||||
uiItemMenuEnumO(layout, C, "ANIM_OT_driver_button_add", "mapping_type",
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Drivers"),
|
||||
uiItemMenuEnumO(layout, C, "ANIM_OT_driver_button_add", "mapping_type",
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Drivers"),
|
||||
ICON_DRIVER);
|
||||
}
|
||||
else {
|
||||
uiItemMenuEnumO(layout, C, "ANIM_OT_driver_button_add", "mapping_type",
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Driver"),
|
||||
uiItemMenuEnumO(layout, C, "ANIM_OT_driver_button_add", "mapping_type",
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Driver"),
|
||||
ICON_DRIVER);
|
||||
}
|
||||
|
||||
@@ -6905,7 +6905,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
|
||||
ICON_NONE, "ANIM_OT_paste_driver_button");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Keying Sets */
|
||||
/* TODO: check on modifyability of Keying Set when doing this */
|
||||
if (is_anim) {
|
||||
@@ -6926,14 +6926,14 @@ static bool ui_but_menu(bContext *C, uiBut *but)
|
||||
ICON_NONE, "ANIM_OT_keyingset_button_remove");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uiItemS(layout);
|
||||
|
||||
|
||||
/* Property Operators */
|
||||
|
||||
|
||||
/* Copy Property Value
|
||||
* Paste Property Value */
|
||||
|
||||
|
||||
if (is_array_component) {
|
||||
uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset All to Default Values"),
|
||||
ICON_LOOP_BACK, "UI_OT_reset_default_button", "all", 1);
|
||||
@@ -6948,7 +6948,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
|
||||
uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Unset"),
|
||||
ICON_NONE, "UI_OT_unset_property_button");
|
||||
}
|
||||
|
||||
|
||||
if (is_array_component) {
|
||||
uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy All To Selected"),
|
||||
ICON_NONE, "UI_OT_copy_to_selected_button", "all", true);
|
||||
@@ -7408,14 +7408,14 @@ bool ui_but_is_active(ARegion *ar)
|
||||
void UI_screen_free_active_but(const bContext *C, bScreen *screen)
|
||||
{
|
||||
ScrArea *sa = screen->areabase.first;
|
||||
|
||||
|
||||
for (; sa; sa = sa->next) {
|
||||
ARegion *ar = sa->regionbase.first;
|
||||
for (; ar; ar = ar->next) {
|
||||
uiBut *but = ui_but_find_active_in_region(ar);
|
||||
if (but) {
|
||||
uiHandleButtonData *data = but->active;
|
||||
|
||||
|
||||
if (data->menu == NULL && data->searchbox == NULL)
|
||||
if (data->state == BUTTON_STATE_HIGHLIGHT)
|
||||
ui_but_active_free(C, but);
|
||||
@@ -7437,7 +7437,7 @@ bool UI_but_active_drop_name(bContext *C)
|
||||
if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU))
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -7479,11 +7479,11 @@ static bool ui_region_contains_point_px(ARegion *ar, int x, int y)
|
||||
if (!BLI_rcti_isect_pt(&winrct, x, y)) {
|
||||
for (uiBlock *block = ar->uiblocks.first; block; block = block->next)
|
||||
block->auto_open = false;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* also, check that with view2d, that the mouse is not over the scrollbars
|
||||
/* also, check that with view2d, that the mouse is not over the scrollbars
|
||||
* NOTE: care is needed here, since the mask rect may include the scrollbars
|
||||
* even when they are not visible, so we need to make a copy of the mask to
|
||||
* use to check
|
||||
@@ -7491,7 +7491,7 @@ static bool ui_region_contains_point_px(ARegion *ar, int x, int y)
|
||||
if (ar->v2d.mask.xmin != ar->v2d.mask.xmax) {
|
||||
View2D *v2d = &ar->v2d;
|
||||
int mx, my;
|
||||
|
||||
|
||||
/* convert window coordinates to region coordinates */
|
||||
mx = x;
|
||||
my = y;
|
||||
@@ -7501,7 +7501,7 @@ static bool ui_region_contains_point_px(ARegion *ar, int x, int y)
|
||||
if (!BLI_rcti_isect_pt(&v2d->mask, mx, my))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7525,7 +7525,7 @@ static bool ui_but_contains_point_px(ARegion *ar, uiBut *but, int x, int y)
|
||||
else if (!ui_but_contains_pt(but, mx, my)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7750,7 +7750,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
|
||||
but->flag |= UI_SELECT;
|
||||
UI_but_tooltip_timer_remove(C, but);
|
||||
}
|
||||
|
||||
|
||||
/* text editing */
|
||||
if (state == BUTTON_STATE_TEXT_EDITING && data->state != BUTTON_STATE_TEXT_SELECTING)
|
||||
ui_textedit_begin(C, but, data);
|
||||
@@ -7758,7 +7758,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
|
||||
ui_textedit_end(C, but, data);
|
||||
else if (data->state == BUTTON_STATE_TEXT_SELECTING && state != BUTTON_STATE_TEXT_EDITING)
|
||||
ui_textedit_end(C, but, data);
|
||||
|
||||
|
||||
/* number editing */
|
||||
if (state == BUTTON_STATE_NUM_EDITING) {
|
||||
if (ui_but_is_cursor_warp(but))
|
||||
@@ -7835,7 +7835,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* wait for mousemove to enable drag */
|
||||
if (state == BUTTON_STATE_WAIT_DRAG) {
|
||||
but->flag &= ~UI_SELECT;
|
||||
@@ -7879,7 +7879,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
|
||||
data->interactive = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
data->state = BUTTON_STATE_INIT;
|
||||
|
||||
/* activate button */
|
||||
@@ -7897,14 +7897,14 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
|
||||
data->used_mouse = true;
|
||||
}
|
||||
button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT);
|
||||
|
||||
|
||||
/* activate right away */
|
||||
if (but->flag & UI_BUT_IMMEDIATE) {
|
||||
if (but->type == UI_BTYPE_HOTKEY_EVENT)
|
||||
button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT);
|
||||
/* .. more to be added here */
|
||||
}
|
||||
|
||||
|
||||
if (type == BUTTON_ACTIVATE_OPEN) {
|
||||
button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
|
||||
|
||||
@@ -7913,7 +7913,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
|
||||
ARegion *subar = data->menu->region;
|
||||
uiBlock *subblock = subar->uiblocks.first;
|
||||
uiBut *subbut;
|
||||
|
||||
|
||||
if (subblock) {
|
||||
subbut = ui_but_first(subblock);
|
||||
|
||||
@@ -8212,7 +8212,7 @@ void UI_context_update_anim_flag(const bContext *C)
|
||||
for (but = block->buttons.first; but; but = but->next) {
|
||||
ui_but_anim_flag(but, (scene) ? scene->r.cfra : 0.0f);
|
||||
ED_region_tag_redraw(ar);
|
||||
|
||||
|
||||
if (but->active) {
|
||||
activebut = but;
|
||||
}
|
||||
@@ -8245,7 +8245,7 @@ static uiBut *ui_but_find_open_event(ARegion *ar, const wmEvent *event)
|
||||
{
|
||||
uiBlock *block;
|
||||
uiBut *but;
|
||||
|
||||
|
||||
for (block = ar->uiblocks.first; block; block = block->next) {
|
||||
for (but = block->buttons.first; but; but = but->next)
|
||||
if (but == event->customdata)
|
||||
@@ -8285,15 +8285,15 @@ void ui_but_activate_event(bContext *C, ARegion *ar, uiBut *but)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
wmEvent event;
|
||||
|
||||
|
||||
button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER);
|
||||
|
||||
|
||||
wm_event_init_from_window(win, &event);
|
||||
event.type = EVT_BUT_OPEN;
|
||||
event.val = KM_PRESS;
|
||||
event.customdata = but;
|
||||
event.customdatafree = false;
|
||||
|
||||
|
||||
ui_do_button(C, but->block, but, &event);
|
||||
}
|
||||
|
||||
@@ -8360,7 +8360,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
|
||||
ar = data->region;
|
||||
|
||||
retval = WM_UI_HANDLER_CONTINUE;
|
||||
|
||||
|
||||
if (data->state == BUTTON_STATE_HIGHLIGHT) {
|
||||
switch (event->type) {
|
||||
case WINDEACTIVATE:
|
||||
@@ -8509,7 +8509,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
|
||||
}
|
||||
|
||||
bt = ui_but_find_mouse_over(ar, event);
|
||||
|
||||
|
||||
if (bt && bt->active != data) {
|
||||
if (but->type != UI_BTYPE_COLOR) { /* exception */
|
||||
data->cancel = true;
|
||||
@@ -8720,7 +8720,7 @@ static void ui_handle_button_return_submenu(bContext *C, const wmEvent *event, u
|
||||
|
||||
menu->menuretval = 0;
|
||||
}
|
||||
|
||||
|
||||
/* now change button state or exit, which will close the submenu */
|
||||
if ((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_CANCEL)) {
|
||||
if (menu->menuretval != UI_RETURN_OK)
|
||||
@@ -8831,7 +8831,7 @@ static bool ui_mouse_motion_towards_check(
|
||||
|
||||
p2[0] = rect_px.xmax + margin;
|
||||
p2[1] = rect_px.ymin - margin;
|
||||
|
||||
|
||||
p3[0] = rect_px.xmax + margin;
|
||||
p3[1] = rect_px.ymax + margin;
|
||||
|
||||
@@ -8889,7 +8889,7 @@ static bool ui_mouse_motion_keynav_test(struct uiKeyNavLock *keynav, const wmEve
|
||||
static char ui_menu_scroll_test(uiBlock *block, int my)
|
||||
{
|
||||
if (block->flag & (UI_BLOCK_CLIPTOP | UI_BLOCK_CLIPBOTTOM)) {
|
||||
if (block->flag & UI_BLOCK_CLIPTOP)
|
||||
if (block->flag & UI_BLOCK_CLIPTOP)
|
||||
if (my > block->rect.ymax - UI_MENU_SCROLL_MOUSE)
|
||||
return 't';
|
||||
if (block->flag & UI_BLOCK_CLIPBOTTOM)
|
||||
@@ -8955,12 +8955,12 @@ static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my, uiBut *to_bt)
|
||||
|
||||
/* set flags again */
|
||||
ui_popup_block_scrolltest(block);
|
||||
|
||||
|
||||
ED_region_tag_redraw(ar);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -9125,14 +9125,14 @@ static int ui_handle_menu_event(
|
||||
if (block->flag & UI_BLOCK_MOVEMOUSE_QUIT) {
|
||||
ui_mouse_motion_towards_init(menu, &event->x);
|
||||
}
|
||||
|
||||
|
||||
/* add menu scroll timer, if needed */
|
||||
if (ui_menu_scroll_test(block, my))
|
||||
if (menu->scrolltimer == NULL)
|
||||
menu->scrolltimer =
|
||||
WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, MENU_SCROLL_INTERVAL);
|
||||
}
|
||||
|
||||
|
||||
/* first block own event func */
|
||||
if (block->block_event_func && block->block_event_func(C, block, event)) {
|
||||
/* pass */
|
||||
@@ -9172,7 +9172,7 @@ static int ui_handle_menu_event(
|
||||
|
||||
retval = WM_UI_HANDLER_BREAK;
|
||||
break;
|
||||
|
||||
|
||||
case UPARROWKEY:
|
||||
case DOWNARROWKEY:
|
||||
case WHEELUPMOUSE:
|
||||
@@ -9185,11 +9185,11 @@ static int ui_handle_menu_event(
|
||||
else if (inside || (block->flag & UI_BLOCK_LOOP)) {
|
||||
int type = event->type;
|
||||
int val = event->val;
|
||||
|
||||
|
||||
/* convert pan to scrollwheel */
|
||||
if (type == MOUSEPAN)
|
||||
ui_pan_to_scroll(event, &type, &val);
|
||||
|
||||
|
||||
if (val == KM_PRESS) {
|
||||
const bool is_next =
|
||||
(ELEM(type, DOWNARROWKEY, WHEELDOWNMOUSE) ==
|
||||
@@ -9260,10 +9260,10 @@ static int ui_handle_menu_event(
|
||||
count = 0;
|
||||
for (but = block->buttons.first; but; but = but->next) {
|
||||
bool doit = false;
|
||||
|
||||
|
||||
if (!ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE))
|
||||
count++;
|
||||
|
||||
|
||||
/* exception for rna layer buts */
|
||||
if (but->rnapoin.data && but->rnaprop &&
|
||||
ELEM(RNA_property_subtype(but->rnaprop), PROP_LAYER, PROP_LAYER_MEMBER))
|
||||
@@ -9363,7 +9363,7 @@ static int ui_handle_menu_event(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* here we check return conditions for menus */
|
||||
if (block->flag & UI_BLOCK_LOOP) {
|
||||
/* if we click outside the block, verify if we clicked on the
|
||||
@@ -9443,7 +9443,7 @@ static int ui_handle_menu_event(
|
||||
uiSafetyRct *saferct;
|
||||
|
||||
ui_mouse_motion_towards_check(block, menu, &event->x, is_parent_inside == false);
|
||||
|
||||
|
||||
/* check for all parent rects, enables arrowkeys to be used */
|
||||
for (saferct = block->saferct.first; saferct; saferct = saferct->next) {
|
||||
/* for mouse move we only check our own rect, for other
|
||||
@@ -10030,7 +10030,7 @@ static int ui_region_handler(bContext *C, const wmEvent *event, void *UNUSED(use
|
||||
/* re-enable tooltips */
|
||||
if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy))
|
||||
ui_blocks_set_tooltips(ar, true);
|
||||
|
||||
|
||||
/* delayed apply callbacks */
|
||||
ui_apply_but_funcs_after(C);
|
||||
|
||||
@@ -10046,7 +10046,7 @@ static void ui_region_handler_remove(bContext *C, void *UNUSED(userdata))
|
||||
if (ar == NULL) return;
|
||||
|
||||
UI_blocklist_free(C, &ar->uiblocks);
|
||||
|
||||
|
||||
sc = CTX_wm_screen(C);
|
||||
if (sc == NULL) return;
|
||||
|
||||
@@ -10180,7 +10180,7 @@ static int ui_popup_handler(bContext *C, const wmEvent *event, void *userdata)
|
||||
win->last_pie_event = block->pie_data.event;
|
||||
reset_pie = true;
|
||||
}
|
||||
|
||||
|
||||
ui_popup_block_free(C, menu);
|
||||
UI_popup_handlers_remove(&win->modalhandlers, menu);
|
||||
CTX_wm_menu_set(C, NULL);
|
||||
@@ -10290,7 +10290,7 @@ bool UI_textbutton_activate_rna(
|
||||
{
|
||||
uiBlock *block;
|
||||
uiBut *but = NULL;
|
||||
|
||||
|
||||
for (block = ar->uiblocks.first; block; block = block->next) {
|
||||
for (but = block->buttons.first; but; but = but->next) {
|
||||
if (but->type == UI_BTYPE_TEXT) {
|
||||
@@ -10304,7 +10304,7 @@ bool UI_textbutton_activate_rna(
|
||||
if (but)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (but) {
|
||||
UI_but_active_only(C, ar, block, but);
|
||||
return true;
|
||||
@@ -10319,7 +10319,7 @@ bool UI_textbutton_activate_but(const bContext *C, uiBut *actbut)
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
uiBlock *block;
|
||||
uiBut *but = NULL;
|
||||
|
||||
|
||||
for (block = ar->uiblocks.first; block; block = block->next) {
|
||||
for (but = block->buttons.first; but; but = but->next)
|
||||
if (but == actbut && but->type == UI_BTYPE_TEXT)
|
||||
@@ -10328,7 +10328,7 @@ bool UI_textbutton_activate_but(const bContext *C, uiBut *actbut)
|
||||
if (but)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (but) {
|
||||
UI_but_active_only(C, ar, block, but);
|
||||
return true;
|
||||
|
||||
@@ -121,7 +121,7 @@ typedef struct IconTexture {
|
||||
} IconTexture;
|
||||
|
||||
/* ******************* STATIC LOCAL VARS ******************* */
|
||||
/* static here to cache results of icon directory scan, so it's not
|
||||
/* static here to cache results of icon directory scan, so it's not
|
||||
* scanning the filesystem each time the menu is drawn */
|
||||
static struct ListBase iconfilelist = {NULL, NULL};
|
||||
static IconTexture icongltex = {0, 0, 0, 0.0f, 0.0f};
|
||||
@@ -158,9 +158,9 @@ static DrawInfo *def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs,
|
||||
/* icon buffers can get initialized runtime now, via datatoc */
|
||||
if (bbuf) {
|
||||
int y, imgsize;
|
||||
|
||||
|
||||
iimg->rect = MEM_mallocN(size * size * sizeof(unsigned int), "icon_rect");
|
||||
|
||||
|
||||
/* Here we store the rect in the icon - same as before */
|
||||
if (size == bbuf->x && size == bbuf->y && xofs == 0 && yofs == 0)
|
||||
memcpy(iimg->rect, bbuf->rect, size * size * sizeof(int));
|
||||
@@ -179,7 +179,7 @@ static DrawInfo *def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs,
|
||||
new_icon->drawinfo = di;
|
||||
|
||||
BKE_icon_set(icon_id, new_icon);
|
||||
|
||||
|
||||
return di;
|
||||
}
|
||||
|
||||
@@ -240,24 +240,24 @@ static void vicon_keytype_draw_wrapper(int x, int y, int w, int h, float alpha,
|
||||
*/
|
||||
struct bThemeState theme_state;
|
||||
int xco, yco;
|
||||
|
||||
|
||||
UI_Theme_Store(&theme_state);
|
||||
UI_SetTheme(SPACE_ACTION, RGN_TYPE_WINDOW);
|
||||
|
||||
|
||||
/* the "x" and "y" given are the bottom-left coordinates of the icon,
|
||||
* while the draw_keyframe_shape() function needs the midpoint for
|
||||
* the keyframe
|
||||
*/
|
||||
xco = x + w / 2;
|
||||
yco = y + h / 2;
|
||||
|
||||
|
||||
/* draw keyframe
|
||||
* - xscale: 1.0 (since there's no timeline scaling to compensate for)
|
||||
* - yscale: 0.3 * h (found out experimentally... dunno why!)
|
||||
* - sel: true (so that "keyframe" state shows the iconic yellow icon)
|
||||
*/
|
||||
draw_keyframe_shape(xco, yco, 1.0f, 0.3f * h, true, key_type, KEYFRAME_SHAPE_BOTH, alpha);
|
||||
|
||||
|
||||
UI_Theme_Restore(&theme_state);
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNU
|
||||
{
|
||||
bTheme *btheme = UI_GetTheme();
|
||||
ThemeWireColor *cs = &btheme->tarm[index];
|
||||
|
||||
|
||||
/* Draw three bands of color: One per color
|
||||
* x-----a-----b-----c
|
||||
* | N | S | A |
|
||||
@@ -299,16 +299,16 @@ static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNU
|
||||
const int a = x + w / 3;
|
||||
const int b = x + w / 3 * 2;
|
||||
const int c = x + w;
|
||||
|
||||
|
||||
/* XXX: Include alpha into this... */
|
||||
/* normal */
|
||||
glColor3ubv((unsigned char *)cs->solid);
|
||||
glRecti(x, y, a, y + h);
|
||||
|
||||
|
||||
/* selected */
|
||||
glColor3ubv((unsigned char *)cs->select);
|
||||
glRecti(a, y, b, y + h);
|
||||
|
||||
|
||||
/* active */
|
||||
glColor3ubv((unsigned char *)cs->active);
|
||||
glRecti(b, y, c, y + h);
|
||||
@@ -319,7 +319,7 @@ static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNU
|
||||
{ \
|
||||
vicon_colorset_draw(index, x, y, w, h, alpha); \
|
||||
}
|
||||
|
||||
|
||||
DEF_VICON_COLORSET_DRAW_NTH(01, 0)
|
||||
DEF_VICON_COLORSET_DRAW_NTH(02, 1)
|
||||
DEF_VICON_COLORSET_DRAW_NTH(03, 2)
|
||||
@@ -403,14 +403,14 @@ static void icon_verify_datatoc(IconImage *iimg)
|
||||
/* if it has own rect, things are all OK */
|
||||
if (iimg->rect)
|
||||
return;
|
||||
|
||||
|
||||
if (iimg->datatoc_rect) {
|
||||
ImBuf *bbuf = IMB_ibImageFromMemory(iimg->datatoc_rect,
|
||||
iimg->datatoc_size, IB_rect, NULL, "<matcap icon>");
|
||||
/* w and h were set on initialize */
|
||||
if (bbuf->x != iimg->h && bbuf->y != iimg->w)
|
||||
IMB_scaleImBuf(bbuf, iimg->w, iimg->h);
|
||||
|
||||
|
||||
iimg->rect = bbuf->rect;
|
||||
bbuf->rect = NULL;
|
||||
IMB_freeImBuf(bbuf);
|
||||
@@ -470,7 +470,7 @@ static void init_internal_icons(void)
|
||||
if ((btheme != NULL) && btheme->tui.iconfile[0]) {
|
||||
char *icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons");
|
||||
char iconfilestr[FILE_MAX];
|
||||
|
||||
|
||||
if (icondir) {
|
||||
BLI_join_dirfile(iconfilestr, sizeof(iconfilestr), icondir, btheme->tui.iconfile);
|
||||
bbuf = IMB_loadiffname(iconfilestr, IB_rect, NULL); /* if the image is missing bbuf will just be NULL */
|
||||
@@ -496,7 +496,7 @@ static void init_internal_icons(void)
|
||||
datatoc_blender_icons32_png_size, IB_rect, NULL, "<blender icons>");
|
||||
if (b32buf)
|
||||
IMB_premultiply_alpha(b32buf);
|
||||
|
||||
|
||||
if (b16buf && b32buf) {
|
||||
/* free existing texture if any */
|
||||
if (icongltex.id) {
|
||||
@@ -510,17 +510,17 @@ static void init_internal_icons(void)
|
||||
|
||||
if (icongltex.id) {
|
||||
int level = 2;
|
||||
|
||||
|
||||
icongltex.w = b32buf->x;
|
||||
icongltex.h = b32buf->y;
|
||||
icongltex.invw = 1.0f / b32buf->x;
|
||||
icongltex.invh = 1.0f / b32buf->y;
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, icongltex.id);
|
||||
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, b32buf->x, b32buf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, b32buf->rect);
|
||||
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA8, b16buf->x, b16buf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, b16buf->rect);
|
||||
|
||||
|
||||
while (b16buf->x > 1) {
|
||||
ImBuf *nbuf = IMB_onehalf(b16buf);
|
||||
glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA8, nbuf->x, nbuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, nbuf->rect);
|
||||
@@ -528,12 +528,12 @@ static void init_internal_icons(void)
|
||||
IMB_freeImBuf(b16buf);
|
||||
b16buf = nbuf;
|
||||
}
|
||||
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
|
||||
if (glGetError() == GL_OUT_OF_MEMORY) {
|
||||
glDeleteTextures(1, &icongltex.id);
|
||||
icongltex.id = 0;
|
||||
@@ -546,7 +546,7 @@ static void init_internal_icons(void)
|
||||
icontype = ICON_TYPE_TEXTURE;
|
||||
else
|
||||
icontype = ICON_TYPE_BUFFER;
|
||||
|
||||
|
||||
if (b32buf) {
|
||||
for (y = 0; y < ICON_GRID_ROWS; y++) {
|
||||
for (x = 0; x < ICON_GRID_COLS; x++) {
|
||||
@@ -559,13 +559,13 @@ static void init_internal_icons(void)
|
||||
}
|
||||
|
||||
def_internal_vicon(VICO_SMALL_TRI_RIGHT_VEC, vicon_small_tri_right_draw);
|
||||
|
||||
|
||||
def_internal_vicon(VICO_KEYTYPE_KEYFRAME_VEC, vicon_keytype_keyframe_draw);
|
||||
def_internal_vicon(VICO_KEYTYPE_BREAKDOWN_VEC, vicon_keytype_breakdown_draw);
|
||||
def_internal_vicon(VICO_KEYTYPE_EXTREME_VEC, vicon_keytype_extreme_draw);
|
||||
def_internal_vicon(VICO_KEYTYPE_JITTER_VEC, vicon_keytype_jitter_draw);
|
||||
def_internal_vicon(VICO_KEYTYPE_MOVING_HOLD_VEC, vicon_keytype_moving_hold_draw);
|
||||
|
||||
|
||||
def_internal_vicon(VICO_COLORSET_01_VEC, vicon_colorset_draw_01);
|
||||
def_internal_vicon(VICO_COLORSET_02_VEC, vicon_colorset_draw_02);
|
||||
def_internal_vicon(VICO_COLORSET_03_VEC, vicon_colorset_draw_03);
|
||||
@@ -589,7 +589,7 @@ static void init_internal_icons(void)
|
||||
|
||||
IMB_freeImBuf(b16buf);
|
||||
IMB_freeImBuf(b32buf);
|
||||
|
||||
|
||||
}
|
||||
#endif /* WITH_HEADLESS */
|
||||
|
||||
@@ -605,13 +605,13 @@ static void init_iconfile_list(struct ListBase *list)
|
||||
|
||||
if (icondir == NULL)
|
||||
return;
|
||||
|
||||
|
||||
totfile = BLI_filelist_dir_contents(icondir, &dir);
|
||||
|
||||
for (i = 0; i < totfile; i++) {
|
||||
if ((dir[i].type & S_IFREG)) {
|
||||
const char *filename = dir[i].relname;
|
||||
|
||||
|
||||
if (BLI_testextensie(filename, ".png")) {
|
||||
/* loading all icons on file start is overkill & slows startup
|
||||
* its possible they change size after blender load anyway. */
|
||||
@@ -633,7 +633,7 @@ static void init_iconfile_list(struct ListBase *list)
|
||||
else {
|
||||
ifilex = ifiley = 0;
|
||||
}
|
||||
|
||||
|
||||
/* bad size or failed to load */
|
||||
if ((ifilex != ICON_IMAGE_W) || (ifiley != ICON_IMAGE_H)) {
|
||||
printf("icon '%s' is wrong size %dx%d\n", iconfilestr, ifilex, ifiley);
|
||||
@@ -643,12 +643,12 @@ static void init_iconfile_list(struct ListBase *list)
|
||||
|
||||
/* found a potential icon file, so make an entry for it in the cache list */
|
||||
ifile = MEM_callocN(sizeof(IconFile), "IconFile");
|
||||
|
||||
|
||||
BLI_strncpy(ifile->filename, filename, sizeof(ifile->filename));
|
||||
ifile->index = index;
|
||||
|
||||
BLI_addtail(list, ifile);
|
||||
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@@ -661,7 +661,7 @@ static void init_iconfile_list(struct ListBase *list)
|
||||
static void free_iconfile_list(struct ListBase *list)
|
||||
{
|
||||
IconFile *ifile = NULL, *next_ifile = NULL;
|
||||
|
||||
|
||||
for (ifile = list->first; ifile; ifile = next_ifile) {
|
||||
next_ifile = ifile->next;
|
||||
BLI_freelinkN(list, ifile);
|
||||
@@ -674,20 +674,20 @@ int UI_iconfile_get_index(const char *filename)
|
||||
{
|
||||
IconFile *ifile;
|
||||
ListBase *list = &(iconfilelist);
|
||||
|
||||
|
||||
for (ifile = list->first; ifile; ifile = ifile->next) {
|
||||
if (BLI_path_cmp(filename, ifile->filename) == 0) {
|
||||
return ifile->index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ListBase *UI_iconfile_list(void)
|
||||
{
|
||||
ListBase *list = &(iconfilelist);
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -739,13 +739,13 @@ int UI_icon_get_width(int icon_id)
|
||||
DrawInfo *di = NULL;
|
||||
|
||||
icon = BKE_icon_get(icon_id);
|
||||
|
||||
|
||||
if (icon == NULL) {
|
||||
if (G.debug & G_DEBUG)
|
||||
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
di = (DrawInfo *)icon->drawinfo;
|
||||
if (!di) {
|
||||
di = icon_create_drawinfo();
|
||||
@@ -764,20 +764,20 @@ int UI_icon_get_height(int icon_id)
|
||||
DrawInfo *di = NULL;
|
||||
|
||||
icon = BKE_icon_get(icon_id);
|
||||
|
||||
|
||||
if (icon == NULL) {
|
||||
if (G.debug & G_DEBUG)
|
||||
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
di = (DrawInfo *)icon->drawinfo;
|
||||
|
||||
if (!di) {
|
||||
di = icon_create_drawinfo();
|
||||
icon->drawinfo = di;
|
||||
}
|
||||
|
||||
|
||||
if (di)
|
||||
return ICON_DEFAULT_HEIGHT;
|
||||
|
||||
@@ -900,7 +900,7 @@ static void icon_set_image(
|
||||
PreviewImage *UI_icon_to_preview(int icon_id)
|
||||
{
|
||||
Icon *icon = BKE_icon_get(icon_id);
|
||||
|
||||
|
||||
if (icon) {
|
||||
DrawInfo *di = (DrawInfo *)icon->drawinfo;
|
||||
if (di) {
|
||||
@@ -1003,7 +1003,7 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect),
|
||||
/* restore color */
|
||||
if (alpha != 0.0f)
|
||||
glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
|
||||
|
||||
|
||||
if (rgb) {
|
||||
glPixelTransferf(GL_RED_SCALE, 1.0f);
|
||||
glPixelTransferf(GL_GREEN_SCALE, 1.0f);
|
||||
@@ -1076,10 +1076,10 @@ static void icon_draw_size(
|
||||
IconImage *iimg;
|
||||
const float fdraw_size = (float)draw_size;
|
||||
int w, h;
|
||||
|
||||
|
||||
icon = BKE_icon_get(icon_id);
|
||||
alpha *= btheme->tui.icon_alpha;
|
||||
|
||||
|
||||
if (icon == NULL) {
|
||||
if (G.debug & G_DEBUG)
|
||||
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
|
||||
@@ -1087,18 +1087,18 @@ static void icon_draw_size(
|
||||
}
|
||||
|
||||
di = (DrawInfo *)icon->drawinfo;
|
||||
|
||||
|
||||
if (!di) {
|
||||
di = icon_create_drawinfo();
|
||||
|
||||
|
||||
icon->drawinfo = di;
|
||||
icon->drawinfo_free = UI_icons_free_drawinfo;
|
||||
}
|
||||
|
||||
|
||||
/* scale width and height according to aspect */
|
||||
w = (int)(fdraw_size / aspect + 0.5f);
|
||||
h = (int)(fdraw_size / aspect + 0.5f);
|
||||
|
||||
|
||||
if (di->type == ICON_TYPE_VECTOR) {
|
||||
/* vector icons use the uiBlock transformation, they are not drawn
|
||||
* with untransformed coordinates like the other icons */
|
||||
@@ -1129,7 +1129,7 @@ static void icon_draw_size(
|
||||
if (pi) {
|
||||
/* no create icon on this level in code */
|
||||
if (!pi->rect[size]) return; /* something has gone wrong! */
|
||||
|
||||
|
||||
/* preview images use premul alpha ... */
|
||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
@@ -1166,10 +1166,10 @@ static void ui_id_brush_render(const bContext *C, ID *id)
|
||||
{
|
||||
PreviewImage *pi = BKE_previewimg_id_ensure(id);
|
||||
enum eIconSizes i;
|
||||
|
||||
|
||||
if (!pi)
|
||||
return;
|
||||
|
||||
|
||||
for (i = 0; i < NUM_ICON_SIZES; i++) {
|
||||
/* check if rect needs to be created; changed
|
||||
* only set by dynamic icons */
|
||||
@@ -1237,7 +1237,7 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
|
||||
int ui_id_icon_get(const bContext *C, ID *id, const bool big)
|
||||
{
|
||||
int iconid = 0;
|
||||
|
||||
|
||||
/* icon */
|
||||
switch (GS(id->name)) {
|
||||
case ID_BR:
|
||||
|
||||
@@ -73,19 +73,19 @@ typedef enum {
|
||||
UI_WTYPE_SLIDER,
|
||||
UI_WTYPE_EXEC,
|
||||
UI_WTYPE_TOOLTIP,
|
||||
|
||||
|
||||
/* strings */
|
||||
UI_WTYPE_NAME,
|
||||
UI_WTYPE_NAME_LINK,
|
||||
UI_WTYPE_POINTER_LINK,
|
||||
UI_WTYPE_FILENAME,
|
||||
|
||||
|
||||
/* menus */
|
||||
UI_WTYPE_MENU_RADIO,
|
||||
UI_WTYPE_MENU_ICON_RADIO,
|
||||
UI_WTYPE_MENU_POINTER_LINK,
|
||||
UI_WTYPE_MENU_NODE_LINK,
|
||||
|
||||
|
||||
UI_WTYPE_PULLDOWN,
|
||||
UI_WTYPE_MENU_ITEM,
|
||||
UI_WTYPE_MENU_ITEM_RADIAL,
|
||||
@@ -197,10 +197,10 @@ typedef struct {
|
||||
void **poin; /* pointer to original pointer */
|
||||
void ***ppoin; /* pointer to original pointer-array */
|
||||
short *totlink; /* if pointer-array, here is the total */
|
||||
|
||||
|
||||
short maxlink, pad;
|
||||
short fromcode, tocode;
|
||||
|
||||
|
||||
ListBase lines;
|
||||
} uiLink;
|
||||
|
||||
@@ -255,7 +255,7 @@ struct uiBut {
|
||||
|
||||
uiButCompleteFunc autocomplete_func;
|
||||
void *autofunc_arg;
|
||||
|
||||
|
||||
uiButSearchCreateFunc search_create_func;
|
||||
uiButSearchFunc search_func;
|
||||
void *search_arg;
|
||||
@@ -270,7 +270,7 @@ struct uiBut {
|
||||
|
||||
uiLink *link;
|
||||
short linkto[2]; /* region relative coords */
|
||||
|
||||
|
||||
const char *tip;
|
||||
uiButToolTipFunc tip_func;
|
||||
void *tip_argN;
|
||||
@@ -314,7 +314,7 @@ struct uiBut {
|
||||
void *dragpoin;
|
||||
struct ImBuf *imb;
|
||||
float imb_scale;
|
||||
|
||||
|
||||
/* active button data */
|
||||
struct uiHandleButtonData *active;
|
||||
|
||||
@@ -326,7 +326,7 @@ struct uiBut {
|
||||
float *editvec;
|
||||
void *editcoba;
|
||||
void *editcumap;
|
||||
|
||||
|
||||
/* pointer back */
|
||||
uiBlock *block;
|
||||
};
|
||||
@@ -369,9 +369,9 @@ struct uiBlock {
|
||||
struct uiLayout *curlayout;
|
||||
|
||||
ListBase contexts;
|
||||
|
||||
|
||||
char name[UI_MAX_NAME_STR];
|
||||
|
||||
|
||||
float winmat[4][4];
|
||||
|
||||
rctf rect;
|
||||
@@ -391,10 +391,10 @@ struct uiBlock {
|
||||
|
||||
uiBlockHandleFunc handle_func;
|
||||
void *handle_func_arg;
|
||||
|
||||
|
||||
/* custom extra handling */
|
||||
int (*block_event_func)(const struct bContext *C, struct uiBlock *, const struct wmEvent *);
|
||||
|
||||
|
||||
/* extra draw function for custom blocks */
|
||||
void (*drawextra)(const struct bContext *C, void *idv, void *arg1, void *arg2, rcti *rect);
|
||||
void *drawextra_arg1;
|
||||
@@ -551,7 +551,7 @@ struct uiPopupBlockHandle {
|
||||
void (*popup_func)(struct bContext *C, void *arg, int event);
|
||||
void (*cancel_func)(struct bContext *C, void *arg);
|
||||
void *popup_arg;
|
||||
|
||||
|
||||
/* store data for refreshing popups */
|
||||
struct uiPopupBlockCreate popup_create_vars;
|
||||
/* true if we can re-create the popup using 'popup_create_vars' */
|
||||
@@ -567,7 +567,7 @@ struct uiPopupBlockHandle {
|
||||
ScrArea *ctx_area;
|
||||
ARegion *ctx_region;
|
||||
int opcontext;
|
||||
|
||||
|
||||
/* return values */
|
||||
int butretval;
|
||||
int menuretval;
|
||||
|
||||
@@ -299,7 +299,7 @@ static void ui_item_position(uiItem *item, int x, int y, int w, int h)
|
||||
bitem->but->rect.ymin = y;
|
||||
bitem->but->rect.xmax = x + w;
|
||||
bitem->but->rect.ymax = y + h;
|
||||
|
||||
|
||||
ui_but_update(bitem->but); /* for strlen */
|
||||
}
|
||||
else {
|
||||
@@ -319,7 +319,7 @@ static void ui_item_move(uiItem *item, int delta_xmin, int delta_xmax)
|
||||
|
||||
bitem->but->rect.xmin += delta_xmin;
|
||||
bitem->but->rect.xmax += delta_xmax;
|
||||
|
||||
|
||||
ui_but_update(bitem->but); /* for strlen */
|
||||
}
|
||||
else {
|
||||
@@ -359,7 +359,7 @@ static uiLayout *ui_item_local_sublayout(uiLayout *test, uiLayout *layout, int a
|
||||
sub = uiLayoutRow(layout, align);
|
||||
else
|
||||
sub = uiLayoutColumn(layout, align);
|
||||
|
||||
|
||||
sub->space = 0;
|
||||
return sub;
|
||||
}
|
||||
@@ -429,9 +429,9 @@ static void ui_item_array(
|
||||
|
||||
if (ptr->type == &RNA_Armature) {
|
||||
bArmature *arm = (bArmature *)ptr->data;
|
||||
|
||||
|
||||
layer_used = arm->layer_used;
|
||||
|
||||
|
||||
if (arm->edbo) {
|
||||
if (arm->act_edbone) {
|
||||
layer_active |= arm->act_edbone->layer;
|
||||
@@ -450,7 +450,7 @@ static void ui_item_array(
|
||||
for (a = 0; a < colbuts; a++) {
|
||||
const int layer_num = a + b * colbuts;
|
||||
const unsigned int layer_flag = (1u << layer_num);
|
||||
|
||||
|
||||
if (layer_used & layer_flag) {
|
||||
if (layer_active & layer_flag)
|
||||
icon = ICON_LAYER_ACTIVE;
|
||||
@@ -468,7 +468,7 @@ static void ui_item_array(
|
||||
for (a = 0; a < colbuts; a++) {
|
||||
const int layer_num = a + len / 2 + b * colbuts;
|
||||
const unsigned int layer_flag = (1u << layer_num);
|
||||
|
||||
|
||||
if (layer_used & layer_flag) {
|
||||
if (layer_active & layer_flag)
|
||||
icon = ICON_LAYER_ACTIVE;
|
||||
@@ -496,7 +496,7 @@ static void ui_item_array(
|
||||
|
||||
totdim = RNA_property_array_dimension(ptr, prop, dim_size);
|
||||
if (totdim != 2) return; /* only 2D matrices supported in UI so far */
|
||||
|
||||
|
||||
w /= dim_size[0];
|
||||
/* h /= dim_size[1]; */ /* UNUSED */
|
||||
|
||||
@@ -1402,7 +1402,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
|
||||
|
||||
if (icon == ICON_NONE)
|
||||
icon = RNA_property_ui_icon(prop);
|
||||
|
||||
|
||||
if (flag & UI_ITEM_R_ICON_ONLY) {
|
||||
/* pass */
|
||||
}
|
||||
@@ -1447,7 +1447,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
|
||||
|
||||
if (no_bg)
|
||||
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
||||
|
||||
|
||||
/* array property */
|
||||
if (index == RNA_NO_INDEX && is_array)
|
||||
ui_item_array(layout, block, name, icon, ptr, prop, len, 0, 0, w, h, expand, slider, toggle, icon_only);
|
||||
@@ -1467,7 +1467,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
|
||||
else if (type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) {
|
||||
but = ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, flag);
|
||||
ui_but_add_search(but, ptr, prop, NULL, NULL);
|
||||
|
||||
|
||||
if (layout->redalert)
|
||||
UI_but_flag_enable(but, UI_BUT_REDALERT);
|
||||
}
|
||||
@@ -1480,7 +1480,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
|
||||
|
||||
if (toggle && but->type == UI_BTYPE_CHECKBOX)
|
||||
but->type = UI_BTYPE_TOGGLE;
|
||||
|
||||
|
||||
if (layout->redalert)
|
||||
UI_but_flag_enable(but, UI_BUT_REDALERT);
|
||||
}
|
||||
@@ -1650,7 +1650,7 @@ static int sort_search_items_list(const void *a, const void *b)
|
||||
{
|
||||
const CollItemSearch *cis1 = a;
|
||||
const CollItemSearch *cis2 = b;
|
||||
|
||||
|
||||
if (BLI_strcasecmp(cis1->name, cis2->name) > 0)
|
||||
return 1;
|
||||
else
|
||||
@@ -1711,9 +1711,9 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s
|
||||
i++;
|
||||
}
|
||||
RNA_PROP_END;
|
||||
|
||||
|
||||
BLI_listbase_sort(items_list, sort_search_items_list);
|
||||
|
||||
|
||||
/* add search items from temporary list */
|
||||
for (cis = items_list->first; cis; cis = cis->next) {
|
||||
if (false == UI_search_item_add(items, cis->name, SET_INT_IN_POINTER(cis->index), cis->iconid)) {
|
||||
@@ -1800,7 +1800,7 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
|
||||
StructRNA *icontype;
|
||||
int w, h;
|
||||
char namestr[UI_MAX_NAME_STR];
|
||||
|
||||
|
||||
/* validate arguments */
|
||||
prop = RNA_struct_find_property(ptr, propname);
|
||||
|
||||
@@ -1809,7 +1809,7 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
|
||||
RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
type = RNA_property_type(prop);
|
||||
if (!ELEM(type, PROP_POINTER, PROP_STRING, PROP_ENUM)) {
|
||||
RNA_warning("Property %s must be a pointer, string or enum", propname);
|
||||
@@ -2214,7 +2214,7 @@ static void ui_litem_layout_row(uiLayout *litem)
|
||||
|
||||
if (totw == 0)
|
||||
return;
|
||||
|
||||
|
||||
if (w != 0)
|
||||
w -= (tot - 1) * litem->space;
|
||||
fixedw = 0;
|
||||
@@ -2245,7 +2245,7 @@ static void ui_litem_layout_row(uiLayout *litem)
|
||||
/* ignore min flag for rows with right or center alignment */
|
||||
if (item->type != ITEM_BUTTON &&
|
||||
ELEM(((uiLayout *)item)->alignment, UI_LAYOUT_ALIGN_RIGHT, UI_LAYOUT_ALIGN_CENTER) &&
|
||||
litem->alignment == UI_LAYOUT_ALIGN_EXPAND &&
|
||||
litem->alignment == UI_LAYOUT_ALIGN_EXPAND &&
|
||||
((uiItem *)litem)->flag & UI_ITEM_MIN)
|
||||
{
|
||||
min_flag = false;
|
||||
@@ -2353,7 +2353,7 @@ static void ui_litem_estimate_column(uiLayout *litem, bool is_box)
|
||||
if (item->next && (!is_box || item != litem->items.first))
|
||||
litem->h += litem->space;
|
||||
}
|
||||
|
||||
|
||||
if (min_size_flag) {
|
||||
litem->item.flag |= UI_ITEM_MIN;
|
||||
}
|
||||
@@ -2743,7 +2743,7 @@ static void ui_litem_layout_absolute(uiLayout *litem)
|
||||
scalex = (float)litem->w / (float)totw;
|
||||
if (litem->h && toth > 0)
|
||||
scaley = (float)litem->h / (float)toth;
|
||||
|
||||
|
||||
x = litem->x;
|
||||
y = litem->y - scaley * toth;
|
||||
|
||||
@@ -2794,7 +2794,7 @@ static void ui_litem_layout_split(uiLayout *litem)
|
||||
y = litem->y;
|
||||
|
||||
percentage = (split->percentage == 0.0f) ? 1.0f / (float)tot : split->percentage;
|
||||
|
||||
|
||||
w = (litem->w - (tot - 1) * litem->space);
|
||||
colw = w * percentage;
|
||||
colw = MAX2(colw, 0);
|
||||
@@ -3437,7 +3437,7 @@ uiLayout *UI_block_layout(uiBlock *block, int dir, int type, int x, int y, int s
|
||||
BLI_addtail(&block->layouts, root);
|
||||
|
||||
ui_layout_add_padding_button(root);
|
||||
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
@@ -3460,7 +3460,7 @@ void UI_block_layout_set_current(uiBlock *block, uiLayout *layout)
|
||||
void ui_layout_add_but(uiLayout *layout, uiBut *but)
|
||||
{
|
||||
uiButtonItem *bitem;
|
||||
|
||||
|
||||
bitem = MEM_callocN(sizeof(uiButtonItem), "uiButtonItem");
|
||||
bitem->item.type = ITEM_BUTTON;
|
||||
bitem->but = but;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Contributor(s): Blender Foundation, Joshua Leung
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
@@ -72,7 +72,7 @@ static int reset_default_theme_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
ui_theme_init_default();
|
||||
ui_style_init_default();
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -82,10 +82,10 @@ static void UI_OT_reset_default_theme(wmOperatorType *ot)
|
||||
ot->name = "Reset to Default Theme";
|
||||
ot->idname = "UI_OT_reset_default_theme";
|
||||
ot->description = "Reset to the default theme colors";
|
||||
|
||||
|
||||
/* callbacks */
|
||||
ot->exec = reset_default_theme_exec;
|
||||
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ static int copy_data_path_button_poll(bContext *C)
|
||||
|
||||
if (ptr.id.data && ptr.data && prop) {
|
||||
path = RNA_path_from_ID_to_property(&ptr, prop);
|
||||
|
||||
|
||||
if (path) {
|
||||
MEM_freeN(path);
|
||||
return 1;
|
||||
@@ -249,7 +249,7 @@ static int reset_default_button_poll(bContext *C)
|
||||
int index;
|
||||
|
||||
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
|
||||
|
||||
|
||||
return (ptr.data && prop && RNA_property_editable(&ptr, prop));
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ static int reset_default_button_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* try to reset the nominated setting to its default value */
|
||||
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
|
||||
|
||||
|
||||
/* if there is a valid property that is editable... */
|
||||
if (ptr.data && prop && RNA_property_editable(&ptr, prop)) {
|
||||
if (RNA_property_reset(&ptr, prop, (all) ? -1 : index))
|
||||
@@ -285,7 +285,7 @@ static void UI_OT_reset_default_button(wmOperatorType *ot)
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_UNDO;
|
||||
|
||||
|
||||
/* properties */
|
||||
RNA_def_boolean(ot->srna, "all", 1, "All", "Reset to default values all elements of the array");
|
||||
}
|
||||
@@ -585,7 +585,7 @@ static void UI_OT_copy_to_selected_button(wmOperatorType *ot)
|
||||
|
||||
/* Reports to Textblock Operator ------------------------ */
|
||||
|
||||
/* FIXME: this is just a temporary operator so that we can see all the reports somewhere
|
||||
/* FIXME: this is just a temporary operator so that we can see all the reports somewhere
|
||||
* when there are too many to display...
|
||||
*/
|
||||
|
||||
@@ -600,10 +600,10 @@ static int reports_to_text_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Text *txt;
|
||||
char *str;
|
||||
|
||||
|
||||
/* create new text-block to write to */
|
||||
txt = BKE_text_add(bmain, "Recent Reports");
|
||||
|
||||
|
||||
/* convert entire list to a display string, and add this to the text-block
|
||||
* - if commandline debug option enabled, show debug reports too
|
||||
* - otherwise, up to info (which is what users normally see)
|
||||
@@ -628,7 +628,7 @@ static void UI_OT_reports_to_textblock(wmOperatorType *ot)
|
||||
ot->name = "Reports to Text Block";
|
||||
ot->idname = "UI_OT_reports_to_textblock";
|
||||
ot->description = "Write the reports ";
|
||||
|
||||
|
||||
/* callbacks */
|
||||
ot->poll = reports_to_text_poll;
|
||||
ot->exec = reports_to_text_exec;
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
|
||||
/* a full doc with API notes can be found in bf-blender/trunk/blender/doc/guides/interface_API.txt */
|
||||
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -130,7 +130,7 @@ static int panel_aligned(ScrArea *sa, ARegion *ar)
|
||||
return BUT_VERTICAL;
|
||||
else if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS))
|
||||
return BUT_VERTICAL;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ static int panels_re_align(ScrArea *sa, ARegion *ar, Panel **r_pa)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, P
|
||||
else
|
||||
pa->flag |= PNL_CLOSEDX;
|
||||
}
|
||||
|
||||
|
||||
pa->ofsx = 0;
|
||||
pa->ofsy = 0;
|
||||
pa->sizex = 0;
|
||||
@@ -319,7 +319,7 @@ Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, P
|
||||
for (palast = ar->panels.first; palast; palast = palast->next)
|
||||
if (palast->runtime_flag & PNL_LAST_ADDED)
|
||||
break;
|
||||
|
||||
|
||||
if (newpanel) {
|
||||
pa->sortorder = (palast) ? palast->sortorder + 1 : 0;
|
||||
|
||||
@@ -341,7 +341,7 @@ Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, P
|
||||
if (pa->flag & PNL_CLOSED) return pa;
|
||||
|
||||
*r_open = true;
|
||||
|
||||
|
||||
return pa;
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ static void ui_offset_panel_block(uiBlock *block)
|
||||
#if 0 /*UNUSED 2.5*/
|
||||
static void uiPanelPush(uiBlock *block)
|
||||
{
|
||||
glPushMatrix();
|
||||
glPushMatrix();
|
||||
|
||||
if (block->panel)
|
||||
glTranslatef((float)block->panel->ofsx, (float)block->panel->ofsy, 0.0);
|
||||
@@ -415,7 +415,7 @@ void UI_draw_icon_tri(float x, float y, char dir)
|
||||
float f3 = 0.15 * U.widget_unit;
|
||||
float f5 = 0.25 * U.widget_unit;
|
||||
float f7 = 0.35 * U.widget_unit;
|
||||
|
||||
|
||||
if (dir == 'h') {
|
||||
ui_draw_anti_tria(x - f3, y - f5, x - f3, y + f5, x + f7, y);
|
||||
}
|
||||
@@ -448,13 +448,13 @@ static void ui_draw_anti_x(float x1, float y1, float x2, float y2)
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
glLineWidth(2.0);
|
||||
|
||||
|
||||
fdrawline(x1, y1, x2, y2);
|
||||
fdrawline(x1, y2, x2, y1);
|
||||
|
||||
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* x 'icon' for panel header */
|
||||
@@ -471,20 +471,20 @@ static void ui_draw_panel_scalewidget(const rcti *rect)
|
||||
{
|
||||
float xmin, xmax, dx;
|
||||
float ymin, ymax, dy;
|
||||
|
||||
|
||||
xmin = rect->xmax - PNL_HEADER + 2;
|
||||
xmax = rect->xmax - 3;
|
||||
ymin = rect->ymin + 3;
|
||||
ymax = rect->ymin + PNL_HEADER - 2;
|
||||
|
||||
|
||||
dx = 0.5f * (xmax - xmin);
|
||||
dy = 0.5f * (ymax - ymin);
|
||||
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glColor4ub(255, 255, 255, 50);
|
||||
fdrawline(xmin, ymin, xmax, ymax);
|
||||
fdrawline(xmin + dx, ymin, xmax, ymax - dy);
|
||||
|
||||
|
||||
glColor4ub(0, 0, 0, 50);
|
||||
fdrawline(xmin, ymin + 1, xmax, ymax + 1);
|
||||
fdrawline(xmin + dx, ymin + 1, xmax, ymax - dy + 1);
|
||||
@@ -540,11 +540,11 @@ static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, const r
|
||||
pnl_icons = (panel->labelofs + 2 * PNL_ICON + 5) / block->aspect + 0.001f;
|
||||
else
|
||||
pnl_icons = (panel->labelofs + PNL_ICON + 5) / block->aspect + 0.001f;
|
||||
|
||||
|
||||
/* active tab */
|
||||
/* draw text label */
|
||||
UI_ThemeColor(TH_TITLE);
|
||||
|
||||
|
||||
hrect = *rect;
|
||||
if (dir == 'h') {
|
||||
hrect.xmin = rect->xmin + pnl_icons;
|
||||
@@ -552,7 +552,7 @@ static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, const r
|
||||
UI_fontstyle_draw(&style->paneltitle, &hrect, activename);
|
||||
}
|
||||
else {
|
||||
/* ignore 'pnl_icons', otherwise the text gets offset horizontally
|
||||
/* ignore 'pnl_icons', otherwise the text gets offset horizontally
|
||||
* + 0.001f to avoid flirting with float inaccuracy
|
||||
*/
|
||||
hrect.xmin = rect->xmin + (PNL_ICON + 5) / block->aspect + 0.001f;
|
||||
@@ -753,7 +753,7 @@ typedef struct PanelSort {
|
||||
static int find_leftmost_panel(const void *a1, const void *a2)
|
||||
{
|
||||
const PanelSort *ps1 = a1, *ps2 = a2;
|
||||
|
||||
|
||||
if (ps1->pa->ofsx > ps2->pa->ofsx) return 1;
|
||||
else if (ps1->pa->ofsx < ps2->pa->ofsx) return -1;
|
||||
else if (ps1->pa->sortorder > ps2->pa->sortorder) return 1;
|
||||
@@ -766,7 +766,7 @@ static int find_leftmost_panel(const void *a1, const void *a2)
|
||||
static int find_highest_panel(const void *a1, const void *a2)
|
||||
{
|
||||
const PanelSort *ps1 = a1, *ps2 = a2;
|
||||
|
||||
|
||||
/* stick uppermost header-less panels to the top of the region -
|
||||
* prevent them from being sorted (multiple header-less panels have to be sorted though) */
|
||||
if (ps1->pa->type->flag & PNL_NO_HEADER && ps2->pa->type->flag & PNL_NO_HEADER) {
|
||||
@@ -779,17 +779,17 @@ static int find_highest_panel(const void *a1, const void *a2)
|
||||
else if (ps1->pa->ofsy + ps1->pa->sizey > ps2->pa->ofsy + ps2->pa->sizey) return -1;
|
||||
else if (ps1->pa->sortorder > ps2->pa->sortorder) return 1;
|
||||
else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int compare_panel(const void *a1, const void *a2)
|
||||
{
|
||||
const PanelSort *ps1 = a1, *ps2 = a2;
|
||||
|
||||
|
||||
if (ps1->pa->sortorder > ps2->pa->sortorder) return 1;
|
||||
else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -803,7 +803,7 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
|
||||
bool done;
|
||||
int align = panel_aligned(sa, ar);
|
||||
bool has_category_tabs = UI_panel_category_is_visible(ar);
|
||||
|
||||
|
||||
/* count active, not tabbed panels */
|
||||
for (pa = ar->panels.first; pa; pa = pa->next)
|
||||
if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL)
|
||||
@@ -823,7 +823,7 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
|
||||
|
||||
/* sort panels */
|
||||
panelsort = MEM_callocN(tot * sizeof(PanelSort), "panelsort");
|
||||
|
||||
|
||||
ps = panelsort;
|
||||
for (pa = ar->panels.first; pa; pa = pa->next) {
|
||||
if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL) {
|
||||
@@ -832,7 +832,7 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
|
||||
ps++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (drag) {
|
||||
/* while we are dragging, we sort on location and update sortorder */
|
||||
if (align == BUT_VERTICAL)
|
||||
@@ -846,7 +846,7 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
|
||||
else
|
||||
/* otherwise use sortorder */
|
||||
qsort(panelsort, tot, sizeof(PanelSort), compare_panel);
|
||||
|
||||
|
||||
/* no smart other default start loc! this keeps switching f5/f6/etc compatible */
|
||||
ps = panelsort;
|
||||
ps->pa->ofsx = 0;
|
||||
@@ -870,7 +870,7 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
|
||||
psnext->pa->ofsy = ps->pa->ofsy + get_panel_size_y(ps->pa) - get_panel_size_y(psnext->pa);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* we interpolate */
|
||||
done = false;
|
||||
ps = panelsort;
|
||||
@@ -894,7 +894,7 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
|
||||
MEM_freeN(ps->pa);
|
||||
}
|
||||
MEM_freeN(panelsort);
|
||||
|
||||
|
||||
return done;
|
||||
}
|
||||
|
||||
@@ -928,7 +928,7 @@ static void ui_panels_size(ScrArea *sa, ARegion *ar, int *x, int *y)
|
||||
sizex = UI_PANEL_WIDTH;
|
||||
if (sizey == 0)
|
||||
sizey = -UI_PANEL_WIDTH;
|
||||
|
||||
|
||||
*x = sizex;
|
||||
*y = sizey;
|
||||
}
|
||||
@@ -977,7 +977,7 @@ void UI_panels_end(const bContext *C, ARegion *ar, int *x, int *y)
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
uiBlock *block;
|
||||
Panel *panot, *panew, *patest, *pa, *firstpa;
|
||||
|
||||
|
||||
/* offset contents */
|
||||
for (block = ar->uiblocks.first; block; block = block->next)
|
||||
if (block->active && block->panel)
|
||||
@@ -1023,10 +1023,10 @@ void UI_panels_end(const bContext *C, ARegion *ar, int *x, int *y)
|
||||
if (block->active && block->panel)
|
||||
if (!firstpa || block->panel->sortorder < firstpa->sortorder)
|
||||
firstpa = block->panel;
|
||||
|
||||
|
||||
if (firstpa)
|
||||
firstpa->runtime_flag |= PNL_FIRST;
|
||||
|
||||
|
||||
/* compute size taken up by panel */
|
||||
ui_panels_size(sa, ar, x, y);
|
||||
}
|
||||
@@ -1036,7 +1036,7 @@ void UI_panels_draw(const bContext *C, ARegion *ar)
|
||||
uiBlock *block;
|
||||
|
||||
UI_ThemeClearColor(TH_BACK);
|
||||
|
||||
|
||||
/* draw panels, selected on top */
|
||||
for (block = ar->uiblocks.first; block; block = block->next) {
|
||||
if (block->active && block->panel && !(block->panel->flag & PNL_SELECT)) {
|
||||
@@ -1055,12 +1055,12 @@ void UI_panels_scale(ARegion *ar, float new_width)
|
||||
{
|
||||
uiBlock *block;
|
||||
uiBut *but;
|
||||
|
||||
|
||||
for (block = ar->uiblocks.first; block; block = block->next) {
|
||||
if (block->panel) {
|
||||
float fac = new_width / (float)block->panel->sizex;
|
||||
block->panel->sizex = new_width;
|
||||
|
||||
|
||||
for (but = block->buttons.first; but; but = but->next) {
|
||||
but->rect.xmin *= fac;
|
||||
but->rect.xmax *= fac;
|
||||
@@ -1076,13 +1076,13 @@ static void check_panel_overlap(ARegion *ar, Panel *panel)
|
||||
Panel *pa;
|
||||
|
||||
/* also called with (panel == NULL) for clear */
|
||||
|
||||
|
||||
for (pa = ar->panels.first; pa; pa = pa->next) {
|
||||
pa->flag &= ~PNL_OVERLAP;
|
||||
if (panel && (pa != panel)) {
|
||||
if (pa->paneltab == NULL && (pa->runtime_flag & PNL_ACTIVE)) {
|
||||
float safex = 0.2, safey = 0.2;
|
||||
|
||||
|
||||
if (pa->flag & PNL_CLOSEDX) safex = 0.05;
|
||||
else if (pa->flag & PNL_CLOSEDY) safey = 0.05;
|
||||
else if (panel->flag & PNL_CLOSEDX) safex = 0.05;
|
||||
@@ -1106,7 +1106,7 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel)
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
short align = panel_aligned(sa, ar), dx = 0, dy = 0;
|
||||
|
||||
|
||||
/* first clip for window, no dragging outside */
|
||||
if (!BLI_rcti_isect_pt_v(&ar->winrct, &event->x))
|
||||
return;
|
||||
@@ -1116,10 +1116,10 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel)
|
||||
|
||||
dx *= (float)BLI_rctf_size_x(&ar->v2d.cur) / (float)BLI_rcti_size_x(&ar->winrct);
|
||||
dy *= (float)BLI_rctf_size_y(&ar->v2d.cur) / (float)BLI_rcti_size_y(&ar->winrct);
|
||||
|
||||
|
||||
if (data->state == PANEL_STATE_DRAG_SCALE) {
|
||||
panel->sizex = MAX2(data->startsizex + dx, UI_PANEL_MINX);
|
||||
|
||||
|
||||
if (data->startsizey - dy < UI_PANEL_MINY)
|
||||
dy = -UI_PANEL_MINY + data->startsizey;
|
||||
|
||||
@@ -1129,11 +1129,11 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel)
|
||||
else {
|
||||
/* reset the panel snapping, to allow dragging away from snapped edges */
|
||||
panel->snap = PNL_SNAP_NONE;
|
||||
|
||||
|
||||
panel->ofsx = data->startofsx + dx;
|
||||
panel->ofsy = data->startofsy + dy;
|
||||
check_panel_overlap(ar, panel);
|
||||
|
||||
|
||||
if (align) uiAlignPanelStep(sa, ar, 0.2, true);
|
||||
}
|
||||
|
||||
@@ -1323,9 +1323,9 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
|
||||
rect_leftmost = rect_pin.xmin;
|
||||
|
||||
/* mouse coordinates in panel space! */
|
||||
|
||||
|
||||
/* XXX weak code, currently it assumes layout style for location of widgets */
|
||||
|
||||
|
||||
/* check open/collapsed button */
|
||||
if (event == RETKEY)
|
||||
button = 1;
|
||||
@@ -1346,7 +1346,7 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
|
||||
else if (mx < rect_leftmost) {
|
||||
button = 1;
|
||||
}
|
||||
|
||||
|
||||
if (button) {
|
||||
if (button == 2) { /* close */
|
||||
ED_region_tag_redraw(ar);
|
||||
@@ -1362,7 +1362,7 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
|
||||
if (block->panel->flag & PNL_CLOSED) {
|
||||
block->panel->flag &= ~PNL_CLOSED;
|
||||
/* snap back up so full panel aligns with screen edge */
|
||||
if (block->panel->snap & PNL_SNAP_BOTTOM)
|
||||
if (block->panel->snap & PNL_SNAP_BOTTOM)
|
||||
block->panel->ofsy = 0;
|
||||
|
||||
if (event == LEFTMOUSE) {
|
||||
@@ -1379,14 +1379,14 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
|
||||
else {
|
||||
/* snap down to bottom screen edge */
|
||||
block->panel->flag |= PNL_CLOSEDY;
|
||||
if (block->panel->snap & PNL_SNAP_BOTTOM)
|
||||
if (block->panel->snap & PNL_SNAP_BOTTOM)
|
||||
block->panel->ofsy = -block->panel->sizey;
|
||||
|
||||
if (event == LEFTMOUSE) {
|
||||
ui_panel_drag_collapse_handler_add(C, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (pa = ar->panels.first; pa; pa = pa->next) {
|
||||
if (pa->paneltab == block->panel) {
|
||||
if (block->panel->flag & PNL_CLOSED) pa->flag |= PNL_CLOSED;
|
||||
@@ -1945,27 +1945,27 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons
|
||||
/* XXX hardcoded key warning */
|
||||
if (ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER) && event->val == KM_PRESS) {
|
||||
if (event->type == AKEY && ((event->ctrl + event->oskey + event->shift + event->alt) == 0)) {
|
||||
|
||||
|
||||
if (pa->flag & PNL_CLOSEDY) {
|
||||
if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my))
|
||||
ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift);
|
||||
}
|
||||
else
|
||||
ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift);
|
||||
|
||||
|
||||
retval = WM_UI_HANDLER_BREAK;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* on active button, do not handle panels */
|
||||
if (ui_but_is_active(ar))
|
||||
continue;
|
||||
|
||||
|
||||
if (ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER)) {
|
||||
|
||||
if (event->val == KM_PRESS) {
|
||||
|
||||
|
||||
/* open close on header */
|
||||
if (ELEM(event->type, RETKEY, PADENTER)) {
|
||||
if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) {
|
||||
@@ -1977,7 +1977,7 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons
|
||||
else if (event->type == LEFTMOUSE) {
|
||||
/* all inside clicks should return in break - overlapping/float panels */
|
||||
retval = WM_UI_HANDLER_BREAK;
|
||||
|
||||
|
||||
if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) {
|
||||
ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift);
|
||||
retval = WM_UI_HANDLER_BREAK;
|
||||
@@ -2010,7 +2010,7 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons
|
||||
else if (event->type == PADPLUSKEY || event->type == PADMINUS) {
|
||||
#if 0 /* XXX make float panel exception? */
|
||||
int zoom = 0;
|
||||
|
||||
|
||||
/* if panel is closed, only zoom if mouse is over the header */
|
||||
if (pa->flag & (PNL_CLOSEDX | PNL_CLOSEDY)) {
|
||||
if (inside_header)
|
||||
@@ -2093,7 +2093,7 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
|
||||
uiHandlePanelData *data = pa->activedata;
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
|
||||
|
||||
if (data && data->state == state)
|
||||
return;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Contributor(s): Blender Foundation
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Contributor(s): Blender Foundation
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
@@ -65,10 +65,10 @@
|
||||
/* style + theme + layout-engine = UI */
|
||||
|
||||
/**
|
||||
* This is a complete set of layout rules, the 'state' of the Layout
|
||||
* Engine. Multiple styles are possible, defined via C or Python. Styles
|
||||
* get a name, and will typically get activated per region type, like
|
||||
* "Header", or "Listview" or "Toolbar". Properties of Style definitions
|
||||
* This is a complete set of layout rules, the 'state' of the Layout
|
||||
* Engine. Multiple styles are possible, defined via C or Python. Styles
|
||||
* get a name, and will typically get activated per region type, like
|
||||
* "Header", or "Listview" or "Toolbar". Properties of Style definitions
|
||||
* are:
|
||||
*
|
||||
* - default column properties, internal spacing, aligning, min/max width
|
||||
@@ -85,10 +85,10 @@
|
||||
static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id)
|
||||
{
|
||||
uiStyle *style = MEM_callocN(sizeof(uiStyle), "new style");
|
||||
|
||||
|
||||
BLI_addtail(styles, style);
|
||||
BLI_strncpy(style->name, name, MAX_STYLE_NAME);
|
||||
|
||||
|
||||
style->panelzoom = 1.0; /* unused */
|
||||
|
||||
style->paneltitle.uifont_id = uifont_id;
|
||||
@@ -129,14 +129,14 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id
|
||||
style->buttonspacey = 2;
|
||||
style->panelspace = 8;
|
||||
style->panelouter = 4;
|
||||
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
static uiFont *uifont_to_blfont(int id)
|
||||
{
|
||||
uiFont *font = U.uifonts.first;
|
||||
|
||||
|
||||
for (; font; font = font->next) {
|
||||
if (font->uifont_id == id) {
|
||||
return font;
|
||||
@@ -154,7 +154,7 @@ void UI_fontstyle_draw_ex(
|
||||
{
|
||||
int xofs = 0, yofs;
|
||||
int font_flag = BLF_CLIPPING;
|
||||
|
||||
|
||||
UI_fontstyle_set(fs);
|
||||
|
||||
/* set the flag */
|
||||
@@ -192,7 +192,7 @@ void UI_fontstyle_draw_ex(
|
||||
else if (fs->align == UI_STYLE_TEXT_RIGHT) {
|
||||
xofs = BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str, len) - 0.1f * U.widget_unit;
|
||||
}
|
||||
|
||||
|
||||
/* clip is very strict, so we give it some space */
|
||||
BLF_clipping(fs->uifont_id, rect->xmin - 2, rect->ymin - 4, rect->xmax + 1, rect->ymax + 4);
|
||||
BLF_position(fs->uifont_id, rect->xmin + xofs, rect->ymin + yofs, 0.0f);
|
||||
@@ -348,16 +348,16 @@ uiStyle *UI_style_get_dpi(void)
|
||||
{
|
||||
uiStyle *style = UI_style_get();
|
||||
static uiStyle _style;
|
||||
|
||||
|
||||
_style = *style;
|
||||
|
||||
|
||||
_style.paneltitle.shadx = (short)(UI_DPI_FAC * _style.paneltitle.shadx);
|
||||
_style.paneltitle.shady = (short)(UI_DPI_FAC * _style.paneltitle.shady);
|
||||
_style.grouplabel.shadx = (short)(UI_DPI_FAC * _style.grouplabel.shadx);
|
||||
_style.grouplabel.shady = (short)(UI_DPI_FAC * _style.grouplabel.shady);
|
||||
_style.widgetlabel.shadx = (short)(UI_DPI_FAC * _style.widgetlabel.shadx);
|
||||
_style.widgetlabel.shady = (short)(UI_DPI_FAC * _style.widgetlabel.shady);
|
||||
|
||||
|
||||
_style.columnspace = (short)(UI_DPI_FAC * _style.columnspace);
|
||||
_style.templatespace = (short)(UI_DPI_FAC * _style.templatespace);
|
||||
_style.boxspace = (short)(UI_DPI_FAC * _style.boxspace);
|
||||
@@ -365,23 +365,23 @@ uiStyle *UI_style_get_dpi(void)
|
||||
_style.buttonspacey = (short)(UI_DPI_FAC * _style.buttonspacey);
|
||||
_style.panelspace = (short)(UI_DPI_FAC * _style.panelspace);
|
||||
_style.panelouter = (short)(UI_DPI_FAC * _style.panelouter);
|
||||
|
||||
|
||||
return &_style;
|
||||
}
|
||||
|
||||
int UI_fontstyle_string_width(const uiFontStyle *fs, const char *str)
|
||||
{
|
||||
int width;
|
||||
|
||||
|
||||
if (fs->kerning == 1) /* for BLF_width */
|
||||
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
|
||||
|
||||
|
||||
UI_fontstyle_set(fs);
|
||||
width = BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
|
||||
|
||||
|
||||
if (fs->kerning == 1)
|
||||
BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
|
||||
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
@@ -402,12 +402,12 @@ void uiStyleInit(void)
|
||||
uiStyle *style = U.uistyles.first;
|
||||
int monofont_size = datatoc_bmonofont_ttf_size;
|
||||
unsigned char *monofont_ttf = (unsigned char *)datatoc_bmonofont_ttf;
|
||||
|
||||
|
||||
/* recover from uninitialized dpi */
|
||||
if (U.dpi == 0)
|
||||
U.dpi = 72;
|
||||
CLAMP(U.dpi, 48, 144);
|
||||
|
||||
|
||||
for (font = U.uifonts.first; font; font = font->next) {
|
||||
BLF_unload_id(font->blf_id);
|
||||
}
|
||||
@@ -438,9 +438,9 @@ void uiStyleInit(void)
|
||||
BLI_strncpy(font->filename, "default", sizeof(font->filename));
|
||||
font->uifont_id = UIFONT_DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
for (font = U.uifonts.first; font; font = font->next) {
|
||||
|
||||
|
||||
if (font->uifont_id == UIFONT_DEFAULT) {
|
||||
#ifdef WITH_INTERNATIONAL
|
||||
int font_size = datatoc_bfont_ttf_size;
|
||||
@@ -492,11 +492,11 @@ void uiStyleInit(void)
|
||||
BLF_size(font->blf_id, 14 * U.pixelsize, U.dpi);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (style == NULL) {
|
||||
ui_style_new(&U.uistyles, "Default Style", UIFONT_DEFAULT);
|
||||
}
|
||||
|
||||
|
||||
#ifdef WITH_INTERNATIONAL
|
||||
/* use unicode font for text editor and interactive console */
|
||||
if (U.transopts & USER_DOTRANSLATE) {
|
||||
@@ -520,7 +520,7 @@ void uiStyleInit(void)
|
||||
}
|
||||
|
||||
BLF_size(blf_mono_font, 12 * U.pixelsize, 72);
|
||||
|
||||
|
||||
/**
|
||||
* Second for rendering else we get threading problems,
|
||||
*
|
||||
@@ -536,7 +536,7 @@ void uiStyleInit(void)
|
||||
void UI_fontstyle_set(const uiFontStyle *fs)
|
||||
{
|
||||
uiFont *font = uifont_to_blfont(fs->uifont_id);
|
||||
|
||||
|
||||
BLF_size(font->blf_id, fs->points * U.pixelsize, U.dpi);
|
||||
}
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
|
||||
search[0] = 0;
|
||||
/* arg_litem is malloced, can be freed by parent button */
|
||||
template_ui = *((TemplateID *)arg_litem);
|
||||
|
||||
|
||||
/* get active id for showing first item */
|
||||
idptr = RNA_property_pointer_get(&template_ui.ptr, template_ui.prop);
|
||||
|
||||
@@ -267,15 +267,15 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
|
||||
|
||||
block = UI_block_begin(C, ar, "_popup", UI_EMBOSS);
|
||||
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_SEARCH_MENU);
|
||||
|
||||
|
||||
/* preview thumbnails */
|
||||
if (template_ui.prv_rows > 0 && template_ui.prv_cols > 0) {
|
||||
int w = 4 * U.widget_unit * template_ui.prv_cols;
|
||||
int h = 5 * U.widget_unit * template_ui.prv_rows;
|
||||
|
||||
|
||||
/* fake button, it holds space for search items */
|
||||
uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 26, w, h, NULL, 0, 0, 0, 0, NULL);
|
||||
|
||||
|
||||
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, w, UI_UNIT_Y,
|
||||
template_ui.prv_rows, template_ui.prv_cols, "");
|
||||
UI_but_func_search_set(
|
||||
@@ -286,7 +286,7 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
|
||||
else {
|
||||
const int searchbox_width = UI_searchbox_size_x();
|
||||
const int searchbox_height = UI_searchbox_size_y();
|
||||
|
||||
|
||||
/* fake button, it holds space for search items */
|
||||
uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 15, searchbox_width, searchbox_height, NULL, 0, 0, 0, 0, NULL);
|
||||
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, searchbox_width, UI_UNIT_Y - 1, 0, 0, "");
|
||||
@@ -294,16 +294,16 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
|
||||
but, ui_searchbox_create_generic, id_search_cb_p,
|
||||
&template_ui, id_search_call_cb, idptr.data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
UI_block_bounds_set_normal(block, 0.3f * U.widget_unit);
|
||||
UI_block_direction_set(block, UI_DIR_DOWN);
|
||||
|
||||
|
||||
/* give search-field focus */
|
||||
UI_but_focus_on_enter_event(win, but);
|
||||
/* this type of search menu requires undo */
|
||||
but->flag |= UI_BUT_UNDO;
|
||||
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
|
||||
PointerRNA idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop);
|
||||
ID *id = idptr.data;
|
||||
int event = GET_INT_FROM_POINTER(arg_event);
|
||||
|
||||
|
||||
switch (event) {
|
||||
case UI_ID_BROWSE:
|
||||
case UI_ID_PIN:
|
||||
@@ -504,7 +504,7 @@ static void template_ID(
|
||||
|
||||
if ((idfrom && idfrom->lib) || !editable)
|
||||
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
||||
|
||||
|
||||
uiLayoutRow(layout, true);
|
||||
}
|
||||
else if (flag & UI_ID_BROWSE) {
|
||||
@@ -569,17 +569,17 @@ static void template_ID(
|
||||
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (user_alert) UI_but_flag_enable(but, UI_BUT_REDALERT);
|
||||
|
||||
|
||||
if (id->lib == NULL && !(ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB))) {
|
||||
uiDefButR(block, UI_BTYPE_TOGGLE, 0, "F", 0, 0, UI_UNIT_X, UI_UNIT_Y, &idptr, "use_fake_user", -1, 0, 0, -1, -1, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (flag & UI_ID_ADD_NEW) {
|
||||
int w = id ? UI_UNIT_X : (flag & UI_ID_OPEN) ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
|
||||
|
||||
|
||||
/* i18n markup, does nothing! */
|
||||
BLT_I18N_MSGID_MULTI_CTXT("New", BLT_I18NCONTEXT_DEFAULT,
|
||||
BLT_I18NCONTEXT_ID_SCENE,
|
||||
@@ -607,7 +607,7 @@ static void template_ID(
|
||||
BLT_I18NCONTEXT_ID_GPENCIL,
|
||||
BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE,
|
||||
);
|
||||
|
||||
|
||||
if (newop) {
|
||||
but = uiDefIconTextButO(block, UI_BTYPE_BUT, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN,
|
||||
(id) ? "" : CTX_IFACE_(template_id_context(type), "New"), 0, 0, w, UI_UNIT_Y, NULL);
|
||||
@@ -629,14 +629,14 @@ static void template_ID(
|
||||
but = uiDefIconButO(block, UI_BTYPE_BUT, "FILE_OT_unpack_item", WM_OP_INVOKE_REGION_WIN, ICON_PACKAGE, 0, 0,
|
||||
UI_UNIT_X, UI_UNIT_Y, TIP_("Packed File, click to unpack"));
|
||||
UI_but_operator_ptr_get(but);
|
||||
|
||||
|
||||
RNA_string_set(but->opptr, "id_name", id->name + 2);
|
||||
RNA_int_set(but->opptr, "id_type", GS(id->name));
|
||||
|
||||
|
||||
}
|
||||
else if (flag & UI_ID_OPEN) {
|
||||
int w = id ? UI_UNIT_X : (flag & UI_ID_ADD_NEW) ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
|
||||
|
||||
|
||||
if (openop) {
|
||||
but = uiDefIconTextButO(block, UI_BTYPE_BUT, openop, WM_OP_INVOKE_DEFAULT, ICON_FILESEL, (id) ? "" : IFACE_("Open"),
|
||||
0, 0, w, UI_UNIT_Y, NULL);
|
||||
@@ -651,7 +651,7 @@ static void template_ID(
|
||||
if ((idfrom && idfrom->lib) || !editable)
|
||||
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
||||
}
|
||||
|
||||
|
||||
/* delete button */
|
||||
/* don't use RNA_property_is_unlink here */
|
||||
if (id && (flag & UI_ID_DELETE)) {
|
||||
@@ -776,7 +776,7 @@ void uiTemplateAnyID(
|
||||
{
|
||||
PropertyRNA *propID, *propType;
|
||||
uiLayout *split, *row, *sub;
|
||||
|
||||
|
||||
/* get properties... */
|
||||
propID = RNA_struct_find_property(ptr, propname);
|
||||
propType = RNA_struct_find_property(ptr, proptypename);
|
||||
@@ -789,13 +789,13 @@ void uiTemplateAnyID(
|
||||
RNA_warning("pointer-type property not found: %s.%s", RNA_struct_identifier(ptr->type), proptypename);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Start drawing UI Elements using standard defines */
|
||||
split = uiLayoutSplit(layout, 0.33f, false); /* NOTE: split amount here needs to be synced with normal labels */
|
||||
|
||||
|
||||
/* FIRST PART ................................................ */
|
||||
row = uiLayoutRow(split, false);
|
||||
|
||||
|
||||
/* Label - either use the provided text, or will become "ID-Block:" */
|
||||
if (text) {
|
||||
if (text[0])
|
||||
@@ -804,20 +804,20 @@ void uiTemplateAnyID(
|
||||
else {
|
||||
uiItemL(row, IFACE_("ID-Block:"), ICON_NONE);
|
||||
}
|
||||
|
||||
|
||||
/* SECOND PART ................................................ */
|
||||
row = uiLayoutRow(split, true);
|
||||
|
||||
|
||||
/* ID-Type Selector - just have a menu of icons */
|
||||
sub = uiLayoutRow(row, true); /* HACK: special group just for the enum, otherwise we */
|
||||
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); /* we get ugly layout with text included too... */
|
||||
|
||||
|
||||
uiItemFullR(sub, ptr, propType, 0, 0, UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
|
||||
|
||||
|
||||
/* ID-Block Selector - just use pointer widget... */
|
||||
sub = uiLayoutRow(row, true); /* HACK: special group to counteract the effects of the previous */
|
||||
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_EXPAND); /* enum, which now pushes everything too far right */
|
||||
|
||||
|
||||
uiItemFullR(sub, ptr, propID, 0, 0, 0, "", ICON_NONE);
|
||||
}
|
||||
|
||||
@@ -837,20 +837,20 @@ void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propna
|
||||
{
|
||||
PropertyRNA *propPath;
|
||||
uiLayout *row;
|
||||
|
||||
|
||||
/* check that properties are valid */
|
||||
propPath = RNA_struct_find_property(ptr, propname);
|
||||
if (!propPath || RNA_property_type(propPath) != PROP_STRING) {
|
||||
RNA_warning("path property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Start drawing UI Elements using standard defines */
|
||||
row = uiLayoutRow(layout, true);
|
||||
|
||||
|
||||
/* Path (existing string) Widget */
|
||||
uiItemR(row, ptr, propname, 0, text, ICON_RNA);
|
||||
|
||||
|
||||
/* TODO: attach something to this to make allow searching of nested properties to 'build' the path */
|
||||
}
|
||||
|
||||
@@ -868,7 +868,7 @@ static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v)
|
||||
nmd->mode &= ~eModifierMode_Virtual;
|
||||
|
||||
BLI_addhead(&ob->modifiers, nmd);
|
||||
|
||||
|
||||
modifier_unique_name(&ob->modifiers, nmd);
|
||||
|
||||
ob->partype = PAROBJECT;
|
||||
@@ -928,7 +928,7 @@ static uiLayout *draw_modifier(
|
||||
|
||||
/* rounded header ------------------------------------------------------------------- */
|
||||
box = uiLayoutBox(column);
|
||||
|
||||
|
||||
if (isVirtual) {
|
||||
row = uiLayoutRow(box, false);
|
||||
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND);
|
||||
@@ -937,7 +937,7 @@ static uiLayout *draw_modifier(
|
||||
/* XXX this is not used now, since these cannot be accessed via RNA */
|
||||
BLI_snprintf(str, sizeof(str), IFACE_("%s parent deform"), md->name);
|
||||
uiDefBut(block, UI_BTYPE_LABEL, 0, str, 0, 0, 185, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Modifier name"));
|
||||
|
||||
|
||||
but = uiDefBut(block, UI_BTYPE_BUT, 0, IFACE_("Make Real"), 0, 0, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0,
|
||||
TIP_("Convert virtual modifier to a real modifier"));
|
||||
UI_but_func_set(but, modifiers_convertToReal, ob, md);
|
||||
@@ -946,15 +946,15 @@ static uiLayout *draw_modifier(
|
||||
/* REAL MODIFIER */
|
||||
row = uiLayoutRow(box, false);
|
||||
block = uiLayoutGetBlock(row);
|
||||
|
||||
|
||||
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
||||
/* Open/Close ................................. */
|
||||
uiItemR(row, &ptr, "show_expanded", 0, "", ICON_NONE);
|
||||
|
||||
|
||||
/* modifier-type icon */
|
||||
uiItemL(row, "", RNA_struct_ui_icon(ptr.type));
|
||||
UI_block_emboss_set(block, UI_EMBOSS);
|
||||
|
||||
|
||||
/* modifier name */
|
||||
md->scene = scene;
|
||||
if (mti->isDisabled && mti->isDisabled(md, 0)) {
|
||||
@@ -962,7 +962,7 @@ static uiLayout *draw_modifier(
|
||||
}
|
||||
uiItemR(row, &ptr, "name", 0, "", ICON_NONE);
|
||||
uiLayoutSetRedAlert(row, false);
|
||||
|
||||
|
||||
/* mode enabling buttons */
|
||||
UI_block_align_begin(block);
|
||||
/* Collision and Surface are always enabled, hide buttons! */
|
||||
@@ -971,7 +971,7 @@ static uiLayout *draw_modifier(
|
||||
{
|
||||
uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE);
|
||||
uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE);
|
||||
|
||||
|
||||
if (mti->flags & eModifierTypeFlag_SupportsEditmode) {
|
||||
sub = uiLayoutRow(row, true);
|
||||
if (!(md->mode & eModifierMode_Realtime)) {
|
||||
@@ -1007,13 +1007,13 @@ static uiLayout *draw_modifier(
|
||||
}
|
||||
|
||||
UI_block_align_end(block);
|
||||
|
||||
|
||||
/* Up/Down + Delete ........................... */
|
||||
UI_block_align_begin(block);
|
||||
uiItemO(row, "", ICON_TRIA_UP, "OBJECT_OT_modifier_move_up");
|
||||
uiItemO(row, "", ICON_TRIA_DOWN, "OBJECT_OT_modifier_move_down");
|
||||
UI_block_align_end(block);
|
||||
|
||||
|
||||
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
||||
/* When Modifier is a simulation, show button to switch to context rather than the delete button. */
|
||||
if (modifier_can_delete(md) &&
|
||||
@@ -1031,20 +1031,20 @@ static uiLayout *draw_modifier(
|
||||
UI_block_emboss_set(block, UI_EMBOSS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* modifier settings (under the header) --------------------------------------------------- */
|
||||
if (!isVirtual && (md->mode & eModifierMode_Expanded)) {
|
||||
/* apply/convert/copy */
|
||||
box = uiLayoutBox(column);
|
||||
row = uiLayoutRow(box, false);
|
||||
|
||||
|
||||
if (!ELEM(md->type, eModifierType_Collision, eModifierType_Surface)) {
|
||||
/* only here obdata, the rest of modifiers is ob level */
|
||||
UI_block_lock_set(block, BKE_object_obdata_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
|
||||
|
||||
|
||||
if (md->type == eModifierType_ParticleSystem) {
|
||||
ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
|
||||
|
||||
|
||||
if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) {
|
||||
if (ELEM(psys->part->ren_as, PART_DRAW_GR, PART_DRAW_OB))
|
||||
uiItemO(row, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Convert"), ICON_NONE,
|
||||
@@ -1058,17 +1058,17 @@ static uiLayout *draw_modifier(
|
||||
uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT);
|
||||
uiItemEnumO(row, "OBJECT_OT_modifier_apply", CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply"),
|
||||
0, "apply_as", MODIFIER_APPLY_DATA);
|
||||
|
||||
|
||||
if (modifier_isSameTopology(md) && !modifier_isNonGeometrical(md)) {
|
||||
uiItemEnumO(row, "OBJECT_OT_modifier_apply",
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply as Shape Key"),
|
||||
0, "apply_as", MODIFIER_APPLY_SHAPE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UI_block_lock_clear(block);
|
||||
UI_block_lock_set(block, ob && ID_IS_LINKED(ob), ERROR_LIBDATA_MESSAGE);
|
||||
|
||||
|
||||
if (!ELEM(md->type, eModifierType_Fluidsim, eModifierType_Softbody, eModifierType_ParticleSystem,
|
||||
eModifierType_Cloth, eModifierType_Smoke))
|
||||
{
|
||||
@@ -1076,19 +1076,19 @@ static uiLayout *draw_modifier(
|
||||
"OBJECT_OT_modifier_copy");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* result is the layout block inside the box, that we return so that modifier settings can be drawn */
|
||||
result = uiLayoutColumn(box, false);
|
||||
block = uiLayoutAbsoluteBlock(box);
|
||||
}
|
||||
|
||||
|
||||
/* error messages */
|
||||
if (md->error) {
|
||||
box = uiLayoutBox(column);
|
||||
row = uiLayoutRow(box, false);
|
||||
uiItemL(row, md->error, ICON_ERROR);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1113,9 +1113,9 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
||||
RNA_warning("Expected modifier on object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ID_IS_LINKED(ob)), ERROR_LIBDATA_MESSAGE);
|
||||
|
||||
|
||||
/* find modifier and draw it */
|
||||
cageIndex = modifiers_getCageIndex(scene, ob, &lastCageIndex, 0);
|
||||
|
||||
@@ -1168,7 +1168,7 @@ static void do_constraint_panels(bContext *C, void *ob_pt, int event)
|
||||
*
|
||||
* object_test_constraints(ob);
|
||||
* if (ob->pose) BKE_pose_update_constraint_flags(ob->pose); */
|
||||
|
||||
|
||||
if (ob->type == OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
|
||||
else DAG_id_tag_update(&ob->id, OB_RECALC_OB);
|
||||
|
||||
@@ -1200,7 +1200,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
|
||||
}
|
||||
else
|
||||
BLI_strncpy(typestr, IFACE_(cti->name), sizeof(typestr));
|
||||
|
||||
|
||||
/* determine whether constraint is proxy protected or not */
|
||||
if (BKE_constraints_proxylocked_owner(ob, pchan))
|
||||
proxy_protected = (con->flag & CONSTRAINT_PROXY_LOCAL) == 0;
|
||||
@@ -1234,34 +1234,34 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
|
||||
|
||||
if (con->flag & CONSTRAINT_DISABLE)
|
||||
uiLayoutSetRedAlert(row, true);
|
||||
|
||||
|
||||
if (proxy_protected == 0) {
|
||||
uiItemR(row, &ptr, "name", 0, "", ICON_NONE);
|
||||
}
|
||||
else
|
||||
uiItemL(row, con->name, ICON_NONE);
|
||||
|
||||
|
||||
uiLayoutSetRedAlert(row, false);
|
||||
|
||||
|
||||
/* proxy-protected constraints cannot be edited, so hide up/down + close buttons */
|
||||
if (proxy_protected) {
|
||||
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
||||
|
||||
|
||||
/* draw a ghost icon (for proxy) and also a lock beside it, to show that constraint is "proxy locked" */
|
||||
uiDefIconBut(block, UI_BTYPE_BUT, B_CONSTRAINT_TEST, ICON_GHOST, xco + 12.2f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
|
||||
NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected"));
|
||||
uiDefIconBut(block, UI_BTYPE_BUT, B_CONSTRAINT_TEST, ICON_LOCKED, xco + 13.1f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
|
||||
NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected"));
|
||||
|
||||
|
||||
UI_block_emboss_set(block, UI_EMBOSS);
|
||||
}
|
||||
else {
|
||||
short prev_proxylock, show_upbut, show_downbut;
|
||||
|
||||
/* Up/Down buttons:
|
||||
|
||||
/* Up/Down buttons:
|
||||
* Proxy-constraints are not allowed to occur after local (non-proxy) constraints
|
||||
* as that poses problems when restoring them, so disable the "up" button where
|
||||
* it may cause this situation.
|
||||
* it may cause this situation.
|
||||
*
|
||||
* Up/Down buttons should only be shown (or not grayed - todo) if they serve some purpose.
|
||||
*/
|
||||
@@ -1274,29 +1274,29 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
|
||||
}
|
||||
else
|
||||
prev_proxylock = 0;
|
||||
|
||||
|
||||
show_upbut = ((prev_proxylock == 0) && (con->prev));
|
||||
show_downbut = (con->next) ? 1 : 0;
|
||||
|
||||
|
||||
/* enabled */
|
||||
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
||||
uiItemR(row, &ptr, "mute", 0, "",
|
||||
(con->flag & CONSTRAINT_OFF) ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF);
|
||||
UI_block_emboss_set(block, UI_EMBOSS);
|
||||
|
||||
|
||||
uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT);
|
||||
|
||||
|
||||
/* up/down */
|
||||
if (show_upbut || show_downbut) {
|
||||
UI_block_align_begin(block);
|
||||
if (show_upbut)
|
||||
uiItemO(row, "", ICON_TRIA_UP, "CONSTRAINT_OT_move_up");
|
||||
|
||||
|
||||
if (show_downbut)
|
||||
uiItemO(row, "", ICON_TRIA_DOWN, "CONSTRAINT_OT_move_down");
|
||||
UI_block_align_end(block);
|
||||
}
|
||||
|
||||
|
||||
/* Close 'button' - emboss calls here disable drawing of 'button' behind X */
|
||||
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
||||
uiItemO(row, "", ICON_X, "CONSTRAINT_OT_delete");
|
||||
@@ -1341,7 +1341,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
|
||||
RNA_warning("Expected constraint on object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ID_IS_LINKED(ob)), ERROR_LIBDATA_MESSAGE);
|
||||
|
||||
/* hrms, the temporal constraint should not draw! */
|
||||
@@ -1460,7 +1460,7 @@ void uiTemplatePreview(
|
||||
if (GS(pid->name) == ID_MA || (pparent && GS(pparent->name) == ID_MA)) {
|
||||
if (GS(pid->name) == ID_MA) ma = (Material *)pid;
|
||||
else ma = (Material *)pparent;
|
||||
|
||||
|
||||
/* Create RNA Pointer */
|
||||
RNA_pointer_create(&ma->id, &RNA_Material, ma, &material_ptr);
|
||||
|
||||
@@ -1472,7 +1472,7 @@ void uiTemplatePreview(
|
||||
if (pr_texture) {
|
||||
/* Create RNA Pointer */
|
||||
RNA_pointer_create(id, &RNA_Texture, tex, &texture_ptr);
|
||||
|
||||
|
||||
uiLayoutRow(layout, true);
|
||||
uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("Texture"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
|
||||
pr_texture, 10, TEX_PR_TEXTURE, 0, 0, "");
|
||||
@@ -1494,7 +1494,7 @@ void uiTemplatePreview(
|
||||
}
|
||||
uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("Both"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
|
||||
pr_texture, 10, TEX_PR_BOTH, 0, 0, "");
|
||||
|
||||
|
||||
/* Alpha button for texture preview */
|
||||
if (*pr_texture != TEX_PR_OTHER) {
|
||||
row = uiLayoutRow(layout, false);
|
||||
@@ -1776,7 +1776,7 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *ar, void *arg_litem)
|
||||
if (free) {
|
||||
MEM_freeN((void *)item);
|
||||
}
|
||||
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
@@ -1954,26 +1954,26 @@ static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(u
|
||||
if (BLI_rctf_size_x(&cumap->curr) < 20.0f * BLI_rctf_size_x(&cumap->clipr)) {
|
||||
d = d1 = 0.15f * BLI_rctf_size_x(&cumap->curr);
|
||||
|
||||
if (cumap->flag & CUMA_DO_CLIP)
|
||||
if (cumap->flag & CUMA_DO_CLIP)
|
||||
if (cumap->curr.xmin - d < cumap->clipr.xmin)
|
||||
d1 = cumap->curr.xmin - cumap->clipr.xmin;
|
||||
cumap->curr.xmin -= d1;
|
||||
|
||||
d1 = d;
|
||||
if (cumap->flag & CUMA_DO_CLIP)
|
||||
if (cumap->flag & CUMA_DO_CLIP)
|
||||
if (cumap->curr.xmax + d > cumap->clipr.xmax)
|
||||
d1 = -cumap->curr.xmax + cumap->clipr.xmax;
|
||||
cumap->curr.xmax += d1;
|
||||
|
||||
d = d1 = 0.15f * BLI_rctf_size_y(&cumap->curr);
|
||||
|
||||
if (cumap->flag & CUMA_DO_CLIP)
|
||||
if (cumap->flag & CUMA_DO_CLIP)
|
||||
if (cumap->curr.ymin - d < cumap->clipr.ymin)
|
||||
d1 = cumap->curr.ymin - cumap->clipr.ymin;
|
||||
cumap->curr.ymin -= d1;
|
||||
|
||||
d1 = d;
|
||||
if (cumap->flag & CUMA_DO_CLIP)
|
||||
if (cumap->flag & CUMA_DO_CLIP)
|
||||
if (cumap->curr.ymax + d > cumap->clipr.ymax)
|
||||
d1 = -cumap->curr.ymax + cumap->clipr.ymax;
|
||||
cumap->curr.ymax += d1;
|
||||
@@ -1987,7 +1987,7 @@ static void curvemap_buttons_setclip(bContext *UNUSED(C), void *cumap_v, void *U
|
||||
CurveMapping *cumap = cumap_v;
|
||||
|
||||
curvemapping_changed(cumap, false);
|
||||
}
|
||||
}
|
||||
|
||||
static void curvemap_buttons_delete(bContext *C, void *cb_v, void *cumap_v)
|
||||
{
|
||||
@@ -2160,15 +2160,15 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v)
|
||||
{
|
||||
CurveMapping *cumap = cumap_v;
|
||||
int a;
|
||||
|
||||
|
||||
cumap->preset = CURVE_PRESET_LINE;
|
||||
for (a = 0; a < CM_TOT; a++)
|
||||
curvemap_reset(cumap->cm + a, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE);
|
||||
|
||||
|
||||
cumap->black[0] = cumap->black[1] = cumap->black[2] = 0.0f;
|
||||
cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f;
|
||||
curvemapping_set_black_white(cumap, NULL, NULL);
|
||||
|
||||
|
||||
curvemapping_changed(cumap, false);
|
||||
|
||||
rna_update_cb(C, cb_v, NULL);
|
||||
@@ -2238,7 +2238,7 @@ static void curvemap_buttons_layout(
|
||||
/* HSV */
|
||||
sub = uiLayoutRow(row, true);
|
||||
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT);
|
||||
|
||||
|
||||
if (cumap->cm[0].curve) {
|
||||
bt = uiDefButI(block, UI_BTYPE_ROW, 0, "H", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
|
||||
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
|
||||
@@ -2254,7 +2254,7 @@ static void curvemap_buttons_layout(
|
||||
}
|
||||
else
|
||||
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT);
|
||||
|
||||
|
||||
if (labeltype == 'h')
|
||||
bg = UI_GRAD_H;
|
||||
|
||||
@@ -2444,7 +2444,7 @@ void uiTemplateColorPicker(
|
||||
if (cubic)
|
||||
but->flag |= UI_BUT_COLOR_CUBIC;
|
||||
|
||||
|
||||
|
||||
if (value_slider) {
|
||||
switch (U.color_picker_type) {
|
||||
case USER_CP_CIRCLE_HSL:
|
||||
@@ -2543,7 +2543,7 @@ static void handle_layer_buttons(bContext *C, void *arg1, void *arg2)
|
||||
|
||||
if (!shift) {
|
||||
tot = RNA_property_array_length(&but->rnapoin, but->rnaprop);
|
||||
|
||||
|
||||
/* Normally clicking only selects one layer */
|
||||
RNA_property_boolean_set_index(&but->rnapoin, but->rnaprop, cur, true);
|
||||
for (i = 0; i < tot; ++i) {
|
||||
@@ -2575,8 +2575,8 @@ void uiTemplateLayers(
|
||||
RNA_warning("layers property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
|
||||
/* the number of layers determines the way we group them
|
||||
|
||||
/* the number of layers determines the way we group them
|
||||
* - we want 2 rows only (for now)
|
||||
* - the number of columns (cols) is the total number of buttons per row
|
||||
* the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be
|
||||
@@ -2596,12 +2596,12 @@ void uiTemplateLayers(
|
||||
if (RNA_property_array_length(used_ptr, used_prop) < layers)
|
||||
used_prop = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* layers are laid out going across rows, with the columns being divided into groups */
|
||||
|
||||
|
||||
for (group = 0; group < groups; group++) {
|
||||
uCol = uiLayoutColumn(layout, true);
|
||||
|
||||
|
||||
for (row = 0; row < 2; row++) {
|
||||
uiBlock *block;
|
||||
uiBut *but;
|
||||
@@ -2609,7 +2609,7 @@ void uiTemplateLayers(
|
||||
uRow = uiLayoutRow(uCol, true);
|
||||
block = uiLayoutGetBlock(uRow);
|
||||
layer = groups * cols_per_group * row + cols_per_group * group;
|
||||
|
||||
|
||||
/* add layers as toggle buts */
|
||||
for (col = 0; (col < cols_per_group) && (layer < layers); col++, layer++) {
|
||||
int icon = 0;
|
||||
@@ -2619,7 +2619,7 @@ void uiTemplateLayers(
|
||||
icon = ICON_LAYER_ACTIVE;
|
||||
else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, layer))
|
||||
icon = ICON_LAYER_USED;
|
||||
|
||||
|
||||
but = uiDefAutoButR(block, ptr, prop, layer, "", icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2);
|
||||
UI_but_func_set(but, handle_layer_buttons, but, SET_INT_IN_POINTER(layer));
|
||||
but->type = UI_BTYPE_TOGGLE;
|
||||
@@ -2644,8 +2644,8 @@ void uiTemplateGameStates(
|
||||
RNA_warning("states property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
|
||||
/* the number of states determines the way we group them
|
||||
|
||||
/* the number of states determines the way we group them
|
||||
* - we want 2 rows only (for now)
|
||||
* - the number of columns (cols) is the total number of buttons per row
|
||||
* the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be
|
||||
@@ -2665,12 +2665,12 @@ void uiTemplateGameStates(
|
||||
if (RNA_property_array_length(used_ptr, used_prop) < states)
|
||||
used_prop = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* layers are laid out going across rows, with the columns being divided into groups */
|
||||
|
||||
|
||||
for (group = 0; group < groups; group++) {
|
||||
uCol = uiLayoutColumn(layout, true);
|
||||
|
||||
|
||||
for (row = 0; row < 2; row++) {
|
||||
uiBlock *block;
|
||||
uiBut *but;
|
||||
@@ -2678,7 +2678,7 @@ void uiTemplateGameStates(
|
||||
uRow = uiLayoutRow(uCol, true);
|
||||
block = uiLayoutGetBlock(uRow);
|
||||
state = groups * cols_per_group * row + cols_per_group * group;
|
||||
|
||||
|
||||
/* add layers as toggle buts */
|
||||
for (col = 0; (col < cols_per_group) && (state < states); col++, state++) {
|
||||
int icon = 0;
|
||||
@@ -2688,7 +2688,7 @@ void uiTemplateGameStates(
|
||||
icon = ICON_LAYER_ACTIVE;
|
||||
else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, state))
|
||||
icon = ICON_LAYER_USED;
|
||||
|
||||
|
||||
but = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2, ptr, prop,
|
||||
state, 0, 0, -1, -1, sca_state_name_get(ob, state));
|
||||
UI_but_func_set(but, handle_layer_buttons, but, SET_INT_IN_POINTER(state));
|
||||
@@ -3387,7 +3387,7 @@ void uiTemplateList(
|
||||
static void operator_call_cb(bContext *C, void *UNUSED(arg1), void *arg2)
|
||||
{
|
||||
wmOperatorType *ot = arg2;
|
||||
|
||||
|
||||
if (ot)
|
||||
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, NULL);
|
||||
}
|
||||
@@ -3436,10 +3436,10 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char
|
||||
if (WM_operator_poll((bContext *)C, ot)) {
|
||||
char name[256];
|
||||
int len = strlen(ot_ui_name);
|
||||
|
||||
|
||||
/* display name for menu, can hold hotkey */
|
||||
BLI_strncpy(name, ot_ui_name, sizeof(name));
|
||||
|
||||
|
||||
/* check for hotkey */
|
||||
if (len < sizeof(name) - 6) {
|
||||
if (WM_key_event_operator_string(
|
||||
@@ -3449,7 +3449,7 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char
|
||||
name[len] = UI_SEP_CHAR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (false == UI_search_item_add(items, name, ot, 0))
|
||||
break;
|
||||
}
|
||||
@@ -3469,7 +3469,7 @@ void uiTemplateOperatorSearch(uiLayout *layout)
|
||||
uiBlock *block;
|
||||
uiBut *but;
|
||||
static char search[256] = "";
|
||||
|
||||
|
||||
block = uiLayoutGetBlock(layout);
|
||||
UI_block_layout_set_current(block, layout);
|
||||
|
||||
@@ -3679,7 +3679,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
|
||||
uiBlock *block;
|
||||
void *owner = NULL;
|
||||
int handle_event, icon = 0;
|
||||
|
||||
|
||||
block = uiLayoutGetBlock(layout);
|
||||
UI_block_layout_set_current(block, layout);
|
||||
|
||||
@@ -3763,7 +3763,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
|
||||
if (owner) {
|
||||
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
|
||||
bool active = !(G.is_break || WM_jobs_is_stopped(wm, owner));
|
||||
|
||||
|
||||
uiLayout *row = uiLayoutRow(layout, false);
|
||||
block = uiLayoutGetBlock(row);
|
||||
|
||||
@@ -3815,29 +3815,29 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
|
||||
ReportList *reports = CTX_wm_reports(C);
|
||||
Report *report = BKE_reports_last_displayable(reports);
|
||||
ReportTimerInfo *rti;
|
||||
|
||||
|
||||
uiLayout *ui_abs;
|
||||
uiBlock *block;
|
||||
uiBut *but;
|
||||
uiStyle *style = UI_style_get();
|
||||
int width;
|
||||
int icon;
|
||||
|
||||
|
||||
/* if the report display has timed out, don't show */
|
||||
if (!reports->reporttimer) return;
|
||||
|
||||
|
||||
rti = (ReportTimerInfo *)reports->reporttimer->customdata;
|
||||
|
||||
|
||||
if (!rti || rti->widthfac == 0.0f || !report) return;
|
||||
|
||||
|
||||
ui_abs = uiLayoutAbsolute(layout, false);
|
||||
block = uiLayoutGetBlock(ui_abs);
|
||||
|
||||
|
||||
UI_fontstyle_set(&style->widgetlabel);
|
||||
width = BLF_width(style->widgetlabel.uifont_id, report->message, report->len);
|
||||
width = min_ii((int)(rti->widthfac * width), width);
|
||||
width = max_ii(width, 10);
|
||||
|
||||
|
||||
/* make a box around the report to make it stand out */
|
||||
UI_block_align_begin(block);
|
||||
but = uiDefBut(block, UI_BTYPE_ROUNDBOX, 0, "", 0, 0, UI_UNIT_X + 10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
|
||||
@@ -3851,12 +3851,12 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
|
||||
but->col[3] = 255;
|
||||
|
||||
UI_block_align_end(block);
|
||||
|
||||
|
||||
|
||||
|
||||
/* icon and report message on top */
|
||||
icon = UI_icon_from_report_type(report->type);
|
||||
|
||||
/* XXX: temporary operator to dump all reports to a text block, but only if more than 1 report
|
||||
|
||||
/* XXX: temporary operator to dump all reports to a text block, but only if more than 1 report
|
||||
* to be shown instead of icon when appropriate...
|
||||
*/
|
||||
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
||||
@@ -3868,7 +3868,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
|
||||
uiDefIconBut(block, UI_BTYPE_LABEL, 0, icon, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
|
||||
|
||||
UI_block_emboss_set(block, UI_EMBOSS);
|
||||
|
||||
|
||||
uiDefBut(block, UI_BTYPE_LABEL, 0, report->message, UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y,
|
||||
NULL, 0.0f, 0.0f, 0, 0, "");
|
||||
}
|
||||
@@ -3889,7 +3889,7 @@ static void template_keymap_item_properties(uiLayout *layout, const char *title,
|
||||
|
||||
if (title)
|
||||
uiItemL(layout, title, ICON_NONE);
|
||||
|
||||
|
||||
flow = uiLayoutColumnFlow(layout, 2, false);
|
||||
|
||||
RNA_STRUCT_BEGIN (ptr, prop)
|
||||
@@ -4018,17 +4018,17 @@ static uiBlock *component_menu(bContext *C, ARegion *ar, void *args_v)
|
||||
ComponentMenuArgs *args = (ComponentMenuArgs *)args_v;
|
||||
uiBlock *block;
|
||||
uiLayout *layout;
|
||||
|
||||
|
||||
block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
|
||||
UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN);
|
||||
|
||||
|
||||
layout = uiLayoutColumn(UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, 0, UI_style_get()), 0);
|
||||
|
||||
|
||||
uiItemR(layout, &args->ptr, args->propname, UI_ITEM_R_EXPAND, "", ICON_NONE);
|
||||
|
||||
|
||||
UI_block_bounds_set_normal(block, 6);
|
||||
UI_block_direction_set(block, UI_DIR_DOWN);
|
||||
|
||||
|
||||
return block;
|
||||
}
|
||||
void uiTemplateComponentMenu(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name)
|
||||
@@ -4036,10 +4036,10 @@ void uiTemplateComponentMenu(uiLayout *layout, PointerRNA *ptr, const char *prop
|
||||
ComponentMenuArgs *args = MEM_callocN(sizeof(ComponentMenuArgs), "component menu template args");
|
||||
uiBlock *block;
|
||||
uiBut *but;
|
||||
|
||||
|
||||
args->ptr = *ptr;
|
||||
BLI_strncpy(args->propname, propname, sizeof(args->propname));
|
||||
|
||||
|
||||
block = uiLayoutGetBlock(layout);
|
||||
UI_block_align_begin(block);
|
||||
|
||||
@@ -4048,7 +4048,7 @@ void uiTemplateComponentMenu(uiLayout *layout, PointerRNA *ptr, const char *prop
|
||||
but->rnapoin = *ptr;
|
||||
but->rnaprop = RNA_struct_find_property(ptr, propname);
|
||||
but->rnaindex = 0;
|
||||
|
||||
|
||||
UI_block_align_end(block);
|
||||
}
|
||||
|
||||
@@ -4058,17 +4058,17 @@ void uiTemplateNodeSocket(uiLayout *layout, bContext *UNUSED(C), float *color)
|
||||
{
|
||||
uiBlock *block;
|
||||
uiBut *but;
|
||||
|
||||
|
||||
block = uiLayoutGetBlock(layout);
|
||||
UI_block_align_begin(block);
|
||||
|
||||
|
||||
/* XXX using explicit socket colors is not quite ideal.
|
||||
* Eventually it should be possible to use theme colors for this purpose,
|
||||
* but this requires a better design for extendable color palettes in user prefs.
|
||||
*/
|
||||
but = uiDefBut(block, UI_BTYPE_NODE_SOCKET, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
|
||||
rgba_float_to_uchar(but->col, color);
|
||||
|
||||
|
||||
UI_block_align_end(block);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Contributor(s): Blender Foundation
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
@@ -71,7 +71,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
|
||||
|
||||
if (arraylen && index == -1)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (icon && name && name[0] == '\0')
|
||||
but = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
|
||||
else if (icon)
|
||||
@@ -225,7 +225,7 @@ int UI_icon_from_id(ID *id)
|
||||
|
||||
if (id == NULL)
|
||||
return ICON_NONE;
|
||||
|
||||
|
||||
idcode = GS(id->name);
|
||||
|
||||
/* exception for objects */
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Contributor(s): Blender Foundation
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
@@ -98,10 +98,10 @@ enum {
|
||||
|
||||
typedef struct uiWidgetTrias {
|
||||
unsigned int tot;
|
||||
|
||||
|
||||
float vec[16][2];
|
||||
const unsigned int (*index)[3];
|
||||
|
||||
|
||||
} uiWidgetTrias;
|
||||
|
||||
/* max as used by round_box__edges */
|
||||
@@ -109,36 +109,36 @@ typedef struct uiWidgetTrias {
|
||||
#define WIDGET_SIZE_MAX (WIDGET_CURVE_RESOLU * 4)
|
||||
|
||||
typedef struct uiWidgetBase {
|
||||
|
||||
|
||||
int totvert, halfwayvert;
|
||||
float outer_v[WIDGET_SIZE_MAX][2];
|
||||
float inner_v[WIDGET_SIZE_MAX][2];
|
||||
float inner_uv[WIDGET_SIZE_MAX][2];
|
||||
|
||||
|
||||
bool draw_inner, draw_outline, draw_emboss, draw_shadedir;
|
||||
|
||||
|
||||
uiWidgetTrias tria1;
|
||||
uiWidgetTrias tria2;
|
||||
|
||||
|
||||
} uiWidgetBase;
|
||||
|
||||
/** uiWidgetType: for time being only for visual appearance,
|
||||
* later, a handling callback can be added too
|
||||
* later, a handling callback can be added too
|
||||
*/
|
||||
typedef struct uiWidgetType {
|
||||
|
||||
|
||||
/* pointer to theme color definition */
|
||||
uiWidgetColors *wcol_theme;
|
||||
uiWidgetStateColors *wcol_state;
|
||||
|
||||
|
||||
/* converted colors for state */
|
||||
uiWidgetColors wcol;
|
||||
|
||||
|
||||
void (*state)(struct uiWidgetType *, int state);
|
||||
void (*draw)(uiWidgetColors *, rcti *, int state, int roundboxalign);
|
||||
void (*custom)(uiBut *, uiWidgetColors *, rcti *, int state, int roundboxalign);
|
||||
void (*text)(uiFontStyle *, uiWidgetColors *, uiBut *, rcti *);
|
||||
|
||||
|
||||
} uiWidgetType;
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ static const uint g_shape_preset_checkmark_face[4][3] = {
|
||||
{3, 2, 4}, {3, 4, 5}, {1, 0, 3}, {0, 2, 3}
|
||||
};
|
||||
|
||||
#define OY -0.2
|
||||
#define OY -0.2
|
||||
#define SC 0.35
|
||||
static const float g_shape_preset_hold_action_vert[6][2] = {
|
||||
{-0.5 + SC, 1.0 + OY}, {0.5, 1.0 + OY}, {0.5, 0.0 + OY + SC},
|
||||
@@ -213,7 +213,7 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y
|
||||
float tri_arr[3][2] = {{x1, y1}, {x2, y2}, {x3, y3}};
|
||||
float color[4];
|
||||
int j;
|
||||
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glGetFloatv(GL_CURRENT_COLOR, color);
|
||||
color[3] *= 0.125f;
|
||||
@@ -237,7 +237,7 @@ void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float m
|
||||
{
|
||||
float color[4];
|
||||
int j;
|
||||
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glGetFloatv(GL_CURRENT_COLOR, color);
|
||||
if (use_alpha) {
|
||||
@@ -245,7 +245,7 @@ void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float m
|
||||
}
|
||||
color[3] *= 0.125f;
|
||||
glColor4fv(color);
|
||||
|
||||
|
||||
for (j = 0; j < WIDGET_AA_JITTER; j++) {
|
||||
glTranslate2fv(jit[j]);
|
||||
UI_draw_roundbox_gl_mode(mode, minx, miny, maxx, maxy, rad);
|
||||
@@ -274,9 +274,9 @@ static int round_box_shadow_edges(float (*vert)[2], const rcti *rect, float rad,
|
||||
float vec[WIDGET_CURVE_RESOLU][2];
|
||||
float minx, miny, maxx, maxy;
|
||||
int a, tot = 0;
|
||||
|
||||
|
||||
rad += step;
|
||||
|
||||
|
||||
if (2.0f * rad > BLI_rcti_size_y(rect))
|
||||
rad = 0.5f * BLI_rcti_size_y(rect);
|
||||
|
||||
@@ -284,13 +284,13 @@ static int round_box_shadow_edges(float (*vert)[2], const rcti *rect, float rad,
|
||||
miny = rect->ymin - step;
|
||||
maxx = rect->xmax + step;
|
||||
maxy = rect->ymax + step;
|
||||
|
||||
|
||||
/* mult */
|
||||
for (a = 0; a < WIDGET_CURVE_RESOLU; a++) {
|
||||
vec[a][0] = rad * cornervec[a][0];
|
||||
vec[a][1] = rad * cornervec[a][1];
|
||||
}
|
||||
|
||||
|
||||
/* start with left-top, anti clockwise */
|
||||
if (roundboxalign & UI_CNR_TOP_LEFT) {
|
||||
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
||||
@@ -304,7 +304,7 @@ static int round_box_shadow_edges(float (*vert)[2], const rcti *rect, float rad,
|
||||
vert[tot][1] = maxy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (roundboxalign & UI_CNR_BOTTOM_LEFT) {
|
||||
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
||||
vert[tot][0] = minx + vec[a][1];
|
||||
@@ -317,7 +317,7 @@ static int round_box_shadow_edges(float (*vert)[2], const rcti *rect, float rad,
|
||||
vert[tot][1] = miny;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (roundboxalign & UI_CNR_BOTTOM_RIGHT) {
|
||||
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
||||
vert[tot][0] = maxx - rad + vec[a][0];
|
||||
@@ -330,7 +330,7 @@ static int round_box_shadow_edges(float (*vert)[2], const rcti *rect, float rad,
|
||||
vert[tot][1] = miny;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (roundboxalign & UI_CNR_TOP_RIGHT) {
|
||||
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
||||
vert[tot][0] = maxx - vec[a][1];
|
||||
@@ -365,13 +365,13 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, const rcti *re
|
||||
|
||||
minsize = min_ii(BLI_rcti_size_x(rect) * hnum,
|
||||
BLI_rcti_size_y(rect) * vnum);
|
||||
|
||||
|
||||
if (2.0f * rad > minsize)
|
||||
rad = 0.5f * minsize;
|
||||
|
||||
if (2.0f * (radi + 1.0f) > minsize)
|
||||
radi = 0.5f * minsize - U.pixelsize;
|
||||
|
||||
|
||||
/* mult */
|
||||
for (a = 0; a < WIDGET_CURVE_RESOLU; a++) {
|
||||
veci[a][0] = radi * cornervec[a][0];
|
||||
@@ -379,17 +379,17 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, const rcti *re
|
||||
vec[a][0] = rad * cornervec[a][0];
|
||||
vec[a][1] = rad * cornervec[a][1];
|
||||
}
|
||||
|
||||
|
||||
/* corner left-bottom */
|
||||
if (roundboxalign & UI_CNR_BOTTOM_LEFT) {
|
||||
|
||||
|
||||
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
||||
wt->inner_v[tot][0] = minxi + veci[a][1];
|
||||
wt->inner_v[tot][1] = minyi + radi - veci[a][0];
|
||||
|
||||
|
||||
wt->outer_v[tot][0] = minx + vec[a][1];
|
||||
wt->outer_v[tot][1] = miny + rad - vec[a][0];
|
||||
|
||||
|
||||
wt->inner_uv[tot][0] = facxi * (wt->inner_v[tot][0] - minxi);
|
||||
wt->inner_uv[tot][1] = facyi * (wt->inner_v[tot][1] - minyi);
|
||||
}
|
||||
@@ -397,26 +397,26 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, const rcti *re
|
||||
else {
|
||||
wt->inner_v[tot][0] = minxi;
|
||||
wt->inner_v[tot][1] = minyi;
|
||||
|
||||
|
||||
wt->outer_v[tot][0] = minx;
|
||||
wt->outer_v[tot][1] = miny;
|
||||
|
||||
wt->inner_uv[tot][0] = 0.0f;
|
||||
wt->inner_uv[tot][1] = 0.0f;
|
||||
|
||||
|
||||
tot++;
|
||||
}
|
||||
|
||||
|
||||
/* corner right-bottom */
|
||||
if (roundboxalign & UI_CNR_BOTTOM_RIGHT) {
|
||||
|
||||
|
||||
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
||||
wt->inner_v[tot][0] = maxxi - radi + veci[a][0];
|
||||
wt->inner_v[tot][1] = minyi + veci[a][1];
|
||||
|
||||
|
||||
wt->outer_v[tot][0] = maxx - rad + vec[a][0];
|
||||
wt->outer_v[tot][1] = miny + vec[a][1];
|
||||
|
||||
|
||||
wt->inner_uv[tot][0] = facxi * (wt->inner_v[tot][0] - minxi);
|
||||
wt->inner_uv[tot][1] = facyi * (wt->inner_v[tot][1] - minyi);
|
||||
}
|
||||
@@ -424,28 +424,28 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, const rcti *re
|
||||
else {
|
||||
wt->inner_v[tot][0] = maxxi;
|
||||
wt->inner_v[tot][1] = minyi;
|
||||
|
||||
|
||||
wt->outer_v[tot][0] = maxx;
|
||||
wt->outer_v[tot][1] = miny;
|
||||
|
||||
wt->inner_uv[tot][0] = 1.0f;
|
||||
wt->inner_uv[tot][1] = 0.0f;
|
||||
|
||||
|
||||
tot++;
|
||||
}
|
||||
|
||||
|
||||
wt->halfwayvert = tot;
|
||||
|
||||
|
||||
/* corner right-top */
|
||||
if (roundboxalign & UI_CNR_TOP_RIGHT) {
|
||||
|
||||
|
||||
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
||||
wt->inner_v[tot][0] = maxxi - veci[a][1];
|
||||
wt->inner_v[tot][1] = maxyi - radi + veci[a][0];
|
||||
|
||||
|
||||
wt->outer_v[tot][0] = maxx - vec[a][1];
|
||||
wt->outer_v[tot][1] = maxy - rad + vec[a][0];
|
||||
|
||||
|
||||
wt->inner_uv[tot][0] = facxi * (wt->inner_v[tot][0] - minxi);
|
||||
wt->inner_uv[tot][1] = facyi * (wt->inner_v[tot][1] - minyi);
|
||||
}
|
||||
@@ -453,42 +453,42 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, const rcti *re
|
||||
else {
|
||||
wt->inner_v[tot][0] = maxxi;
|
||||
wt->inner_v[tot][1] = maxyi;
|
||||
|
||||
|
||||
wt->outer_v[tot][0] = maxx;
|
||||
wt->outer_v[tot][1] = maxy;
|
||||
|
||||
|
||||
wt->inner_uv[tot][0] = 1.0f;
|
||||
wt->inner_uv[tot][1] = 1.0f;
|
||||
|
||||
|
||||
tot++;
|
||||
}
|
||||
|
||||
|
||||
/* corner left-top */
|
||||
if (roundboxalign & UI_CNR_TOP_LEFT) {
|
||||
|
||||
|
||||
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
||||
wt->inner_v[tot][0] = minxi + radi - veci[a][0];
|
||||
wt->inner_v[tot][1] = maxyi - veci[a][1];
|
||||
|
||||
|
||||
wt->outer_v[tot][0] = minx + rad - vec[a][0];
|
||||
wt->outer_v[tot][1] = maxy - vec[a][1];
|
||||
|
||||
|
||||
wt->inner_uv[tot][0] = facxi * (wt->inner_v[tot][0] - minxi);
|
||||
wt->inner_uv[tot][1] = facyi * (wt->inner_v[tot][1] - minyi);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
wt->inner_v[tot][0] = minxi;
|
||||
wt->inner_v[tot][1] = maxyi;
|
||||
|
||||
|
||||
wt->outer_v[tot][0] = minx;
|
||||
wt->outer_v[tot][1] = maxy;
|
||||
|
||||
|
||||
wt->inner_uv[tot][0] = 0.0f;
|
||||
wt->inner_uv[tot][1] = 1.0f;
|
||||
|
||||
|
||||
tot++;
|
||||
}
|
||||
|
||||
@@ -601,17 +601,17 @@ static void shape_preset_trias_from_rect_checkmark(uiWidgetTrias *tria, const rc
|
||||
{
|
||||
float centx, centy, size;
|
||||
int a;
|
||||
|
||||
|
||||
/* center position and size */
|
||||
centx = rect->xmin + 0.5f * BLI_rcti_size_y(rect);
|
||||
centy = rect->ymin + 0.5f * BLI_rcti_size_y(rect);
|
||||
size = 0.5f * BLI_rcti_size_y(rect);
|
||||
|
||||
|
||||
for (a = 0; a < 6; a++) {
|
||||
tria->vec[a][0] = size * g_shape_preset_checkmark_vert[a][0] + centx;
|
||||
tria->vec[a][1] = size * g_shape_preset_checkmark_vert[a][1] + centy;
|
||||
}
|
||||
|
||||
|
||||
tria->tot = 4;
|
||||
tria->index = g_shape_preset_checkmark_face;
|
||||
}
|
||||
@@ -680,7 +680,7 @@ static void widgetbase_outline(uiWidgetBase *wtb)
|
||||
static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
|
||||
{
|
||||
int j, a;
|
||||
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
/* backdrop non AA */
|
||||
@@ -746,7 +746,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
|
||||
char col1[4], col2[4];
|
||||
unsigned char col_array[WIDGET_SIZE_MAX * 4];
|
||||
unsigned char *col_pt = col_array;
|
||||
|
||||
|
||||
shadecolors4(col1, col2, wcol->inner, wcol->shadetop, wcol->shadedown);
|
||||
|
||||
for (a = 0; a < wtb->totvert; a++, col_pt += 4) {
|
||||
@@ -762,7 +762,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* for each AA step */
|
||||
if (wtb->draw_outline) {
|
||||
BLI_assert(wtb->totvert != 0);
|
||||
@@ -786,7 +786,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
|
||||
|
||||
for (j = 0; j < WIDGET_AA_JITTER; j++) {
|
||||
glTranslate2fv(jit[j]);
|
||||
|
||||
|
||||
/* outline */
|
||||
glColor4ubv(tcol);
|
||||
|
||||
@@ -801,13 +801,13 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, wtb->halfwayvert * 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
glTranslatef(-jit[j][0], -jit[j][1], 0.0f);
|
||||
}
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
|
||||
/* decoration */
|
||||
if (wtb->tria1.tot || wtb->tria2.tot) {
|
||||
const unsigned char tcol[4] = {wcol->item[0],
|
||||
@@ -874,17 +874,17 @@ static void widget_draw_icon_ex(
|
||||
{
|
||||
float xs = 0.0f, ys = 0.0f;
|
||||
float aspect, height;
|
||||
|
||||
|
||||
if (but->flag & UI_BUT_ICON_PREVIEW) {
|
||||
glEnable(GL_BLEND);
|
||||
widget_draw_preview(icon, alpha, rect);
|
||||
glDisable(GL_BLEND);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* this icon doesn't need draw... */
|
||||
if (icon == ICON_BLANK1 && (but->flag & UI_BUT_ICON_SUBMENU) == 0) return;
|
||||
|
||||
|
||||
aspect = but->block->aspect / UI_DPI_FAC;
|
||||
height = icon_size / aspect;
|
||||
|
||||
@@ -905,12 +905,12 @@ static void widget_draw_icon_ex(
|
||||
alpha *= 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
|
||||
if (icon && icon != ICON_BLANK1) {
|
||||
float ofs = 1.0f / aspect;
|
||||
|
||||
|
||||
if (but->drawflag & UI_BUT_ICON_LEFT) {
|
||||
/* special case - icon_only pie buttons */
|
||||
if (ui_block_is_pie_menu(but->block) && but->type != UI_BTYPE_MENU && but->str && but->str[0] == '\0')
|
||||
@@ -930,7 +930,7 @@ static void widget_draw_icon_ex(
|
||||
xs = (int)(xs + 0.1f);
|
||||
ys = (int)(ys + 0.1f);
|
||||
}
|
||||
|
||||
|
||||
/* to indicate draggable */
|
||||
if (but->dragpoin && (but->flag & UI_ACTIVE)) {
|
||||
float rgb[3] = {1.25f, 1.25f, 1.25f};
|
||||
@@ -943,10 +943,10 @@ static void widget_draw_icon_ex(
|
||||
if (show_menu_icon) {
|
||||
xs = rect->xmax - UI_DPI_ICON_SIZE - aspect;
|
||||
ys = (rect->ymin + rect->ymax - height) / 2.0f;
|
||||
|
||||
|
||||
UI_icon_draw_aspect(xs, ys, ICON_RIGHTARROW_THIN, aspect, alpha);
|
||||
}
|
||||
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
@@ -1219,16 +1219,16 @@ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti
|
||||
char *cpoin = NULL;
|
||||
int drawstr_len = strlen(but->drawstr);
|
||||
const char *cpend = but->drawstr + drawstr_len;
|
||||
|
||||
|
||||
/* need to set this first */
|
||||
UI_fontstyle_set(fstyle);
|
||||
|
||||
|
||||
if (fstyle->kerning == 1) /* for BLF_width */
|
||||
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
||||
|
||||
|
||||
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr, sizeof(but->drawstr));
|
||||
but->ofs = 0;
|
||||
|
||||
|
||||
|
||||
/* First shorten num-buttons eg,
|
||||
* Translucency: 0.000
|
||||
@@ -1238,10 +1238,10 @@ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti
|
||||
|
||||
/* find the space after ':' separator */
|
||||
cpoin = strrchr(but->drawstr, ':');
|
||||
|
||||
|
||||
if (cpoin && (cpoin < cpend - 2)) {
|
||||
char *cp2 = cpoin;
|
||||
|
||||
|
||||
/* chop off the leading text, starting from the right */
|
||||
while (but->strwidth > okwidth && cp2 > but->drawstr) {
|
||||
const char *prev_utf8 = BLI_str_find_prev_char_utf8(but->drawstr, cp2);
|
||||
@@ -1253,12 +1253,12 @@ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti
|
||||
|
||||
drawstr_len -= bytes;
|
||||
// BLI_assert(strlen(but->drawstr) == drawstr_len);
|
||||
|
||||
|
||||
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs);
|
||||
if (but->strwidth < 10) break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* after the leading text is gone, chop off the : and following space, with ofs */
|
||||
while ((but->strwidth > okwidth) && (but->ofs < 2)) {
|
||||
ui_text_clip_give_next_off(but, but->drawstr);
|
||||
@@ -1277,7 +1277,7 @@ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti
|
||||
but->strwidth = strwidth;
|
||||
but->drawstr[drawstr_len] = 0;
|
||||
}
|
||||
|
||||
|
||||
if (fstyle->kerning == 1)
|
||||
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
||||
}
|
||||
@@ -1338,17 +1338,17 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
|
||||
#endif
|
||||
|
||||
UI_fontstyle_set(fstyle);
|
||||
|
||||
|
||||
if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT))
|
||||
fstyle->align = UI_STYLE_TEXT_LEFT;
|
||||
else if (but->drawflag & UI_BUT_TEXT_RIGHT)
|
||||
fstyle->align = UI_STYLE_TEXT_RIGHT;
|
||||
else
|
||||
fstyle->align = UI_STYLE_TEXT_CENTER;
|
||||
|
||||
|
||||
if (fstyle->kerning == 1) /* for BLF_width */
|
||||
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
||||
|
||||
|
||||
|
||||
/* Special case: when we're entering text for multiple buttons,
|
||||
* don't draw the text for any of the multi-editing buttons */
|
||||
@@ -1392,7 +1392,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
|
||||
/* text button selection */
|
||||
if ((but->selend - but->selsta) > 0) {
|
||||
int selsta_draw, selwidth_draw;
|
||||
|
||||
|
||||
if (drawstr[0] != 0) {
|
||||
|
||||
if (but->selsta >= but->ofs) {
|
||||
@@ -1452,7 +1452,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
if (fstyle->kerning == 1)
|
||||
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
||||
|
||||
@@ -1473,7 +1473,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_NUMBUTS_LR_ALIGN
|
||||
if (!drawstr_right && ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER) &&
|
||||
/* if we're editing or multi-drag (fake editing), then use left alignment */
|
||||
@@ -1688,10 +1688,10 @@ static struct uiWidgetColors wcol_num = {
|
||||
{180, 180, 180, 255},
|
||||
{153, 153, 153, 255},
|
||||
{90, 90, 90, 255},
|
||||
|
||||
|
||||
{0, 0, 0, 255},
|
||||
{255, 255, 255, 255},
|
||||
|
||||
|
||||
1,
|
||||
-20, 0
|
||||
};
|
||||
@@ -1701,10 +1701,10 @@ static struct uiWidgetColors wcol_numslider = {
|
||||
{180, 180, 180, 255},
|
||||
{153, 153, 153, 255},
|
||||
{128, 128, 128, 255},
|
||||
|
||||
|
||||
{0, 0, 0, 255},
|
||||
{255, 255, 255, 255},
|
||||
|
||||
|
||||
1,
|
||||
-20, 0
|
||||
};
|
||||
@@ -1714,10 +1714,10 @@ static struct uiWidgetColors wcol_text = {
|
||||
{153, 153, 153, 255},
|
||||
{153, 153, 153, 255},
|
||||
{90, 90, 90, 255},
|
||||
|
||||
|
||||
{0, 0, 0, 255},
|
||||
{255, 255, 255, 255},
|
||||
|
||||
|
||||
1,
|
||||
0, 25
|
||||
};
|
||||
@@ -1727,10 +1727,10 @@ static struct uiWidgetColors wcol_option = {
|
||||
{70, 70, 70, 255},
|
||||
{70, 70, 70, 255},
|
||||
{255, 255, 255, 255},
|
||||
|
||||
|
||||
{0, 0, 0, 255},
|
||||
{255, 255, 255, 255},
|
||||
|
||||
|
||||
1,
|
||||
15, -15
|
||||
};
|
||||
@@ -1741,10 +1741,10 @@ static struct uiWidgetColors wcol_menu = {
|
||||
{70, 70, 70, 255},
|
||||
{70, 70, 70, 255},
|
||||
{255, 255, 255, 255},
|
||||
|
||||
|
||||
{255, 255, 255, 255},
|
||||
{204, 204, 204, 255},
|
||||
|
||||
|
||||
1,
|
||||
15, -15
|
||||
};
|
||||
@@ -1755,10 +1755,10 @@ static struct uiWidgetColors wcol_pulldown = {
|
||||
{63, 63, 63, 255},
|
||||
{86, 128, 194, 255},
|
||||
{255, 255, 255, 255},
|
||||
|
||||
|
||||
{0, 0, 0, 255},
|
||||
{0, 0, 0, 255},
|
||||
|
||||
|
||||
0,
|
||||
25, -20
|
||||
};
|
||||
@@ -1769,10 +1769,10 @@ static struct uiWidgetColors wcol_menu_item = {
|
||||
{0, 0, 0, 0},
|
||||
{86, 128, 194, 255},
|
||||
{172, 172, 172, 128},
|
||||
|
||||
|
||||
{255, 255, 255, 255},
|
||||
{0, 0, 0, 255},
|
||||
|
||||
|
||||
1,
|
||||
38, 0
|
||||
};
|
||||
@@ -1783,10 +1783,10 @@ static struct uiWidgetColors wcol_menu_back = {
|
||||
{25, 25, 25, 230},
|
||||
{45, 45, 45, 230},
|
||||
{100, 100, 100, 255},
|
||||
|
||||
|
||||
{160, 160, 160, 255},
|
||||
{255, 255, 255, 255},
|
||||
|
||||
|
||||
0,
|
||||
25, -20
|
||||
};
|
||||
@@ -1825,10 +1825,10 @@ static struct uiWidgetColors wcol_radio = {
|
||||
{70, 70, 70, 255},
|
||||
{86, 128, 194, 255},
|
||||
{255, 255, 255, 255},
|
||||
|
||||
|
||||
{255, 255, 255, 255},
|
||||
{0, 0, 0, 255},
|
||||
|
||||
|
||||
1,
|
||||
15, -15
|
||||
};
|
||||
@@ -1838,10 +1838,10 @@ static struct uiWidgetColors wcol_regular = {
|
||||
{153, 153, 153, 255},
|
||||
{100, 100, 100, 255},
|
||||
{25, 25, 25, 255},
|
||||
|
||||
|
||||
{0, 0, 0, 255},
|
||||
{255, 255, 255, 255},
|
||||
|
||||
|
||||
0,
|
||||
0, 0
|
||||
};
|
||||
@@ -1851,10 +1851,10 @@ static struct uiWidgetColors wcol_tool = {
|
||||
{153, 153, 153, 255},
|
||||
{100, 100, 100, 255},
|
||||
{25, 25, 25, 255},
|
||||
|
||||
|
||||
{0, 0, 0, 255},
|
||||
{255, 255, 255, 255},
|
||||
|
||||
|
||||
1,
|
||||
15, -15
|
||||
};
|
||||
@@ -1864,10 +1864,10 @@ static struct uiWidgetColors wcol_box = {
|
||||
{128, 128, 128, 255},
|
||||
{100, 100, 100, 255},
|
||||
{25, 25, 25, 255},
|
||||
|
||||
|
||||
{0, 0, 0, 255},
|
||||
{255, 255, 255, 255},
|
||||
|
||||
|
||||
0,
|
||||
0, 0
|
||||
};
|
||||
@@ -1877,10 +1877,10 @@ static struct uiWidgetColors wcol_toggle = {
|
||||
{153, 153, 153, 255},
|
||||
{100, 100, 100, 255},
|
||||
{25, 25, 25, 255},
|
||||
|
||||
|
||||
{0, 0, 0, 255},
|
||||
{255, 255, 255, 255},
|
||||
|
||||
|
||||
0,
|
||||
0, 0
|
||||
};
|
||||
@@ -1890,10 +1890,10 @@ static struct uiWidgetColors wcol_scroll = {
|
||||
{80, 80, 80, 180},
|
||||
{100, 100, 100, 180},
|
||||
{128, 128, 128, 255},
|
||||
|
||||
|
||||
{0, 0, 0, 255},
|
||||
{255, 255, 255, 255},
|
||||
|
||||
|
||||
1,
|
||||
5, -5
|
||||
};
|
||||
@@ -1903,10 +1903,10 @@ static struct uiWidgetColors wcol_progress = {
|
||||
{190, 190, 190, 255},
|
||||
{100, 100, 100, 180},
|
||||
{128, 128, 128, 255},
|
||||
|
||||
|
||||
{0, 0, 0, 255},
|
||||
{255, 255, 255, 255},
|
||||
|
||||
|
||||
0,
|
||||
0, 0
|
||||
};
|
||||
@@ -1916,10 +1916,10 @@ static struct uiWidgetColors wcol_list_item = {
|
||||
{0, 0, 0, 0},
|
||||
{86, 128, 194, 255},
|
||||
{90, 90, 90, 255},
|
||||
|
||||
|
||||
{0, 0, 0, 255},
|
||||
{255, 255, 255, 255},
|
||||
|
||||
|
||||
0,
|
||||
0, 0
|
||||
};
|
||||
@@ -1930,10 +1930,10 @@ static struct uiWidgetColors wcol_tmp = {
|
||||
{128, 128, 128, 255},
|
||||
{100, 100, 100, 255},
|
||||
{25, 25, 25, 255},
|
||||
|
||||
|
||||
{0, 0, 0, 255},
|
||||
{255, 255, 255, 255},
|
||||
|
||||
|
||||
0,
|
||||
0, 0
|
||||
};
|
||||
@@ -2020,7 +2020,7 @@ static void widget_state(uiWidgetType *wt, int state)
|
||||
widget_state_blend(wt->wcol.inner, wcol_state->inner_driven_sel, wcol_state->blend);
|
||||
|
||||
copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel);
|
||||
|
||||
|
||||
if (state & UI_SELECT)
|
||||
SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown);
|
||||
}
|
||||
@@ -2065,18 +2065,18 @@ static void widget_state_numslider(uiWidgetType *wt, int state)
|
||||
|
||||
/* call this for option button */
|
||||
widget_state(wt, state);
|
||||
|
||||
|
||||
/* now, set the inner-part so that it reflects state settings too */
|
||||
/* TODO: maybe we should have separate settings for the blending colors used for this case? */
|
||||
if (state & UI_SELECT) {
|
||||
|
||||
|
||||
if (state & UI_BUT_ANIMATED_KEY)
|
||||
widget_state_blend(wt->wcol.item, wcol_state->inner_key_sel, blend);
|
||||
else if (state & UI_BUT_ANIMATED)
|
||||
widget_state_blend(wt->wcol.item, wcol_state->inner_anim_sel, blend);
|
||||
else if (state & UI_BUT_DRIVEN)
|
||||
widget_state_blend(wt->wcol.item, wcol_state->inner_driven_sel, blend);
|
||||
|
||||
|
||||
if (state & UI_SELECT)
|
||||
SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown);
|
||||
}
|
||||
@@ -2094,10 +2094,10 @@ static void widget_state_numslider(uiWidgetType *wt, int state)
|
||||
static void widget_state_option_menu(uiWidgetType *wt, int state)
|
||||
{
|
||||
bTheme *btheme = UI_GetTheme(); /* XXX */
|
||||
|
||||
|
||||
/* call this for option button */
|
||||
widget_state(wt, state);
|
||||
|
||||
|
||||
/* if not selected we get theme from menu back */
|
||||
if (state & UI_SELECT)
|
||||
copy_v3_v3_char(wt->wcol.text, btheme->tui.wcol_menu_back.text_sel);
|
||||
@@ -2109,13 +2109,13 @@ static void widget_state_option_menu(uiWidgetType *wt, int state)
|
||||
static void widget_state_nothing(uiWidgetType *wt, int UNUSED(state))
|
||||
{
|
||||
wt->wcol = *(wt->wcol_theme);
|
||||
}
|
||||
}
|
||||
|
||||
/* special case, button that calls pulldown */
|
||||
static void widget_state_pulldown(uiWidgetType *wt, int state)
|
||||
{
|
||||
wt->wcol = *(wt->wcol_theme);
|
||||
|
||||
|
||||
copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel);
|
||||
copy_v3_v3_char(wt->wcol.outline, wt->wcol.inner);
|
||||
|
||||
@@ -2155,7 +2155,7 @@ static void widget_state_pie_menu_item(uiWidgetType *wt, int state)
|
||||
static void widget_state_menu_item(uiWidgetType *wt, int state)
|
||||
{
|
||||
wt->wcol = *(wt->wcol_theme);
|
||||
|
||||
|
||||
/* active and disabled (not so common) */
|
||||
if ((state & UI_BUT_DISABLED) && (state & UI_ACTIVE)) {
|
||||
widget_state_blend(wt->wcol.text, wt->wcol.text_sel, 0.5f);
|
||||
@@ -2188,30 +2188,30 @@ static void widget_softshadow(const rcti *rect, int roundboxalign, const float r
|
||||
int step, totvert;
|
||||
float triangle_strip[WIDGET_SIZE_MAX * 2 + 2][2];
|
||||
const float radout = UI_ThemeMenuShadowWidth();
|
||||
|
||||
|
||||
/* disabled shadow */
|
||||
if (radout == 0.0f)
|
||||
return;
|
||||
|
||||
|
||||
/* prevent tooltips to not show round shadow */
|
||||
if (radout > 0.2f * BLI_rcti_size_y(&rect1))
|
||||
rect1.ymax -= 0.2f * BLI_rcti_size_y(&rect1);
|
||||
else
|
||||
rect1.ymax -= radout;
|
||||
|
||||
|
||||
/* inner part */
|
||||
totvert = round_box_shadow_edges(wtb.inner_v, &rect1, radin, roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT), 0.0f);
|
||||
|
||||
/* we draw a number of increasing size alpha quad strips */
|
||||
alphastep = 3.0f * btheme->tui.menu_shadow_fac / radout;
|
||||
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
for (step = 1; step <= (int)radout; step++) {
|
||||
float expfac = sqrtf(step / radout);
|
||||
|
||||
|
||||
round_box_shadow_edges(wtb.outer_v, &rect1, radin, UI_CNR_ALL, (float)step);
|
||||
|
||||
|
||||
glColor4f(0.0f, 0.0f, 0.0f, alphastep * (1.0f - expfac));
|
||||
|
||||
widget_verts_to_triangle_strip(&wtb, totvert, triangle_strip);
|
||||
@@ -2227,9 +2227,9 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
|
||||
{
|
||||
uiWidgetBase wtb;
|
||||
int roundboxalign = UI_CNR_ALL;
|
||||
|
||||
|
||||
widget_init(&wtb);
|
||||
|
||||
|
||||
/* menu is 2nd level or deeper */
|
||||
if (flag & UI_BLOCK_POPUP) {
|
||||
//rect->ymin -= 4.0;
|
||||
@@ -2243,14 +2243,14 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
|
||||
roundboxalign = UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT;
|
||||
rect->ymax += 0.1f * U.widget_unit;
|
||||
}
|
||||
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
widget_softshadow(rect, roundboxalign, 0.25f * U.widget_unit);
|
||||
|
||||
|
||||
round_box_edges(&wtb, roundboxalign, rect, 0.25f * U.widget_unit);
|
||||
wtb.draw_emboss = false;
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
@@ -2259,17 +2259,17 @@ static void ui_hsv_cursor(float x, float y)
|
||||
{
|
||||
glPushMatrix();
|
||||
glTranslatef(x, y, 0.0f);
|
||||
|
||||
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
glutil_draw_filled_arc(0.0f, M_PI * 2.0, 3.0f * U.pixelsize, 8);
|
||||
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glColor3f(0.0f, 0.0f, 0.0f);
|
||||
glutil_draw_lined_arc(0.0f, M_PI * 2.0, 3.0f * U.pixelsize, 12);
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -2295,14 +2295,14 @@ void ui_hsvcircle_pos_from_vals(uiBut *but, const rcti *rect, float *hsv, float
|
||||
const float centy = BLI_rcti_cent_y_fl(rect);
|
||||
float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f;
|
||||
float ang, radius_t;
|
||||
|
||||
|
||||
ang = 2.0f * (float)M_PI * hsv[0] + (float)M_PI_2;
|
||||
|
||||
|
||||
if ((but->flag & UI_BUT_COLOR_CUBIC) && (U.color_picker_type == USER_CP_CIRCLE_HSV))
|
||||
radius_t = (1.0f - pow3f(1.0f - hsv[1]));
|
||||
else
|
||||
radius_t = hsv[1];
|
||||
|
||||
|
||||
radius = CLAMPIS(radius_t, 0.0f, 1.0f) * radius;
|
||||
*xpos = centx + cosf(-ang) * radius;
|
||||
*ypos = centy + sinf(-ang) * radius;
|
||||
@@ -2323,7 +2323,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
|
||||
float rgb[3], hsvo[3], hsv[3], col[3], colcent[3];
|
||||
int a;
|
||||
bool color_profile = ui_but_is_colorpicker_display_space(but);
|
||||
|
||||
|
||||
/* color */
|
||||
ui_but_v3_get(but, rgb);
|
||||
|
||||
@@ -2349,17 +2349,17 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
|
||||
else
|
||||
hsv[2] = 0.5f;
|
||||
}
|
||||
|
||||
|
||||
ui_color_picker_to_rgb(0.0f, 0.0f, hsv[2], colcent, colcent + 1, colcent + 2);
|
||||
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
glColor3fv(colcent);
|
||||
glVertex2f(centx, centy);
|
||||
|
||||
|
||||
for (a = 0; a <= tot; a++, ang += radstep) {
|
||||
float si = sinf(ang);
|
||||
float co = cosf(ang);
|
||||
|
||||
|
||||
ui_hsvcircle_vals_from_pos(hsv, hsv + 1, rect, centx + co * radius, centy + si * radius);
|
||||
|
||||
ui_color_picker_to_rgb_v(hsv, col);
|
||||
@@ -2368,7 +2368,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
|
||||
glVertex2f(centx + co * radius, centy + si * radius);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
|
||||
/* fully rounded outline */
|
||||
glPushMatrix();
|
||||
glTranslatef(centx, centy, 0.0f);
|
||||
@@ -2400,7 +2400,7 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
|
||||
float col1[4][3]; /* right half, rect bottom to top */
|
||||
|
||||
/* draw series of gouraud rects */
|
||||
|
||||
|
||||
switch (type) {
|
||||
case UI_GRAD_SV:
|
||||
hsv_to_rgb(h, 0.0, 0.0, &col1[0][0], &col1[0][1], &col1[0][2]);
|
||||
@@ -2446,9 +2446,9 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
|
||||
copy_v3_v3(col1[3], col1[2]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* old below */
|
||||
|
||||
|
||||
for (dx = 0.0f; dx < 0.999f; dx += color_step) { /* 0.999 = prevent float inaccuracy for steps */
|
||||
const float dx_next = dx + color_step;
|
||||
|
||||
@@ -2457,7 +2457,7 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
|
||||
copy_v3_v3(col0[1], col1[1]);
|
||||
copy_v3_v3(col0[2], col1[2]);
|
||||
copy_v3_v3(col0[3], col1[3]);
|
||||
|
||||
|
||||
/* new color */
|
||||
switch (type) {
|
||||
case UI_GRAD_SV:
|
||||
@@ -2499,24 +2499,24 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
|
||||
copy_v3_v3(col1[3], col1[2]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* rect */
|
||||
sx1 = rect->xmin + dx * BLI_rcti_size_x(rect);
|
||||
sx2 = rect->xmin + dx_next * BLI_rcti_size_x(rect);
|
||||
sy = rect->ymin;
|
||||
dy = (float)BLI_rcti_size_y(rect) / 3.0f;
|
||||
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
for (a = 0; a < 3; a++, sy += dy) {
|
||||
glColor4f(col0[a][0], col0[a][1], col0[a][2], alpha);
|
||||
glVertex2f(sx1, sy);
|
||||
|
||||
|
||||
glColor4f(col1[a][0], col1[a][1], col1[a][2], alpha);
|
||||
glVertex2f(sx2, sy);
|
||||
|
||||
glColor4f(col1[a + 1][0], col1[a + 1][1], col1[a + 1][2], alpha);
|
||||
glVertex2f(sx2, sy + dy);
|
||||
|
||||
|
||||
glColor4f(col0[a + 1][0], col0[a + 1][1], col0[a + 1][2], alpha);
|
||||
glVertex2f(sx1, sy + dy);
|
||||
}
|
||||
@@ -2578,24 +2578,24 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect)
|
||||
float *hsv = cpicker->color_data;
|
||||
float hsv_n[3];
|
||||
bool use_display_colorspace = ui_but_is_colorpicker_display_space(but);
|
||||
|
||||
|
||||
copy_v3_v3(hsv_n, hsv);
|
||||
|
||||
|
||||
ui_but_v3_get(but, rgb);
|
||||
|
||||
|
||||
if (use_display_colorspace)
|
||||
ui_block_cm_to_display_space_v3(but->block, rgb);
|
||||
|
||||
|
||||
rgb_to_hsv_compat_v(rgb, hsv_n);
|
||||
|
||||
|
||||
ui_draw_gradient(rect, hsv_n, but->a1, 1.0f);
|
||||
|
||||
ui_hsvcube_pos_from_vals(but, rect, hsv_n, &x, &y);
|
||||
CLAMP(x, rect->xmin + 3.0f, rect->xmax - 3.0f);
|
||||
CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f);
|
||||
|
||||
|
||||
ui_hsv_cursor(x, y);
|
||||
|
||||
|
||||
/* outline */
|
||||
glColor3ub(0, 0, 0);
|
||||
fdrawbox((rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax));
|
||||
@@ -2609,7 +2609,7 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect)
|
||||
float x, y;
|
||||
float rgb[3], hsv[3], v;
|
||||
bool color_profile = but->block->color_profile;
|
||||
|
||||
|
||||
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
|
||||
color_profile = false;
|
||||
|
||||
@@ -2623,7 +2623,7 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect)
|
||||
else
|
||||
rgb_to_hsv_v(rgb, hsv);
|
||||
v = hsv[2];
|
||||
|
||||
|
||||
/* map v from property range to [0,1] */
|
||||
if (but->a1 == UI_GRAD_V_ALT) {
|
||||
float min = but->softmin, max = but->softmax;
|
||||
@@ -2634,17 +2634,17 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect)
|
||||
}
|
||||
|
||||
widget_init(&wtb);
|
||||
|
||||
|
||||
/* fully rounded */
|
||||
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
|
||||
|
||||
|
||||
/* setup temp colors */
|
||||
wcol_tmp.outline[0] = wcol_tmp.outline[1] = wcol_tmp.outline[2] = 0;
|
||||
wcol_tmp.inner[0] = wcol_tmp.inner[1] = wcol_tmp.inner[2] = 128;
|
||||
wcol_tmp.shadetop = 127;
|
||||
wcol_tmp.shadedown = -128;
|
||||
wcol_tmp.shaded = 1;
|
||||
|
||||
|
||||
widgetbase_draw(&wtb, &wcol_tmp);
|
||||
|
||||
/* cursor */
|
||||
@@ -2666,7 +2666,7 @@ static void ui_draw_separator(const rcti *rect, uiWidgetColors *wcol)
|
||||
wcol->text[2],
|
||||
30
|
||||
};
|
||||
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glColor4ubv(col);
|
||||
glLineWidth(1.0f);
|
||||
@@ -2683,9 +2683,9 @@ static void widget_numbut_draw(uiWidgetColors *wcol, rcti *rect, int state, int
|
||||
|
||||
if (state & UI_SELECT)
|
||||
SWAP(short, wcol->shadetop, wcol->shadedown);
|
||||
|
||||
|
||||
widget_init(&wtb);
|
||||
|
||||
|
||||
if (!emboss) {
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
}
|
||||
@@ -2701,7 +2701,7 @@ static void widget_numbut_draw(uiWidgetColors *wcol, rcti *rect, int state, int
|
||||
}
|
||||
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
|
||||
|
||||
if (!(state & UI_STATE_TEXT_INPUT)) {
|
||||
/* text space */
|
||||
rect->xmin += textofs;
|
||||
@@ -2730,15 +2730,15 @@ bool ui_link_bezier_points(const rcti *rect, float coord_array[][2], int resol)
|
||||
vec[0][1] = rect->ymin;
|
||||
vec[3][0] = rect->xmax;
|
||||
vec[3][1] = rect->ymax;
|
||||
|
||||
|
||||
dist = 0.5f * fabsf(vec[0][0] - vec[3][0]);
|
||||
|
||||
|
||||
vec[1][0] = vec[0][0] + dist;
|
||||
vec[1][1] = vec[0][1];
|
||||
|
||||
|
||||
vec[2][0] = vec[3][0] - dist;
|
||||
vec[2][1] = vec[3][1];
|
||||
|
||||
|
||||
BKE_curve_forward_diff_bezier(vec[0][0], vec[1][0], vec[2][0], vec[3][0], &coord_array[0][0], resol, sizeof(float[2]));
|
||||
BKE_curve_forward_diff_bezier(vec[0][1], vec[1][1], vec[2][1], vec[3][1], &coord_array[0][1], resol, sizeof(float[2]));
|
||||
|
||||
@@ -2786,29 +2786,29 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s
|
||||
rad = 0.5f * BLI_rcti_size_y(rect);
|
||||
else
|
||||
rad = 0.5f * BLI_rcti_size_x(rect);
|
||||
|
||||
|
||||
wtb.draw_shadedir = (horizontal) ? true : false;
|
||||
|
||||
|
||||
/* draw back part, colors swapped and shading inverted */
|
||||
if (horizontal)
|
||||
SWAP(short, wcol->shadetop, wcol->shadedown);
|
||||
|
||||
|
||||
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
|
||||
|
||||
/* slider */
|
||||
if ((BLI_rcti_size_x(slider) < 2) || (BLI_rcti_size_y(slider) < 2)) {
|
||||
/* pass */
|
||||
}
|
||||
else {
|
||||
SWAP(short, wcol->shadetop, wcol->shadedown);
|
||||
|
||||
|
||||
copy_v4_v4_char(wcol->inner, wcol->item);
|
||||
|
||||
|
||||
if (wcol->shadetop > wcol->shadedown)
|
||||
wcol->shadetop += 20; /* XXX violates themes... */
|
||||
else wcol->shadedown += 20;
|
||||
|
||||
|
||||
if (state & UI_SCROLL_PRESSED) {
|
||||
wcol->inner[0] = wcol->inner[0] >= 250 ? 255 : wcol->inner[0] + 5;
|
||||
wcol->inner[1] = wcol->inner[1] >= 250 ? 255 : wcol->inner[1] + 5;
|
||||
@@ -2817,20 +2817,20 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s
|
||||
|
||||
/* draw */
|
||||
wtb.draw_emboss = false; /* only emboss once */
|
||||
|
||||
|
||||
/* exception for progress bar */
|
||||
if (state & UI_SCROLL_NO_OUTLINE) {
|
||||
SWAP(bool, outline, wtb.draw_outline);
|
||||
}
|
||||
|
||||
|
||||
round_box_edges(&wtb, UI_CNR_ALL, slider, rad);
|
||||
|
||||
|
||||
if (state & UI_SCROLL_ARROWS) {
|
||||
if (wcol->item[0] > 48) wcol->item[0] -= 48;
|
||||
if (wcol->item[1] > 48) wcol->item[1] -= 48;
|
||||
if (wcol->item[2] > 48) wcol->item[2] -= 48;
|
||||
wcol->item[3] = 255;
|
||||
|
||||
|
||||
if (horizontal) {
|
||||
shape_preset_init_scroll_circle(&wtb.tria1, slider, 0.6f, 'l');
|
||||
shape_preset_init_scroll_circle(&wtb.tria2, slider, 0.6f, 'r');
|
||||
@@ -2841,7 +2841,7 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s
|
||||
}
|
||||
}
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
|
||||
|
||||
if (state & UI_SCROLL_NO_OUTLINE) {
|
||||
SWAP(bool, outline, wtb.draw_outline);
|
||||
}
|
||||
@@ -2860,13 +2860,13 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
|
||||
|
||||
size = (but->softmax + but->a1 - but->softmin);
|
||||
size = max_ff(size, 2.0f);
|
||||
|
||||
|
||||
/* position */
|
||||
rect1 = *rect;
|
||||
|
||||
/* determine horizontal/vertical */
|
||||
horizontal = (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect));
|
||||
|
||||
|
||||
if (horizontal) {
|
||||
fac = BLI_rcti_size_x(rect) / size;
|
||||
rect1.xmin = rect1.xmin + ceilf(fac * ((float)value - but->softmin));
|
||||
@@ -2944,17 +2944,17 @@ static void widget_progressbar(uiBut *but, uiWidgetColors *wcol, rcti *rect, int
|
||||
|
||||
static void widget_link(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect, int UNUSED(state), int UNUSED(roundboxalign))
|
||||
{
|
||||
|
||||
|
||||
if (but->flag & UI_SELECT) {
|
||||
rcti rectlink;
|
||||
|
||||
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
|
||||
|
||||
rectlink.xmin = BLI_rcti_cent_x(rect);
|
||||
rectlink.ymin = BLI_rcti_cent_y(rect);
|
||||
rectlink.xmax = but->linkto[0];
|
||||
rectlink.ymax = but->linkto[1];
|
||||
|
||||
|
||||
ui_draw_link_bezier(&rectlink);
|
||||
}
|
||||
}
|
||||
@@ -2969,9 +2969,9 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
|
||||
|
||||
widget_init(&wtb);
|
||||
widget_init(&wtb1);
|
||||
|
||||
|
||||
/* backdrop first */
|
||||
|
||||
|
||||
/* fully rounded */
|
||||
offs = 0.5f * BLI_rcti_size_y(rect);
|
||||
toffs = offs * 0.75f;
|
||||
@@ -2979,11 +2979,11 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
|
||||
|
||||
wtb.draw_outline = false;
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
|
||||
|
||||
/* draw left/right parts only when not in text editing */
|
||||
if (!(state & UI_STATE_TEXT_INPUT)) {
|
||||
int roundboxalign_slider;
|
||||
|
||||
|
||||
/* slider part */
|
||||
copy_v3_v3_char(outline, wcol->outline);
|
||||
copy_v3_v3_char(wcol->outline, wcol->item);
|
||||
@@ -2991,24 +2991,24 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
|
||||
|
||||
if (!(state & UI_SELECT))
|
||||
SWAP(short, wcol->shadetop, wcol->shadedown);
|
||||
|
||||
|
||||
rect1 = *rect;
|
||||
|
||||
|
||||
value = ui_but_value_get(but);
|
||||
if ((but->softmax - but->softmin) > 0) {
|
||||
fac = ((float)value - but->softmin) * (BLI_rcti_size_x(&rect1) - offs) / (but->softmax - but->softmin);
|
||||
}
|
||||
|
||||
|
||||
/* left part of slider, always rounded */
|
||||
rect1.xmax = rect1.xmin + ceil(offs + U.pixelsize);
|
||||
round_box_edges(&wtb1, roundboxalign & ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT), &rect1, offs);
|
||||
wtb1.draw_outline = false;
|
||||
widgetbase_draw(&wtb1, wcol);
|
||||
|
||||
|
||||
/* right part of slider, interpolate roundness */
|
||||
rect1.xmax = rect1.xmin + fac + offs;
|
||||
rect1.xmin += floor(offs - U.pixelsize);
|
||||
|
||||
|
||||
if (rect1.xmax + offs > rect->xmax) {
|
||||
roundboxalign_slider = roundboxalign & ~(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT);
|
||||
offs *= (rect1.xmax + offs - rect->xmax) / offs;
|
||||
@@ -3018,14 +3018,14 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
|
||||
offs = 0.0f;
|
||||
}
|
||||
round_box_edges(&wtb1, roundboxalign_slider, &rect1, offs);
|
||||
|
||||
|
||||
widgetbase_draw(&wtb1, wcol);
|
||||
copy_v3_v3_char(wcol->outline, outline);
|
||||
|
||||
|
||||
if (!(state & UI_SELECT))
|
||||
SWAP(short, wcol->shadetop, wcol->shadedown);
|
||||
}
|
||||
|
||||
|
||||
/* outline */
|
||||
wtb.draw_outline = true;
|
||||
wtb.draw_inner = false;
|
||||
@@ -3046,7 +3046,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
|
||||
uiWidgetBase wtb;
|
||||
float rad, col[4];
|
||||
bool color_profile = but->block->color_profile;
|
||||
|
||||
|
||||
col[3] = 1.0f;
|
||||
|
||||
if (but->rnaprop) {
|
||||
@@ -3059,13 +3059,13 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
|
||||
col[3] = RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
widget_init(&wtb);
|
||||
|
||||
|
||||
/* half rounded */
|
||||
rad = 0.25f * U.widget_unit;
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
|
||||
|
||||
ui_but_v3_get(but, col);
|
||||
|
||||
if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT)) {
|
||||
@@ -3077,18 +3077,18 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
|
||||
rect->xmax -= SWATCH_KEYED_BORDER;
|
||||
rect->ymin += SWATCH_KEYED_BORDER;
|
||||
rect->ymax -= SWATCH_KEYED_BORDER;
|
||||
|
||||
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
}
|
||||
|
||||
|
||||
if (color_profile)
|
||||
ui_block_cm_to_display_space_v3(but->block, col);
|
||||
|
||||
|
||||
rgba_float_to_uchar((unsigned char *)wcol->inner, col);
|
||||
|
||||
wcol->shaded = 0;
|
||||
wcol->alpha_check = (wcol->inner[3] < 255);
|
||||
|
||||
|
||||
if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) {
|
||||
/* Now we reduce alpha of the inner color (i.e. the color shown)
|
||||
* so that this setting can look grayed out, while retaining
|
||||
@@ -3099,7 +3099,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
|
||||
}
|
||||
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
|
||||
|
||||
if (but->a1 == UI_PALETTE_COLOR && ((Palette *)but->rnapoin.id.data)->active_color == (int)but->a2) {
|
||||
float width = rect->xmax - rect->xmin;
|
||||
float height = rect->ymax - rect->ymin;
|
||||
@@ -3107,7 +3107,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
|
||||
float bw = rgb_to_grayscale(col);
|
||||
|
||||
bw += (bw < 0.5f) ? 0.5f : -0.5f;
|
||||
|
||||
|
||||
glColor4f(bw, bw, bw, 1.0);
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex2f(rect->xmin + 0.1f * width, rect->ymin + 0.9f * height);
|
||||
@@ -3127,17 +3127,17 @@ static void widget_icon_has_anim(uiBut *but, uiWidgetColors *wcol, rcti *rect, i
|
||||
if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT)) {
|
||||
uiWidgetBase wtb;
|
||||
float rad;
|
||||
|
||||
|
||||
widget_init(&wtb);
|
||||
wtb.draw_outline = false;
|
||||
|
||||
|
||||
/* rounded */
|
||||
rad = 0.5f * BLI_rcti_size_y(rect);
|
||||
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
}
|
||||
else if (but->type == UI_BTYPE_NUM) {
|
||||
/* Draw number buttons still with left/right
|
||||
/* Draw number buttons still with left/right
|
||||
* triangles when field is not embossed */
|
||||
widget_numbut_embossn(but, wcol, rect, state, roundboxalign);
|
||||
}
|
||||
@@ -3148,16 +3148,16 @@ static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roun
|
||||
{
|
||||
uiWidgetBase wtb;
|
||||
float rad;
|
||||
|
||||
|
||||
if (state & UI_SELECT)
|
||||
SWAP(short, wcol->shadetop, wcol->shadedown);
|
||||
|
||||
|
||||
widget_init(&wtb);
|
||||
|
||||
|
||||
/* half rounded */
|
||||
rad = 0.2f * U.widget_unit;
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
|
||||
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
}
|
||||
|
||||
@@ -3166,18 +3166,18 @@ static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
|
||||
{
|
||||
uiWidgetBase wtb;
|
||||
float rad;
|
||||
|
||||
|
||||
widget_init(&wtb);
|
||||
|
||||
|
||||
/* half rounded */
|
||||
rad = 0.2f * U.widget_unit;
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
|
||||
|
||||
/* decoration */
|
||||
shape_preset_trias_from_rect_menu(&wtb.tria1, rect);
|
||||
|
||||
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
|
||||
|
||||
/* text space, arrows are about 0.6 height of button */
|
||||
rect->xmax -= (6 * BLI_rcti_size_y(rect)) / 10;
|
||||
}
|
||||
@@ -3186,13 +3186,13 @@ static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(stat
|
||||
{
|
||||
uiWidgetBase wtb;
|
||||
float rad;
|
||||
|
||||
|
||||
widget_init(&wtb);
|
||||
|
||||
|
||||
/* half rounded */
|
||||
rad = 0.2f * U.widget_unit;
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
|
||||
|
||||
/* decoration */
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
}
|
||||
@@ -3203,9 +3203,9 @@ static void widget_menunodebut(uiWidgetColors *wcol, rcti *rect, int UNUSED(stat
|
||||
uiWidgetBase wtb;
|
||||
uiWidgetColors wcol_backup = *wcol;
|
||||
float rad;
|
||||
|
||||
|
||||
widget_init(&wtb);
|
||||
|
||||
|
||||
/* half rounded */
|
||||
rad = 0.2f * U.widget_unit;
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
@@ -3216,7 +3216,7 @@ static void widget_menunodebut(uiWidgetColors *wcol, rcti *rect, int UNUSED(stat
|
||||
wcol->outline[0] = min_ii(wcol->outline[0] + 15, 255);
|
||||
wcol->outline[1] = min_ii(wcol->outline[1] + 15, 255);
|
||||
wcol->outline[2] = min_ii(wcol->outline[2] + 15, 255);
|
||||
|
||||
|
||||
/* decoration */
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
*wcol = wcol_backup;
|
||||
@@ -3232,7 +3232,7 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int
|
||||
|
||||
/* half rounded */
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
|
||||
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
}
|
||||
}
|
||||
@@ -3240,13 +3240,13 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int
|
||||
static void widget_menu_itembut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign))
|
||||
{
|
||||
uiWidgetBase wtb;
|
||||
|
||||
|
||||
widget_init(&wtb);
|
||||
|
||||
|
||||
/* not rounded, no outline */
|
||||
wtb.draw_outline = false;
|
||||
round_box_edges(&wtb, 0, rect, 0.0f);
|
||||
|
||||
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
}
|
||||
|
||||
@@ -3277,14 +3277,14 @@ static void widget_list_itembut(uiWidgetColors *wcol, rcti *rect, int UNUSED(sta
|
||||
{
|
||||
uiWidgetBase wtb;
|
||||
float rad;
|
||||
|
||||
|
||||
widget_init(&wtb);
|
||||
|
||||
|
||||
/* rounded, but no outline */
|
||||
wtb.draw_outline = false;
|
||||
rad = 0.2f * U.widget_unit;
|
||||
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
|
||||
|
||||
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
}
|
||||
|
||||
@@ -3294,30 +3294,30 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
|
||||
rcti recttemp = *rect;
|
||||
float rad;
|
||||
int delta;
|
||||
|
||||
|
||||
widget_init(&wtb);
|
||||
|
||||
|
||||
/* square */
|
||||
recttemp.xmax = recttemp.xmin + BLI_rcti_size_y(&recttemp);
|
||||
|
||||
|
||||
/* smaller */
|
||||
delta = 1 + BLI_rcti_size_y(&recttemp) / 8;
|
||||
recttemp.xmin += delta;
|
||||
recttemp.ymin += delta;
|
||||
recttemp.xmax -= delta;
|
||||
recttemp.ymax -= delta;
|
||||
|
||||
|
||||
/* half rounded */
|
||||
rad = BLI_rcti_size_y(&recttemp) / 3;
|
||||
round_box_edges(&wtb, UI_CNR_ALL, &recttemp, rad);
|
||||
|
||||
|
||||
/* decoration */
|
||||
if (state & UI_SELECT) {
|
||||
shape_preset_trias_from_rect_checkmark(&wtb.tria1, &recttemp);
|
||||
}
|
||||
|
||||
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
|
||||
|
||||
/* text space */
|
||||
rect->xmin += BLI_rcti_size_y(rect) * 0.7 + delta;
|
||||
}
|
||||
@@ -3346,13 +3346,13 @@ static void widget_radiobut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
|
||||
{
|
||||
uiWidgetBase wtb;
|
||||
float rad;
|
||||
|
||||
|
||||
widget_init(&wtb);
|
||||
|
||||
|
||||
/* half rounded */
|
||||
rad = 0.2f * U.widget_unit;
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
|
||||
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
}
|
||||
|
||||
@@ -3361,24 +3361,24 @@ static void widget_box(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(
|
||||
uiWidgetBase wtb;
|
||||
float rad;
|
||||
char old_col[3];
|
||||
|
||||
|
||||
widget_init(&wtb);
|
||||
|
||||
|
||||
copy_v3_v3_char(old_col, wcol->inner);
|
||||
|
||||
|
||||
/* abuse but->hsv - if it's non-zero, use this color as the box's background */
|
||||
if (but->col[3]) {
|
||||
wcol->inner[0] = but->col[0];
|
||||
wcol->inner[1] = but->col[1];
|
||||
wcol->inner[2] = but->col[2];
|
||||
}
|
||||
|
||||
|
||||
/* half rounded */
|
||||
rad = 0.2f * U.widget_unit;
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
|
||||
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
|
||||
|
||||
copy_v3_v3_char(wcol->inner, old_col);
|
||||
}
|
||||
|
||||
@@ -3386,13 +3386,13 @@ static void widget_but(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int
|
||||
{
|
||||
uiWidgetBase wtb;
|
||||
float rad;
|
||||
|
||||
|
||||
widget_init(&wtb);
|
||||
|
||||
|
||||
/* half rounded */
|
||||
rad = 0.2f * U.widget_unit;
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
|
||||
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
}
|
||||
|
||||
@@ -3401,9 +3401,9 @@ static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
|
||||
{
|
||||
uiWidgetBase wtb;
|
||||
const float rad = 0.25f * U.widget_unit;
|
||||
|
||||
|
||||
widget_init(&wtb);
|
||||
|
||||
|
||||
/* half rounded */
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
|
||||
@@ -3434,24 +3434,24 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *
|
||||
uiWidgetBase wtb;
|
||||
const float rad = 0.25f * U.widget_unit;
|
||||
unsigned char col[4];
|
||||
|
||||
|
||||
/* state copy! */
|
||||
wt->wcol = *(wt->wcol_theme);
|
||||
|
||||
|
||||
widget_init(&wtb);
|
||||
|
||||
|
||||
if (but->block->drawextra) {
|
||||
/* note: drawextra can change rect +1 or -1, to match round errors of existing previews */
|
||||
but->block->drawextra(C, but->poin, but->block->drawextra_arg1, but->block->drawextra_arg2, rect);
|
||||
|
||||
|
||||
/* make mask to draw over image */
|
||||
UI_GetThemeColor3ubv(TH_BACK, col);
|
||||
glColor3ubv(col);
|
||||
|
||||
|
||||
round_box__edges(&wtb, UI_CNR_ALL, rect, 0.0f, rad);
|
||||
widgetbase_outline(&wtb);
|
||||
}
|
||||
|
||||
|
||||
/* outline */
|
||||
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
|
||||
wtb.draw_outline = true;
|
||||
@@ -3463,7 +3463,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
|
||||
{
|
||||
bTheme *btheme = UI_GetTheme();
|
||||
static uiWidgetType wt;
|
||||
|
||||
|
||||
/* defaults */
|
||||
wt.wcol_theme = &btheme->tui.wcol_regular;
|
||||
wt.wcol_state = &btheme->tui.wcol_state;
|
||||
@@ -3471,7 +3471,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
|
||||
wt.draw = widget_but;
|
||||
wt.custom = NULL;
|
||||
wt.text = widget_draw_text_icon;
|
||||
|
||||
|
||||
switch (type) {
|
||||
case UI_WTYPE_REGULAR:
|
||||
break;
|
||||
@@ -3480,16 +3480,16 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
|
||||
wt.draw = NULL;
|
||||
wt.state = widget_state_label;
|
||||
break;
|
||||
|
||||
|
||||
case UI_WTYPE_TOGGLE:
|
||||
wt.wcol_theme = &btheme->tui.wcol_toggle;
|
||||
break;
|
||||
|
||||
|
||||
case UI_WTYPE_CHECKBOX:
|
||||
wt.wcol_theme = &btheme->tui.wcol_option;
|
||||
wt.draw = widget_optionbut;
|
||||
break;
|
||||
|
||||
|
||||
case UI_WTYPE_RADIO:
|
||||
wt.wcol_theme = &btheme->tui.wcol_radio;
|
||||
wt.draw = widget_radiobut;
|
||||
@@ -3499,13 +3499,13 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
|
||||
wt.wcol_theme = &btheme->tui.wcol_num;
|
||||
wt.draw = widget_numbut;
|
||||
break;
|
||||
|
||||
|
||||
case UI_WTYPE_SLIDER:
|
||||
wt.wcol_theme = &btheme->tui.wcol_numslider;
|
||||
wt.custom = widget_numslider;
|
||||
wt.state = widget_state_numslider;
|
||||
break;
|
||||
|
||||
|
||||
case UI_WTYPE_EXEC:
|
||||
wt.wcol_theme = &btheme->tui.wcol_tool;
|
||||
wt.draw = widget_roundbut_exec;
|
||||
@@ -3515,24 +3515,24 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
|
||||
wt.wcol_theme = &btheme->tui.wcol_tooltip;
|
||||
wt.draw = widget_menu_back;
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
/* strings */
|
||||
case UI_WTYPE_NAME:
|
||||
wt.wcol_theme = &btheme->tui.wcol_text;
|
||||
wt.draw = widget_textbut;
|
||||
break;
|
||||
|
||||
|
||||
case UI_WTYPE_NAME_LINK:
|
||||
break;
|
||||
|
||||
|
||||
case UI_WTYPE_POINTER_LINK:
|
||||
break;
|
||||
|
||||
|
||||
case UI_WTYPE_FILENAME:
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
/* start menus */
|
||||
case UI_WTYPE_MENU_RADIO:
|
||||
wt.wcol_theme = &btheme->tui.wcol_menu;
|
||||
@@ -3543,7 +3543,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
|
||||
wt.wcol_theme = &btheme->tui.wcol_menu;
|
||||
wt.draw = widget_menuiconbut;
|
||||
break;
|
||||
|
||||
|
||||
case UI_WTYPE_MENU_POINTER_LINK:
|
||||
wt.wcol_theme = &btheme->tui.wcol_menu;
|
||||
wt.draw = widget_menubut;
|
||||
@@ -3553,25 +3553,25 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
|
||||
wt.wcol_theme = &btheme->tui.wcol_menu;
|
||||
wt.draw = widget_menunodebut;
|
||||
break;
|
||||
|
||||
|
||||
case UI_WTYPE_PULLDOWN:
|
||||
wt.wcol_theme = &btheme->tui.wcol_pulldown;
|
||||
wt.draw = widget_pulldownbut;
|
||||
wt.state = widget_state_pulldown;
|
||||
break;
|
||||
|
||||
|
||||
/* in menus */
|
||||
case UI_WTYPE_MENU_ITEM:
|
||||
wt.wcol_theme = &btheme->tui.wcol_menu_item;
|
||||
wt.draw = widget_menu_itembut;
|
||||
wt.state = widget_state_menu_item;
|
||||
break;
|
||||
|
||||
|
||||
case UI_WTYPE_MENU_BACK:
|
||||
wt.wcol_theme = &btheme->tui.wcol_menu_back;
|
||||
wt.draw = widget_menu_back;
|
||||
break;
|
||||
|
||||
|
||||
/* specials */
|
||||
case UI_WTYPE_ICON:
|
||||
wt.custom = widget_icon_has_anim;
|
||||
@@ -3582,19 +3582,19 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
|
||||
wt.state = widget_state_label;
|
||||
wt.custom = widget_icon_has_anim;
|
||||
break;
|
||||
|
||||
|
||||
case UI_WTYPE_SWATCH:
|
||||
wt.custom = widget_swatch;
|
||||
break;
|
||||
|
||||
|
||||
case UI_WTYPE_BOX:
|
||||
wt.custom = widget_box;
|
||||
wt.wcol_theme = &btheme->tui.wcol_box;
|
||||
break;
|
||||
|
||||
|
||||
case UI_WTYPE_RGB_PICKER:
|
||||
break;
|
||||
|
||||
|
||||
case UI_WTYPE_UNITVEC:
|
||||
wt.custom = widget_unitvec;
|
||||
break;
|
||||
@@ -3609,7 +3609,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
|
||||
wt.wcol_theme = &btheme->tui.wcol_list_item;
|
||||
wt.draw = widget_list_itembut;
|
||||
break;
|
||||
|
||||
|
||||
case UI_WTYPE_PROGRESSBAR:
|
||||
wt.wcol_theme = &btheme->tui.wcol_progress;
|
||||
wt.custom = widget_progressbar;
|
||||
@@ -3621,7 +3621,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
|
||||
wt.state = widget_state_pie_menu_item;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return &wt;
|
||||
}
|
||||
|
||||
@@ -3632,13 +3632,13 @@ static int widget_roundbox_set(uiBut *but, rcti *rect)
|
||||
|
||||
/* alignment */
|
||||
if ((but->drawflag & UI_BUT_ALIGN) && but->type != UI_BTYPE_PULLDOWN) {
|
||||
|
||||
|
||||
/* ui_block_position has this correction too, keep in sync */
|
||||
if (but->drawflag & (UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_STITCH_TOP))
|
||||
rect->ymax += U.pixelsize;
|
||||
if (but->drawflag & (UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_STITCH_LEFT))
|
||||
rect->xmin -= U.pixelsize;
|
||||
|
||||
|
||||
switch (but->drawflag & UI_BUT_ALIGN) {
|
||||
case UI_BUT_ALIGN_TOP:
|
||||
roundbox = UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT;
|
||||
@@ -3743,7 +3743,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
|
||||
case UI_BTYPE_SEPR:
|
||||
case UI_BTYPE_SEPR_LINE:
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_BUT:
|
||||
wt = widget_type(UI_WTYPE_EXEC);
|
||||
break;
|
||||
@@ -3751,11 +3751,11 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
|
||||
case UI_BTYPE_NUM:
|
||||
wt = widget_type(UI_WTYPE_NUMBER);
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_NUM_SLIDER:
|
||||
wt = widget_type(UI_WTYPE_SLIDER);
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_ROW:
|
||||
wt = widget_type(UI_WTYPE_RADIO);
|
||||
break;
|
||||
@@ -3763,7 +3763,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
|
||||
case UI_BTYPE_LISTROW:
|
||||
wt = widget_type(UI_WTYPE_LISTITEM);
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_TEXT:
|
||||
wt = widget_type(UI_WTYPE_NAME);
|
||||
break;
|
||||
@@ -3773,13 +3773,13 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
|
||||
if (but->block->flag & UI_BLOCK_LOOP)
|
||||
wt->wcol_theme = &btheme->tui.wcol_menu_back;
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_BUT_TOGGLE:
|
||||
case UI_BTYPE_TOGGLE:
|
||||
case UI_BTYPE_TOGGLE_N:
|
||||
wt = widget_type(UI_WTYPE_TOGGLE);
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_CHECKBOX:
|
||||
case UI_BTYPE_CHECKBOX_N:
|
||||
if (!(but->flag & UI_HAS_ICON)) {
|
||||
@@ -3788,13 +3788,13 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
|
||||
}
|
||||
else
|
||||
wt = widget_type(UI_WTYPE_TOGGLE);
|
||||
|
||||
|
||||
/* option buttons have strings outside, on menus use different colors */
|
||||
if (but->block->flag & UI_BLOCK_LOOP)
|
||||
wt->state = widget_state_option_menu;
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_MENU:
|
||||
case UI_BTYPE_BLOCK:
|
||||
if (but->flag & UI_BUT_NODE_LINK) {
|
||||
@@ -3818,35 +3818,35 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_PULLDOWN:
|
||||
wt = widget_type(UI_WTYPE_PULLDOWN);
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_BUT_MENU:
|
||||
wt = widget_type(UI_WTYPE_MENU_ITEM);
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_COLOR:
|
||||
wt = widget_type(UI_WTYPE_SWATCH);
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_ROUNDBOX:
|
||||
case UI_BTYPE_LISTBOX:
|
||||
wt = widget_type(UI_WTYPE_BOX);
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_LINK:
|
||||
case UI_BTYPE_INLINK:
|
||||
wt = widget_type(UI_WTYPE_ICON);
|
||||
wt->custom = widget_link;
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_EXTRA:
|
||||
widget_draw_extra_mask(C, but, widget_type(UI_WTYPE_BOX), rect);
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_HSVCUBE:
|
||||
if (ELEM(but->a1, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) { /* vertical V slider, uses new widget draw now */
|
||||
ui_draw_but_HSV_v(but, rect);
|
||||
@@ -3855,39 +3855,39 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
|
||||
ui_draw_but_HSVCUBE(but, rect);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_HSVCIRCLE:
|
||||
ui_draw_but_HSVCIRCLE(but, &tui->wcol_regular, rect);
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_COLORBAND:
|
||||
ui_draw_but_COLORBAND(but, &tui->wcol_regular, rect);
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_UNITVEC:
|
||||
wt = widget_type(UI_WTYPE_UNITVEC);
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_IMAGE:
|
||||
ui_draw_but_IMAGE(ar, but, &tui->wcol_regular, rect);
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_HISTOGRAM:
|
||||
ui_draw_but_HISTOGRAM(ar, but, &tui->wcol_regular, rect);
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_WAVEFORM:
|
||||
ui_draw_but_WAVEFORM(ar, but, &tui->wcol_regular, rect);
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_VECTORSCOPE:
|
||||
ui_draw_but_VECTORSCOPE(ar, but, &tui->wcol_regular, rect);
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_CURVE:
|
||||
ui_draw_but_CURVE(ar, but, &tui->wcol_regular, rect);
|
||||
break;
|
||||
|
||||
|
||||
case UI_BTYPE_PROGRESS_BAR:
|
||||
wt = widget_type(UI_WTYPE_PROGRESSBAR);
|
||||
fstyle = &style->widgetlabel;
|
||||
@@ -3914,12 +3914,12 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (wt) {
|
||||
//rcti disablerect = *rect; /* rect gets clipped smaller for text */
|
||||
int roundboxalign, state;
|
||||
bool disabled = false;
|
||||
|
||||
|
||||
roundboxalign = widget_roundbox_set(but, rect);
|
||||
|
||||
/* Mask out flags re-used for local state. */
|
||||
@@ -3942,7 +3942,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
|
||||
if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE))
|
||||
if (but->dt != UI_EMBOSS_PULLDOWN)
|
||||
disabled = true;
|
||||
|
||||
|
||||
if (disabled)
|
||||
ui_widget_color_disabled(wt);
|
||||
|
||||
@@ -3957,7 +3957,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
|
||||
wt->text(fstyle, &wt->wcol, but, rect);
|
||||
if (disabled)
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
|
||||
// if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE))
|
||||
// if (but->dt != UI_EMBOSS_PULLDOWN)
|
||||
// widget_disabled(&disablerect);
|
||||
@@ -3967,13 +3967,13 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
|
||||
void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
|
||||
{
|
||||
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK);
|
||||
|
||||
|
||||
wt->state(wt, 0);
|
||||
if (block)
|
||||
wt->draw(&wt->wcol, rect, block->flag, block->direction);
|
||||
else
|
||||
wt->draw(&wt->wcol, rect, 0, 0);
|
||||
|
||||
|
||||
if (block) {
|
||||
if (block->flag & UI_BLOCK_CLIPTOP) {
|
||||
/* XXX no scaling for UI here yet */
|
||||
@@ -4131,7 +4131,7 @@ void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *UNUSED(block),
|
||||
void ui_draw_search_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
|
||||
{
|
||||
uiWidgetType *wt = widget_type(UI_WTYPE_BOX);
|
||||
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
widget_softshadow(rect, UI_CNR_ALL, 0.25f * U.widget_unit);
|
||||
glDisable(GL_BLEND);
|
||||
@@ -4154,10 +4154,10 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
|
||||
|
||||
wt->state(wt, state);
|
||||
wt->draw(&wt->wcol, rect, 0, 0);
|
||||
|
||||
|
||||
UI_fontstyle_set(fstyle);
|
||||
fstyle->align = UI_STYLE_TEXT_LEFT;
|
||||
|
||||
|
||||
/* text location offset */
|
||||
rect->xmin += 0.25f * UI_UNIT_X;
|
||||
if (iconid) rect->xmin += UI_DPI_ICON_SIZE;
|
||||
@@ -4207,7 +4207,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
|
||||
*cpoin = UI_SEP_CHAR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* restore rect, was messed with */
|
||||
*rect = _rect;
|
||||
|
||||
@@ -4218,7 +4218,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
|
||||
|
||||
height = ICON_SIZE_FROM_BUTRECT(rect);
|
||||
aspect = ICON_DEFAULT_HEIGHT / height;
|
||||
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
UI_icon_draw_aspect(xs, ys, iconid, aspect, 1.0f); /* XXX scale weak get from fstyle? */
|
||||
glDisable(GL_BLEND);
|
||||
@@ -4231,17 +4231,17 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int
|
||||
const float text_size = UI_UNIT_Y;
|
||||
float font_dims[2] = {0.0f, 0.0f};
|
||||
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM);
|
||||
|
||||
|
||||
/* drawing button background */
|
||||
wt->state(wt, state);
|
||||
wt->draw(&wt->wcol, rect, 0, 0);
|
||||
|
||||
|
||||
/* draw icon in rect above the space reserved for the label */
|
||||
rect->ymin += text_size;
|
||||
glEnable(GL_BLEND);
|
||||
widget_draw_preview(iconid, 1.0f, rect);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
|
||||
BLF_width_and_height(fstyle->uifont_id, name, BLF_DRAW_STR_DUMMY_MAX, &font_dims[0], &font_dims[1]);
|
||||
|
||||
/* text rect */
|
||||
|
||||
@@ -96,16 +96,16 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
|
||||
static char headerdesel[4] = {0, 0, 0, 255};
|
||||
static char setting = 0;
|
||||
const char *cp = error;
|
||||
|
||||
|
||||
/* ensure we're not getting a color after running BKE_blender_userdef_free */
|
||||
BLI_assert(BLI_findindex(&U.themes, theme_active) != -1);
|
||||
BLI_assert(colorid != TH_UNDEFINED);
|
||||
|
||||
if (btheme) {
|
||||
|
||||
|
||||
/* first check for ui buttons theme */
|
||||
if (colorid < TH_THEMEUI) {
|
||||
|
||||
|
||||
switch (colorid) {
|
||||
|
||||
case TH_REDALERT:
|
||||
@@ -113,7 +113,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
switch (spacetype) {
|
||||
case SPACE_BUTS:
|
||||
ts = &btheme->tbuts;
|
||||
@@ -250,7 +250,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
|
||||
cp = &setting;
|
||||
setting = ts->panelcolors.show_back;
|
||||
break;
|
||||
|
||||
|
||||
case TH_BUTBACK:
|
||||
cp = ts->button; break;
|
||||
case TH_BUTBACK_TEXT:
|
||||
@@ -273,7 +273,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
|
||||
cp = ts->shade2; break;
|
||||
case TH_HILITE:
|
||||
cp = ts->hilite; break;
|
||||
|
||||
|
||||
case TH_GRID:
|
||||
cp = ts->grid; break;
|
||||
case TH_VIEW_OVERLAY:
|
||||
@@ -524,7 +524,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
|
||||
case TH_HANDLE_VERTEX_SIZE:
|
||||
cp = &ts->handle_vertex_size;
|
||||
break;
|
||||
|
||||
|
||||
case TH_GP_VERTEX:
|
||||
cp = ts->gp_vertex;
|
||||
break;
|
||||
@@ -534,7 +534,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
|
||||
case TH_GP_VERTEX_SIZE:
|
||||
cp = &ts->gp_vertex_size;
|
||||
break;
|
||||
|
||||
|
||||
case TH_DOPESHEET_CHANNELOB:
|
||||
cp = ts->ds_channel;
|
||||
break;
|
||||
@@ -622,21 +622,21 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
|
||||
case TH_SKIN_ROOT:
|
||||
cp = ts->skin_root;
|
||||
break;
|
||||
|
||||
|
||||
case TH_ANIM_ACTIVE:
|
||||
cp = ts->anim_active;
|
||||
break;
|
||||
case TH_ANIM_INACTIVE:
|
||||
cp = ts->anim_non_active;
|
||||
break;
|
||||
|
||||
|
||||
case TH_NLA_TWEAK:
|
||||
cp = ts->nla_tweaking;
|
||||
break;
|
||||
case TH_NLA_TWEAK_DUPLI:
|
||||
cp = ts->nla_tweakdupli;
|
||||
break;
|
||||
|
||||
|
||||
case TH_NLA_TRANSITION:
|
||||
cp = ts->nla_transition;
|
||||
break;
|
||||
@@ -655,7 +655,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
|
||||
case TH_NLA_SOUND_SEL:
|
||||
cp = ts->nla_sound_sel;
|
||||
break;
|
||||
|
||||
|
||||
case TH_WIDGET_EMBOSS:
|
||||
cp = btheme->tui.widget_emboss; break;
|
||||
|
||||
@@ -702,7 +702,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (const unsigned char *)cp;
|
||||
}
|
||||
|
||||
@@ -710,7 +710,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
|
||||
static void ui_theme_init_boneColorSets(bTheme *btheme)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
/* define default color sets - currently we only define 15 of these, though that should be ample */
|
||||
/* set 1 */
|
||||
rgba_char_args_set(btheme->tarm[0].solid, 0x9a, 0x00, 0x00, 255);
|
||||
@@ -772,7 +772,7 @@ static void ui_theme_init_boneColorSets(bTheme *btheme)
|
||||
rgba_char_args_set(btheme->tarm[14].solid, 0x08, 0x31, 0x0e, 255);
|
||||
rgba_char_args_set(btheme->tarm[14].select, 0x1c, 0x43, 0x0b, 255);
|
||||
rgba_char_args_set(btheme->tarm[14].active, 0x34, 0x62, 0x2b, 255);
|
||||
|
||||
|
||||
/* reset flags too */
|
||||
for (i = 0; i < 20; i++)
|
||||
btheme->tarm[i].flag = 0;
|
||||
@@ -844,16 +844,16 @@ static void ui_theme_space_init_handles_color(ThemeSpace *theme_space)
|
||||
void ui_theme_init_default(void)
|
||||
{
|
||||
bTheme *btheme;
|
||||
|
||||
|
||||
/* we search for the theme with name Default */
|
||||
btheme = BLI_findstring(&U.themes, "Default", offsetof(bTheme, name));
|
||||
|
||||
|
||||
if (btheme == NULL) {
|
||||
btheme = MEM_callocN(sizeof(bTheme), "theme");
|
||||
BLI_addtail(&U.themes, btheme);
|
||||
strcpy(btheme->name, "Default");
|
||||
}
|
||||
|
||||
|
||||
UI_SetTheme(0, 0); /* make sure the global used in this file is set */
|
||||
|
||||
/* UI buttons */
|
||||
@@ -869,22 +869,22 @@ void ui_theme_init_default(void)
|
||||
|
||||
btheme->tui.menu_shadow_fac = 0.5f;
|
||||
btheme->tui.menu_shadow_width = 12;
|
||||
|
||||
|
||||
/* Bone Color Sets */
|
||||
ui_theme_init_boneColorSets(btheme);
|
||||
|
||||
|
||||
/* common (new) variables */
|
||||
ui_theme_init_new(btheme);
|
||||
|
||||
|
||||
/* space view3d */
|
||||
rgba_char_args_set_fl(btheme->tv3d.back, 0.225, 0.225, 0.225, 1.0);
|
||||
rgba_char_args_set(btheme->tv3d.text, 0, 0, 0, 255);
|
||||
rgba_char_args_set(btheme->tv3d.text_hi, 255, 255, 255, 255);
|
||||
|
||||
|
||||
rgba_char_args_set_fl(btheme->tv3d.header, 0.45, 0.45, 0.45, 1.0);
|
||||
rgba_char_args_set_fl(btheme->tv3d.button, 0.45, 0.45, 0.45, 0.5);
|
||||
// rgba_char_args_set(btheme->tv3d.panel, 165, 165, 165, 127);
|
||||
|
||||
|
||||
rgba_char_args_set(btheme->tv3d.shade1, 160, 160, 160, 100);
|
||||
rgba_char_args_set(btheme->tv3d.shade2, 0x7f, 0x70, 0x70, 100);
|
||||
|
||||
@@ -997,7 +997,7 @@ void ui_theme_init_default(void)
|
||||
rgba_char_args_set(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
|
||||
rgba_char_args_set(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
|
||||
btheme->tipo.handle_vertex_size = 5;
|
||||
|
||||
|
||||
rgba_char_args_set(btheme->tipo.ds_channel, 82, 96, 110, 255);
|
||||
rgba_char_args_set(btheme->tipo.ds_subchannel, 124, 137, 150, 255);
|
||||
rgba_char_args_set(btheme->tipo.group, 79, 101, 73, 255);
|
||||
@@ -1007,9 +1007,9 @@ void ui_theme_init_default(void)
|
||||
btheme->tact = btheme->tipo;
|
||||
rgba_char_args_set(btheme->tact.strip, 12, 10, 10, 128);
|
||||
rgba_char_args_set(btheme->tact.strip_select, 255, 140, 0, 255);
|
||||
|
||||
|
||||
rgba_char_args_set(btheme->tact.anim_active, 204, 112, 26, 102);
|
||||
|
||||
|
||||
rgba_char_args_set(btheme->tact.keytype_keyframe, 232, 232, 232, 255);
|
||||
rgba_char_args_set(btheme->tact.keytype_keyframe_select, 255, 190, 50, 255);
|
||||
rgba_char_args_set(btheme->tact.keytype_extreme, 232, 179, 204, 255);
|
||||
@@ -1018,31 +1018,31 @@ void ui_theme_init_default(void)
|
||||
rgba_char_args_set(btheme->tact.keytype_breakdown_select, 84, 191, 237, 255);
|
||||
rgba_char_args_set(btheme->tact.keytype_jitter, 148, 229, 117, 255);
|
||||
rgba_char_args_set(btheme->tact.keytype_jitter_select, 97, 192, 66, 255);
|
||||
|
||||
|
||||
rgba_char_args_set(btheme->tact.keyborder, 0, 0, 0, 255);
|
||||
rgba_char_args_set(btheme->tact.keyborder_select, 0, 0, 0, 255);
|
||||
|
||||
|
||||
btheme->tact.keyframe_scale_fac = 1.0f;
|
||||
|
||||
|
||||
/* space nla */
|
||||
btheme->tnla = btheme->tact;
|
||||
|
||||
|
||||
rgba_char_args_set(btheme->tnla.anim_active, 204, 112, 26, 102); /* same as for dopesheet; duplicate here for easier reference */
|
||||
rgba_char_args_set(btheme->tnla.anim_non_active, 153, 135, 97, 77);
|
||||
|
||||
|
||||
rgba_char_args_set(btheme->tnla.nla_tweaking, 77, 243, 26, 77);
|
||||
rgba_char_args_set(btheme->tnla.nla_tweakdupli, 217, 0, 0, 255);
|
||||
|
||||
|
||||
rgba_char_args_set(btheme->tnla.nla_transition, 28, 38, 48, 255);
|
||||
rgba_char_args_set(btheme->tnla.nla_transition_sel, 46, 117, 219, 255);
|
||||
rgba_char_args_set(btheme->tnla.nla_meta, 51, 38, 66, 255);
|
||||
rgba_char_args_set(btheme->tnla.nla_meta_sel, 105, 33, 150, 255);
|
||||
rgba_char_args_set(btheme->tnla.nla_sound, 43, 61, 61, 255);
|
||||
rgba_char_args_set(btheme->tnla.nla_sound_sel, 31, 122, 122, 255);
|
||||
|
||||
|
||||
rgba_char_args_set(btheme->tnla.keyborder, 0, 0, 0, 255);
|
||||
rgba_char_args_set(btheme->tnla.keyborder_select, 0, 0, 0, 255);
|
||||
|
||||
|
||||
/* space file */
|
||||
/* to have something initialized */
|
||||
btheme->tfile = btheme->tv3d;
|
||||
@@ -1058,7 +1058,7 @@ void ui_theme_init_default(void)
|
||||
rgba_char_args_set(btheme->tfile.movie, 250, 250, 250, 255);
|
||||
rgba_char_args_set(btheme->tfile.scene, 250, 250, 250, 255);
|
||||
|
||||
|
||||
|
||||
/* space seq */
|
||||
btheme->tseq = btheme->tv3d;
|
||||
rgba_char_args_set(btheme->tseq.back, 116, 116, 116, 255);
|
||||
@@ -1107,7 +1107,7 @@ void ui_theme_init_default(void)
|
||||
rgba_char_args_set(btheme->text.shade1, 143, 143, 143, 255);
|
||||
rgba_char_args_set(btheme->text.shade2, 0xc6, 0x77, 0x77, 255);
|
||||
rgba_char_args_set(btheme->text.hilite, 255, 0, 0, 255);
|
||||
|
||||
|
||||
/* syntax highlighting */
|
||||
rgba_char_args_set(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/
|
||||
rgba_char_args_set(btheme->text.syntaxl, 100, 0, 0, 255); /* Strings Red */
|
||||
@@ -1117,11 +1117,11 @@ void ui_theme_init_default(void)
|
||||
rgba_char_args_set(btheme->text.syntaxr, 140, 60, 0, 255); /* Reserved Orange*/
|
||||
rgba_char_args_set(btheme->text.syntaxb, 128, 0, 80, 255); /* Builtin Red-purple */
|
||||
rgba_char_args_set(btheme->text.syntaxs, 76, 76, 76, 255); /* Gray (mix between fg/bg) */
|
||||
|
||||
|
||||
/* space oops */
|
||||
btheme->toops = btheme->tv3d;
|
||||
rgba_char_args_set_fl(btheme->toops.back, 0.45, 0.45, 0.45, 1.0);
|
||||
|
||||
|
||||
rgba_char_args_set_fl(btheme->toops.match, 0.2, 0.5, 0.2, 0.3); /* highlighting search match - soft green*/
|
||||
rgba_char_args_set_fl(btheme->toops.selected_highlight, 0.51, 0.53, 0.55, 0.3);
|
||||
|
||||
@@ -1142,7 +1142,7 @@ void ui_theme_init_default(void)
|
||||
/* space user preferences */
|
||||
btheme->tuserpref = btheme->tv3d;
|
||||
rgba_char_args_set_fl(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
|
||||
|
||||
|
||||
/* space console */
|
||||
btheme->tconsole = btheme->tv3d;
|
||||
rgba_char_args_set(btheme->tconsole.back, 0, 0, 0, 255);
|
||||
@@ -1152,16 +1152,16 @@ void ui_theme_init_default(void)
|
||||
rgba_char_args_set(btheme->tconsole.console_error, 220, 96, 96, 255);
|
||||
rgba_char_args_set(btheme->tconsole.console_cursor, 220, 96, 96, 255);
|
||||
rgba_char_args_set(btheme->tconsole.console_select, 255, 255, 255, 48);
|
||||
|
||||
|
||||
/* space time */
|
||||
btheme->ttime = btheme->tv3d;
|
||||
rgba_char_args_set_fl(btheme->ttime.back, 0.45, 0.45, 0.45, 1.0);
|
||||
rgba_char_args_set_fl(btheme->ttime.grid, 0.36, 0.36, 0.36, 1.0);
|
||||
rgba_char_args_set(btheme->ttime.shade1, 173, 173, 173, 255); /* sliders */
|
||||
|
||||
|
||||
rgba_char_args_set(btheme->ttime.time_keyframe, 0xDD, 0xD7, 0x00, 0xFF);
|
||||
rgba_char_args_set(btheme->ttime.time_gp_keyframe, 0xB5, 0xE6, 0x1D, 0xFF);
|
||||
|
||||
|
||||
/* space node, re-uses syntax and console color storage */
|
||||
btheme->tnode = btheme->tv3d;
|
||||
rgba_char_args_set(btheme->tnode.syntaxr, 115, 115, 115, 255); /* wire inner color */
|
||||
@@ -1188,7 +1188,7 @@ void ui_theme_init_default(void)
|
||||
/* space logic */
|
||||
btheme->tlogic = btheme->tv3d;
|
||||
rgba_char_args_set(btheme->tlogic.back, 100, 100, 100, 255);
|
||||
|
||||
|
||||
/* space clip */
|
||||
btheme->tclip = btheme->tv3d;
|
||||
|
||||
@@ -1260,7 +1260,7 @@ void UI_Theme_Restore(struct bThemeState *theme_state)
|
||||
void UI_ThemeColor(int colorid)
|
||||
{
|
||||
const unsigned char *cp;
|
||||
|
||||
|
||||
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
|
||||
glColor3ubv(cp);
|
||||
|
||||
@@ -1270,7 +1270,7 @@ void UI_ThemeColor(int colorid)
|
||||
void UI_ThemeColor4(int colorid)
|
||||
{
|
||||
const unsigned char *cp;
|
||||
|
||||
|
||||
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
|
||||
glColor4ubv(cp);
|
||||
|
||||
@@ -1281,7 +1281,7 @@ void UI_ThemeColorShade(int colorid, int offset)
|
||||
{
|
||||
int r, g, b;
|
||||
const unsigned char *cp;
|
||||
|
||||
|
||||
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
|
||||
r = offset + (int) cp[0];
|
||||
CLAMP(r, 0, 255);
|
||||
@@ -1295,7 +1295,7 @@ void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
|
||||
{
|
||||
int r, g, b, a;
|
||||
const unsigned char *cp;
|
||||
|
||||
|
||||
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
|
||||
r = coloffset + (int) cp[0];
|
||||
CLAMP(r, 0, 255);
|
||||
@@ -1334,7 +1334,7 @@ void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
|
||||
{
|
||||
int r, g, b;
|
||||
const unsigned char *cp1, *cp2;
|
||||
|
||||
|
||||
cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
|
||||
cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
|
||||
|
||||
@@ -1342,11 +1342,11 @@ void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
|
||||
r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
|
||||
g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
|
||||
b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
|
||||
|
||||
|
||||
CLAMP(r, 0, 255);
|
||||
CLAMP(g, 0, 255);
|
||||
CLAMP(b, 0, 255);
|
||||
|
||||
|
||||
glColor3ub(r, g, b);
|
||||
}
|
||||
|
||||
@@ -1355,7 +1355,7 @@ void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int off
|
||||
{
|
||||
int r, g, b, a;
|
||||
const unsigned char *cp1, *cp2;
|
||||
|
||||
|
||||
cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
|
||||
cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
|
||||
|
||||
@@ -1364,7 +1364,7 @@ void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int off
|
||||
g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
|
||||
b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
|
||||
a = alphaoffset + floorf((1.0f - fac) * cp1[3] + fac * cp2[3]);
|
||||
|
||||
|
||||
CLAMP(r, 0, 255);
|
||||
CLAMP(g, 0, 255);
|
||||
CLAMP(b, 0, 255);
|
||||
@@ -1378,7 +1378,7 @@ void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int off
|
||||
float UI_GetThemeValuef(int colorid)
|
||||
{
|
||||
const unsigned char *cp;
|
||||
|
||||
|
||||
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
|
||||
return ((float)cp[0]);
|
||||
}
|
||||
@@ -1387,7 +1387,7 @@ float UI_GetThemeValuef(int colorid)
|
||||
int UI_GetThemeValue(int colorid)
|
||||
{
|
||||
const unsigned char *cp;
|
||||
|
||||
|
||||
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
|
||||
return ((int) cp[0]);
|
||||
}
|
||||
@@ -1414,7 +1414,7 @@ int UI_GetThemeValueType(int colorid, int spacetype)
|
||||
void UI_GetThemeColor3fv(int colorid, float col[3])
|
||||
{
|
||||
const unsigned char *cp;
|
||||
|
||||
|
||||
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
|
||||
col[0] = ((float)cp[0]) / 255.0f;
|
||||
col[1] = ((float)cp[1]) / 255.0f;
|
||||
@@ -1424,7 +1424,7 @@ void UI_GetThemeColor3fv(int colorid, float col[3])
|
||||
void UI_GetThemeColor4fv(int colorid, float col[4])
|
||||
{
|
||||
const unsigned char *cp;
|
||||
|
||||
|
||||
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
|
||||
col[0] = ((float)cp[0]) / 255.0f;
|
||||
col[1] = ((float)cp[1]) / 255.0f;
|
||||
@@ -1437,16 +1437,16 @@ void UI_GetThemeColorShade3fv(int colorid, int offset, float col[3])
|
||||
{
|
||||
int r, g, b;
|
||||
const unsigned char *cp;
|
||||
|
||||
|
||||
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
|
||||
|
||||
|
||||
r = offset + (int) cp[0];
|
||||
CLAMP(r, 0, 255);
|
||||
g = offset + (int) cp[1];
|
||||
CLAMP(g, 0, 255);
|
||||
b = offset + (int) cp[2];
|
||||
CLAMP(b, 0, 255);
|
||||
|
||||
|
||||
col[0] = ((float)r) / 255.0f;
|
||||
col[1] = ((float)g) / 255.0f;
|
||||
col[2] = ((float)b) / 255.0f;
|
||||
@@ -1475,7 +1475,7 @@ void UI_GetThemeColorShade3ubv(int colorid, int offset, unsigned char col[3])
|
||||
void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
|
||||
{
|
||||
const unsigned char *cp;
|
||||
|
||||
|
||||
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
|
||||
col[0] = cp[0];
|
||||
col[1] = cp[1];
|
||||
@@ -1487,19 +1487,19 @@ void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4])
|
||||
{
|
||||
int r, g, b, a;
|
||||
const unsigned char *cp;
|
||||
|
||||
|
||||
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
|
||||
|
||||
|
||||
r = offset + (int) cp[0];
|
||||
CLAMP(r, 0, 255);
|
||||
g = offset + (int) cp[1];
|
||||
CLAMP(g, 0, 255);
|
||||
b = offset + (int) cp[2];
|
||||
CLAMP(b, 0, 255);
|
||||
|
||||
|
||||
a = (int) cp[3]; /* no shading offset... */
|
||||
CLAMP(a, 0, 255);
|
||||
|
||||
|
||||
col[0] = ((float)r) / 255.0f;
|
||||
col[1] = ((float)g) / 255.0f;
|
||||
col[2] = ((float)b) / 255.0f;
|
||||
@@ -1510,7 +1510,7 @@ void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4])
|
||||
void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
|
||||
{
|
||||
const unsigned char *cp;
|
||||
|
||||
|
||||
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
|
||||
col[0] = cp[0];
|
||||
col[1] = cp[1];
|
||||
@@ -1521,7 +1521,7 @@ void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
|
||||
void UI_GetThemeColorType4ubv(int colorid, int spacetype, char col[4])
|
||||
{
|
||||
const unsigned char *cp;
|
||||
|
||||
|
||||
cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
|
||||
col[0] = cp[0];
|
||||
col[1] = cp[1];
|
||||
@@ -1541,7 +1541,7 @@ void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char c
|
||||
r = r < 0 ? 0 : (r > 255 ? 255 : r);
|
||||
g = g < 0 ? 0 : (g > 255 ? 255 : g);
|
||||
b = b < 0 ? 0 : (b > 255 ? 255 : b);
|
||||
|
||||
|
||||
glColor3ub(r, g, b);
|
||||
}
|
||||
|
||||
@@ -1586,7 +1586,7 @@ void UI_GetColorPtrBlendShade3ubv(
|
||||
void UI_ThemeClearColor(int colorid)
|
||||
{
|
||||
float col[3];
|
||||
|
||||
|
||||
UI_GetThemeColor3fv(colorid, col);
|
||||
glClearColor(col[0], col[1], col[2], 0.0f);
|
||||
}
|
||||
@@ -1608,7 +1608,7 @@ int UI_ThemeMenuShadowWidth(void)
|
||||
void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3], const char axis)
|
||||
{
|
||||
unsigned char col[3];
|
||||
|
||||
|
||||
switch (axis) {
|
||||
case 'X':
|
||||
UI_GetThemeColor3ubv(TH_AXIS_X, col);
|
||||
@@ -1634,7 +1634,7 @@ void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3]
|
||||
void init_userdef_do_versions(void)
|
||||
{
|
||||
Main *bmain = G.main;
|
||||
|
||||
|
||||
#define USER_VERSION_ATLEAST(ver, subver) MAIN_VERSION_ATLEAST(bmain, ver, subver)
|
||||
|
||||
/* the UserDef struct is not corrected with do_versions() .... ugh! */
|
||||
@@ -1667,12 +1667,12 @@ void init_userdef_do_versions(void)
|
||||
}
|
||||
if (U.pad_rot_angle == 0.0f)
|
||||
U.pad_rot_angle = 15.0f;
|
||||
|
||||
|
||||
/* graph editor - unselected F-Curve visibility */
|
||||
if (U.fcu_inactive_alpha == 0) {
|
||||
U.fcu_inactive_alpha = 0.25f;
|
||||
}
|
||||
|
||||
|
||||
/* signal for derivedmesh to use colorband */
|
||||
/* run in case this was on and is now off in the user prefs [#28096] */
|
||||
vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, UI_GetTheme()->tv3d.vertex_unreferenced);
|
||||
@@ -1680,19 +1680,19 @@ void init_userdef_do_versions(void)
|
||||
if (!USER_VERSION_ATLEAST(192, 0)) {
|
||||
strcpy(U.sounddir, "/");
|
||||
}
|
||||
|
||||
|
||||
/* patch to set Dupli Armature */
|
||||
if (!USER_VERSION_ATLEAST(220, 0)) {
|
||||
U.dupflag |= USER_DUP_ARM;
|
||||
}
|
||||
|
||||
|
||||
/* added seam, normal color, undo */
|
||||
if (!USER_VERSION_ATLEAST(235, 0)) {
|
||||
bTheme *btheme;
|
||||
|
||||
|
||||
U.uiflag |= USER_GLOBALUNDO;
|
||||
if (U.undosteps == 0) U.undosteps = 32;
|
||||
|
||||
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
/* check for (alpha == 0) is safe, then color was never set */
|
||||
if (btheme->tv3d.edge_seam[3] == 0) {
|
||||
@@ -1712,7 +1712,7 @@ void init_userdef_do_versions(void)
|
||||
}
|
||||
if (!USER_VERSION_ATLEAST(236, 0)) {
|
||||
/* illegal combo... */
|
||||
if (U.flag & USER_LMOUSESELECT)
|
||||
if (U.flag & USER_LMOUSESELECT)
|
||||
U.flag &= ~USER_TWOBUTTONMOUSE;
|
||||
}
|
||||
if (!USER_VERSION_ATLEAST(237, 0)) {
|
||||
@@ -1760,15 +1760,15 @@ void init_userdef_do_versions(void)
|
||||
}
|
||||
if (!USER_VERSION_ATLEAST(240, 0)) {
|
||||
bTheme *btheme;
|
||||
|
||||
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
/* Lamp theme, check for alpha==0 is safe, then color was never set */
|
||||
if (btheme->tv3d.lamp[3] == 0) {
|
||||
rgba_char_args_set(btheme->tv3d.lamp, 0, 0, 0, 40);
|
||||
/* TEMPORAL, remove me! (ton) */
|
||||
/* TEMPORAL, remove me! (ton) */
|
||||
U.uiflag |= USER_PLAINMENUS;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (U.obcenter_dia == 0) U.obcenter_dia = 6;
|
||||
}
|
||||
@@ -1802,19 +1802,19 @@ void init_userdef_do_versions(void)
|
||||
rgba_char_args_set(btheme->tseq.meta, 109, 145, 131, 255);
|
||||
}
|
||||
}
|
||||
|
||||
/* set defaults for 3D View rotating axis indicator */
|
||||
|
||||
/* set defaults for 3D View rotating axis indicator */
|
||||
/* since size can't be set to 0, this indicates it's not saved in startup.blend */
|
||||
if (U.rvisize == 0) {
|
||||
U.rvisize = 15;
|
||||
U.rvibright = 8;
|
||||
U.uiflag |= USER_SHOW_ROTVIEWICON;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (!USER_VERSION_ATLEAST(243, 0)) {
|
||||
bTheme *btheme;
|
||||
|
||||
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
/* long keyframe color */
|
||||
/* check for alpha==0 is safe, then color was never set */
|
||||
@@ -1823,7 +1823,7 @@ void init_userdef_do_versions(void)
|
||||
rgba_char_args_set(btheme->tact.strip_select, 0xff, 0xff, 0xaa, 204);
|
||||
rgba_char_args_set(btheme->tact.strip, 0xe4, 0x9c, 0xc6, 204);
|
||||
}
|
||||
|
||||
|
||||
/* IPO-Editor - Vertex Size*/
|
||||
if (btheme->tipo.vertex_size == 0) {
|
||||
btheme->tipo.vertex_size = 3;
|
||||
@@ -1861,7 +1861,7 @@ void init_userdef_do_versions(void)
|
||||
/* action channel groups (recolor anyway) */
|
||||
rgba_char_args_set(btheme->tact.group, 0x39, 0x7d, 0x1b, 255);
|
||||
rgba_char_args_set(btheme->tact.group_active, 0x7d, 0xe9, 0x60, 255);
|
||||
|
||||
|
||||
/* bone custom-color sets */
|
||||
if (btheme->tarm[0].solid[3] == 0)
|
||||
ui_theme_init_boneColorSets(btheme);
|
||||
@@ -1872,18 +1872,18 @@ void init_userdef_do_versions(void)
|
||||
}
|
||||
if (!USER_VERSION_ATLEAST(245, 3)) {
|
||||
bTheme *btheme;
|
||||
|
||||
|
||||
/* adjust themes */
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
const char *col;
|
||||
|
||||
|
||||
/* IPO Editor: Handles/Vertices */
|
||||
col = btheme->tipo.vertex;
|
||||
rgba_char_args_set(btheme->tipo.handle_vertex, col[0], col[1], col[2], 255);
|
||||
col = btheme->tipo.vertex_select;
|
||||
rgba_char_args_set(btheme->tipo.handle_vertex_select, col[0], col[1], col[2], 255);
|
||||
btheme->tipo.handle_vertex_size = btheme->tipo.vertex_size;
|
||||
|
||||
|
||||
/* Sequence/Image Editor: colors for GPencil text */
|
||||
col = btheme->tv3d.bone_pose;
|
||||
rgba_char_args_set(btheme->tseq.bone_pose, col[0], col[1], col[2], 255);
|
||||
@@ -1894,7 +1894,7 @@ void init_userdef_do_versions(void)
|
||||
}
|
||||
if (!USER_VERSION_ATLEAST(250, 0)) {
|
||||
bTheme *btheme;
|
||||
|
||||
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
/* this was not properly initialized in 2.45 */
|
||||
if (btheme->tima.face_dot[3] == 0) {
|
||||
@@ -1902,21 +1902,21 @@ void init_userdef_do_versions(void)
|
||||
rgba_char_args_set(btheme->tima.face_dot, 255, 133, 0, 255);
|
||||
btheme->tima.facedot_size = 2;
|
||||
}
|
||||
|
||||
|
||||
/* DopeSheet - (Object) Channel color */
|
||||
rgba_char_args_set(btheme->tact.ds_channel, 82, 96, 110, 255);
|
||||
rgba_char_args_set(btheme->tact.ds_subchannel, 124, 137, 150, 255);
|
||||
/* DopeSheet - Group Channel color (saner version) */
|
||||
rgba_char_args_set(btheme->tact.group, 79, 101, 73, 255);
|
||||
rgba_char_args_set(btheme->tact.group_active, 135, 177, 125, 255);
|
||||
|
||||
|
||||
/* Graph Editor - (Object) Channel color */
|
||||
rgba_char_args_set(btheme->tipo.ds_channel, 82, 96, 110, 255);
|
||||
rgba_char_args_set(btheme->tipo.ds_subchannel, 124, 137, 150, 255);
|
||||
/* Graph Editor - Group Channel color */
|
||||
rgba_char_args_set(btheme->tipo.group, 79, 101, 73, 255);
|
||||
rgba_char_args_set(btheme->tipo.group_active, 135, 177, 125, 255);
|
||||
|
||||
|
||||
/* Nla Editor - (Object) Channel color */
|
||||
rgba_char_args_set(btheme->tnla.ds_channel, 82, 96, 110, 255);
|
||||
rgba_char_args_set(btheme->tnla.ds_subchannel, 124, 137, 150, 255);
|
||||
@@ -1924,26 +1924,26 @@ void init_userdef_do_versions(void)
|
||||
rgba_char_args_set(btheme->tnla.strip, 12, 10, 10, 128);
|
||||
rgba_char_args_set(btheme->tnla.strip_select, 255, 140, 0, 255);
|
||||
}
|
||||
|
||||
|
||||
/* adjust grease-pencil distances */
|
||||
U.gp_manhattendist = 1;
|
||||
U.gp_euclideandist = 2;
|
||||
|
||||
|
||||
/* adjust default interpolation for new IPO-curves */
|
||||
U.ipo_new = BEZT_IPO_BEZ;
|
||||
}
|
||||
|
||||
|
||||
if (!USER_VERSION_ATLEAST(250, 1)) {
|
||||
bTheme *btheme;
|
||||
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
|
||||
|
||||
/* common (new) variables, it checks for alpha==0 */
|
||||
ui_theme_init_new(btheme);
|
||||
|
||||
if (btheme->tui.wcol_num.outline[3] == 0)
|
||||
ui_widget_color_init(&btheme->tui);
|
||||
|
||||
|
||||
/* Logic editor theme, check for alpha==0 is safe, then color was never set */
|
||||
if (btheme->tlogic.syntaxn[3] == 0) {
|
||||
/* re-uses syntax color storage */
|
||||
@@ -1973,10 +1973,10 @@ void init_userdef_do_versions(void)
|
||||
if (U.audiorate == 0)
|
||||
U.audiorate = 48000;
|
||||
}
|
||||
|
||||
|
||||
if (!USER_VERSION_ATLEAST(250, 8)) {
|
||||
wmKeyMap *km;
|
||||
|
||||
|
||||
for (km = U.user_keymaps.first; km; km = km->next) {
|
||||
if (STREQ(km->idname, "Armature_Sketch"))
|
||||
strcpy(km->idname, "Armature Sketch");
|
||||
@@ -2018,17 +2018,17 @@ void init_userdef_do_versions(void)
|
||||
if (U.wmdrawmethod == USER_DRAW_TRIPLE)
|
||||
U.wmdrawmethod = USER_DRAW_AUTOMATIC;
|
||||
}
|
||||
|
||||
|
||||
if (!USER_VERSION_ATLEAST(252, 3)) {
|
||||
if (U.flag & USER_LMOUSESELECT)
|
||||
if (U.flag & USER_LMOUSESELECT)
|
||||
U.flag &= ~USER_TWOBUTTONMOUSE;
|
||||
}
|
||||
if (!USER_VERSION_ATLEAST(252, 4)) {
|
||||
bTheme *btheme;
|
||||
|
||||
|
||||
/* default new handle type is auto handles */
|
||||
U.keyhandles_new = HD_AUTO;
|
||||
|
||||
|
||||
/* init new curve colors */
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
ui_theme_space_init_handles_color(&btheme->tv3d);
|
||||
@@ -2049,21 +2049,21 @@ void init_userdef_do_versions(void)
|
||||
}
|
||||
if (!USER_VERSION_ATLEAST(252, 5)) {
|
||||
bTheme *btheme;
|
||||
|
||||
|
||||
/* interface_widgets.c */
|
||||
struct uiWidgetColors wcol_progress = {
|
||||
{0, 0, 0, 255},
|
||||
{190, 190, 190, 255},
|
||||
{100, 100, 100, 180},
|
||||
{128, 128, 128, 255},
|
||||
|
||||
|
||||
{0, 0, 0, 255},
|
||||
{255, 255, 255, 255},
|
||||
|
||||
|
||||
0,
|
||||
5, -5
|
||||
};
|
||||
|
||||
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
/* init progress bar theme */
|
||||
btheme->tui.wcol_progress = wcol_progress;
|
||||
@@ -2078,7 +2078,7 @@ void init_userdef_do_versions(void)
|
||||
rgba_char_args_set(btheme->tv3d.extra_face_area, 0, 0, 128, 255);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!USER_VERSION_ATLEAST(256, 4)) {
|
||||
bTheme *btheme;
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
@@ -2101,7 +2101,7 @@ void init_userdef_do_versions(void)
|
||||
|
||||
if (!USER_VERSION_ATLEAST(259, 1)) {
|
||||
bTheme *btheme;
|
||||
|
||||
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
btheme->tv3d.speaker[3] = 255;
|
||||
}
|
||||
@@ -2109,23 +2109,23 @@ void init_userdef_do_versions(void)
|
||||
|
||||
if (!USER_VERSION_ATLEAST(260, 3)) {
|
||||
bTheme *btheme;
|
||||
|
||||
/* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead
|
||||
|
||||
/* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead
|
||||
* was changed in 260 as part of GSoC11, but version patch was wrong
|
||||
*/
|
||||
if (U.keyhandles_new == HD_AUTO)
|
||||
if (U.keyhandles_new == HD_AUTO)
|
||||
U.keyhandles_new = HD_AUTO_ANIM;
|
||||
|
||||
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
if (btheme->tv3d.bundle_solid[3] == 0)
|
||||
rgba_char_args_set(btheme->tv3d.bundle_solid, 200, 200, 200, 255);
|
||||
|
||||
|
||||
if (btheme->tv3d.camera_path[3] == 0)
|
||||
rgba_char_args_set(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255);
|
||||
|
||||
|
||||
if ((btheme->tclip.back[3]) == 0) {
|
||||
btheme->tclip = btheme->tv3d;
|
||||
|
||||
|
||||
rgba_char_args_set(btheme->tclip.marker_outline, 0x00, 0x00, 0x00, 255);
|
||||
rgba_char_args_set(btheme->tclip.marker, 0x7f, 0x7f, 0x00, 255);
|
||||
rgba_char_args_set(btheme->tclip.act_marker, 0xff, 0xff, 0xff, 255);
|
||||
@@ -2140,7 +2140,7 @@ void init_userdef_do_versions(void)
|
||||
rgba_char_args_set(btheme->tclip.handle_vertex_select, 0xff, 0xff, 0, 0xff);
|
||||
btheme->tclip.handle_vertex_size = 5;
|
||||
}
|
||||
|
||||
|
||||
/* auto-clamped handles -> based on auto */
|
||||
if (btheme->tipo.handle_auto_clamped[3] == 0)
|
||||
rgba_char_args_set(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
|
||||
@@ -2151,16 +2151,16 @@ void init_userdef_do_versions(void)
|
||||
/* enable (Cycles) addon by default */
|
||||
BKE_addon_ensure(&U.addons, "cycles");
|
||||
}
|
||||
|
||||
|
||||
if (!USER_VERSION_ATLEAST(260, 5)) {
|
||||
bTheme *btheme;
|
||||
|
||||
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
rgba_char_args_set(btheme->tui.panel.header, 0, 0, 0, 25);
|
||||
btheme->tui.icon_alpha = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!USER_VERSION_ATLEAST(261, 4)) {
|
||||
bTheme *btheme;
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
@@ -2170,11 +2170,11 @@ void init_userdef_do_versions(void)
|
||||
rgba_char_args_set_fl(btheme->tima.preview_stitch_stitchable, 0.0, 1.0, 0.0, 1.0);
|
||||
rgba_char_args_set_fl(btheme->tima.preview_stitch_unstitchable, 1.0, 0.0, 0.0, 1.0);
|
||||
rgba_char_args_set_fl(btheme->tima.preview_stitch_active, 0.886, 0.824, 0.765, 0.140);
|
||||
|
||||
|
||||
rgba_char_args_set_fl(btheme->toops.match, 0.2, 0.5, 0.2, 0.3);
|
||||
rgba_char_args_set_fl(btheme->toops.selected_highlight, 0.51, 0.53, 0.55, 0.3);
|
||||
}
|
||||
|
||||
|
||||
U.use_16bit_textures = true;
|
||||
}
|
||||
|
||||
@@ -2223,21 +2223,21 @@ void init_userdef_do_versions(void)
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next)
|
||||
rgba_char_args_set(btheme->tv3d.skin_root, 180, 77, 77, 255);
|
||||
}
|
||||
|
||||
|
||||
if (!USER_VERSION_ATLEAST(263, 7)) {
|
||||
bTheme *btheme;
|
||||
|
||||
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
/* DopeSheet Summary */
|
||||
rgba_char_args_set(btheme->tact.anim_active, 204, 112, 26, 102);
|
||||
|
||||
rgba_char_args_set(btheme->tact.anim_active, 204, 112, 26, 102);
|
||||
|
||||
/* NLA Colors */
|
||||
rgba_char_args_set(btheme->tnla.anim_active, 204, 112, 26, 102); /* same as dopesheet above */
|
||||
rgba_char_args_set(btheme->tnla.anim_non_active, 153, 135, 97, 77);
|
||||
|
||||
|
||||
rgba_char_args_set(btheme->tnla.nla_tweaking, 77, 243, 26, 77);
|
||||
rgba_char_args_set(btheme->tnla.nla_tweakdupli, 217, 0, 0, 255);
|
||||
|
||||
|
||||
rgba_char_args_set(btheme->tnla.nla_transition, 28, 38, 48, 255);
|
||||
rgba_char_args_set(btheme->tnla.nla_transition_sel, 46, 117, 219, 255);
|
||||
rgba_char_args_set(btheme->tnla.nla_meta, 51, 38, 66, 255);
|
||||
@@ -2286,10 +2286,10 @@ void init_userdef_do_versions(void)
|
||||
rgba_char_args_set(btheme->tv3d.skin_root, 180, 77, 77, 255);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!USER_VERSION_ATLEAST(264, 9)) {
|
||||
bTheme *btheme;
|
||||
|
||||
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
rgba_char_args_set(btheme->tui.xaxis, 220, 0, 0, 255);
|
||||
rgba_char_args_set(btheme->tui.yaxis, 0, 220, 0, 255);
|
||||
@@ -2345,7 +2345,7 @@ void init_userdef_do_versions(void)
|
||||
U.ndof_sensitivity = 1.0f;
|
||||
U.ndof_flag = (NDOF_LOCK_HORIZON | NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE);
|
||||
}
|
||||
|
||||
|
||||
if (U.ndof_orbit_sensitivity == 0.0f) {
|
||||
U.ndof_orbit_sensitivity = U.ndof_sensitivity;
|
||||
|
||||
@@ -2358,7 +2358,7 @@ void init_userdef_do_versions(void)
|
||||
|
||||
if (!USER_VERSION_ATLEAST(265, 1)) {
|
||||
bTheme *btheme;
|
||||
|
||||
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
/* note: the toggle operator for transparent backdrops limits to these spacetypes */
|
||||
if (btheme->tnode.button[3] == 255) {
|
||||
@@ -2370,18 +2370,18 @@ void init_userdef_do_versions(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* panel header/backdrop supported locally per editor now */
|
||||
if (!USER_VERSION_ATLEAST(265, 2)) {
|
||||
bTheme *btheme;
|
||||
|
||||
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
ThemeSpace *ts;
|
||||
|
||||
|
||||
/* new color, panel backdrop. Not used anywhere yet, until you enable it */
|
||||
copy_v3_v3_char(btheme->tui.panel.back, btheme->tbuts.button);
|
||||
btheme->tui.panel.back[3] = 128;
|
||||
|
||||
|
||||
for (ts = UI_THEMESPACE_START(btheme); ts != UI_THEMESPACE_END(btheme); ts++) {
|
||||
ts->panelcolors = btheme->tui.panel;
|
||||
}
|
||||
@@ -2394,7 +2394,7 @@ void init_userdef_do_versions(void)
|
||||
|
||||
if (!USER_VERSION_ATLEAST(266, 0)) {
|
||||
bTheme *btheme;
|
||||
|
||||
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
/* rna definition limits fac to 0.01 */
|
||||
if (btheme->tui.menu_shadow_fac == 0.0f) {
|
||||
@@ -2494,12 +2494,12 @@ void init_userdef_do_versions(void)
|
||||
rgba_char_args_test_set(btheme->tinfo.info_debug_text, 0, 0, 0, 255);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!USER_VERSION_ATLEAST(269, 9)) {
|
||||
bTheme *btheme;
|
||||
|
||||
|
||||
U.tw_size = U.tw_size * 5.0f;
|
||||
|
||||
|
||||
/* Action Editor (and NLA Editor) - Keyframe Colors */
|
||||
/* Graph Editor - larger vertex size defaults */
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
@@ -2513,21 +2513,21 @@ void init_userdef_do_versions(void)
|
||||
rgba_char_args_set(btheme->tact.keytype_breakdown_select, 84, 191, 237, 255);
|
||||
rgba_char_args_set(btheme->tact.keytype_jitter, 148, 229, 117, 255);
|
||||
rgba_char_args_set(btheme->tact.keytype_jitter_select, 97, 192, 66, 255);
|
||||
|
||||
|
||||
/* key border */
|
||||
rgba_char_args_set(btheme->tact.keyborder, 0, 0, 0, 255);
|
||||
rgba_char_args_set(btheme->tact.keyborder_select, 0, 0, 0, 255);
|
||||
|
||||
|
||||
/* NLA ............................ */
|
||||
/* key border */
|
||||
rgba_char_args_set(btheme->tnla.keyborder, 0, 0, 0, 255);
|
||||
rgba_char_args_set(btheme->tnla.keyborder_select, 0, 0, 0, 255);
|
||||
|
||||
|
||||
/* Graph Editor ................... */
|
||||
btheme->tipo.vertex_size = 6;
|
||||
btheme->tipo.handle_vertex_size = 5;
|
||||
}
|
||||
|
||||
|
||||
/* grease pencil - new layer color */
|
||||
if (U.gpencil_new_layer_col[3] < 0.1f) {
|
||||
/* defaults to black, but must at least be visible! */
|
||||
@@ -2613,7 +2613,7 @@ void init_userdef_do_versions(void)
|
||||
rgba_char_args_set_fl(btheme->tui.widget_emboss, 1.0f, 1.0f, 1.0f, 0.02f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!USER_VERSION_ATLEAST(273, 1)) {
|
||||
bTheme *btheme;
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
@@ -2621,19 +2621,19 @@ void init_userdef_do_versions(void)
|
||||
rgba_char_args_set(btheme->tv3d.gp_vertex, 0, 0, 0, 255);
|
||||
rgba_char_args_set(btheme->tv3d.gp_vertex_select, 255, 133, 0, 255);
|
||||
btheme->tv3d.gp_vertex_size = 3;
|
||||
|
||||
|
||||
rgba_char_args_set(btheme->tseq.gp_vertex, 0, 0, 0, 255);
|
||||
rgba_char_args_set(btheme->tseq.gp_vertex_select, 255, 133, 0, 255);
|
||||
btheme->tseq.gp_vertex_size = 3;
|
||||
|
||||
|
||||
rgba_char_args_set(btheme->tima.gp_vertex, 0, 0, 0, 255);
|
||||
rgba_char_args_set(btheme->tima.gp_vertex_select, 255, 133, 0, 255);
|
||||
btheme->tima.gp_vertex_size = 3;
|
||||
|
||||
|
||||
rgba_char_args_set(btheme->tnode.gp_vertex, 0, 0, 0, 255);
|
||||
rgba_char_args_set(btheme->tnode.gp_vertex_select, 255, 133, 0, 255);
|
||||
btheme->tnode.gp_vertex_size = 3;
|
||||
|
||||
|
||||
/* Timeline Keyframe Indicators */
|
||||
rgba_char_args_set(btheme->ttime.time_keyframe, 0xDD, 0xD7, 0x00, 0xFF);
|
||||
rgba_char_args_set(btheme->ttime.time_gp_keyframe, 0xB5, 0xE6, 0x1D, 0xFF);
|
||||
@@ -2730,7 +2730,7 @@ void init_userdef_do_versions(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!USER_VERSION_ATLEAST(277, 2)) {
|
||||
bTheme *btheme;
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
@@ -2782,10 +2782,10 @@ void init_userdef_do_versions(void)
|
||||
|
||||
if (U.pixelsize == 0.0f)
|
||||
U.pixelsize = 1.0f;
|
||||
|
||||
|
||||
if (U.image_draw_method == 0)
|
||||
U.image_draw_method = IMAGE_DRAW_METHOD_2DTEXTURE;
|
||||
|
||||
|
||||
// keep the following until the new audaspace is default to be built with
|
||||
#ifdef WITH_SYSTEM_AUDASPACE
|
||||
// we default to the first audio device
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Contributor(s): Blender Foundation, Joshua Leung
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
@@ -119,7 +119,7 @@ static int view2d_scroll_mapped(int scroll)
|
||||
static void view2d_masks(View2D *v2d, bool check_scrollers)
|
||||
{
|
||||
int scroll;
|
||||
|
||||
|
||||
/* mask - view frame */
|
||||
v2d->mask.xmin = v2d->mask.ymin = 0;
|
||||
v2d->mask.xmax = v2d->winx - 1; /* -1 yes! masks are pixels */
|
||||
@@ -144,10 +144,10 @@ static void view2d_masks(View2D *v2d, bool check_scrollers)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
scroll = view2d_scroll_mapped(v2d->scroll);
|
||||
|
||||
/* scrollers shrink mask area, but should be based off regionsize
|
||||
|
||||
/* scrollers shrink mask area, but should be based off regionsize
|
||||
* - they can only be on one to two edges of the region they define
|
||||
* - if they overlap, they must not occupy the corners (which are reserved for other widgets)
|
||||
*/
|
||||
@@ -166,7 +166,7 @@ static void view2d_masks(View2D *v2d, bool check_scrollers)
|
||||
v2d->vert.xmin = v2d->vert.xmax - V2D_SCROLL_WIDTH;
|
||||
v2d->mask.xmax = v2d->vert.xmin - 1;
|
||||
}
|
||||
|
||||
|
||||
/* horizontal scroller */
|
||||
if (scroll & (V2D_SCROLL_BOTTOM)) {
|
||||
/* on bottom edge of region */
|
||||
@@ -180,7 +180,7 @@ static void view2d_masks(View2D *v2d, bool check_scrollers)
|
||||
v2d->hor.ymin = v2d->hor.ymax - V2D_SCROLL_HEIGHT;
|
||||
v2d->mask.ymax = v2d->hor.ymin - 1;
|
||||
}
|
||||
|
||||
|
||||
/* adjust vertical scroller if there's a horizontal scroller, to leave corner free */
|
||||
if (scroll & V2D_SCROLL_VERTICAL) {
|
||||
/* just set y min/max for vertical scroller to y min/max of mask as appropriate */
|
||||
@@ -224,20 +224,20 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
|
||||
v2d->keepzoom = (V2D_KEEPASPECT | V2D_LIMITZOOM);
|
||||
v2d->minzoom = 0.01f;
|
||||
v2d->maxzoom = 1000.0f;
|
||||
|
||||
/* tot rect and cur should be same size, and aligned using 'standard' OpenGL coordinates for now
|
||||
|
||||
/* tot rect and cur should be same size, and aligned using 'standard' OpenGL coordinates for now
|
||||
* - region can resize 'tot' later to fit other data
|
||||
* - keeptot is only within bounds, as strict locking is not that critical
|
||||
* - view is aligned for (0,0) -> (winx-1, winy-1) setup
|
||||
*/
|
||||
v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y);
|
||||
v2d->keeptot = V2D_KEEPTOT_BOUNDS;
|
||||
|
||||
|
||||
if (do_init) {
|
||||
v2d->tot.xmin = v2d->tot.ymin = 0.0f;
|
||||
v2d->tot.xmax = (float)(winx - 1);
|
||||
v2d->tot.ymax = (float)(winy - 1);
|
||||
|
||||
|
||||
v2d->cur = v2d->tot;
|
||||
}
|
||||
/* scrollers - should we have these by default? */
|
||||
@@ -250,28 +250,28 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
|
||||
/* zoom + aspect ratio are locked */
|
||||
v2d->keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
|
||||
v2d->minzoom = v2d->maxzoom = 1.0f;
|
||||
|
||||
|
||||
/* tot rect has strictly regulated placement, and must only occur in +/- quadrant */
|
||||
v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y);
|
||||
v2d->keeptot = V2D_KEEPTOT_STRICT;
|
||||
tot_changed = do_init;
|
||||
|
||||
|
||||
/* scroller settings are currently not set here... that is left for regions... */
|
||||
break;
|
||||
}
|
||||
/* 'stack view' - practically the same as list/channel view, except is located in the pos y half instead.
|
||||
/* 'stack view' - practically the same as list/channel view, except is located in the pos y half instead.
|
||||
* zoom, aspect ratio, and alignment restrictions are set here */
|
||||
case V2D_COMMONVIEW_STACK:
|
||||
{
|
||||
/* zoom + aspect ratio are locked */
|
||||
v2d->keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
|
||||
v2d->minzoom = v2d->maxzoom = 1.0f;
|
||||
|
||||
|
||||
/* tot rect has strictly regulated placement, and must only occur in +/+ quadrant */
|
||||
v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y);
|
||||
v2d->keeptot = V2D_KEEPTOT_STRICT;
|
||||
tot_changed = do_init;
|
||||
|
||||
|
||||
/* scroller settings are currently not set here... that is left for regions... */
|
||||
break;
|
||||
}
|
||||
@@ -281,14 +281,14 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
|
||||
/* zoom + aspect ratio are locked */
|
||||
v2d->keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
|
||||
v2d->minzoom = v2d->maxzoom = 1.0f;
|
||||
|
||||
|
||||
if (do_init) {
|
||||
v2d->tot.xmin = 0.0f;
|
||||
v2d->tot.xmax = winx;
|
||||
v2d->tot.ymin = 0.0f;
|
||||
v2d->tot.ymax = winy;
|
||||
v2d->cur = v2d->tot;
|
||||
|
||||
|
||||
v2d->min[0] = v2d->max[0] = (float)(winx - 1);
|
||||
v2d->min[1] = v2d->max[1] = (float)(winy - 1);
|
||||
}
|
||||
@@ -296,10 +296,10 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
|
||||
v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y);
|
||||
v2d->keeptot = V2D_KEEPTOT_STRICT;
|
||||
tot_changed = do_init;
|
||||
|
||||
|
||||
/* panning in y-axis is prohibited */
|
||||
v2d->keepofs = V2D_LOCKOFS_Y;
|
||||
|
||||
|
||||
/* absolutely no scrollers allowed */
|
||||
v2d->scroll = 0;
|
||||
break;
|
||||
@@ -307,15 +307,15 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
|
||||
/* panels view, with horizontal/vertical align */
|
||||
case V2D_COMMONVIEW_PANELS_UI:
|
||||
{
|
||||
|
||||
|
||||
/* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
|
||||
v2d->keepzoom = (V2D_KEEPASPECT | V2D_LIMITZOOM | V2D_KEEPZOOM);
|
||||
v2d->minzoom = 0.5f;
|
||||
v2d->maxzoom = 2.0f;
|
||||
|
||||
|
||||
v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y);
|
||||
v2d->keeptot = V2D_KEEPTOT_BOUNDS;
|
||||
|
||||
|
||||
/* note, scroll is being flipped in ED_region_panels() drawing */
|
||||
v2d->scroll |= (V2D_SCROLL_HORIZONTAL_HIDE | V2D_SCROLL_VERTICAL_HIDE);
|
||||
|
||||
@@ -326,16 +326,16 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
|
||||
|
||||
if (do_init) {
|
||||
float panelzoom = (style) ? style->panelzoom : 1.0f;
|
||||
|
||||
|
||||
v2d->tot.xmin = 0.0f;
|
||||
v2d->tot.xmax = winx;
|
||||
|
||||
|
||||
v2d->tot.ymax = 0.0f;
|
||||
v2d->tot.ymin = -winy;
|
||||
|
||||
|
||||
v2d->cur.xmin = 0.0f;
|
||||
v2d->cur.xmax = (winx) * panelzoom;
|
||||
|
||||
|
||||
v2d->cur.ymax = 0.0f;
|
||||
v2d->cur.ymin = (-winy) * panelzoom;
|
||||
}
|
||||
@@ -346,24 +346,24 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
|
||||
/* we don't do anything here, as settings should be fine, but just make sure that rect */
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* set initialized flag so that View2D doesn't get reinitialised next time again */
|
||||
v2d->flag |= V2D_IS_INITIALISED;
|
||||
|
||||
/* store view size */
|
||||
v2d->winx = winx;
|
||||
v2d->winy = winy;
|
||||
|
||||
|
||||
/* set masks (always do), but leave scroller scheck to totrect_set */
|
||||
view2d_masks(v2d, 0);
|
||||
|
||||
|
||||
/* set 'tot' rect before setting cur? */
|
||||
/* XXX confusing stuff here still - I made this function not check scroller hide - that happens in totrect_set */
|
||||
if (tot_changed)
|
||||
UI_view2d_totRect_set_resize(v2d, winx, winy, !do_init);
|
||||
else
|
||||
ui_view2d_curRect_validate_resize(v2d, !do_init, 0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -376,16 +376,16 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
float totwidth, totheight, curwidth, curheight, width, height;
|
||||
float winx, winy;
|
||||
rctf *cur, *tot;
|
||||
|
||||
|
||||
/* use mask as size of region that View2D resides in, as it takes into account
|
||||
* scrollbars already - keep in sync with zoomx/zoomy in view_zoomstep_apply_ex! */
|
||||
winx = (float)(BLI_rcti_size_x(&v2d->mask) + 1);
|
||||
winy = (float)(BLI_rcti_size_y(&v2d->mask) + 1);
|
||||
|
||||
|
||||
/* get pointers to rcts for less typing */
|
||||
cur = &v2d->cur;
|
||||
tot = &v2d->tot;
|
||||
|
||||
|
||||
/* we must satisfy the following constraints (in decreasing order of importance):
|
||||
* - alignment restrictions are respected
|
||||
* - cur must not fall outside of tot
|
||||
@@ -393,7 +393,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
* - zoom must not be excessive (check either sizes or zoom values)
|
||||
* - aspect ratio should be respected (NOTE: this is quite closely related to zoom too)
|
||||
*/
|
||||
|
||||
|
||||
/* Step 1: if keepzoom, adjust the sizes of the rects only
|
||||
* - firstly, we calculate the sizes of the rects
|
||||
* - curwidth and curheight are saved as reference... modify width and height values here
|
||||
@@ -403,14 +403,14 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
/* keep in sync with zoomx/zoomy in view_zoomstep_apply_ex! */
|
||||
curwidth = width = BLI_rctf_size_x(cur);
|
||||
curheight = height = BLI_rctf_size_y(cur);
|
||||
|
||||
|
||||
/* if zoom is locked, size on the appropriate axis is reset to mask size */
|
||||
if (v2d->keepzoom & V2D_LOCKZOOM_X)
|
||||
width = winx;
|
||||
if (v2d->keepzoom & V2D_LOCKZOOM_Y)
|
||||
height = winy;
|
||||
|
||||
/* values used to divide, so make it safe
|
||||
|
||||
/* values used to divide, so make it safe
|
||||
* NOTE: width and height must use FLT_MIN instead of 1, otherwise it is impossible to
|
||||
* get enough resolution in Graph Editor for editing some curves
|
||||
*/
|
||||
@@ -418,7 +418,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
if (height < FLT_MIN) height = 1;
|
||||
if (winx < 1) winx = 1;
|
||||
if (winy < 1) winy = 1;
|
||||
|
||||
|
||||
/* V2D_LIMITZOOM indicates that zoom level should be preserved when the window size changes */
|
||||
if (resize && (v2d->keepzoom & V2D_KEEPZOOM)) {
|
||||
float zoom, oldzoom;
|
||||
@@ -439,11 +439,11 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
height *= zoom / oldzoom;
|
||||
}
|
||||
}
|
||||
/* keepzoom (V2D_LIMITZOOM set), indicates that zoom level on each axis must not exceed limits
|
||||
/* keepzoom (V2D_LIMITZOOM set), indicates that zoom level on each axis must not exceed limits
|
||||
* NOTE: in general, it is not expected that the lock-zoom will be used in conjunction with this
|
||||
*/
|
||||
else if (v2d->keepzoom & V2D_LIMITZOOM) {
|
||||
|
||||
|
||||
/* check if excessive zoom on x-axis */
|
||||
if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
|
||||
const float zoom = winx / width;
|
||||
@@ -454,7 +454,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
width = winx / v2d->maxzoom;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* check if excessive zoom on y-axis */
|
||||
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
|
||||
const float zoom = winy / height;
|
||||
@@ -471,21 +471,21 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
CLAMP(width, v2d->min[0], v2d->max[0]);
|
||||
CLAMP(height, v2d->min[1], v2d->max[1]);
|
||||
}
|
||||
|
||||
|
||||
/* check if we should restore aspect ratio (if view size changed) */
|
||||
if (v2d->keepzoom & V2D_KEEPASPECT) {
|
||||
bool do_x = false, do_y = false, do_cur /* , do_win */ /* UNUSED */;
|
||||
float curRatio, winRatio;
|
||||
|
||||
|
||||
/* when a window edge changes, the aspect ratio can't be used to
|
||||
* find which is the best new 'cur' rect. thats why it stores 'old'
|
||||
* find which is the best new 'cur' rect. thats why it stores 'old'
|
||||
*/
|
||||
if (winx != v2d->oldwinx) do_x = true;
|
||||
if (winy != v2d->oldwiny) do_y = true;
|
||||
|
||||
|
||||
curRatio = height / width;
|
||||
winRatio = winy / winx;
|
||||
|
||||
|
||||
/* both sizes change (area/region maximized) */
|
||||
if (do_x == do_y) {
|
||||
if (do_x && do_y) {
|
||||
@@ -502,7 +502,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
}
|
||||
do_cur = do_x;
|
||||
/* do_win = do_y; */ /* UNUSED */
|
||||
|
||||
|
||||
if (do_cur) {
|
||||
if ((v2d->keeptot == V2D_KEEPTOT_STRICT) && (winx != v2d->oldwinx)) {
|
||||
/* special exception for Outliner (and later channel-lists):
|
||||
@@ -512,12 +512,12 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
*/
|
||||
if (winx < v2d->oldwinx) {
|
||||
float temp = v2d->oldwinx - winx;
|
||||
|
||||
|
||||
cur->xmin -= temp;
|
||||
cur->xmax -= temp;
|
||||
|
||||
/* width does not get modified, as keepaspect here is just set to make
|
||||
* sure visible area adjusts to changing view shape!
|
||||
|
||||
/* width does not get modified, as keepaspect here is just set to make
|
||||
* sure visible area adjusts to changing view shape!
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -534,7 +534,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
|
||||
if (winy < v2d->oldwiny) {
|
||||
float temp = v2d->oldwiny - winy;
|
||||
|
||||
|
||||
if (v2d->align & V2D_ALIGN_NO_NEG_Y) {
|
||||
cur->ymin -= temp;
|
||||
cur->ymax -= temp;
|
||||
@@ -551,16 +551,16 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
height = width * winRatio;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* store region size for next time */
|
||||
v2d->oldwinx = (short)winx;
|
||||
v2d->oldwiny = (short)winy;
|
||||
}
|
||||
|
||||
|
||||
/* Step 2: apply new sizes to cur rect, but need to take into account alignment settings here... */
|
||||
if ((width != curwidth) || (height != curheight)) {
|
||||
float temp, dh;
|
||||
|
||||
|
||||
/* resize from centerpoint, unless otherwise specified */
|
||||
if (width != curwidth) {
|
||||
if (v2d->keepofs & V2D_LOCKOFS_X) {
|
||||
@@ -575,7 +575,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
else {
|
||||
temp = BLI_rctf_cent_x(cur);
|
||||
dh = width * 0.5f;
|
||||
|
||||
|
||||
cur->xmin = temp - dh;
|
||||
cur->xmax = temp + dh;
|
||||
}
|
||||
@@ -593,21 +593,21 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
else {
|
||||
temp = BLI_rctf_cent_y(cur);
|
||||
dh = height * 0.5f;
|
||||
|
||||
|
||||
cur->ymin = temp - dh;
|
||||
cur->ymax = temp + dh;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Step 3: adjust so that it doesn't fall outside of bounds of 'tot' */
|
||||
if (v2d->keeptot) {
|
||||
float temp, diff;
|
||||
|
||||
|
||||
/* recalculate extents of cur */
|
||||
curwidth = BLI_rctf_size_x(cur);
|
||||
curheight = BLI_rctf_size_y(cur);
|
||||
|
||||
|
||||
/* width */
|
||||
if ((curwidth > totwidth) && !(v2d->keepzoom & (V2D_KEEPZOOM | V2D_LOCKZOOM_X | V2D_LIMITZOOM))) {
|
||||
/* if zoom doesn't have to be maintained, just clamp edges */
|
||||
@@ -615,28 +615,28 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
if (cur->xmax > tot->xmax) cur->xmax = tot->xmax;
|
||||
}
|
||||
else if (v2d->keeptot == V2D_KEEPTOT_STRICT) {
|
||||
/* This is an exception for the outliner (and later channel-lists, headers)
|
||||
/* This is an exception for the outliner (and later channel-lists, headers)
|
||||
* - must clamp within tot rect (absolutely no excuses)
|
||||
* --> therefore, cur->xmin must not be less than tot->xmin
|
||||
*/
|
||||
if (cur->xmin < tot->xmin) {
|
||||
/* move cur across so that it sits at minimum of tot */
|
||||
temp = tot->xmin - cur->xmin;
|
||||
|
||||
|
||||
cur->xmin += temp;
|
||||
cur->xmax += temp;
|
||||
}
|
||||
else if (cur->xmax > tot->xmax) {
|
||||
/* - only offset by difference of cur-xmax and tot-xmax if that would not move
|
||||
/* - only offset by difference of cur-xmax and tot-xmax if that would not move
|
||||
* cur-xmin to lie past tot-xmin
|
||||
* - otherwise, simply shift to tot-xmin???
|
||||
*/
|
||||
temp = cur->xmax - tot->xmax;
|
||||
|
||||
|
||||
if ((cur->xmin - temp) < tot->xmin) {
|
||||
/* only offset by difference from cur-min and tot-min */
|
||||
temp = cur->xmin - tot->xmin;
|
||||
|
||||
|
||||
cur->xmin -= temp;
|
||||
cur->xmax -= temp;
|
||||
}
|
||||
@@ -650,7 +650,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
/* This here occurs when:
|
||||
* - width too big, but maintaining zoom (i.e. widths cannot be changed)
|
||||
* - width is OK, but need to check if outside of boundaries
|
||||
*
|
||||
*
|
||||
* So, resolution is to just shift view by the gap between the extremities.
|
||||
* We favour moving the 'minimum' across, as that's origin for most things
|
||||
* (XXX - in the past, max was favored... if there are bugs, swap!)
|
||||
@@ -659,28 +659,28 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
/* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */
|
||||
temp = BLI_rctf_cent_x(tot);
|
||||
diff = curwidth * 0.5f;
|
||||
|
||||
|
||||
cur->xmin = temp - diff;
|
||||
cur->xmax = temp + diff;
|
||||
}
|
||||
else if (cur->xmin < tot->xmin) {
|
||||
/* move cur across so that it sits at minimum of tot */
|
||||
temp = tot->xmin - cur->xmin;
|
||||
|
||||
|
||||
cur->xmin += temp;
|
||||
cur->xmax += temp;
|
||||
}
|
||||
else if (cur->xmax > tot->xmax) {
|
||||
/* - only offset by difference of cur-xmax and tot-xmax if that would not move
|
||||
/* - only offset by difference of cur-xmax and tot-xmax if that would not move
|
||||
* cur-xmin to lie past tot-xmin
|
||||
* - otherwise, simply shift to tot-xmin???
|
||||
*/
|
||||
temp = cur->xmax - tot->xmax;
|
||||
|
||||
|
||||
if ((cur->xmin - temp) < tot->xmin) {
|
||||
/* only offset by difference from cur-min and tot-min */
|
||||
temp = cur->xmin - tot->xmin;
|
||||
|
||||
|
||||
cur->xmin -= temp;
|
||||
cur->xmax -= temp;
|
||||
}
|
||||
@@ -690,7 +690,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* height */
|
||||
if ((curheight > totheight) && !(v2d->keepzoom & (V2D_KEEPZOOM | V2D_LOCKZOOM_Y | V2D_LIMITZOOM))) {
|
||||
/* if zoom doesn't have to be maintained, just clamp edges */
|
||||
@@ -701,7 +701,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
/* This here occurs when:
|
||||
* - height too big, but maintaining zoom (i.e. heights cannot be changed)
|
||||
* - height is OK, but need to check if outside of boundaries
|
||||
*
|
||||
*
|
||||
* So, resolution is to just shift view by the gap between the extremities.
|
||||
* We favour moving the 'minimum' across, as that's origin for most things
|
||||
*/
|
||||
@@ -709,37 +709,37 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
/* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */
|
||||
temp = BLI_rctf_cent_y(tot);
|
||||
diff = curheight * 0.5f;
|
||||
|
||||
|
||||
cur->ymin = temp - diff;
|
||||
cur->ymax = temp + diff;
|
||||
}
|
||||
else if (cur->ymin < tot->ymin) {
|
||||
/* there's still space remaining, so shift up */
|
||||
temp = tot->ymin - cur->ymin;
|
||||
|
||||
|
||||
cur->ymin += temp;
|
||||
cur->ymax += temp;
|
||||
}
|
||||
else if (cur->ymax > tot->ymax) {
|
||||
/* there's still space remaining, so shift down */
|
||||
temp = cur->ymax - tot->ymax;
|
||||
|
||||
|
||||
cur->ymin -= temp;
|
||||
cur->ymax -= temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Step 4: Make sure alignment restrictions are respected */
|
||||
if (v2d->align) {
|
||||
/* If alignment flags are set (but keeptot is not), they must still be respected, as although
|
||||
* they don't specify any particular bounds to stay within, they do define ranges which are
|
||||
* they don't specify any particular bounds to stay within, they do define ranges which are
|
||||
* invalid.
|
||||
*
|
||||
* Here, we only check to make sure that on each axis, the 'cur' rect doesn't stray into these
|
||||
* Here, we only check to make sure that on each axis, the 'cur' rect doesn't stray into these
|
||||
* invalid zones, otherwise we offset.
|
||||
*/
|
||||
|
||||
|
||||
/* handle width - posx and negx flags are mutually exclusive, so watch out */
|
||||
if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
|
||||
/* width is in negative-x half */
|
||||
@@ -755,7 +755,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
v2d->cur.xmin = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* handle height - posx and negx flags are mutually exclusive, so watch out */
|
||||
if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) {
|
||||
/* height is in negative-y half */
|
||||
@@ -772,7 +772,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* set masks */
|
||||
view2d_masks(v2d, mask_scrollers);
|
||||
}
|
||||
@@ -789,11 +789,11 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
|
||||
{
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
|
||||
|
||||
/* don't continue if no view syncing to be done */
|
||||
if ((v2dcur->flag & (V2D_VIEWSYNC_SCREEN_TIME | V2D_VIEWSYNC_AREA_VERTICAL)) == 0)
|
||||
return;
|
||||
|
||||
|
||||
/* check if doing within area syncing (i.e. channels/vertical) */
|
||||
if ((v2dcur->flag & V2D_VIEWSYNC_AREA_VERTICAL) && (area)) {
|
||||
for (ar = area->regionbase.first; ar; ar = ar->next) {
|
||||
@@ -811,14 +811,14 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
|
||||
v2dcur->cur.ymin = ar->v2d.cur.ymin;
|
||||
v2dcur->cur.ymax = ar->v2d.cur.ymax;
|
||||
}
|
||||
|
||||
|
||||
/* region possibly changed, so refresh */
|
||||
ED_region_tag_redraw(ar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* check if doing whole screen syncing (i.e. time/horizontal) */
|
||||
if ((v2dcur->flag & V2D_VIEWSYNC_SCREEN_TIME) && (screen)) {
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
@@ -837,7 +837,7 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
|
||||
v2dcur->cur.xmin = ar->v2d.cur.xmin;
|
||||
v2dcur->cur.xmax = ar->v2d.cur.xmax;
|
||||
}
|
||||
|
||||
|
||||
/* region possibly changed, so refresh */
|
||||
ED_region_tag_redraw(ar);
|
||||
}
|
||||
@@ -855,11 +855,11 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
|
||||
void UI_view2d_curRect_reset(View2D *v2d)
|
||||
{
|
||||
float width, height;
|
||||
|
||||
|
||||
/* assume width and height of 'cur' rect by default, should be same size as mask */
|
||||
width = (float)(BLI_rcti_size_x(&v2d->mask) + 1);
|
||||
height = (float)(BLI_rcti_size_y(&v2d->mask) + 1);
|
||||
|
||||
|
||||
/* handle width - posx and negx flags are mutually exclusive, so watch out */
|
||||
if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
|
||||
/* width is in negative-x half */
|
||||
@@ -874,11 +874,11 @@ void UI_view2d_curRect_reset(View2D *v2d)
|
||||
else {
|
||||
/* width is centered around (x == 0) */
|
||||
const float dx = width / 2.0f;
|
||||
|
||||
|
||||
v2d->cur.xmin = -dx;
|
||||
v2d->cur.xmax = dx;
|
||||
}
|
||||
|
||||
|
||||
/* handle height - posx and negx flags are mutually exclusive, so watch out */
|
||||
if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) {
|
||||
/* height is in negative-y half */
|
||||
@@ -893,7 +893,7 @@ void UI_view2d_curRect_reset(View2D *v2d)
|
||||
else {
|
||||
/* height is centered around (y == 0) */
|
||||
const float dy = height / 2.0f;
|
||||
|
||||
|
||||
v2d->cur.ymin = -dy;
|
||||
v2d->cur.ymax = dy;
|
||||
}
|
||||
@@ -905,11 +905,11 @@ void UI_view2d_curRect_reset(View2D *v2d)
|
||||
void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resize)
|
||||
{
|
||||
// int scroll = view2d_scroll_mapped(v2d->scroll);
|
||||
|
||||
|
||||
/* don't do anything if either value is 0 */
|
||||
width = abs(width);
|
||||
height = abs(height);
|
||||
|
||||
|
||||
/* hrumf! */
|
||||
/* XXX: there are work arounds for this in the panel and file browse code. */
|
||||
/* round to int, because this is called with width + V2D_SCROLL_WIDTH */
|
||||
@@ -917,13 +917,13 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resiz
|
||||
// width -= (int)V2D_SCROLL_WIDTH;
|
||||
// if (scroll & V2D_SCROLL_VERTICAL)
|
||||
// height -= (int)V2D_SCROLL_HEIGHT;
|
||||
|
||||
|
||||
if (ELEM(0, width, height)) {
|
||||
if (G.debug & G_DEBUG)
|
||||
printf("Error: View2D totRect set exiting: v2d=%p width=%d height=%d\n", (void *)v2d, width, height); // XXX temp debug info
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* handle width - posx and negx flags are mutually exclusive, so watch out */
|
||||
if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
|
||||
/* width is in negative-x half */
|
||||
@@ -938,11 +938,11 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resiz
|
||||
else {
|
||||
/* width is centered around (x == 0) */
|
||||
const float dx = (float)width / 2.0f;
|
||||
|
||||
|
||||
v2d->tot.xmin = -dx;
|
||||
v2d->tot.xmax = dx;
|
||||
}
|
||||
|
||||
|
||||
/* handle height - posx and negx flags are mutually exclusive, so watch out */
|
||||
if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) {
|
||||
/* height is in negative-y half */
|
||||
@@ -957,14 +957,14 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resiz
|
||||
else {
|
||||
/* height is centered around (y == 0) */
|
||||
const float dy = (float)height / 2.0f;
|
||||
|
||||
|
||||
v2d->tot.ymin = -dy;
|
||||
v2d->tot.ymax = dy;
|
||||
}
|
||||
|
||||
|
||||
/* make sure that 'cur' rect is in a valid state as a result of these changes */
|
||||
ui_view2d_curRect_validate_resize(v2d, resize, 1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void UI_view2d_totRect_set(View2D *v2d, int width, int height)
|
||||
@@ -972,12 +972,12 @@ void UI_view2d_totRect_set(View2D *v2d, int width, int height)
|
||||
int scroll = view2d_scroll_mapped(v2d->scroll);
|
||||
|
||||
UI_view2d_totRect_set_resize(v2d, width, height, 0);
|
||||
|
||||
|
||||
/* solve bad recursion... if scroller state changed, mask is different, so you get different rects */
|
||||
if (scroll != view2d_scroll_mapped(v2d->scroll)) {
|
||||
UI_view2d_totRect_set_resize(v2d, width, height, 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool UI_view2d_tab_set(View2D *v2d, int tab)
|
||||
@@ -1048,21 +1048,21 @@ void UI_view2d_zoom_cache_reset(void)
|
||||
static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked)
|
||||
{
|
||||
*curmasked = v2d->cur;
|
||||
|
||||
|
||||
if (view2d_scroll_mapped(v2d->scroll)) {
|
||||
float sizex = BLI_rcti_size_x(&v2d->mask);
|
||||
float sizey = BLI_rcti_size_y(&v2d->mask);
|
||||
|
||||
|
||||
/* prevent tiny or narrow regions to get invalid coordinates - mask can get negative even... */
|
||||
if (sizex > 0.0f && sizey > 0.0f) {
|
||||
float dx = BLI_rctf_size_x(&v2d->cur) / (sizex + 1);
|
||||
float dy = BLI_rctf_size_y(&v2d->cur) / (sizey + 1);
|
||||
|
||||
|
||||
if (v2d->mask.xmin != 0)
|
||||
curmasked->xmin -= dx * (float)v2d->mask.xmin;
|
||||
if (v2d->mask.xmax + 1 != v2d->winx)
|
||||
curmasked->xmax += dx * (float)(v2d->winx - v2d->mask.xmax - 1);
|
||||
|
||||
|
||||
if (v2d->mask.ymin != 0)
|
||||
curmasked->ymin -= dy * (float)v2d->mask.ymin;
|
||||
if (v2d->mask.ymax + 1 != v2d->winy)
|
||||
@@ -1079,7 +1079,7 @@ void UI_view2d_view_ortho(View2D *v2d)
|
||||
const int sizey = BLI_rcti_size_y(&v2d->mask);
|
||||
const float eps = 0.001f;
|
||||
float xofs = 0.0f, yofs = 0.0f;
|
||||
|
||||
|
||||
/* pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1 correspondence with pixels for smooth UI drawing,
|
||||
* but only applied where requested
|
||||
*/
|
||||
@@ -1089,12 +1089,12 @@ void UI_view2d_view_ortho(View2D *v2d)
|
||||
xofs = eps * BLI_rctf_size_x(&v2d->cur) / sizex;
|
||||
if (sizey > 0)
|
||||
yofs = eps * BLI_rctf_size_y(&v2d->cur) / sizey;
|
||||
|
||||
|
||||
/* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */
|
||||
view2d_map_cur_using_mask(v2d, &curmasked);
|
||||
|
||||
BLI_rctf_translate(&curmasked, -xofs, -yofs);
|
||||
|
||||
|
||||
/* XXX ton: this flag set by outliner, for icons */
|
||||
if (v2d->flag & V2D_PIXELOFS_X) {
|
||||
curmasked.xmin = floorf(curmasked.xmin) - (eps + xofs);
|
||||
@@ -1104,7 +1104,7 @@ void UI_view2d_view_ortho(View2D *v2d)
|
||||
curmasked.ymin = floorf(curmasked.ymin) - (eps + yofs);
|
||||
curmasked.ymax = floorf(curmasked.ymax) - (eps + yofs);
|
||||
}
|
||||
|
||||
|
||||
/* set matrix on all appropriate axes */
|
||||
wmOrtho2(curmasked.xmin, curmasked.xmax, curmasked.ymin, curmasked.ymax);
|
||||
|
||||
@@ -1121,26 +1121,26 @@ void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, const bool xaxis)
|
||||
{
|
||||
rctf curmasked;
|
||||
float xofs, yofs;
|
||||
|
||||
|
||||
/* pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1 correspondence with pixels for smooth UI drawing,
|
||||
* but only applied where requested
|
||||
*/
|
||||
/* XXX temp (ton) */
|
||||
xofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_X) ? GLA_PIXEL_OFS : 0.0f;
|
||||
yofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_Y) ? GLA_PIXEL_OFS : 0.0f;
|
||||
|
||||
|
||||
/* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */
|
||||
view2d_map_cur_using_mask(v2d, &curmasked);
|
||||
|
||||
|
||||
/* only set matrix with 'cur' coordinates on relevant axes */
|
||||
if (xaxis)
|
||||
wmOrtho2(curmasked.xmin - xofs, curmasked.xmax - xofs, -yofs, ar->winy - yofs);
|
||||
else
|
||||
wmOrtho2(-xofs, ar->winx - xofs, curmasked.ymin - yofs, curmasked.ymax - yofs);
|
||||
|
||||
|
||||
/* XXX is this necessary? */
|
||||
glLoadIdentity();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Restore view matrices after drawing */
|
||||
@@ -1149,10 +1149,10 @@ void UI_view2d_view_restore(const bContext *C)
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
int width = BLI_rcti_size_x(&ar->winrct) + 1;
|
||||
int height = BLI_rcti_size_y(&ar->winrct) + 1;
|
||||
|
||||
|
||||
wmOrtho2(0.0f, (float)width, 0.0f, (float)height);
|
||||
glLoadIdentity();
|
||||
|
||||
|
||||
// ED_region_pixelspace(CTX_wm_region(C));
|
||||
}
|
||||
|
||||
@@ -1173,25 +1173,25 @@ static void step_to_grid(float *step, int *power, int unit)
|
||||
{
|
||||
const float loga = (float)log10(*step);
|
||||
float rem;
|
||||
|
||||
|
||||
*power = (int)(loga);
|
||||
|
||||
|
||||
rem = loga - (*power);
|
||||
rem = (float)pow(10.0, rem);
|
||||
|
||||
|
||||
if (loga < 0.0f) {
|
||||
if (rem < 0.2f) rem = 0.2f;
|
||||
else if (rem < 0.5f) rem = 0.5f;
|
||||
else rem = 1.0f;
|
||||
|
||||
|
||||
*step = rem * (float)pow(10.0, (*power));
|
||||
|
||||
|
||||
/* for frames, we want 1.0 frame intervals only */
|
||||
if (unit == V2D_UNIT_FRAMES) {
|
||||
rem = 1.0f;
|
||||
*step = 2.0f; /* use 2 since there are grid lines drawn in between, this way to get 1 line per frane */
|
||||
}
|
||||
|
||||
|
||||
/* prevents printing 1.0 2.0 3.0 etc */
|
||||
if (rem == 1.0f) (*power)++;
|
||||
}
|
||||
@@ -1199,9 +1199,9 @@ static void step_to_grid(float *step, int *power, int unit)
|
||||
if (rem < 2.0f) rem = 2.0f;
|
||||
else if (rem < 5.0f) rem = 5.0f;
|
||||
else rem = 10.0f;
|
||||
|
||||
|
||||
*step = rem * (float)pow(10.0, (*power));
|
||||
|
||||
|
||||
(*power)++;
|
||||
/* prevents printing 1.0, 2.0, 3.0, etc. */
|
||||
if (rem == 10.0f) (*power)++;
|
||||
@@ -1229,14 +1229,14 @@ View2DGrid *UI_view2d_grid_calc(
|
||||
|
||||
View2DGrid *grid;
|
||||
float space, seconddiv;
|
||||
|
||||
|
||||
/* check that there are at least some workable args */
|
||||
if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) && ELEM(V2D_ARG_DUMMY, yunits, yclamp))
|
||||
return NULL;
|
||||
|
||||
|
||||
/* grid here is allocated... */
|
||||
grid = MEM_callocN(sizeof(View2DGrid), "View2DGrid");
|
||||
|
||||
|
||||
/* rule: gridstep is minimal GRIDSTEP pixels */
|
||||
if (xunits == V2D_UNIT_SECONDS) {
|
||||
seconddiv = (float)(0.01 * FPS);
|
||||
@@ -1244,7 +1244,7 @@ View2DGrid *UI_view2d_grid_calc(
|
||||
else {
|
||||
seconddiv = 1.0f;
|
||||
}
|
||||
|
||||
|
||||
/* calculate x-axis grid scale (only if both args are valid) */
|
||||
if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) {
|
||||
space = BLI_rctf_size_x(&v2d->cur);
|
||||
@@ -1257,14 +1257,14 @@ View2DGrid *UI_view2d_grid_calc(
|
||||
grid->dx *= seconddiv;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (xclamp == V2D_GRID_CLAMP) {
|
||||
CLAMP_MIN(grid->dx, 0.1f);
|
||||
CLAMP_MIN(grid->powerx, 0);
|
||||
grid->powerx -= 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* calculate y-axis grid scale (only if both args are valid) */
|
||||
if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) {
|
||||
space = BLI_rctf_size_y(&v2d->cur);
|
||||
@@ -1281,7 +1281,7 @@ View2DGrid *UI_view2d_grid_calc(
|
||||
CLAMP_MIN(grid->powery, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* calculate start position */
|
||||
if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) {
|
||||
grid->startx = seconddiv * (v2d->cur.xmin / seconddiv - (float)fmod(v2d->cur.xmin / seconddiv, grid->dx / seconddiv));
|
||||
@@ -1289,14 +1289,14 @@ View2DGrid *UI_view2d_grid_calc(
|
||||
}
|
||||
else
|
||||
grid->startx = v2d->cur.xmin;
|
||||
|
||||
|
||||
if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) {
|
||||
grid->starty = (v2d->cur.ymin - (float)fmod(v2d->cur.ymin, grid->dy));
|
||||
if (v2d->cur.ymin < 0.0f) grid->starty -= grid->dy;
|
||||
}
|
||||
else
|
||||
grid->starty = v2d->cur.ymin;
|
||||
|
||||
|
||||
return grid;
|
||||
}
|
||||
|
||||
@@ -1305,7 +1305,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
|
||||
{
|
||||
float vec1[2], vec2[2];
|
||||
int a, step;
|
||||
|
||||
|
||||
/* check for grid first, as it may not exist */
|
||||
if (grid == NULL)
|
||||
return;
|
||||
@@ -1318,82 +1318,82 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
|
||||
vec1[0] = vec2[0] = grid->startx;
|
||||
vec1[1] = grid->starty;
|
||||
vec2[1] = v2d->cur.ymax;
|
||||
|
||||
|
||||
/* minor gridlines */
|
||||
step = (BLI_rcti_size_x(&v2d->mask) + 1) / (U.v2d_min_gridsize * UI_DPI_FAC);
|
||||
UI_ThemeColor(TH_GRID);
|
||||
|
||||
|
||||
for (a = 0; a < step; a++) {
|
||||
glVertex2fv(vec1);
|
||||
glVertex2fv(vec2);
|
||||
|
||||
|
||||
vec2[0] = vec1[0] += grid->dx;
|
||||
}
|
||||
|
||||
|
||||
/* major gridlines */
|
||||
vec2[0] = vec1[0] -= 0.5f * grid->dx;
|
||||
UI_ThemeColorShade(TH_GRID, 16);
|
||||
|
||||
|
||||
step++;
|
||||
for (a = 0; a <= step; a++) {
|
||||
glVertex2fv(vec1);
|
||||
glVertex2fv(vec2);
|
||||
|
||||
|
||||
vec2[0] = vec1[0] -= grid->dx;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* horizontal lines */
|
||||
if (flag & V2D_HORIZONTAL_LINES) {
|
||||
/* only major gridlines */
|
||||
vec1[1] = vec2[1] = grid->starty;
|
||||
vec1[0] = grid->startx;
|
||||
vec2[0] = v2d->cur.xmax;
|
||||
|
||||
|
||||
step = (BLI_rcti_size_y(&v2d->mask) + 1) / (U.v2d_min_gridsize * UI_DPI_FAC);
|
||||
|
||||
|
||||
UI_ThemeColor(TH_GRID);
|
||||
for (a = 0; a <= step; a++) {
|
||||
glVertex2fv(vec1);
|
||||
glVertex2fv(vec2);
|
||||
|
||||
|
||||
vec2[1] = vec1[1] += grid->dy;
|
||||
}
|
||||
|
||||
|
||||
/* fine grid lines */
|
||||
vec2[1] = vec1[1] -= 0.5f * grid->dy;
|
||||
step++;
|
||||
|
||||
|
||||
if (flag & V2D_HORIZONTAL_FINELINES) {
|
||||
UI_ThemeColorShade(TH_GRID, 16);
|
||||
for (a = 0; a < step; a++) {
|
||||
glVertex2fv(vec1);
|
||||
glVertex2fv(vec2);
|
||||
|
||||
|
||||
vec2[1] = vec1[1] -= grid->dy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Axes are drawn as darker lines */
|
||||
UI_ThemeColorShade(TH_GRID, -50);
|
||||
|
||||
|
||||
/* horizontal axis */
|
||||
if (flag & V2D_HORIZONTAL_AXIS) {
|
||||
vec1[0] = v2d->cur.xmin;
|
||||
vec2[0] = v2d->cur.xmax;
|
||||
vec1[1] = vec2[1] = 0.0f;
|
||||
|
||||
|
||||
glVertex2fv(vec1);
|
||||
glVertex2fv(vec2);
|
||||
}
|
||||
|
||||
|
||||
/* vertical axis */
|
||||
if (flag & V2D_VERTICAL_AXIS) {
|
||||
vec1[1] = v2d->cur.ymin;
|
||||
vec2[1] = v2d->cur.ymax;
|
||||
vec1[0] = vec2[0] = 0.0f;
|
||||
|
||||
|
||||
glVertex2fv(vec1);
|
||||
glVertex2fv(vec2);
|
||||
}
|
||||
@@ -1407,9 +1407,9 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step)
|
||||
float start;
|
||||
|
||||
UI_ThemeColorShade(TH_BACK, -10);
|
||||
|
||||
|
||||
start = v2d->cur.xmin - (float)fmod(v2d->cur.xmin, step);
|
||||
|
||||
|
||||
glBegin(GL_LINES);
|
||||
for (; start < v2d->cur.xmax; start += step) {
|
||||
glVertex2f(start, v2d->cur.ymin);
|
||||
@@ -1421,14 +1421,14 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step)
|
||||
glVertex2f(v2d->cur.xmin, start);
|
||||
glVertex2f(v2d->cur.xmax, start);
|
||||
}
|
||||
|
||||
|
||||
/* X and Y axis */
|
||||
UI_ThemeColorShade(TH_BACK, -18);
|
||||
glVertex2f(0.0f, v2d->cur.ymin);
|
||||
glVertex2f(0.0f, v2d->cur.ymax);
|
||||
glVertex2f(v2d->cur.xmin, 0.0f);
|
||||
glVertex2f(v2d->cur.xmax, 0.0f);
|
||||
|
||||
|
||||
glEnd();
|
||||
}
|
||||
|
||||
@@ -1443,12 +1443,12 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s
|
||||
for (level = 0; level < totlevels; ++level) {
|
||||
int i;
|
||||
float start;
|
||||
|
||||
|
||||
UI_ThemeColorShade(colorid, offset);
|
||||
|
||||
|
||||
i = (v2d->cur.xmin >= 0.0f ? -(int)(-v2d->cur.xmin / lstep) : (int)(v2d->cur.xmin / lstep));
|
||||
start = i * lstep;
|
||||
|
||||
|
||||
glBegin(GL_LINES);
|
||||
for (; start < v2d->cur.xmax; start += lstep, ++i) {
|
||||
if (i == 0 || (level < totlevels - 1 && i % level_size == 0))
|
||||
@@ -1456,26 +1456,26 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s
|
||||
glVertex2f(start, v2d->cur.ymin);
|
||||
glVertex2f(start, v2d->cur.ymax);
|
||||
}
|
||||
|
||||
|
||||
i = (v2d->cur.ymin >= 0.0f ? -(int)(-v2d->cur.ymin / lstep) : (int)(v2d->cur.ymin / lstep));
|
||||
start = i * lstep;
|
||||
|
||||
|
||||
for (; start < v2d->cur.ymax; start += lstep, ++i) {
|
||||
if (i == 0 || (level < totlevels - 1 && i % level_size == 0))
|
||||
continue;
|
||||
glVertex2f(v2d->cur.xmin, start);
|
||||
glVertex2f(v2d->cur.xmax, start);
|
||||
}
|
||||
|
||||
|
||||
/* X and Y axis */
|
||||
UI_ThemeColorShade(colorid, offset - 8);
|
||||
glVertex2f(0.0f, v2d->cur.ymin);
|
||||
glVertex2f(0.0f, v2d->cur.ymax);
|
||||
glVertex2f(v2d->cur.xmin, 0.0f);
|
||||
glVertex2f(v2d->cur.xmax, 0.0f);
|
||||
|
||||
|
||||
glEnd();
|
||||
|
||||
|
||||
lstep *= level_size;
|
||||
offset -= 6;
|
||||
}
|
||||
@@ -1510,10 +1510,10 @@ struct View2DScrollers {
|
||||
/* focus bubbles */
|
||||
int vert_min, vert_max; /* vertical scrollbar */
|
||||
int hor_min, hor_max; /* horizontal scrollbar */
|
||||
|
||||
|
||||
rcti hor, vert; /* exact size of slider backdrop */
|
||||
int horfull, vertfull; /* set if sliders are full, we don't draw them */
|
||||
|
||||
|
||||
/* scales */
|
||||
View2DGrid *grid; /* grid for coordinate drawing */
|
||||
short xunits, xclamp; /* units and clamping options for x-axis */
|
||||
@@ -1530,13 +1530,13 @@ View2DScrollers *UI_view2d_scrollers_calc(
|
||||
float fac1, fac2, totsize, scrollsize;
|
||||
int scroll = view2d_scroll_mapped(v2d->scroll);
|
||||
int smaller;
|
||||
|
||||
|
||||
/* scrollers is allocated here... */
|
||||
scrollers = MEM_callocN(sizeof(View2DScrollers), "View2DScrollers");
|
||||
|
||||
|
||||
vert = v2d->vert;
|
||||
hor = v2d->hor;
|
||||
|
||||
|
||||
/* slider rects need to be smaller than region */
|
||||
smaller = (int)(0.2f * U.widget_unit);
|
||||
hor.xmin += smaller;
|
||||
@@ -1545,26 +1545,26 @@ View2DScrollers *UI_view2d_scrollers_calc(
|
||||
hor.ymin += smaller;
|
||||
else
|
||||
hor.ymax -= smaller;
|
||||
|
||||
|
||||
if (scroll & V2D_SCROLL_LEFT)
|
||||
vert.xmin += smaller;
|
||||
else
|
||||
vert.xmax -= smaller;
|
||||
vert.ymin += smaller;
|
||||
vert.ymax -= smaller;
|
||||
|
||||
|
||||
CLAMP(vert.ymin, vert.ymin, vert.ymax - V2D_SCROLLER_HANDLE_SIZE);
|
||||
CLAMP(hor.xmin, hor.xmin, hor.xmax - V2D_SCROLLER_HANDLE_SIZE);
|
||||
|
||||
|
||||
/* store in scrollers, used for drawing */
|
||||
scrollers->vert = vert;
|
||||
scrollers->hor = hor;
|
||||
|
||||
|
||||
/* scroller 'buttons':
|
||||
* - These should always remain within the visible region of the scrollbar
|
||||
* - They represent the region of 'tot' that is visible in 'cur'
|
||||
*/
|
||||
|
||||
|
||||
/* horizontal scrollers */
|
||||
if (scroll & V2D_SCROLL_HORIZONTAL) {
|
||||
/* scroller 'button' extents */
|
||||
@@ -1577,15 +1577,15 @@ View2DScrollers *UI_view2d_scrollers_calc(
|
||||
scrollers->hor_min = hor.xmin;
|
||||
else
|
||||
scrollers->hor_min = (int)(hor.xmin + (fac1 * scrollsize));
|
||||
|
||||
|
||||
fac2 = (v2d->cur.xmax - v2d->tot.xmin) / totsize;
|
||||
if (fac2 >= 1.0f)
|
||||
scrollers->hor_max = hor.xmax;
|
||||
else
|
||||
scrollers->hor_max = (int)(hor.xmin + (fac2 * scrollsize));
|
||||
|
||||
|
||||
/* prevent inverted sliders */
|
||||
if (scrollers->hor_min > scrollers->hor_max)
|
||||
if (scrollers->hor_min > scrollers->hor_max)
|
||||
scrollers->hor_min = scrollers->hor_max;
|
||||
/* prevent sliders from being too small, and disappearing */
|
||||
if ((scrollers->hor_max - scrollers->hor_min) < V2D_SCROLLER_HANDLE_SIZE) {
|
||||
@@ -1594,9 +1594,9 @@ View2DScrollers *UI_view2d_scrollers_calc(
|
||||
CLAMP(scrollers->hor_max, hor.xmin + V2D_SCROLLER_HANDLE_SIZE, hor.xmax);
|
||||
CLAMP(scrollers->hor_min, hor.xmin, hor.xmax - V2D_SCROLLER_HANDLE_SIZE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* vertical scrollers */
|
||||
if (scroll & V2D_SCROLL_VERTICAL) {
|
||||
/* scroller 'button' extents */
|
||||
@@ -1609,27 +1609,27 @@ View2DScrollers *UI_view2d_scrollers_calc(
|
||||
scrollers->vert_min = vert.ymin;
|
||||
else
|
||||
scrollers->vert_min = (int)(vert.ymin + (fac1 * scrollsize));
|
||||
|
||||
|
||||
fac2 = (v2d->cur.ymax - v2d->tot.ymin) / totsize;
|
||||
if (fac2 >= 1.0f)
|
||||
scrollers->vert_max = vert.ymax;
|
||||
else
|
||||
scrollers->vert_max = (int)(vert.ymin + (fac2 * scrollsize));
|
||||
|
||||
|
||||
/* prevent inverted sliders */
|
||||
if (scrollers->vert_min > scrollers->vert_max)
|
||||
if (scrollers->vert_min > scrollers->vert_max)
|
||||
scrollers->vert_min = scrollers->vert_max;
|
||||
/* prevent sliders from being too small, and disappearing */
|
||||
if ((scrollers->vert_max - scrollers->vert_min) < V2D_SCROLLER_HANDLE_SIZE) {
|
||||
|
||||
|
||||
scrollers->vert_max = scrollers->vert_min + V2D_SCROLLER_HANDLE_SIZE;
|
||||
|
||||
|
||||
CLAMP(scrollers->vert_max, vert.ymin + V2D_SCROLLER_HANDLE_SIZE, vert.ymax);
|
||||
CLAMP(scrollers->vert_min, vert.ymin, vert.ymax - V2D_SCROLLER_HANDLE_SIZE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* grid markings on scrollbars */
|
||||
if (scroll & (V2D_SCROLL_SCALE_HORIZONTAL | V2D_SCROLL_SCALE_VERTICAL)) {
|
||||
/* store clamping */
|
||||
@@ -1637,12 +1637,12 @@ View2DScrollers *UI_view2d_scrollers_calc(
|
||||
scrollers->xunits = xunits;
|
||||
scrollers->yclamp = yclamp;
|
||||
scrollers->yunits = yunits;
|
||||
|
||||
|
||||
scrollers->grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d,
|
||||
xunits, xclamp, yunits, yclamp,
|
||||
BLI_rcti_size_x(&hor), BLI_rcti_size_y(&vert));
|
||||
}
|
||||
|
||||
|
||||
/* return scrollers */
|
||||
return scrollers;
|
||||
}
|
||||
@@ -1652,11 +1652,11 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power
|
||||
{
|
||||
int len;
|
||||
char timecode_str[32];
|
||||
|
||||
|
||||
/* adjust the scale unit to work ok */
|
||||
if (dir == 'v') {
|
||||
/* here we bump up the power by factor of 10, as
|
||||
* rotation values (hence 'degrees') are divided by 10 to
|
||||
/* here we bump up the power by factor of 10, as
|
||||
* rotation values (hence 'degrees') are divided by 10 to
|
||||
* be able to show the curves at the same time
|
||||
*/
|
||||
if (ELEM(unit, V2D_UNIT_DEGREES, V2D_UNIT_TIME)) {
|
||||
@@ -1664,7 +1664,7 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power
|
||||
val *= 10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* get string to print */
|
||||
if (unit == V2D_UNIT_SECONDS) {
|
||||
/* not neces*/
|
||||
@@ -1673,7 +1673,7 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power
|
||||
else {
|
||||
BLI_timecode_string_from_time_seconds(timecode_str, sizeof(timecode_str), power, val);
|
||||
}
|
||||
|
||||
|
||||
/* get length of string, and adjust printing location to fit it into the horizontal scrollbar */
|
||||
len = strlen(timecode_str);
|
||||
if (dir == 'h') {
|
||||
@@ -1683,13 +1683,13 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power
|
||||
else
|
||||
x -= 4 * len;
|
||||
}
|
||||
|
||||
|
||||
/* Add degree sympbol to end of string for vertical scrollbar? */
|
||||
if ((dir == 'v') && (unit == V2D_UNIT_DEGREES)) {
|
||||
timecode_str[len] = 186;
|
||||
timecode_str[len + 1] = 0;
|
||||
}
|
||||
|
||||
|
||||
/* draw it */
|
||||
BLF_draw_default_ascii(x, y, 0.0f, timecode_str, sizeof(timecode_str));
|
||||
}
|
||||
@@ -1700,11 +1700,11 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
rcti vert, hor;
|
||||
int scroll = view2d_scroll_mapped(v2d->scroll);
|
||||
|
||||
|
||||
/* make copies of rects for less typing */
|
||||
vert = vs->vert;
|
||||
hor = vs->hor;
|
||||
|
||||
|
||||
/* horizontal scrollbar */
|
||||
if (scroll & V2D_SCROLL_HORIZONTAL) {
|
||||
bTheme *btheme = UI_GetTheme();
|
||||
@@ -1712,19 +1712,19 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
rcti slider;
|
||||
int state;
|
||||
unsigned char col[4];
|
||||
|
||||
|
||||
slider.xmin = vs->hor_min;
|
||||
slider.xmax = vs->hor_max;
|
||||
slider.ymin = hor.ymin;
|
||||
slider.ymax = hor.ymax;
|
||||
|
||||
|
||||
state = (v2d->scroll_ui & V2D_SCROLL_H_ACTIVE) ? UI_SCROLL_PRESSED : 0;
|
||||
|
||||
|
||||
/* show zoom handles if:
|
||||
* - zooming on x-axis is allowed (no scroll otherwise)
|
||||
* - slider bubble is large enough (no overdraw confusion)
|
||||
* - scale is shown on the scroller
|
||||
* (workaround to make sure that button windows don't show these,
|
||||
* - scale is shown on the scroller
|
||||
* (workaround to make sure that button windows don't show these,
|
||||
* and only the time-grids with their zoomability can do so)
|
||||
*/
|
||||
if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 &&
|
||||
@@ -1733,35 +1733,35 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
{
|
||||
state |= UI_SCROLL_ARROWS;
|
||||
}
|
||||
|
||||
|
||||
/* clean rect behind slider, but not with transparent background */
|
||||
UI_GetThemeColor4ubv(TH_BACK, col);
|
||||
if (col[3] == 255) {
|
||||
glColor3ub(col[0], col[1], col[2]);
|
||||
glRecti(v2d->hor.xmin, v2d->hor.ymin, v2d->hor.xmax, v2d->hor.ymax);
|
||||
}
|
||||
|
||||
|
||||
UI_draw_widget_scroll(&wcol, &hor, &slider, state);
|
||||
|
||||
|
||||
/* scale indicators */
|
||||
if ((scroll & V2D_SCROLL_SCALE_HORIZONTAL) && (vs->grid)) {
|
||||
View2DGrid *grid = vs->grid;
|
||||
float fac, dfac, fac2, val;
|
||||
|
||||
/* the numbers: convert grid->startx and -dx to scroll coordinates
|
||||
|
||||
/* the numbers: convert grid->startx and -dx to scroll coordinates
|
||||
* - fac is x-coordinate to draw to
|
||||
* - dfac is gap between scale markings
|
||||
*/
|
||||
fac = (grid->startx - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
|
||||
fac = (float)hor.xmin + fac * BLI_rcti_size_x(&hor);
|
||||
|
||||
|
||||
dfac = grid->dx / BLI_rctf_size_x(&v2d->cur);
|
||||
dfac = dfac * BLI_rcti_size_x(&hor);
|
||||
|
||||
|
||||
/* set starting value, and text color */
|
||||
UI_ThemeColor(TH_TEXT);
|
||||
val = grid->startx;
|
||||
|
||||
|
||||
/* if we're clamping to whole numbers only, make sure entries won't be repeated */
|
||||
if (vs->xclamp == V2D_GRID_CLAMP) {
|
||||
while (grid->dx < 0.9999f) {
|
||||
@@ -1771,31 +1771,31 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
}
|
||||
if (vs->xunits == V2D_UNIT_FRAMES)
|
||||
grid->powerx = 1;
|
||||
|
||||
|
||||
/* draw numbers in the appropriate range */
|
||||
if (dfac > 0.0f) {
|
||||
float h = 0.1f * UI_UNIT_Y + (float)(hor.ymin);
|
||||
|
||||
|
||||
for (; fac < hor.xmax - 0.5f * U.widget_unit; fac += dfac, val += grid->dx) {
|
||||
|
||||
|
||||
/* make prints look nicer for scrollers */
|
||||
if (fac < hor.xmin + 0.5f * U.widget_unit)
|
||||
continue;
|
||||
|
||||
|
||||
switch (vs->xunits) {
|
||||
case V2D_UNIT_FRAMES: /* frames (as whole numbers)*/
|
||||
scroll_printstr(scene, fac, h, val, grid->powerx, V2D_UNIT_FRAMES, 'h');
|
||||
break;
|
||||
|
||||
|
||||
case V2D_UNIT_FRAMESCALE: /* frames (not always as whole numbers) */
|
||||
scroll_printstr(scene, fac, h, val, grid->powerx, V2D_UNIT_FRAMESCALE, 'h');
|
||||
break;
|
||||
|
||||
|
||||
case V2D_UNIT_SECONDS: /* seconds */
|
||||
fac2 = val / (float)FPS;
|
||||
scroll_printstr(scene, fac, h, fac2, grid->powerx, V2D_UNIT_SECONDS, 'h');
|
||||
break;
|
||||
|
||||
|
||||
case V2D_UNIT_DEGREES: /* Graph Editor for rotation Drivers */
|
||||
/* HACK: although we're drawing horizontal, we make this draw as 'vertical', just to get degree signs */
|
||||
scroll_printstr(scene, fac, h, val, grid->powerx, V2D_UNIT_DEGREES, 'v');
|
||||
@@ -1805,7 +1805,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* vertical scrollbar */
|
||||
if (scroll & V2D_SCROLL_VERTICAL) {
|
||||
bTheme *btheme = UI_GetTheme();
|
||||
@@ -1813,19 +1813,19 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
rcti slider;
|
||||
int state;
|
||||
unsigned char col[4];
|
||||
|
||||
|
||||
slider.xmin = vert.xmin;
|
||||
slider.xmax = vert.xmax;
|
||||
slider.ymin = vs->vert_min;
|
||||
slider.ymax = vs->vert_max;
|
||||
|
||||
|
||||
state = (v2d->scroll_ui & V2D_SCROLL_V_ACTIVE) ? UI_SCROLL_PRESSED : 0;
|
||||
|
||||
|
||||
/* show zoom handles if:
|
||||
* - zooming on y-axis is allowed (no scroll otherwise)
|
||||
* - slider bubble is large enough (no overdraw confusion)
|
||||
* - scale is shown on the scroller
|
||||
* (workaround to make sure that button windows don't show these,
|
||||
* - scale is shown on the scroller
|
||||
* (workaround to make sure that button windows don't show these,
|
||||
* and only the time-grids with their zoomability can do so)
|
||||
*/
|
||||
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0 &&
|
||||
@@ -1834,23 +1834,23 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
{
|
||||
state |= UI_SCROLL_ARROWS;
|
||||
}
|
||||
|
||||
|
||||
/* clean rect behind slider, but not with transparent background */
|
||||
UI_GetThemeColor4ubv(TH_BACK, col);
|
||||
if (col[3] == 255) {
|
||||
glColor3ub(col[0], col[1], col[2]);
|
||||
glRecti(v2d->vert.xmin, v2d->vert.ymin, v2d->vert.xmax, v2d->vert.ymax);
|
||||
}
|
||||
|
||||
|
||||
UI_draw_widget_scroll(&wcol, &vert, &slider, state);
|
||||
|
||||
|
||||
|
||||
|
||||
/* scale indiators */
|
||||
if ((scroll & V2D_SCROLL_SCALE_VERTICAL) && (vs->grid)) {
|
||||
View2DGrid *grid = vs->grid;
|
||||
float fac, dfac, val;
|
||||
|
||||
/* the numbers: convert grid->starty and dy to scroll coordinates
|
||||
|
||||
/* the numbers: convert grid->starty and dy to scroll coordinates
|
||||
* - fac is y-coordinate to draw to
|
||||
* - dfac is gap between scale markings
|
||||
* - these involve a correction for horizontal scrollbar
|
||||
@@ -1858,38 +1858,38 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
*/
|
||||
fac = (grid->starty - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
|
||||
fac = vert.ymin + fac * BLI_rcti_size_y(&vert);
|
||||
|
||||
|
||||
dfac = grid->dy / BLI_rctf_size_y(&v2d->cur);
|
||||
dfac = dfac * BLI_rcti_size_y(&vert);
|
||||
|
||||
|
||||
/* set starting value, and text color */
|
||||
UI_ThemeColor(TH_TEXT);
|
||||
val = grid->starty;
|
||||
|
||||
|
||||
/* if vertical clamping (to whole numbers) is used (i.e. in Sequencer), apply correction */
|
||||
if (vs->yclamp == V2D_GRID_CLAMP)
|
||||
fac += 0.5f * dfac;
|
||||
|
||||
|
||||
/* draw vertical steps */
|
||||
if (dfac > 0.0f) {
|
||||
|
||||
|
||||
BLF_rotation_default(M_PI_2);
|
||||
BLF_enable_default(BLF_ROTATION);
|
||||
|
||||
for (; fac < vert.ymax - 10; fac += dfac, val += grid->dy) {
|
||||
|
||||
|
||||
/* make prints look nicer for scrollers */
|
||||
if (fac < vert.ymin + 10)
|
||||
continue;
|
||||
|
||||
|
||||
scroll_printstr(scene, (float)(vert.xmax) - 2.0f, fac, val, grid->powery, vs->yunits, 'v');
|
||||
}
|
||||
|
||||
|
||||
BLF_disable_default(BLF_ROTATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* free temporary memory used for drawing scrollers */
|
||||
@@ -1932,21 +1932,21 @@ void UI_view2d_listview_cell_to_view(
|
||||
rect->ymin = rect->ymax = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* x-coordinates */
|
||||
rect->xmin = startx + (float)(columnwidth * column);
|
||||
rect->xmax = startx + (float)(columnwidth * (column + 1));
|
||||
|
||||
|
||||
if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
|
||||
/* simply negate the values for the coordinates if in negative half */
|
||||
rect->xmin = -rect->xmin;
|
||||
rect->xmax = -rect->xmax;
|
||||
}
|
||||
|
||||
|
||||
/* y-coordinates */
|
||||
rect->ymin = starty + (float)(rowheight * row);
|
||||
rect->ymax = starty + (float)(rowheight * (row + 1));
|
||||
|
||||
|
||||
if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) {
|
||||
/* simply negate the values for the coordinates if in negative half */
|
||||
rect->ymin = -rect->ymin;
|
||||
@@ -1972,21 +1972,21 @@ void UI_view2d_listview_view_to_cell(
|
||||
/* adjust view coordinates to be all positive ints, corrected for the start offset */
|
||||
const int x = (int)(floorf(fabsf(viewx) + 0.5f) - startx);
|
||||
const int y = (int)(floorf(fabsf(viewy) + 0.5f) - starty);
|
||||
|
||||
|
||||
/* sizes must not be negative */
|
||||
if ((v2d == NULL) || ((columnwidth <= 0) && (rowheight <= 0))) {
|
||||
if (column) *column = 0;
|
||||
if (row) *row = 0;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* get column */
|
||||
if ((column) && (columnwidth > 0))
|
||||
*column = x / columnwidth;
|
||||
else if (column)
|
||||
*column = 0;
|
||||
|
||||
|
||||
/* get row */
|
||||
if ((row) && (rowheight > 0))
|
||||
*row = y / rowheight;
|
||||
@@ -2008,11 +2008,11 @@ void UI_view2d_listview_visible_cells(
|
||||
/* using 'cur' rect coordinates, call the cell-getting function to get the cells for this */
|
||||
if (v2d) {
|
||||
/* min */
|
||||
UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty,
|
||||
UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty,
|
||||
v2d->cur.xmin, v2d->cur.ymin, column_min, row_min);
|
||||
|
||||
/* max*/
|
||||
UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty,
|
||||
UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty,
|
||||
v2d->cur.xmax, v2d->cur.ymax, column_max, row_max);
|
||||
}
|
||||
}
|
||||
@@ -2073,7 +2073,7 @@ bool UI_view2d_view_to_region_clip(View2D *v2d, float x, float y, int *r_region_
|
||||
/* express given coordinates as proportional values */
|
||||
x = (x - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
|
||||
y = (y - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
|
||||
|
||||
|
||||
/* check if values are within bounds */
|
||||
if ((x >= 0.0f) && (x <= 1.0f) && (y >= 0.0f) && (y <= 1.0f)) {
|
||||
*r_region_x = (int)(v2d->mask.xmin + (x * BLI_rcti_size_x(&v2d->mask)));
|
||||
@@ -2225,7 +2225,7 @@ View2D *UI_view2d_fromcontext_rwin(const bContext *C)
|
||||
*
|
||||
* \param x, y: scale on each axis
|
||||
*/
|
||||
void UI_view2d_scale_get(View2D *v2d, float *x, float *y)
|
||||
void UI_view2d_scale_get(View2D *v2d, float *x, float *y)
|
||||
{
|
||||
if (x) *x = BLI_rcti_size_x(&v2d->mask) / BLI_rctf_size_x(&v2d->cur);
|
||||
if (y) *y = BLI_rcti_size_y(&v2d->mask) / BLI_rctf_size_y(&v2d->cur);
|
||||
@@ -2301,11 +2301,11 @@ short UI_view2d_mouse_in_scrollers(const bContext *C, View2D *v2d, int x, int y)
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
int co[2];
|
||||
int scroll = view2d_scroll_mapped(v2d->scroll);
|
||||
|
||||
|
||||
/* clamp x,y to region-coordinates first */
|
||||
co[0] = x - ar->winrct.xmin;
|
||||
co[1] = y - ar->winrct.ymin;
|
||||
|
||||
|
||||
/* check if within scrollbars */
|
||||
if (scroll & V2D_SCROLL_HORIZONTAL) {
|
||||
if (IN_2D_HORIZ_SCROLL(v2d, co)) return 'h';
|
||||
@@ -2313,7 +2313,7 @@ short UI_view2d_mouse_in_scrollers(const bContext *C, View2D *v2d, int x, int y)
|
||||
if (scroll & V2D_SCROLL_VERTICAL) {
|
||||
if (IN_2D_VERT_SCROLL(v2d, co)) return 'v';
|
||||
}
|
||||
|
||||
|
||||
/* not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -2342,7 +2342,7 @@ void UI_view2d_text_cache_add(
|
||||
const char *str, size_t str_len, const char col[4])
|
||||
{
|
||||
int mval[2];
|
||||
|
||||
|
||||
BLI_assert(str_len == strlen(str));
|
||||
|
||||
if (UI_view2d_view_to_region_clip(v2d, x, y, &mval[0], &mval[1])) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Contributor(s): Blender Foundation, Joshua Leung
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
@@ -73,7 +73,7 @@ static int view2d_poll(bContext *C)
|
||||
*/
|
||||
|
||||
/* ------------------ Shared 'core' stuff ---------------------- */
|
||||
|
||||
|
||||
/* temp customdata for operator */
|
||||
typedef struct v2dViewPanData {
|
||||
bScreen *sc; /* screen where view pan was initiated */
|
||||
@@ -87,10 +87,10 @@ typedef struct v2dViewPanData {
|
||||
int startx, starty; /* mouse x/y values in window when operator was initiated */
|
||||
int lastx, lasty; /* previous x/y values of mouse in window */
|
||||
int invoke_event; /* event starting pan, for modal exit */
|
||||
|
||||
|
||||
short in_scroller; /* for MMB in scrollers (old feature in past, but now not that useful) */
|
||||
} v2dViewPanData;
|
||||
|
||||
|
||||
/* initialize panning customdata */
|
||||
static int view_pan_init(bContext *C, wmOperator *op)
|
||||
{
|
||||
@@ -98,32 +98,32 @@ static int view_pan_init(bContext *C, wmOperator *op)
|
||||
v2dViewPanData *vpd;
|
||||
View2D *v2d;
|
||||
float winx, winy;
|
||||
|
||||
|
||||
/* regions now have v2d-data by default, so check for region */
|
||||
if (ar == NULL)
|
||||
return 0;
|
||||
|
||||
|
||||
/* check if panning is allowed at all */
|
||||
v2d = &ar->v2d;
|
||||
if ((v2d->keepofs & V2D_LOCKOFS_X) && (v2d->keepofs & V2D_LOCKOFS_Y))
|
||||
return 0;
|
||||
|
||||
|
||||
/* set custom-data for operator */
|
||||
vpd = MEM_callocN(sizeof(v2dViewPanData), "v2dViewPanData");
|
||||
op->customdata = vpd;
|
||||
|
||||
|
||||
/* set pointers to owners */
|
||||
vpd->sc = CTX_wm_screen(C);
|
||||
vpd->sa = CTX_wm_area(C);
|
||||
vpd->v2d = v2d;
|
||||
vpd->ar = ar;
|
||||
|
||||
|
||||
/* calculate translation factor - based on size of view */
|
||||
winx = (float)(BLI_rcti_size_x(&ar->winrct) + 1);
|
||||
winy = (float)(BLI_rcti_size_y(&ar->winrct) + 1);
|
||||
vpd->facx = (BLI_rctf_size_x(&v2d->cur)) / winx;
|
||||
vpd->facy = (BLI_rctf_size_y(&v2d->cur)) / winy;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -151,11 +151,11 @@ static int view_pan_poll(bContext *C)
|
||||
static void view_pan_apply_ex(bContext *C, v2dViewPanData *vpd, float dx, float dy)
|
||||
{
|
||||
View2D *v2d = vpd->v2d;
|
||||
|
||||
|
||||
/* calculate amount to move view by */
|
||||
dx *= vpd->facx;
|
||||
dy *= vpd->facy;
|
||||
|
||||
|
||||
/* only move view on an axis if change is allowed */
|
||||
if ((v2d->keepofs & V2D_LOCKOFS_X) == 0) {
|
||||
v2d->cur.xmin += dx;
|
||||
@@ -165,16 +165,16 @@ static void view_pan_apply_ex(bContext *C, v2dViewPanData *vpd, float dx, float
|
||||
v2d->cur.ymin += dy;
|
||||
v2d->cur.ymax += dy;
|
||||
}
|
||||
|
||||
|
||||
/* validate that view is in valid configuration after this operation */
|
||||
UI_view2d_curRect_validate(v2d);
|
||||
|
||||
|
||||
/* request updates to be done... */
|
||||
ED_region_tag_redraw(vpd->ar);
|
||||
WM_event_add_mousemove(C);
|
||||
|
||||
|
||||
UI_view2d_sync(vpd->sc, vpd->sa, v2d, V2D_LOCK_COPY);
|
||||
|
||||
|
||||
/* exceptions */
|
||||
if (vpd->sa->spacetype == SPACE_OUTLINER) {
|
||||
/* don't rebuild full tree, since we're just changing our view */
|
||||
@@ -200,8 +200,8 @@ static void view_pan_exit(wmOperator *op)
|
||||
MEM_freeN(op->customdata);
|
||||
op->customdata = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ------------------ Modal Drag Version (1) ---------------------- */
|
||||
|
||||
/* for 'redo' only, with no user input */
|
||||
@@ -209,7 +209,7 @@ static int view_pan_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
if (!view_pan_init(C, op))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
|
||||
view_pan_apply(C, op);
|
||||
view_pan_exit(op);
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -221,38 +221,38 @@ static int view_pan_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
wmWindow *window = CTX_wm_window(C);
|
||||
v2dViewPanData *vpd;
|
||||
View2D *v2d;
|
||||
|
||||
|
||||
/* set up customdata */
|
||||
if (!view_pan_init(C, op))
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
|
||||
|
||||
vpd = op->customdata;
|
||||
v2d = vpd->v2d;
|
||||
|
||||
|
||||
/* set initial settings */
|
||||
vpd->startx = vpd->lastx = event->x;
|
||||
vpd->starty = vpd->lasty = event->y;
|
||||
vpd->invoke_event = event->type;
|
||||
|
||||
|
||||
if (event->type == MOUSEPAN) {
|
||||
RNA_int_set(op->ptr, "deltax", event->prevx - event->x);
|
||||
RNA_int_set(op->ptr, "deltay", event->prevy - event->y);
|
||||
|
||||
|
||||
view_pan_apply(C, op);
|
||||
view_pan_exit(op);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
||||
RNA_int_set(op->ptr, "deltax", 0);
|
||||
RNA_int_set(op->ptr, "deltay", 0);
|
||||
|
||||
|
||||
if (v2d->keepofs & V2D_LOCKOFS_X)
|
||||
WM_cursor_modal_set(window, BC_NS_SCROLLCURSOR);
|
||||
else if (v2d->keepofs & V2D_LOCKOFS_Y)
|
||||
WM_cursor_modal_set(window, BC_EW_SCROLLCURSOR);
|
||||
else
|
||||
WM_cursor_modal_set(window, BC_NSEW_SCROLLCURSOR);
|
||||
|
||||
|
||||
/* add temp handler */
|
||||
WM_event_add_modal_handler(C, op);
|
||||
|
||||
@@ -263,7 +263,7 @@ static int view_pan_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
v2dViewPanData *vpd = op->customdata;
|
||||
|
||||
|
||||
/* execute the events */
|
||||
switch (event->type) {
|
||||
case MOUSEMOVE:
|
||||
@@ -271,10 +271,10 @@ static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
/* calculate new delta transform, then store mouse-coordinates for next-time */
|
||||
RNA_int_set(op->ptr, "deltax", (vpd->lastx - event->x));
|
||||
RNA_int_set(op->ptr, "deltay", (vpd->lasty - event->y));
|
||||
|
||||
|
||||
vpd->lastx = event->x;
|
||||
vpd->lasty = event->y;
|
||||
|
||||
|
||||
view_pan_apply(C, op);
|
||||
break;
|
||||
}
|
||||
@@ -286,7 +286,7 @@ static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
/* calculate overall delta mouse-movement for redo */
|
||||
RNA_int_set(op->ptr, "deltax", (vpd->startx - vpd->lastx));
|
||||
RNA_int_set(op->ptr, "deltay", (vpd->starty - vpd->lasty));
|
||||
|
||||
|
||||
view_pan_exit(op);
|
||||
WM_cursor_modal_restore(CTX_wm_window(C));
|
||||
WM_operator_name_call(C, "VIEW2D_OT_zoom", WM_OP_INVOKE_DEFAULT, NULL);
|
||||
@@ -299,10 +299,10 @@ static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
/* calculate overall delta mouse-movement for redo */
|
||||
RNA_int_set(op->ptr, "deltax", (vpd->startx - vpd->lastx));
|
||||
RNA_int_set(op->ptr, "deltay", (vpd->starty - vpd->lasty));
|
||||
|
||||
|
||||
view_pan_exit(op);
|
||||
WM_cursor_modal_restore(CTX_wm_window(C));
|
||||
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
}
|
||||
@@ -323,16 +323,16 @@ static void VIEW2D_OT_pan(wmOperatorType *ot)
|
||||
ot->name = "Pan View";
|
||||
ot->description = "Pan the view";
|
||||
ot->idname = "VIEW2D_OT_pan";
|
||||
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = view_pan_exec;
|
||||
ot->invoke = view_pan_invoke;
|
||||
ot->modal = view_pan_modal;
|
||||
ot->cancel = view_pan_cancel;
|
||||
|
||||
|
||||
/* operator is modal */
|
||||
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR;
|
||||
|
||||
|
||||
/* rna - must keep these in sync with the other operators */
|
||||
RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX);
|
||||
RNA_def_int(ot->srna, "deltay", 0, INT_MIN, INT_MAX, "Delta Y", "", INT_MIN, INT_MAX);
|
||||
@@ -344,26 +344,26 @@ static void VIEW2D_OT_pan(wmOperatorType *ot)
|
||||
static int view_scrollright_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
v2dViewPanData *vpd;
|
||||
|
||||
|
||||
/* initialize default settings (and validate if ok to run) */
|
||||
if (!view_pan_init(C, op))
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
|
||||
|
||||
/* also, check if can pan in horizontal axis */
|
||||
vpd = op->customdata;
|
||||
if (vpd->v2d->keepofs & V2D_LOCKOFS_X) {
|
||||
view_pan_exit(op);
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
|
||||
/* set RNA-Props - only movement in positive x-direction */
|
||||
RNA_int_set(op->ptr, "deltax", 20);
|
||||
RNA_int_set(op->ptr, "deltay", 0);
|
||||
|
||||
|
||||
/* apply movement, then we're done */
|
||||
view_pan_apply(C, op);
|
||||
view_pan_exit(op);
|
||||
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -373,10 +373,10 @@ static void VIEW2D_OT_scroll_right(wmOperatorType *ot)
|
||||
ot->name = "Scroll Right";
|
||||
ot->description = "Scroll the view right";
|
||||
ot->idname = "VIEW2D_OT_scroll_right";
|
||||
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = view_scrollright_exec;
|
||||
|
||||
|
||||
/* rna - must keep these in sync with the other operators */
|
||||
RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX);
|
||||
RNA_def_int(ot->srna, "deltay", 0, INT_MIN, INT_MAX, "Delta Y", "", INT_MIN, INT_MAX);
|
||||
@@ -388,26 +388,26 @@ static void VIEW2D_OT_scroll_right(wmOperatorType *ot)
|
||||
static int view_scrollleft_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
v2dViewPanData *vpd;
|
||||
|
||||
|
||||
/* initialize default settings (and validate if ok to run) */
|
||||
if (!view_pan_init(C, op))
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
|
||||
|
||||
/* also, check if can pan in horizontal axis */
|
||||
vpd = op->customdata;
|
||||
if (vpd->v2d->keepofs & V2D_LOCKOFS_X) {
|
||||
view_pan_exit(op);
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
|
||||
/* set RNA-Props - only movement in negative x-direction */
|
||||
RNA_int_set(op->ptr, "deltax", -20);
|
||||
RNA_int_set(op->ptr, "deltay", 0);
|
||||
|
||||
|
||||
/* apply movement, then we're done */
|
||||
view_pan_apply(C, op);
|
||||
view_pan_exit(op);
|
||||
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -417,10 +417,10 @@ static void VIEW2D_OT_scroll_left(wmOperatorType *ot)
|
||||
ot->name = "Scroll Left";
|
||||
ot->description = "Scroll the view left";
|
||||
ot->idname = "VIEW2D_OT_scroll_left";
|
||||
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = view_scrollleft_exec;
|
||||
|
||||
|
||||
/* rna - must keep these in sync with the other operators */
|
||||
RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX);
|
||||
RNA_def_int(ot->srna, "deltay", 0, INT_MIN, INT_MAX, "Delta Y", "", INT_MIN, INT_MAX);
|
||||
@@ -431,32 +431,32 @@ static void VIEW2D_OT_scroll_left(wmOperatorType *ot)
|
||||
static int view_scrolldown_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
v2dViewPanData *vpd;
|
||||
|
||||
|
||||
/* initialize default settings (and validate if ok to run) */
|
||||
if (!view_pan_init(C, op))
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
|
||||
|
||||
/* also, check if can pan in vertical axis */
|
||||
vpd = op->customdata;
|
||||
if (vpd->v2d->keepofs & V2D_LOCKOFS_Y) {
|
||||
view_pan_exit(op);
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
|
||||
/* set RNA-Props */
|
||||
RNA_int_set(op->ptr, "deltax", 0);
|
||||
RNA_int_set(op->ptr, "deltay", -40);
|
||||
|
||||
|
||||
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "page");
|
||||
if (RNA_property_is_set(op->ptr, prop) && RNA_property_boolean_get(op->ptr, prop)) {
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
RNA_int_set(op->ptr, "deltay", ar->v2d.mask.ymin - ar->v2d.mask.ymax);
|
||||
}
|
||||
|
||||
|
||||
/* apply movement, then we're done */
|
||||
view_pan_apply(C, op);
|
||||
view_pan_exit(op);
|
||||
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -466,10 +466,10 @@ static void VIEW2D_OT_scroll_down(wmOperatorType *ot)
|
||||
ot->name = "Scroll Down";
|
||||
ot->description = "Scroll the view down";
|
||||
ot->idname = "VIEW2D_OT_scroll_down";
|
||||
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = view_scrolldown_exec;
|
||||
|
||||
|
||||
/* rna - must keep these in sync with the other operators */
|
||||
RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX);
|
||||
RNA_def_int(ot->srna, "deltay", 0, INT_MIN, INT_MAX, "Delta Y", "", INT_MIN, INT_MAX);
|
||||
@@ -482,32 +482,32 @@ static void VIEW2D_OT_scroll_down(wmOperatorType *ot)
|
||||
static int view_scrollup_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
v2dViewPanData *vpd;
|
||||
|
||||
|
||||
/* initialize default settings (and validate if ok to run) */
|
||||
if (!view_pan_init(C, op))
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
|
||||
|
||||
/* also, check if can pan in vertical axis */
|
||||
vpd = op->customdata;
|
||||
if (vpd->v2d->keepofs & V2D_LOCKOFS_Y) {
|
||||
view_pan_exit(op);
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
|
||||
/* set RNA-Props */
|
||||
RNA_int_set(op->ptr, "deltax", 0);
|
||||
RNA_int_set(op->ptr, "deltay", 40);
|
||||
|
||||
|
||||
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "page");
|
||||
if (RNA_property_is_set(op->ptr, prop) && RNA_property_boolean_get(op->ptr, prop)) {
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
RNA_int_set(op->ptr, "deltay", BLI_rcti_size_y(&ar->v2d.mask));
|
||||
}
|
||||
|
||||
|
||||
/* apply movement, then we're done */
|
||||
view_pan_apply(C, op);
|
||||
view_pan_exit(op);
|
||||
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -517,10 +517,10 @@ static void VIEW2D_OT_scroll_up(wmOperatorType *ot)
|
||||
ot->name = "Scroll Up";
|
||||
ot->description = "Scroll the view up";
|
||||
ot->idname = "VIEW2D_OT_scroll_up";
|
||||
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = view_scrollup_exec;
|
||||
|
||||
|
||||
/* rna - must keep these in sync with the other operators */
|
||||
RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX);
|
||||
RNA_def_int(ot->srna, "deltay", 0, INT_MIN, INT_MAX, "Delta Y", "", INT_MIN, INT_MAX);
|
||||
@@ -587,24 +587,24 @@ static int view_zoomdrag_init(bContext *C, wmOperator *op)
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
v2dViewZoomData *vzd;
|
||||
View2D *v2d;
|
||||
|
||||
|
||||
/* regions now have v2d-data by default, so check for region */
|
||||
if (ar == NULL)
|
||||
return 0;
|
||||
v2d = &ar->v2d;
|
||||
|
||||
|
||||
/* check that 2d-view is zoomable */
|
||||
if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y))
|
||||
return 0;
|
||||
|
||||
|
||||
/* set custom-data for operator */
|
||||
vzd = MEM_callocN(sizeof(v2dViewZoomData), "v2dViewZoomData");
|
||||
op->customdata = vzd;
|
||||
|
||||
|
||||
/* set pointers to owners */
|
||||
vzd->v2d = v2d;
|
||||
vzd->ar = ar;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -613,7 +613,7 @@ static int view_zoom_poll(bContext *C)
|
||||
{
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
View2D *v2d;
|
||||
|
||||
|
||||
/* check if there's a region in context to work with */
|
||||
if (ar == NULL)
|
||||
return false;
|
||||
@@ -623,15 +623,15 @@ static int view_zoom_poll(bContext *C)
|
||||
return false;
|
||||
|
||||
v2d = &ar->v2d;
|
||||
|
||||
|
||||
/* check that 2d-view is zoomable */
|
||||
if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y))
|
||||
return false;
|
||||
|
||||
|
||||
/* view is zoomable */
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* apply transform to view (i.e. adjust 'cur' rect) */
|
||||
static void view_zoomstep_apply_ex(
|
||||
bContext *C, v2dViewZoomData *vzd, const bool use_mousepos,
|
||||
@@ -643,7 +643,7 @@ static void view_zoomstep_apply_ex(
|
||||
float dx, dy;
|
||||
|
||||
/* calculate amount to move view by, ensuring symmetry so the
|
||||
* old zoom level is restored after zooming back the same amount
|
||||
* old zoom level is restored after zooming back the same amount
|
||||
*/
|
||||
if (facx >= 0.0f) {
|
||||
dx = BLI_rctf_size_x(&v2d->cur) * facx;
|
||||
@@ -759,40 +759,40 @@ static int view_zoomin_exec(bContext *C, wmOperator *op)
|
||||
/* check that there's an active region, as View2D data resides there */
|
||||
if (!view_zoom_poll(C))
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
|
||||
|
||||
|
||||
view_zoom_axis_lock_defaults(C, do_zoom_xy);
|
||||
|
||||
/* set RNA-Props - zooming in by uniform factor */
|
||||
RNA_float_set(op->ptr, "zoomfacx", do_zoom_xy[0] ? 0.0375f : 0.0f);
|
||||
RNA_float_set(op->ptr, "zoomfacy", do_zoom_xy[1] ? 0.0375f : 0.0f);
|
||||
|
||||
|
||||
/* apply movement, then we're done */
|
||||
view_zoomstep_apply(C, op);
|
||||
|
||||
|
||||
view_zoomstep_exit(op);
|
||||
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int view_zoomin_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
v2dViewZoomData *vzd;
|
||||
|
||||
|
||||
if (!view_zoomdrag_init(C, op))
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
|
||||
|
||||
vzd = op->customdata;
|
||||
|
||||
|
||||
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
|
||||
|
||||
/* store initial mouse position (in view space) */
|
||||
UI_view2d_region_to_view(&ar->v2d,
|
||||
event->mval[0], event->mval[1],
|
||||
&vzd->mx_2d, &vzd->my_2d);
|
||||
}
|
||||
|
||||
|
||||
return view_zoomin_exec(C, op);
|
||||
}
|
||||
|
||||
@@ -804,12 +804,12 @@ static void VIEW2D_OT_zoom_in(wmOperatorType *ot)
|
||||
ot->name = "Zoom In";
|
||||
ot->description = "Zoom in the view";
|
||||
ot->idname = "VIEW2D_OT_zoom_in";
|
||||
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke = view_zoomin_invoke;
|
||||
ot->exec = view_zoomin_exec; // XXX, needs view_zoomdrag_init called first.
|
||||
ot->poll = view_zoom_poll;
|
||||
|
||||
|
||||
/* rna - must keep these in sync with the other operators */
|
||||
prop = RNA_def_float(ot->srna, "zoomfacx", 0, -FLT_MAX, FLT_MAX, "Zoom Factor X", "", -FLT_MAX, FLT_MAX);
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
@@ -825,39 +825,39 @@ static int view_zoomout_exec(bContext *C, wmOperator *op)
|
||||
/* check that there's an active region, as View2D data resides there */
|
||||
if (!view_zoom_poll(C))
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
|
||||
|
||||
view_zoom_axis_lock_defaults(C, do_zoom_xy);
|
||||
|
||||
/* set RNA-Props - zooming in by uniform factor */
|
||||
RNA_float_set(op->ptr, "zoomfacx", do_zoom_xy[0] ? -0.0375f : 0.0f);
|
||||
RNA_float_set(op->ptr, "zoomfacy", do_zoom_xy[1] ? -0.0375f : 0.0f);
|
||||
|
||||
|
||||
/* apply movement, then we're done */
|
||||
view_zoomstep_apply(C, op);
|
||||
|
||||
view_zoomstep_exit(op);
|
||||
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int view_zoomout_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
v2dViewZoomData *vzd;
|
||||
|
||||
|
||||
if (!view_zoomdrag_init(C, op))
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
|
||||
vzd = op->customdata;
|
||||
|
||||
|
||||
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
|
||||
|
||||
/* store initial mouse position (in view space) */
|
||||
UI_view2d_region_to_view(&ar->v2d,
|
||||
UI_view2d_region_to_view(&ar->v2d,
|
||||
event->mval[0], event->mval[1],
|
||||
&vzd->mx_2d, &vzd->my_2d);
|
||||
}
|
||||
|
||||
|
||||
return view_zoomout_exec(C, op);
|
||||
}
|
||||
|
||||
@@ -869,12 +869,12 @@ static void VIEW2D_OT_zoom_out(wmOperatorType *ot)
|
||||
ot->name = "Zoom Out";
|
||||
ot->description = "Zoom out the view";
|
||||
ot->idname = "VIEW2D_OT_zoom_out";
|
||||
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke = view_zoomout_invoke;
|
||||
// ot->exec = view_zoomout_exec; // XXX, needs view_zoomdrag_init called first.
|
||||
ot->poll = view_zoom_poll;
|
||||
|
||||
|
||||
/* rna - must keep these in sync with the other operators */
|
||||
prop = RNA_def_float(ot->srna, "zoomfacx", 0, -FLT_MAX, FLT_MAX, "Zoom Factor X", "", -FLT_MAX, FLT_MAX);
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
@@ -898,7 +898,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
|
||||
v2dViewZoomData *vzd = op->customdata;
|
||||
View2D *v2d = vzd->v2d;
|
||||
float dx, dy;
|
||||
|
||||
|
||||
/* get amount to move view by */
|
||||
dx = RNA_float_get(op->ptr, "deltax");
|
||||
dy = RNA_float_get(op->ptr, "deltay");
|
||||
@@ -907,7 +907,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
|
||||
dx *= -1;
|
||||
dy *= -1;
|
||||
}
|
||||
|
||||
|
||||
/* continuous zoom shouldn't move that fast... */
|
||||
if (U.viewzoom == USER_ZOOM_CONT) { // XXX store this setting as RNA prop?
|
||||
double time = PIL_check_seconds_timer();
|
||||
@@ -915,7 +915,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
|
||||
|
||||
dx *= time_step * 0.5f;
|
||||
dy *= time_step * 0.5f;
|
||||
|
||||
|
||||
vzd->timer_lastdraw = time;
|
||||
}
|
||||
|
||||
@@ -929,7 +929,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
|
||||
float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
|
||||
float mval_faci = 1.0f - mval_fac;
|
||||
float ofs = (mval_fac * dx) - (mval_faci * dx);
|
||||
|
||||
|
||||
v2d->cur.xmin += ofs + dx;
|
||||
v2d->cur.xmax += ofs - dx;
|
||||
}
|
||||
@@ -948,7 +948,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
|
||||
float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
|
||||
float mval_faci = 1.0f - mval_fac;
|
||||
float ofs = (mval_fac * dy) - (mval_faci * dy);
|
||||
|
||||
|
||||
v2d->cur.ymin += ofs + dy;
|
||||
v2d->cur.ymax += ofs - dy;
|
||||
}
|
||||
@@ -958,10 +958,10 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* validate that view is in valid configuration after this operation */
|
||||
UI_view2d_curRect_validate(v2d);
|
||||
|
||||
|
||||
/* request updates to be done... */
|
||||
ED_region_tag_redraw(vzd->ar);
|
||||
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
|
||||
@@ -974,14 +974,14 @@ static void view_zoomdrag_exit(bContext *C, wmOperator *op)
|
||||
|
||||
if (op->customdata) {
|
||||
v2dViewZoomData *vzd = op->customdata;
|
||||
|
||||
|
||||
if (vzd->timer)
|
||||
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), vzd->timer);
|
||||
|
||||
|
||||
MEM_freeN(op->customdata);
|
||||
op->customdata = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void view_zoomdrag_cancel(bContext *C, wmOperator *op)
|
||||
{
|
||||
@@ -993,7 +993,7 @@ static int view_zoomdrag_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
if (!view_zoomdrag_init(C, op))
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
|
||||
|
||||
view_zoomdrag_apply(C, op);
|
||||
view_zoomdrag_exit(C, op);
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -1005,22 +1005,22 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
||||
wmWindow *window = CTX_wm_window(C);
|
||||
v2dViewZoomData *vzd;
|
||||
View2D *v2d;
|
||||
|
||||
|
||||
/* set up customdata */
|
||||
if (!view_zoomdrag_init(C, op))
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
|
||||
|
||||
vzd = op->customdata;
|
||||
v2d = vzd->v2d;
|
||||
|
||||
|
||||
if (event->type == MOUSEZOOM || event->type == MOUSEPAN) {
|
||||
float dx, dy, fac;
|
||||
|
||||
|
||||
vzd->lastx = event->prevx;
|
||||
vzd->lasty = event->prevy;
|
||||
|
||||
|
||||
/* As we have only 1D information (magnify value), feed both axes
|
||||
* with magnify information that is stored in x axis
|
||||
* with magnify information that is stored in x axis
|
||||
*/
|
||||
fac = 0.01f * (event->prevx - event->x);
|
||||
dx = fac * BLI_rctf_size_x(&v2d->cur) / 10.0f;
|
||||
@@ -1037,26 +1037,26 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
||||
}
|
||||
RNA_float_set(op->ptr, "deltax", dx);
|
||||
RNA_float_set(op->ptr, "deltay", dy);
|
||||
|
||||
|
||||
view_zoomdrag_apply(C, op);
|
||||
view_zoomdrag_exit(C, op);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
||||
/* set initial settings */
|
||||
vzd->lastx = event->x;
|
||||
vzd->lasty = event->y;
|
||||
RNA_float_set(op->ptr, "deltax", 0);
|
||||
RNA_float_set(op->ptr, "deltay", 0);
|
||||
|
||||
|
||||
/* for modal exit test */
|
||||
vzd->invoke_event = event->type;
|
||||
|
||||
|
||||
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
|
||||
|
||||
/* store initial mouse position (in view space) */
|
||||
UI_view2d_region_to_view(&ar->v2d,
|
||||
UI_view2d_region_to_view(&ar->v2d,
|
||||
event->mval[0], event->mval[1],
|
||||
&vzd->mx_2d, &vzd->my_2d);
|
||||
}
|
||||
@@ -1067,7 +1067,7 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
||||
WM_cursor_modal_set(window, BC_EW_SCROLLCURSOR);
|
||||
else
|
||||
WM_cursor_modal_set(window, BC_NSEW_SCROLLCURSOR);
|
||||
|
||||
|
||||
/* add temp handler */
|
||||
WM_event_add_modal_handler(C, op);
|
||||
|
||||
@@ -1085,24 +1085,24 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
|
||||
{
|
||||
v2dViewZoomData *vzd = op->customdata;
|
||||
View2D *v2d = vzd->v2d;
|
||||
|
||||
|
||||
/* execute the events */
|
||||
if (event->type == TIMER && event->customdata == vzd->timer) {
|
||||
view_zoomdrag_apply(C, op);
|
||||
}
|
||||
else if (event->type == MOUSEMOVE) {
|
||||
float dx, dy;
|
||||
|
||||
|
||||
/* calculate new delta transform, based on zooming mode */
|
||||
if (U.viewzoom == USER_ZOOM_SCALE) {
|
||||
/* 'scale' zooming */
|
||||
float dist;
|
||||
|
||||
|
||||
/* x-axis transform */
|
||||
dist = BLI_rcti_size_x(&v2d->mask) / 2.0f;
|
||||
dx = 1.0f - (fabsf(vzd->lastx - vzd->ar->winrct.xmin - dist) + 2.0f) / (fabsf(event->mval[0] - dist) + 2.0f);
|
||||
dx *= 0.5f * BLI_rctf_size_x(&v2d->cur);
|
||||
|
||||
|
||||
/* y-axis transform */
|
||||
dist = BLI_rcti_size_y(&v2d->mask) / 2.0f;
|
||||
dy = 1.0f - (fabsf(vzd->lasty - vzd->ar->winrct.ymin - dist) + 2.0f) / (fabsf(event->mval[1] - dist) + 2.0f);
|
||||
@@ -1111,21 +1111,21 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
|
||||
else {
|
||||
/* 'continuous' or 'dolly' */
|
||||
float fac, zoomfac = 0.01f;
|
||||
|
||||
|
||||
/* some view2d's (graph) don't have min/max zoom, or extreme ones */
|
||||
if (v2d->maxzoom > 0.0f)
|
||||
zoomfac = CLAMPIS(0.001f * v2d->maxzoom, 0.001f, 0.01f);
|
||||
|
||||
|
||||
/* x-axis transform */
|
||||
fac = zoomfac * (event->x - vzd->lastx);
|
||||
dx = fac * BLI_rctf_size_x(&v2d->cur);
|
||||
|
||||
|
||||
/* y-axis transform */
|
||||
fac = zoomfac * (event->y - vzd->lasty);
|
||||
dy = fac * BLI_rctf_size_y(&v2d->cur);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* support zoom to always zoom entirely - the v2d code uses portrait or landscape exceptions */
|
||||
if (v2d->keepzoom & V2D_KEEPASPECT) {
|
||||
if (fabsf(dx) > fabsf(dy))
|
||||
@@ -1133,14 +1133,14 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
|
||||
else
|
||||
dx = dy;
|
||||
}
|
||||
|
||||
|
||||
/* set transform amount, and add current deltas to stored total delta (for redo) */
|
||||
RNA_float_set(op->ptr, "deltax", dx);
|
||||
RNA_float_set(op->ptr, "deltay", dy);
|
||||
|
||||
vzd->dx += dx;
|
||||
vzd->dy += dy;
|
||||
|
||||
|
||||
/* store mouse coordinates for next time, if not doing continuous zoom
|
||||
* - continuous zoom only depends on distance of mouse to starting point to determine rate of change
|
||||
*/
|
||||
@@ -1148,28 +1148,28 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
|
||||
vzd->lastx = event->x;
|
||||
vzd->lasty = event->y;
|
||||
}
|
||||
|
||||
|
||||
/* apply zooming */
|
||||
view_zoomdrag_apply(C, op);
|
||||
}
|
||||
else if (event->type == vzd->invoke_event || event->type == ESCKEY) {
|
||||
if (event->val == KM_RELEASE) {
|
||||
|
||||
|
||||
/* for redo, store the overall deltas - need to respect zoom-locks here... */
|
||||
if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0)
|
||||
RNA_float_set(op->ptr, "deltax", vzd->dx);
|
||||
else
|
||||
RNA_float_set(op->ptr, "deltax", 0);
|
||||
|
||||
|
||||
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0)
|
||||
RNA_float_set(op->ptr, "deltay", vzd->dy);
|
||||
else
|
||||
RNA_float_set(op->ptr, "deltay", 0);
|
||||
|
||||
|
||||
/* free customdata */
|
||||
view_zoomdrag_exit(C, op);
|
||||
WM_cursor_modal_restore(CTX_wm_window(C));
|
||||
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
}
|
||||
@@ -1184,18 +1184,18 @@ static void VIEW2D_OT_zoom(wmOperatorType *ot)
|
||||
ot->name = "Zoom 2D View";
|
||||
ot->description = "Zoom in/out the view";
|
||||
ot->idname = "VIEW2D_OT_zoom";
|
||||
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = view_zoomdrag_exec;
|
||||
ot->invoke = view_zoomdrag_invoke;
|
||||
ot->modal = view_zoomdrag_modal;
|
||||
ot->cancel = view_zoomdrag_cancel;
|
||||
|
||||
|
||||
ot->poll = view_zoom_poll;
|
||||
|
||||
|
||||
/* operator is repeatable */
|
||||
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR;
|
||||
|
||||
|
||||
/* rna - must keep these in sync with the other operators */
|
||||
prop = RNA_def_float(ot->srna, "deltax", 0, -FLT_MAX, FLT_MAX, "Delta X", "", -FLT_MAX, FLT_MAX);
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
@@ -1216,7 +1216,7 @@ static void VIEW2D_OT_zoom(wmOperatorType *ot)
|
||||
* Currently, these key mappings are hardcoded, but it shouldn't be too important to
|
||||
* have custom keymappings for this...
|
||||
*/
|
||||
|
||||
|
||||
static int view_borderzoom_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
@@ -1224,17 +1224,17 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
|
||||
rctf rect;
|
||||
rctf cur_new = v2d->cur;
|
||||
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
|
||||
|
||||
|
||||
/* convert coordinates of rect to 'tot' rect coordinates */
|
||||
WM_operator_properties_border_to_rctf(op, &rect);
|
||||
UI_view2d_region_to_view_rctf(v2d, &rect, &rect);
|
||||
|
||||
|
||||
/* check if zooming in/out view */
|
||||
const bool zoom_in = !RNA_boolean_get(op->ptr, "zoom_out");
|
||||
|
||||
|
||||
if (zoom_in) {
|
||||
/* zoom in:
|
||||
* - 'cur' rect will be defined by the coordinates of the border region
|
||||
/* zoom in:
|
||||
* - 'cur' rect will be defined by the coordinates of the border region
|
||||
* - just set the 'cur' rect to have the same coordinates as the border region
|
||||
* if zoom is allowed to be changed
|
||||
*/
|
||||
@@ -1254,13 +1254,13 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
|
||||
* - calculate zoom factor, and adjust using center-point
|
||||
*/
|
||||
float zoom, center, size;
|
||||
|
||||
|
||||
/* TODO: is this zoom factor calculation valid? It seems to produce same results every time... */
|
||||
if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
|
||||
size = BLI_rctf_size_x(&cur_new);
|
||||
zoom = size / BLI_rctf_size_x(&rect);
|
||||
center = BLI_rctf_cent_x(&cur_new);
|
||||
|
||||
|
||||
cur_new.xmin = center - (size * zoom);
|
||||
cur_new.xmax = center + (size * zoom);
|
||||
}
|
||||
@@ -1268,16 +1268,16 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
|
||||
size = BLI_rctf_size_y(&cur_new);
|
||||
zoom = size / BLI_rctf_size_y(&rect);
|
||||
center = BLI_rctf_cent_y(&cur_new);
|
||||
|
||||
|
||||
cur_new.ymin = center - (size * zoom);
|
||||
cur_new.ymax = center + (size * zoom);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UI_view2d_smooth_view(C, ar, &cur_new, smooth_viewtx);
|
||||
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
}
|
||||
|
||||
static void VIEW2D_OT_zoom_border(wmOperatorType *ot)
|
||||
{
|
||||
@@ -1285,15 +1285,15 @@ static void VIEW2D_OT_zoom_border(wmOperatorType *ot)
|
||||
ot->name = "Zoom to Border";
|
||||
ot->description = "Zoom in the view to the nearest item contained in the border";
|
||||
ot->idname = "VIEW2D_OT_zoom_border";
|
||||
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke = WM_gesture_border_invoke;
|
||||
ot->exec = view_borderzoom_exec;
|
||||
ot->modal = WM_gesture_border_modal;
|
||||
ot->cancel = WM_gesture_border_cancel;
|
||||
|
||||
|
||||
ot->poll = view_zoom_poll;
|
||||
|
||||
|
||||
/* rna */
|
||||
WM_operator_properties_gesture_border_zoom(ot);
|
||||
}
|
||||
@@ -1566,17 +1566,17 @@ static void VIEW2D_OT_smoothview(wmOperatorType *ot)
|
||||
typedef struct v2dScrollerMove {
|
||||
View2D *v2d; /* View2D data that this operation affects */
|
||||
ARegion *ar; /* region that the scroller is in */
|
||||
|
||||
|
||||
short scroller; /* scroller that mouse is in ('h' or 'v') */
|
||||
short zone; /* -1 is min zoomer, 0 is bar, 1 is max zoomer */ // XXX find some way to provide visual feedback of this (active color?)
|
||||
|
||||
|
||||
float fac; /* view adjustment factor, based on size of region */
|
||||
float fac_round; /* for pixel rounding (avoid visible UI jitter) */
|
||||
float delta; /* amount moved by mouse on axis of interest */
|
||||
|
||||
|
||||
float scrollbarwidth; /* width of the scrollbar itself, used for page up/down clicks */
|
||||
int scrollbar_orig; /* initial location of scrollbar x/y, mouse relative */
|
||||
|
||||
|
||||
int lastx, lasty; /* previous mouse coordinates (in screen coordinates) for determining movement */
|
||||
} v2dScrollerMove;
|
||||
|
||||
@@ -1588,7 +1588,7 @@ typedef struct v2dScrollerMove {
|
||||
* \warning: The start of this struct must not change, so that it stays in sync with the 'real' version
|
||||
* For now, we don't need to have a separate (internal) header for structs like this...
|
||||
*/
|
||||
struct View2DScrollers {
|
||||
struct View2DScrollers {
|
||||
/* focus bubbles */
|
||||
int vert_min, vert_max; /* vertical scrollbar */
|
||||
int hor_min, hor_max; /* horizontal scrollbar */
|
||||
@@ -1615,10 +1615,10 @@ enum {
|
||||
static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_min, int sh_max)
|
||||
{
|
||||
bool in_min, in_max, in_bar, out_min, out_max, in_view = 1;
|
||||
|
||||
/* firstly, check if
|
||||
* - 'bubble' fills entire scroller
|
||||
* - 'bubble' completely out of view on either side
|
||||
|
||||
/* firstly, check if
|
||||
* - 'bubble' fills entire scroller
|
||||
* - 'bubble' completely out of view on either side
|
||||
*/
|
||||
if ((sh_min <= sc_min) && (sh_max >= sc_max)) in_view = 0;
|
||||
if (sh_min == sh_max) {
|
||||
@@ -1629,12 +1629,12 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_
|
||||
if (sh_max <= sc_min) in_view = 0;
|
||||
if (sh_min >= sc_max) in_view = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (in_view == 0) {
|
||||
return SCROLLHANDLE_BAR;
|
||||
}
|
||||
|
||||
|
||||
/* check if mouse is in or past either handle */
|
||||
/* TODO: check if these extents are still valid or not */
|
||||
in_max = ((mouse >= (sh_max - V2D_SCROLLER_HANDLE_SIZE)) && (mouse <= (sh_max + V2D_SCROLLER_HANDLE_SIZE)));
|
||||
@@ -1642,7 +1642,7 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_
|
||||
in_bar = ((mouse < (sh_max - V2D_SCROLLER_HANDLE_SIZE)) && (mouse > (sh_min + V2D_SCROLLER_HANDLE_SIZE)));
|
||||
out_min = mouse < (sh_min - V2D_SCROLLER_HANDLE_SIZE);
|
||||
out_max = mouse > (sh_max + V2D_SCROLLER_HANDLE_SIZE);
|
||||
|
||||
|
||||
if (in_bar)
|
||||
return SCROLLHANDLE_BAR;
|
||||
else if (in_max)
|
||||
@@ -1653,10 +1653,10 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_
|
||||
return SCROLLHANDLE_MIN_OUTSIDE;
|
||||
else if (out_max)
|
||||
return SCROLLHANDLE_MAX_OUTSIDE;
|
||||
|
||||
|
||||
/* unlikely to happen, though we just cover it in case */
|
||||
return SCROLLHANDLE_BAR;
|
||||
}
|
||||
}
|
||||
|
||||
/* initialize customdata for scroller manipulation operator */
|
||||
static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *event, short in_scroller)
|
||||
@@ -1667,11 +1667,11 @@ static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *e
|
||||
View2D *v2d = &ar->v2d;
|
||||
rctf tot_cur_union;
|
||||
float mask_size;
|
||||
|
||||
|
||||
/* set custom-data for operator */
|
||||
vsm = MEM_callocN(sizeof(v2dScrollerMove), "v2dScrollerMove");
|
||||
op->customdata = vsm;
|
||||
|
||||
|
||||
/* set general data */
|
||||
vsm->v2d = v2d;
|
||||
vsm->ar = ar;
|
||||
@@ -1680,7 +1680,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *e
|
||||
/* store mouse-coordinates, and convert mouse/screen coordinates to region coordinates */
|
||||
vsm->lastx = event->x;
|
||||
vsm->lasty = event->y;
|
||||
/* 'zone' depends on where mouse is relative to bubble
|
||||
/* 'zone' depends on where mouse is relative to bubble
|
||||
* - zooming must be allowed on this axis, otherwise, default to pan
|
||||
*/
|
||||
scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
|
||||
@@ -1702,7 +1702,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *e
|
||||
vsm->zone = mouse_in_scroller_handle(event->mval[0],
|
||||
v2d->hor.xmin, v2d->hor.xmax,
|
||||
scrollers->hor_min, scrollers->hor_max);
|
||||
|
||||
|
||||
if ((v2d->keepzoom & V2D_LOCKZOOM_X) && ELEM(vsm->zone, SCROLLHANDLE_MIN, SCROLLHANDLE_MAX)) {
|
||||
/* default to scroll, as handles not usable */
|
||||
vsm->zone = SCROLLHANDLE_BAR;
|
||||
@@ -1715,7 +1715,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *e
|
||||
/* vertical scroller - calculate adjustment factor first */
|
||||
mask_size = (float)BLI_rcti_size_y(&v2d->vert);
|
||||
vsm->fac = BLI_rctf_size_y(&tot_cur_union) / mask_size;
|
||||
|
||||
|
||||
/* pixel rounding */
|
||||
vsm->fac_round = (BLI_rctf_size_y(&v2d->cur)) / (float)(BLI_rcti_size_y(&ar->winrct) + 1);
|
||||
|
||||
@@ -1723,16 +1723,16 @@ static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *e
|
||||
vsm->zone = mouse_in_scroller_handle(event->mval[1],
|
||||
v2d->vert.ymin, v2d->vert.ymax,
|
||||
scrollers->vert_min, scrollers->vert_max);
|
||||
|
||||
|
||||
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) && ELEM(vsm->zone, SCROLLHANDLE_MIN, SCROLLHANDLE_MAX)) {
|
||||
/* default to scroll, as handles not usable */
|
||||
vsm->zone = SCROLLHANDLE_BAR;
|
||||
}
|
||||
|
||||
|
||||
vsm->scrollbarwidth = scrollers->vert_max - scrollers->vert_min;
|
||||
vsm->scrollbar_orig = ((scrollers->vert_max + scrollers->vert_min) / 2) + ar->winrct.ymin;
|
||||
}
|
||||
|
||||
|
||||
UI_view2d_scrollers_free(scrollers);
|
||||
ED_region_tag_redraw(ar);
|
||||
}
|
||||
@@ -1744,10 +1744,10 @@ static void scroller_activate_exit(bContext *C, wmOperator *op)
|
||||
v2dScrollerMove *vsm = op->customdata;
|
||||
|
||||
vsm->v2d->scroll_ui &= ~(V2D_SCROLL_H_ACTIVE | V2D_SCROLL_V_ACTIVE);
|
||||
|
||||
|
||||
MEM_freeN(op->customdata);
|
||||
op->customdata = NULL;
|
||||
|
||||
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
}
|
||||
}
|
||||
@@ -1763,13 +1763,13 @@ static void scroller_activate_apply(bContext *C, wmOperator *op)
|
||||
v2dScrollerMove *vsm = op->customdata;
|
||||
View2D *v2d = vsm->v2d;
|
||||
float temp;
|
||||
|
||||
|
||||
/* calculate amount to move view by */
|
||||
temp = vsm->fac * vsm->delta;
|
||||
|
||||
/* round to pixel */
|
||||
temp = roundf(temp / vsm->fac_round) * vsm->fac_round;
|
||||
|
||||
|
||||
/* type of movement */
|
||||
switch (vsm->zone) {
|
||||
case SCROLLHANDLE_MIN:
|
||||
@@ -1779,16 +1779,16 @@ static void scroller_activate_apply(bContext *C, wmOperator *op)
|
||||
if ((vsm->scroller == 'v') && !(v2d->keepzoom & V2D_LOCKZOOM_Y))
|
||||
v2d->cur.ymin -= temp;
|
||||
break;
|
||||
|
||||
|
||||
case SCROLLHANDLE_MAX:
|
||||
|
||||
|
||||
/* only expand view on axis if zoom is allowed */
|
||||
if ((vsm->scroller == 'h') && !(v2d->keepzoom & V2D_LOCKZOOM_X))
|
||||
v2d->cur.xmax += temp;
|
||||
if ((vsm->scroller == 'v') && !(v2d->keepzoom & V2D_LOCKZOOM_Y))
|
||||
v2d->cur.ymax += temp;
|
||||
break;
|
||||
|
||||
|
||||
case SCROLLHANDLE_MIN_OUTSIDE:
|
||||
case SCROLLHANDLE_MAX_OUTSIDE:
|
||||
case SCROLLHANDLE_BAR:
|
||||
@@ -1803,12 +1803,12 @@ static void scroller_activate_apply(bContext *C, wmOperator *op)
|
||||
v2d->cur.ymax += temp;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* validate that view is in valid configuration after this operation */
|
||||
UI_view2d_curRect_validate(v2d);
|
||||
|
||||
|
||||
/* request updates to be done... */
|
||||
ED_region_tag_redraw(vsm->ar);
|
||||
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
|
||||
@@ -1821,7 +1821,7 @@ static void scroller_activate_apply(bContext *C, wmOperator *op)
|
||||
static int scroller_activate_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
v2dScrollerMove *vsm = op->customdata;
|
||||
|
||||
|
||||
/* execute the events */
|
||||
switch (event->type) {
|
||||
case MOUSEMOVE:
|
||||
@@ -1849,11 +1849,11 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, const wmEvent *e
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* store previous coordinates */
|
||||
vsm->lastx = event->x;
|
||||
vsm->lasty = event->y;
|
||||
|
||||
|
||||
scroller_activate_apply(C, op);
|
||||
break;
|
||||
}
|
||||
@@ -1866,12 +1866,12 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, const wmEvent *e
|
||||
vsm->delta = -vsm->scrollbarwidth * 0.8f;
|
||||
else if (vsm->zone == SCROLLHANDLE_MAX_OUTSIDE)
|
||||
vsm->delta = vsm->scrollbarwidth * 0.8f;
|
||||
|
||||
|
||||
scroller_activate_apply(C, op);
|
||||
scroller_activate_exit(C, op);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
||||
/* otherwise, end the drag action */
|
||||
if (vsm->lastx || vsm->lasty) {
|
||||
scroller_activate_exit(C, op);
|
||||
@@ -1892,18 +1892,18 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, const wmEvent *
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
View2D *v2d = &ar->v2d;
|
||||
short in_scroller = 0;
|
||||
|
||||
|
||||
/* check if mouse in scrollbars, if they're enabled */
|
||||
in_scroller = UI_view2d_mouse_in_scrollers(C, v2d, event->x, event->y);
|
||||
|
||||
|
||||
/* if in a scroller, init customdata then set modal handler which will catch mousedown to start doing useful stuff */
|
||||
if (in_scroller) {
|
||||
v2dScrollerMove *vsm;
|
||||
|
||||
|
||||
/* initialize customdata */
|
||||
scroller_activate_init(C, op, event, in_scroller);
|
||||
vsm = (v2dScrollerMove *)op->customdata;
|
||||
|
||||
|
||||
/* support for quick jump to location - gtk and qt do this on linux */
|
||||
if (event->type == MIDDLEMOUSE) {
|
||||
switch (vsm->scroller) {
|
||||
@@ -1930,7 +1930,7 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, const wmEvent *
|
||||
vsm->zone = SCROLLHANDLE_BAR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* check if zone is inappropriate (i.e. 'bar' but panning is banned), so cannot continue */
|
||||
if (vsm->zone == SCROLLHANDLE_BAR) {
|
||||
if (((vsm->scroller == 'h') && (v2d->keepofs & V2D_LOCKOFS_X)) ||
|
||||
@@ -1938,30 +1938,30 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, const wmEvent *
|
||||
{
|
||||
/* free customdata initialized */
|
||||
scroller_activate_exit(C, op);
|
||||
|
||||
|
||||
/* can't catch this event for ourselves, so let it go to someone else? */
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* zone is also inappropriate if scroller is not visible... */
|
||||
if (((vsm->scroller == 'h') && (v2d->scroll & (V2D_SCROLL_HORIZONTAL_FULLR))) ||
|
||||
((vsm->scroller == 'v') && (v2d->scroll & (V2D_SCROLL_VERTICAL_FULLR))) )
|
||||
{
|
||||
/* free customdata initialized */
|
||||
scroller_activate_exit(C, op);
|
||||
|
||||
|
||||
/* can't catch this event for ourselves, so let it go to someone else? */
|
||||
/* XXX note: if handlers use mask rect to clip input, input will fail for this case */
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
|
||||
/* activate the scroller */
|
||||
if (vsm->scroller == 'h')
|
||||
v2d->scroll_ui |= V2D_SCROLL_H_ACTIVE;
|
||||
else
|
||||
v2d->scroll_ui |= V2D_SCROLL_V_ACTIVE;
|
||||
|
||||
|
||||
/* still ok, so can add */
|
||||
WM_event_add_modal_handler(C, op);
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
@@ -1982,7 +1982,7 @@ static void VIEW2D_OT_scroller_activate(wmOperatorType *ot)
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_BLOCKING;
|
||||
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke = scroller_activate_invoke;
|
||||
ot->modal = scroller_activate_modal;
|
||||
@@ -2007,7 +2007,7 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
v2d->cur.xmax = v2d->cur.xmin + winx;
|
||||
v2d->cur.ymax = v2d->cur.ymin + winy;
|
||||
|
||||
|
||||
/* align */
|
||||
if (v2d->align) {
|
||||
/* posx and negx flags are mutually exclusive, so watch out */
|
||||
@@ -2033,11 +2033,11 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
/* validate that view is in valid configuration after this operation */
|
||||
UI_view2d_curRect_validate(v2d);
|
||||
|
||||
|
||||
/* request updates to be done... */
|
||||
ED_region_tag_redraw(ar);
|
||||
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
|
||||
|
||||
|
||||
UI_view2d_zoom_cache_reset();
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -2049,27 +2049,27 @@ static void VIEW2D_OT_reset(wmOperatorType *ot)
|
||||
ot->name = "Reset View";
|
||||
ot->description = "Reset the view";
|
||||
ot->idname = "VIEW2D_OT_reset";
|
||||
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = reset_exec;
|
||||
ot->poll = view2d_poll;
|
||||
}
|
||||
|
||||
|
||||
/* ********************************************************* */
|
||||
/* Registration */
|
||||
|
||||
void ED_operatortypes_view2d(void)
|
||||
{
|
||||
WM_operatortype_append(VIEW2D_OT_pan);
|
||||
|
||||
|
||||
WM_operatortype_append(VIEW2D_OT_scroll_left);
|
||||
WM_operatortype_append(VIEW2D_OT_scroll_right);
|
||||
WM_operatortype_append(VIEW2D_OT_scroll_up);
|
||||
WM_operatortype_append(VIEW2D_OT_scroll_down);
|
||||
|
||||
|
||||
WM_operatortype_append(VIEW2D_OT_zoom_in);
|
||||
WM_operatortype_append(VIEW2D_OT_zoom_out);
|
||||
|
||||
|
||||
WM_operatortype_append(VIEW2D_OT_zoom);
|
||||
WM_operatortype_append(VIEW2D_OT_zoom_border);
|
||||
|
||||
@@ -2078,7 +2078,7 @@ void ED_operatortypes_view2d(void)
|
||||
#endif
|
||||
|
||||
WM_operatortype_append(VIEW2D_OT_smoothview);
|
||||
|
||||
|
||||
WM_operatortype_append(VIEW2D_OT_scroller_activate);
|
||||
|
||||
WM_operatortype_append(VIEW2D_OT_reset);
|
||||
@@ -2096,15 +2096,15 @@ void ED_keymap_view2d(wmKeyConfig *keyconf)
|
||||
/* pan/scroll */
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MIDDLEMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MOUSEPAN, 0, 0, 0);
|
||||
|
||||
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_right", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_left", WHEELUPMOUSE, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_down", WHEELDOWNMOUSE, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_up", WHEELUPMOUSE, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
|
||||
#ifdef WITH_INPUT_NDOF
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_ndof", NDOF_MOTION, 0, 0, 0);
|
||||
#endif
|
||||
@@ -2115,7 +2115,7 @@ void ED_keymap_view2d(wmKeyConfig *keyconf)
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_out", PADMINUS, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_in", PADPLUSKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MOUSEPAN, 0, KM_CTRL, 0);
|
||||
|
||||
|
||||
WM_keymap_verify_item(keymap, "VIEW2D_OT_smoothview", TIMER1, KM_ANY, KM_ANY, 0);
|
||||
|
||||
/* scroll up/down - no modifiers, only when zoom fails */
|
||||
@@ -2125,7 +2125,7 @@ void ED_keymap_view2d(wmKeyConfig *keyconf)
|
||||
/* these may be necessary if vertical scroll is disallowed */
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_right", WHEELDOWNMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_left", WHEELUPMOUSE, KM_PRESS, 0, 0);
|
||||
|
||||
|
||||
/* alternatives for page up/down to scroll */
|
||||
#if 0 // XXX disabled, since this causes conflicts with hotkeys in animation editors
|
||||
/* scroll up/down may fall through to left/right */
|
||||
@@ -2137,11 +2137,11 @@ void ED_keymap_view2d(wmKeyConfig *keyconf)
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_right", PAGEDOWNKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_left", PAGEUPKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
#endif
|
||||
|
||||
|
||||
/* zoom - drag */
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MOUSEZOOM, 0, 0, 0);
|
||||
|
||||
|
||||
/* borderzoom - drag */
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_border", BKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
@@ -2155,12 +2155,12 @@ void ED_keymap_view2d(wmKeyConfig *keyconf)
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MOUSEPAN, 0, 0, 0);
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_down", WHEELDOWNMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_up", WHEELUPMOUSE, KM_PRESS, 0, 0);
|
||||
|
||||
|
||||
kmi = WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_down", PAGEDOWNKEY, KM_PRESS, 0, 0);
|
||||
RNA_boolean_set(kmi->ptr, "page", true);
|
||||
kmi = WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_up", PAGEUPKEY, KM_PRESS, 0, 0);
|
||||
RNA_boolean_set(kmi->ptr, "page", true);
|
||||
|
||||
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MOUSEZOOM, 0, 0, 0);
|
||||
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MOUSEPAN, 0, KM_CTRL, 0);
|
||||
|
||||
Reference in New Issue
Block a user