Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/CMakeLists.txt46
-rw-r--r--source/blender/editors/interface/Makefile2
-rw-r--r--source/blender/editors/interface/interface.c29
-rw-r--r--source/blender/editors/interface/interface_anim.c4
-rw-r--r--source/blender/editors/interface/interface_draw.c442
-rw-r--r--source/blender/editors/interface/interface_handlers.c364
-rw-r--r--source/blender/editors/interface/interface_icons.c155
-rw-r--r--source/blender/editors/interface/interface_intern.h14
-rw-r--r--source/blender/editors/interface/interface_layout.c85
-rw-r--r--source/blender/editors/interface/interface_ops.c3
-rw-r--r--source/blender/editors/interface/interface_panel.c80
-rw-r--r--source/blender/editors/interface/interface_regions.c75
-rw-r--r--source/blender/editors/interface/interface_style.c86
-rw-r--r--source/blender/editors/interface/interface_templates.c738
-rw-r--r--source/blender/editors/interface/interface_widgets.c262
-rw-r--r--source/blender/editors/interface/resources.c110
-rw-r--r--source/blender/editors/interface/view2d.c25
-rw-r--r--source/blender/editors/interface/view2d_ops.c157
18 files changed, 1724 insertions, 953 deletions
diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt
new file mode 100644
index 00000000000..4b4590aeee5
--- /dev/null
+++ b/source/blender/editors/interface/CMakeLists.txt
@@ -0,0 +1,46 @@
+# $Id: CMakeLists.txt 12931 2007-12-17 18:20:48Z theeth $
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# 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.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Contributor(s): Jacques Beaurain.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+FILE(GLOB SRC *.c)
+
+SET(INC
+ ../include
+ ../../blenfont
+ ../../blenkernel
+ ../../blenlib
+ ../../gpu
+ ../../imbuf
+ ../../makesdna
+ ../../makesrna
+ ../../python
+ ../../windowmanager
+ ../../../../intern/guardedalloc
+)
+
+IF(WITH_INTERNATIONAL)
+ ADD_DEFINITIONS(-DINTERNATIONAL)
+ENDIF(WITH_INTERNATIONAL)
+
+IF(NOT WITH_PYTHON)
+ ADD_DEFINITIONS(-DDISABLE_PYTHON)
+ENDIF(NOT WITH_PYTHON)
+
+BLENDERLIB(bf_editor_interface "${SRC}" "${INC}")
diff --git a/source/blender/editors/interface/Makefile b/source/blender/editors/interface/Makefile
index 115740a8403..7b5d4e60fbd 100644
--- a/source/blender/editors/interface/Makefile
+++ b/source/blender/editors/interface/Makefile
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) 2007 Blender Foundation
# All rights reserved.
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 1267a1c1737..021dcc940e6 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -41,15 +41,10 @@
#include "BLI_dynstr.h"
#include "BKE_context.h"
-#include "BKE_idprop.h"
#include "BKE_library.h"
-#include "BKE_screen.h"
-#include "BKE_texture.h"
-#include "BKE_utildefines.h"
#include "BKE_unit.h"
#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "BLF_api.h"
@@ -230,7 +225,7 @@ static void ui_text_bounds_block(uiBlock *block, float offset)
//int transopts= ui_translate_buttons();
//if(bt->type==TEX || bt->type==IDPOIN) transopts= 0;
- j= BLF_width(bt->drawstr);
+ j= BLF_width(style->widget.uifont_id, bt->drawstr);
if(j > i) i = j;
}
@@ -1464,13 +1459,13 @@ static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double va
bUnit_AsString(str, len_max, ui_get_but_scale_unit(but, value), precision, scene->unit.system, unit_type, do_split, pad);
}
-static float ui_get_but_step_unit(uiBut *but, double value, float step_default)
+static float ui_get_but_step_unit(uiBut *but, float step_default)
{
Scene *scene= CTX_data_scene((bContext *)but->block->evil_C);
int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop));
float step;
- step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, value), scene->unit.system, unit_type);
+ step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, step_default), scene->unit.system, unit_type);
if(step > 0.0) { /* -1 is an error value */
return (step/ui_get_but_scale_unit(but, 1.0))*100;
@@ -1633,7 +1628,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), scene->unit.system, unit_type);
}
- if(BPY_button_eval(C, str_unit_convert, &value)) {
+ if(BPY_eval_button(C, str_unit_convert, &value)) {
value = ui_get_but_val(but); /* use its original value */
if(str[0])
@@ -1644,7 +1639,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
value= atof(str);
#endif
- if(!ui_is_but_float(but)) value= (int)value;
+ if(!ui_is_but_float(but)) value= (int)floor(value + 0.5);
if(but->type==NUMABS) value= fabs(value);
/* not that we use hard limits here */
@@ -1770,9 +1765,11 @@ static void ui_free_but(const bContext *C, uiBut *but)
}
if(but->func_argN) MEM_freeN(but->func_argN);
if(but->active) {
- /* XXX solve later, buttons should be free-able without context? */
+ /* XXX solve later, buttons should be free-able without context ideally,
+ however they may have open tooltips or popup windows, which need to
+ be closed using a context pointer */
if(C)
- ui_button_active_cancel(C, but);
+ ui_button_active_free(C, but);
else
if(but->active)
MEM_freeN(but->active);
@@ -2376,7 +2373,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short
}
}
- if((block->flag & UI_BLOCK_LOOP) || ELEM7(but->type, MENU, TEX, LABEL, IDPOIN, BLOCK, BUTM, SEARCH_MENU))
+ if((block->flag & UI_BLOCK_LOOP) || ELEM8(but->type, MENU, TEX, LABEL, IDPOIN, BLOCK, BUTM, SEARCH_MENU, PROGRESSBAR))
but->flag |= (UI_TEXT_LEFT|UI_ICON_LEFT);
else if(but->type==BUT_TOGDUAL)
but->flag |= UI_ICON_LEFT;
@@ -2533,8 +2530,10 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1,
}
}
}
- else
+ else {
+ printf("ui_def_but_rna: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
str= (char*)propname;
+ }
/* now create button */
but= ui_def_but(block, type, retval, str, x1, y1, x2, y2, NULL, min, max, a1, a2, tip);
@@ -2563,7 +2562,7 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1,
/* If this button uses units, calculate the step from this */
if(ui_is_but_unit(but))
- but->a1= ui_get_but_step_unit(but, ui_get_but_val(but), but->a1);
+ but->a1= ui_get_but_step_unit(but, but->a1);
if(freestr)
MEM_freeN(str);
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index 207230a914d..c99622c7518 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -3,7 +3,6 @@
#include <stdlib.h>
#include <string.h>
-#include "MEM_guardedalloc.h"
#include "DNA_anim_types.h"
#include "DNA_scene_types.h"
@@ -12,7 +11,6 @@
#include "BLI_listbase.h"
#include "BLI_string.h"
-#include "BKE_animsys.h"
#include "BKE_context.h"
#include "BKE_fcurve.h"
@@ -111,7 +109,7 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
fcu->flag &= ~FCURVE_SELECTED;
insert_keyframe(id, action, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
- WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
}
}
}
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 893c479c7e9..2a9a1335b1f 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -44,6 +44,8 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
+#include "BLF_api.h"
+
#include "UI_interface.h"
#include "interface_intern.h"
@@ -466,7 +468,7 @@ void ui_draw_but_IMAGE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
//int w, h;
/* hardcoded to splash, loading and freeing every draw, eek! */
- ibuf= IMB_ibImageFromMemory((int *)datatoc_splash_png, datatoc_splash_png_size, IB_rect);
+ ibuf= IMB_ibImageFromMemory((unsigned char*)datatoc_splash_png, datatoc_splash_png_size, IB_rect);
if (!ibuf) return;
@@ -685,6 +687,64 @@ static void ui_draw_but_CHARTAB(uiBut *but)
#endif // INTERNATIONAL
#endif
+static void draw_scope_end(rctf *rect, GLint *scissor)
+{
+ float scaler_x1, scaler_x2;
+
+ /* restore scissortest */
+ glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
+
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+
+ /* scale widget */
+ scaler_x1 = rect->xmin + (rect->xmax - rect->xmin)/2 - SCOPE_RESIZE_PAD;
+ scaler_x2 = rect->xmin + (rect->xmax - rect->xmin)/2 + SCOPE_RESIZE_PAD;
+
+ glColor4f(0.f, 0.f, 0.f, 0.25f);
+ fdrawline(scaler_x1, rect->ymin-4, scaler_x2, rect->ymin-4);
+ fdrawline(scaler_x1, rect->ymin-7, scaler_x2, rect->ymin-7);
+ glColor4f(1.f, 1.f, 1.f, 0.25f);
+ fdrawline(scaler_x1, rect->ymin-5, scaler_x2, rect->ymin-5);
+ fdrawline(scaler_x1, rect->ymin-8, scaler_x2, rect->ymin-8);
+
+ /* outline */
+ glColor4f(0.f, 0.f, 0.f, 0.5f);
+ uiSetRoundBox(15);
+ gl_round_box(GL_LINE_LOOP, rect->xmin-1, rect->ymin, rect->xmax+1, rect->ymax+1, 3.0f);
+}
+
+void histogram_draw_one(float r, float g, float b, float alpha, float x, float y, float w, float h, float *data, int res)
+{
+ int i;
+
+ /* under the curve */
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ glColor4f(r, g, b, alpha);
+
+ glShadeModel(GL_FLAT);
+ glBegin(GL_QUAD_STRIP);
+ glVertex2f(x, y);
+ glVertex2f(x, y + (data[0]*h));
+ for (i=1; i < res; i++) {
+ float x2 = x + i * (w/(float)res);
+ glVertex2f(x2, y + (data[i]*h));
+ glVertex2f(x2, y);
+ }
+ glEnd();
+
+ /* curve outline */
+ glColor4f(0.f, 0.f, 0.f, 0.25f);
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_LINE_SMOOTH);
+ glBegin(GL_LINE_STRIP);
+ for (i=0; i < res; i++) {
+ float x2 = x + i * (w/(float)res);
+ glVertex2f(x2, y + (data[i]*h));
+ }
+ glEnd();
+ glDisable(GL_LINE_SMOOTH);
+}
void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *recti)
{
@@ -692,10 +752,8 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *
int res = hist->x_resolution;
rctf rect;
int i;
- int rgb;
float w, h;
- float scaler_x1, scaler_x2;
- float alpha;
+ //float alpha;
GLint scissor[4];
if (hist==NULL) { printf("hist is null \n"); return; }
@@ -706,8 +764,7 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *
rect.ymax = (float)recti->ymax-1;
w = rect.xmax - rect.xmin;
- h = rect.ymax - rect.ymin;
- h *= hist->ymax;
+ h = (rect.ymax - rect.ymin) * hist->ymax;
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
@@ -726,70 +783,327 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *
/* need scissor test, histogram can draw outside of boundary */
glGetIntegerv(GL_VIEWPORT, scissor);
glScissor(ar->winrct.xmin + (rect.xmin-1), ar->winrct.ymin+(rect.ymin-1), (rect.xmax+1)-(rect.xmin-1), (rect.ymax+1)-(rect.ymin-1));
-
- for (rgb=0; rgb<3; rgb++) {
- float *data = NULL;
-
- if (rgb==0) data = hist->data_r;
- else if (rgb==1) data = hist->data_g;
- else if (rgb==2) data = hist->data_b;
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- alpha = 0.75;
- if (rgb==0) glColor4f(1.f, 0.f, 0.f, alpha);
- else if (rgb==1) glColor4f(0.f, 1.f, 0.f, alpha);
- else if (rgb==2) glColor4f(0.f, 0.f, 1.f, alpha);
-
- glShadeModel(GL_FLAT);
- glBegin(GL_QUAD_STRIP);
- glVertex2f(rect.xmin, rect.ymin);
- glVertex2f(rect.xmin, rect.ymin + (data[0]*h));
- for (i=1; i < res; i++) {
- float x = rect.xmin + i * (w/(float)res);
- glVertex2f(x, rect.ymin + (data[i]*h));
- glVertex2f(x, rect.ymin);
+
+ 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);
+ else {
+ if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_R)
+ histogram_draw_one(1.0, 0.0, 0.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_r, res);
+ if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_G)
+ histogram_draw_one(0.0, 1.0, 0.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_g, res);
+ 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);
+ }
+
+ /* outline, scale gripper */
+ draw_scope_end(&rect, scissor);
+}
+
+void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *recti)
+{
+ Scopes *scopes = (Scopes *)but->poin;
+ rctf rect;
+ int i, c;
+ float w, w3, h, alpha, yofs;
+ GLint scissor[4];
+ float colors[3][3] = {{1,0,0},{0,1,0},{0,0,1}};
+ 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;
+
+ rect.xmin = (float)recti->xmin+1;
+ rect.xmax = (float)recti->xmax-1;
+ rect.ymin = (float)recti->ymin+SCOPE_RESIZE_PAD+2;
+ rect.ymax = (float)recti->ymax-1;
+
+ if (scopes->wavefrm_yfac < 0.5f )
+ scopes->wavefrm_yfac =0.98f;
+ w = rect.xmax - rect.xmin-7;
+ h = (rect.ymax - rect.ymin)*scopes->wavefrm_yfac;
+ yofs= rect.ymin + (rect.ymax - rect.ymin -h)/2.0f;
+ w3=w/3.0f;
+
+ /* log scale for alpha */
+ alpha = scopes->wavefrm_alpha*scopes->wavefrm_alpha;
+
+ for(c=0; c<3; c++) {
+ for(i=0; i<3; i++) {
+ colors_alpha[c][i] = colors[c][i] * alpha;
+ colorsycc_alpha[c][i] = colorsycc[c][i] * alpha;
}
- glEnd();
-
- glColor4f(0.f, 0.f, 0.f, 0.25f);
+ }
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+
+ glColor4f(0.f, 0.f, 0.f, 0.3f);
+ uiSetRoundBox(15);
+ gl_round_box(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
+
+
+ /* need scissor test, waveform can draw outside of boundary */
+ glGetIntegerv(GL_VIEWPORT, scissor);
+ glScissor(ar->winrct.xmin + (rect.xmin-1), 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 lines here */
+ for (i=0; i<6; i++) {
+ char str[4];
+ sprintf(str,"%-3d",i*20);
+ str[3]='\0';
+ fdrawline(rect.xmin+22, yofs+(i/5.f)*h, rect.xmax+1, yofs+(i/5.f)*h);
+ BLF_draw_default(rect.xmin+1, yofs-5+(i/5.f)*h, 0, str);
+ /* in the loop because blf_draw reset it */
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ }
+ /* 3 vertical separation */
+ if (scopes->wavefrm_mode!= SCOPES_WAVEFRM_LUMA) {
+ for (i=1; i<3; i++) {
+ 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 */
+ glColor4f(1.f, 0.4f, 0.f, 0.2f);
+ if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709)){
+ fdrawline(rect.xmin+22, yofs+h*16.0f/255.0f, rect.xmax+1, yofs+h*16.0f/255.0f);
+ fdrawline(rect.xmin+22, yofs+h*235.0f/255.0f, rect.xmin+w3, yofs+h*235.0f/255.0f);
+ fdrawline(rect.xmin+3*w3, yofs+h*235.0f/255.0f, rect.xmax+1, yofs+h*235.0f/255.0f);
+ fdrawline(rect.xmin+w3, yofs+h*240.0f/255.0f, rect.xmax+1, yofs+h*240.0f/255.0f);
+ }
+ /* 7.5 IRE black point level for NTSC */
+ if (scopes->wavefrm_mode== SCOPES_WAVEFRM_LUMA)
+ fdrawline(rect.xmin, yofs+h*0.075f, rect.xmax+1, yofs+h*0.075f);
+
+ if (scopes->ok && scopes->waveform_1 != NULL) {
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_LINE_SMOOTH);
- glBegin(GL_LINE_STRIP);
- for (i=0; i < res; i++) {
- float x = rect.xmin + i * (w/(float)res);
- glVertex2f(x, rect.ymin + (data[i]*h));
+ /* LUMA (1 channel) */
+ glBlendFunc(GL_ONE,GL_ONE);
+ glColor3f(alpha, alpha, alpha);
+ 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);
+ glDrawArrays(GL_POINTS, 0, scopes->waveform_tot);
+
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glPopMatrix();
+
+ /* min max */
+ glColor3f(.5f, .5f, .5f);
+ min= yofs+scopes->minmax[0][0]*h;
+ max= yofs+scopes->minmax[0][1]*h;
+ CLAMP(min, rect.ymin, rect.ymax);
+ CLAMP(max, rect.ymin, rect.ymax);
+ fdrawline(rect.xmax-3,min,rect.xmax-3,max);
}
- glEnd();
- glDisable(GL_LINE_SMOOTH);
+
+ /* RGB / YCC (3 channels) */
+ else if (ELEM4(scopes->wavefrm_mode, SCOPES_WAVEFRM_RGB, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709, SCOPES_WAVEFRM_YCC_JPEG)) {
+ int rgb = (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB);
+
+ glBlendFunc(GL_ONE,GL_ONE);
+
+ glPushMatrix();
+ glEnableClientState(GL_VERTEX_ARRAY);
+
+ glTranslatef(rect.xmin, yofs, 0.f);
+ glScalef(w3, h, 0.f);
+
+ glColor3fv((rgb)?colors_alpha[0]:colorsycc_alpha[0]);
+ glVertexPointer(2, GL_FLOAT, 0, scopes->waveform_1);
+ glDrawArrays(GL_POINTS, 0, scopes->waveform_tot);
+
+ glTranslatef(1.f, 0.f, 0.f);
+ glColor3fv((rgb)?colors_alpha[1]:colorsycc_alpha[1]);
+ glVertexPointer(2, GL_FLOAT, 0, scopes->waveform_2);
+ glDrawArrays(GL_POINTS, 0, scopes->waveform_tot);
+
+ glTranslatef(1.f, 0.f, 0.f);
+ glColor3fv((rgb)?colors_alpha[2]:colorsycc_alpha[2]);
+ glVertexPointer(2, GL_FLOAT, 0, scopes->waveform_3);
+ glDrawArrays(GL_POINTS, 0, scopes->waveform_tot);
+
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glPopMatrix();
+
+
+ /* min max */
+ for (c=0; c<3; c++) {
+ if (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB)
+ glColor3f(colors[c][0]*0.75, colors[c][1]*0.75, colors[c][2]*0.75);
+ else
+ glColor3f(colorsycc[c][0]*0.75, colorsycc[c][1]*0.75, colorsycc[c][2]*0.75);
+ min= yofs+scopes->minmax[c][0]*h;
+ max= yofs+scopes->minmax[c][1]*h;
+ CLAMP(min, rect.ymin, rect.ymax);
+ CLAMP(max, rect.ymin, rect.ymax);
+ fdrawline(rect.xmin+w+2+c*2,min,rect.xmin+w+2+c*2,max);
+ }
+ }
+
}
+ /* outline, scale gripper */
+ draw_scope_end(&rect, scissor);
+}
- /* restore scissortest */
- glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
+float polar_to_x(float center, float diam, float ampli, float angle)
+{
+ return center + diam * ampli * cosf(angle);
+}
+
+float polar_to_y(float center, float diam, float ampli, float angle)
+{
+ return center + diam * ampli * sinf(angle);
+}
+
+void vectorscope_draw_target(float centerx, float centery, float diam, float r, float g, float b)
+{
+ float y,u,v;
+ float tangle=0.f, tampli;
+ float dangle, dampli, dangle2, dampli2;
+
+ rgb_to_yuv(r,g,b, &y, &u, &v);
+ if (u>0 && v>=0) tangle=atanf(v/u);
+ else if (u>0 && v<0) tangle=atanf(v/u)+2*M_PI;
+ else if (u<0) tangle=atanf(v/u)+M_PI;
+ else if (u==0 && v>0) tangle=M_PI/2.0f;
+ else if (u==0 && v<0) tangle=-M_PI/2.0f;
+ tampli= sqrtf(u*u+v*v);
+
+ /* small target vary by 2.5 degree and 2.5 IRE unit */
+ glColor4f(1.0f, 1.0f, 1.0, 0.12f);
+ dangle= 2.5*M_PI/180.0f;
+ dampli= 2.5f/200.0f;
+ glBegin(GL_LINE_STRIP);
+ glVertex2f(polar_to_x(centerx,diam,tampli+dampli,tangle+dangle), polar_to_y(centery,diam,tampli+dampli,tangle+dangle));
+ glVertex2f(polar_to_x(centerx,diam,tampli-dampli,tangle+dangle), polar_to_y(centery,diam,tampli-dampli,tangle+dangle));
+ glVertex2f(polar_to_x(centerx,diam,tampli-dampli,tangle-dangle), polar_to_y(centery,diam,tampli-dampli,tangle-dangle));
+ glVertex2f(polar_to_x(centerx,diam,tampli+dampli,tangle-dangle), polar_to_y(centery,diam,tampli+dampli,tangle-dangle));
+ glVertex2f(polar_to_x(centerx,diam,tampli+dampli,tangle+dangle), polar_to_y(centery,diam,tampli+dampli,tangle+dangle));
+ glEnd();
+ /* big target vary by 10 degree and 20% amplitude */
+ glColor4f(1.0f, 1.0f, 1.0, 0.12f);
+ dangle= 10*M_PI/180.0f;
+ dampli= 0.2*tampli;
+ dangle2= 5.0f*M_PI/180.0f;
+ dampli2= 0.5f*dampli;
+ glBegin(GL_LINE_STRIP);
+ glVertex2f(polar_to_x(centerx,diam,tampli+dampli-dampli2,tangle+dangle), polar_to_y(centery,diam,tampli+dampli-dampli2,tangle+dangle));
+ glVertex2f(polar_to_x(centerx,diam,tampli+dampli,tangle+dangle), polar_to_y(centery,diam,tampli+dampli,tangle+dangle));
+ glVertex2f(polar_to_x(centerx,diam,tampli+dampli,tangle+dangle-dangle2), polar_to_y(centery,diam,tampli+dampli,tangle+dangle-dangle2));
+ glEnd();
+ glBegin(GL_LINE_STRIP);
+ glVertex2f(polar_to_x(centerx,diam,tampli-dampli+dampli2,tangle+dangle), polar_to_y(centery ,diam,tampli-dampli+dampli2,tangle+dangle));
+ glVertex2f(polar_to_x(centerx,diam,tampli-dampli,tangle+dangle), polar_to_y(centery,diam,tampli-dampli,tangle+dangle));
+ glVertex2f(polar_to_x(centerx,diam,tampli-dampli,tangle+dangle-dangle2), polar_to_y(centery,diam,tampli-dampli,tangle+dangle-dangle2));
+ glEnd();
+ glBegin(GL_LINE_STRIP);
+ glVertex2f(polar_to_x(centerx,diam,tampli-dampli+dampli2,tangle-dangle), polar_to_y(centery,diam,tampli-dampli+dampli2,tangle-dangle));
+ glVertex2f(polar_to_x(centerx,diam,tampli-dampli,tangle-dangle), polar_to_y(centery,diam,tampli-dampli,tangle-dangle));
+ glVertex2f(polar_to_x(centerx,diam,tampli-dampli,tangle-dangle+dangle2), polar_to_y(centery,diam,tampli-dampli,tangle-dangle+dangle2));
+ glEnd();
+ glBegin(GL_LINE_STRIP);
+ glVertex2f(polar_to_x(centerx,diam,tampli+dampli-dampli2,tangle-dangle), polar_to_y(centery,diam,tampli+dampli-dampli2,tangle-dangle));
+ glVertex2f(polar_to_x(centerx,diam,tampli+dampli,tangle-dangle), polar_to_y(centery,diam,tampli+dampli,tangle-dangle));
+ glVertex2f(polar_to_x(centerx,diam,tampli+dampli,tangle-dangle+dangle2), polar_to_y(centery,diam,tampli+dampli,tangle-dangle+dangle2));
+ glEnd();
+}
+
+void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *recti)
+{
+ Scopes *scopes = (Scopes *)but->poin;
+ rctf rect;
+ int i, j;
+ int skina= 123; /* angle in degree of the skin tone line */
+ float w, h, centerx, centery, diam;
+ float alpha;
+ float colors[6][3]={{.75,0,0},{.75,.75,0},{0,.75,0},{0,.75,.75},{0,0,.75},{.75,0,.75}};
+ GLint scissor[4];
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ rect.xmin = (float)recti->xmin+1;
+ rect.xmax = (float)recti->xmax-1;
+ rect.ymin = (float)recti->ymin+SCOPE_RESIZE_PAD+2;
+ rect.ymax = (float)recti->ymax-1;
- /* height scaling widget */
- scaler_x1 = rect.xmin + w/2 - SCOPE_RESIZE_PAD;
- scaler_x2 = rect.xmin + w/2 + SCOPE_RESIZE_PAD;
+ w = rect.xmax - rect.xmin;
+ h = rect.ymax - rect.ymin;
+ centerx = rect.xmin + w/2;
+ centery = rect.ymin + h/2;
+ diam= (w<h)?w:h;
- glColor4f(0.f, 0.f, 0.f, 0.25f);
- fdrawline(scaler_x1, rect.ymin-4, scaler_x2, rect.ymin-4);
- fdrawline(scaler_x1, rect.ymin-7, scaler_x2, rect.ymin-7);
- glColor4f(1.f, 1.f, 1.f, 0.25f);
- fdrawline(scaler_x1, rect.ymin-5, scaler_x2, rect.ymin-5);
- fdrawline(scaler_x1, rect.ymin-8, scaler_x2, rect.ymin-8);
-
+ alpha = scopes->vecscope_alpha*scopes->vecscope_alpha*scopes->vecscope_alpha;
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glColor4f(0.f, 0.f, 0.f, 0.5f);
+ glColor4f(0.f, 0.f, 0.f, 0.3f);
uiSetRoundBox(15);
- gl_round_box(GL_LINE_LOOP, rect.xmin-1, rect.ymin, rect.xmax+1, rect.ymax+1, 3.0f);
+ gl_round_box(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
+
+ /* need scissor test, hvectorscope can draw outside of boundary */
+ glGetIntegerv(GL_VIEWPORT, scissor);
+ glScissor(ar->winrct.xmin + (rect.xmin-1), 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 */
+ fdrawline(centerx - (diam/2)-5, centery, centerx + (diam/2)+5, centery);
+ fdrawline(centerx, centery - (diam/2)-5, centerx, centery + (diam/2)+5);
+ /* circles */
+ for(j=0; j<5; j++) {
+ glBegin(GL_LINE_STRIP);
+ for(i=0; i<=360; i=i+15) {
+ float a= i*M_PI/180.0;
+ float r= (j+1)/10.0f;
+ glVertex2f( polar_to_x(centerx,diam,r,a), polar_to_y(centery,diam,r,a));
+ }
+ glEnd();
+ }
+ /* skin tone line */
+ glColor4f(1.f, 0.4f, 0.f, 0.2f);
+ fdrawline( polar_to_x(centerx, diam, 0.5f, skina*M_PI/180.0), polar_to_y(centery,diam,0.5,skina*M_PI/180.0),
+ polar_to_x(centerx, diam, 0.1f, skina*M_PI/180.0), polar_to_y(centery,diam,0.1,skina*M_PI/180.0));
+ /* saturation points */
+ for(i=0; i<6; i++)
+ vectorscope_draw_target(centerx, centery, diam, colors[i][0], colors[i][1], colors[i][2]);
+
+ if (scopes->ok && scopes->vecscope != NULL) {
+ /* pixel point cloud */
+ glBlendFunc(GL_ONE,GL_ONE);
+ glColor3f(alpha, alpha, alpha);
+
+ glPushMatrix();
+ glEnableClientState(GL_VERTEX_ARRAY);
+
+ glTranslatef(centerx, centery, 0.f);
+ glScalef(diam, diam, 0.f);
+
+ glVertexPointer(2, GL_FLOAT, 0, scopes->vecscope);
+ glDrawArrays(GL_POINTS, 0, scopes->waveform_tot);
+
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glPopMatrix();
+ }
+
+ /* outline, scale gripper */
+ draw_scope_end(&rect, scissor);
glDisable(GL_BLEND);
}
-
void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *wcol, rcti *rect)
{
ColorBand *coba;
@@ -832,7 +1146,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *wcol, rcti *rect)
glColor4fv( &cbd->r );
glVertex2fv(v1); glVertex2fv(v2);
- for( a = 1; a < sizex; a++ ) {
+ for( a = 1; a <= sizex; a++ ) {
pos = ((float)a) / (sizex-1);
do_colorband( coba, pos, colf );
if (but->block->color_profile != BLI_PR_NONE)
@@ -849,19 +1163,8 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *wcol, rcti *rect)
glDisable(GL_BLEND);
/* outline */
- v1[0]= x1; v1[1]= y1;
-
- cpack(0x0);
- glBegin(GL_LINE_LOOP);
- glVertex2fv(v1);
- v1[0]+= sizex;
- glVertex2fv(v1);
- v1[1]+= sizey;
- glVertex2fv(v1);
- v1[0]-= sizex;
- glVertex2fv(v1);
- glEnd();
-
+ glColor4f(0.0, 0.0, 0.0, 1.0);
+ fdrawbox(x1, y1, x1+sizex, y1+sizey);
/* help lines */
v1[0]= v2[0]=v3[0]= x1;
@@ -917,6 +1220,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *wcol, rcti *rect)
}
}
glEnd();
+
}
void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect)
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index fc69fc6fafa..ac06f635975 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -24,9 +24,11 @@
*/
#include <float.h>
+#include <limits.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include "MEM_guardedalloc.h"
@@ -42,7 +44,6 @@
#include "BKE_idprop.h"
#include "BKE_report.h"
#include "BKE_texture.h"
-#include "BKE_utildefines.h"
#include "ED_screen.h"
#include "ED_util.h"
@@ -176,6 +177,7 @@ typedef struct uiAfterFunc {
int autokey;
} uiAfterFunc;
+static int ui_but_contains_pt(uiBut *but, int mx, int my);
static int ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y);
static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState state);
static int ui_handler_region_menu(bContext *C, wmEvent *event, void *userdata);
@@ -184,11 +186,16 @@ static void button_timers_tooltip_remove(bContext *C, uiBut *but);
/* ******************** menu navigation helpers ************** */
+static int ui_but_editable(uiBut *but)
+{
+ return ELEM5(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX, PROGRESSBAR);
+}
+
static uiBut *ui_but_prev(uiBut *but)
{
while(but->prev) {
but= but->prev;
- if(!ELEM4(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX)) return but;
+ if(!ui_but_editable(but)) return but;
}
return NULL;
}
@@ -197,7 +204,7 @@ static uiBut *ui_but_next(uiBut *but)
{
while(but->next) {
but= but->next;
- if(!ELEM4(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX)) return but;
+ if(!ui_but_editable(but)) return but;
}
return NULL;
}
@@ -208,7 +215,7 @@ static uiBut *ui_but_first(uiBlock *block)
but= block->buttons.first;
while(but) {
- if(!ELEM4(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX)) return but;
+ if(!ui_but_editable(but)) return but;
but= but->next;
}
return NULL;
@@ -220,7 +227,7 @@ static uiBut *ui_but_last(uiBlock *block)
but= block->buttons.last;
while(but) {
- if(!ELEM4(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX)) return but;
+ if(!ui_but_editable(but)) return but;
but= but->prev;
}
return NULL;
@@ -229,7 +236,7 @@ static uiBut *ui_but_last(uiBlock *block)
static int ui_is_a_warp_but(uiBut *but)
{
if(U.uiflag & USER_CONTINUOUS_MOUSE)
- if(ELEM(but->type, NUM, NUMABS))
+ if(ELEM3(but->type, NUM, NUMABS, HSVCIRCLE))
return TRUE;
return FALSE;
@@ -777,6 +784,8 @@ static void ui_apply_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data)
break;
}
if(bt && bt!=but) {
+ if (!ELEM(bt->type, LINK, INLINK) || !ELEM(but->type, LINK, INLINK))
+ return;
if(but->type==LINK) ui_add_link(but, bt);
else ui_add_link(bt, but);
@@ -801,6 +810,14 @@ static void ui_apply_but_HISTOGRAM(bContext *C, uiBut *but, uiHandleButtonData *
data->applied= 1;
}
+static void ui_apply_but_WAVEFORM(bContext *C, uiBut *but, uiHandleButtonData *data)
+{
+ ui_apply_but_func(C, but);
+ data->retval= but->retval;
+ data->applied= 1;
+}
+
+
static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, int interactive)
{
char *editstr;
@@ -926,6 +943,9 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
case HISTOGRAM:
ui_apply_but_HISTOGRAM(C, but, data);
break;
+ case WAVEFORM:
+ ui_apply_but_WAVEFORM(C, but, data);
+ break;
default:
break;
}
@@ -951,7 +971,7 @@ static void ui_but_drop(bContext *C, wmEvent *event, uiBut *but, uiHandleButtonD
if(ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
ID *id= (ID *)wmd->poin;
- if(but->poin==NULL && but->rnapoin.data==NULL);
+ if(but->poin==NULL && but->rnapoin.data==NULL) {}
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
BLI_strncpy(data->str, id->name+2, data->maxlen);
button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -993,7 +1013,11 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
if(but->poin==NULL && but->rnapoin.data==NULL);
else if(mode=='c') {
- sprintf(buf, "%f", ui_get_but_val(but));
+ if(ui_is_but_float(but))
+ sprintf(buf, "%f", ui_get_but_val(but));
+ else
+ sprintf(buf, "%d", (int)ui_get_but_val(but));
+
WM_clipboard_text_set(buf, 0);
}
else {
@@ -1131,7 +1155,7 @@ static int ui_textedit_delete_selection(uiBut *but, uiHandleButtonData *data)
int len= strlen(str);
int change= 0;
if(but->selsta != but->selend && len) {
- memmove( str+but->selsta, str+but->selend, len+1 );
+ memmove( str+but->selsta, str+but->selend, len-but->selsta+1 );
change= 1;
}
@@ -1139,6 +1163,7 @@ static int ui_textedit_delete_selection(uiBut *but, uiHandleButtonData *data)
return change;
}
+/* note, but->block->aspect is used here, when drawing button style is getting scaled too */
static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, short x)
{
uiStyle *style= U.uistyles.first; // XXX pass on as arg
@@ -1149,7 +1174,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
uiStyleFontSet(fstyle);
if (fstyle->kerning==1) /* for BLF_width */
- BLF_enable(BLF_KERNING_DEFAULT);
+ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
origstr= MEM_callocN(sizeof(char)*data->maxlen, "ui_textedit origstr");
@@ -1172,17 +1197,19 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
while (i > 0) {
i--;
- if (BLF_width(origstr+i) > (startx - x)*0.25) break; // 0.25 == scale factor for less sensitivity
+ if (BLF_width(fstyle->uifont_id, origstr+i) > (startx - x)*0.25) break; // 0.25 == scale factor for less sensitivity
}
but->ofs = i;
but->pos = but->ofs;
}
/* mouse inside the widget */
else if (x >= startx) {
+ float aspect= sqrt(but->block->aspect);
+
but->pos= strlen(origstr)-but->ofs;
/* XXX does not take zoom level into account */
- while (startx + BLF_width(origstr+but->ofs) > x) {
+ while (aspect*startx + aspect*BLF_width(fstyle->uifont_id, origstr+but->ofs) > x) {
if (but->pos <= 0) break;
but->pos--;
origstr[but->pos+but->ofs] = 0;
@@ -1192,7 +1219,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
}
if (fstyle->kerning == 1)
- BLF_disable(BLF_KERNING_DEFAULT);
+ BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
MEM_freeN(origstr);
}
@@ -1508,6 +1535,19 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
data->str= MEM_callocN(sizeof(char)*data->maxlen + 1, "textedit str");
ui_get_but_string(but, data->str, data->maxlen);
+ if(ELEM3(but->type, NUM, NUMABS, NUMSLI)) {
+ /* XXX: we dont have utf editing yet so for numbers its best to strip out utf chars
+ * this is so the deg' synbol isnt included in number editing fields: bug 22274 */
+ int i;
+ for(i=0; data->str[i]; i++) {
+ if(!isascii(data->str[i])) {
+ data->str[i]= '\0';
+ break;
+ }
+ }
+ }
+
+
data->origstr= BLI_strdup(data->str);
data->selextend= 0;
data->selstartx= 0;
@@ -1634,7 +1674,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
my= event->y;
ui_window_to_block(data->region, block, &mx, &my);
- if ((but->y1 <= my) && (my <= but->y2) && (but->x1 <= mx) && (mx <= but->x2)) {
+ if (ui_but_contains_pt(but, mx, my)) {
ui_textedit_set_cursor_pos(but, data, mx);
but->selsta = but->selend = but->pos;
data->selstartx= mx;
@@ -1740,7 +1780,11 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
if(event->ascii && (retval == WM_UI_HANDLER_CONTINUE)) {
changed= ui_textedit_type_ascii(but, data, event->ascii);
retval= WM_UI_HANDLER_BREAK;
+
}
+ /* textbutton with magnifier icon: do live update for search button */
+ if(but->icon==ICON_VIEWZOOM)
+ update= 1;
}
if(changed) {
@@ -1970,14 +2014,17 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data
if(event->type == MOUSEMOVE)
return WM_UI_HANDLER_CONTINUE;
- if(event->type == ESCKEY) {
- /* data->cancel doesnt work, this button opens immediate */
- if(but->flag & UI_BUT_IMMEDIATE)
- ui_set_but_val(but, 0);
- else
- data->cancel= 1;
- button_activate_state(C, but, BUTTON_STATE_EXIT);
- return WM_UI_HANDLER_BREAK;
+ if(event->type == LEFTMOUSE && event->val==KM_PRESS) {
+ /* only cancel if click outside the button */
+ if(ui_mouse_inside_button(but->active->region, but, event->x, event->y) == 0) {
+ /* data->cancel doesnt work, this button opens immediate */
+ if(but->flag & UI_BUT_IMMEDIATE)
+ ui_set_but_val(but, 0);
+ else
+ data->cancel= 1;
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+ return WM_UI_HANDLER_BREAK;
+ }
}
/* always set */
@@ -2011,15 +2058,11 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data
return WM_UI_HANDLER_CONTINUE;
}
-
static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
if(data->state == BUTTON_STATE_HIGHLIGHT) {
if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
- short event= (short)ui_get_but_val(but);
- /* hardcoded prevention from editing or assigning ESC */
- if(event!=ESCKEY)
- button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT);
+ button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT);
return WM_UI_HANDLER_BREAK;
}
}
@@ -2028,7 +2071,7 @@ static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, w
return WM_UI_HANDLER_CONTINUE;
if(event->val==KM_PRESS) {
- if(event->type!=ESCKEY && WM_key_event_string(event->type)[0])
+ if(WM_key_event_string(event->type)[0])
ui_set_but_val(but, event->type);
else
data->cancel= 1;
@@ -2095,8 +2138,13 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, wmE
}
if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
+ int ret = WM_UI_HANDLER_BREAK;
+ /* XXX (a bit ugly) Special case handling for filebrowser drag button */
+ if(but->dragpoin && but->imb && ui_but_mouse_inside_icon(but, data->region, event)) {
+ ret = WM_UI_HANDLER_CONTINUE;
+ }
button_activate_state(C, but, BUTTON_STATE_EXIT);
- return WM_UI_HANDLER_BREAK;
+ return ret;
}
}
else if(data->state == BUTTON_STATE_WAIT_DRAG) {
@@ -2189,7 +2237,6 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
softmax= but->softmax;
softrange= softmax - softmin;
-
if(ui_is_a_warp_but(but)) {
/* Mouse location isn't screen clamped to the screen so use a linear mapping
* 2px == 1-int, or 1px == 1-ClickStep */
@@ -2249,15 +2296,18 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
/* Use a non-linear mapping of the mouse drag especially for large floats (normal behavior) */
deler= 500;
if(!ui_is_but_float(but)) {
- if((softrange)<100) deler= 200.0;
- if((softrange)<25) deler= 50.0;
+ /* prevent large ranges from getting too out of control */
+ if (softrange > 600) deler = powf(softrange, 0.75);
+
+ if (softrange < 100) deler= 200.0;
+ if (softrange < 25) deler= 50.0;
}
deler /= fac;
- if(ui_is_but_float(but) && softrange > 11) {
+ if(softrange > 11) {
/* non linear change in mouse input- good for high precicsion */
data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabs(data->dragstartx-mx)*0.002);
- } else if (!ui_is_but_float(but) && softrange > 129) { /* only scale large int buttons */
+ } else if (softrange > 129) { /* only scale large int buttons */
/* non linear change in mouse input- good for high precicsionm ints need less fine tuning */
data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabs(data->dragstartx-mx)*0.004);
} else {
@@ -2265,8 +2315,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
data->dragf+= ((float)(mx-data->draglastx))/deler ;
}
- if(data->dragf>1.0) data->dragf= 1.0;
- if(data->dragf<0.0) data->dragf= 0.0;
+ CLAMP(data->dragf, 0.0, 1.0);
data->draglastx= mx;
tempf= (softmin + data->dragf*softrange);
@@ -2278,7 +2327,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
CLAMP(temp, softmin, softmax);
lvalue= (int)data->value;
-
+
if(temp != lvalue) {
data->dragchange= 1;
data->value= (double)temp;
@@ -2926,6 +2975,8 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
if (color_profile)
hsv[2] = srgb_to_linearrgb(hsv[2]);
+ if (hsv[2] > but->softmax)
+ hsv[2] = but->softmax;
}
hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
@@ -3009,7 +3060,7 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
return WM_UI_HANDLER_CONTINUE;
}
-static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx, int my)
+static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx, int my, int shift)
{
rcti rect;
int changed= 1;
@@ -3023,13 +3074,29 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx
/* exception, when using color wheel in 'locked' value state:
* allow choosing a hue for black values, by giving a tiny increment */
- if (but->a2 == 1) { // lock
+ if (but->flag & UI_BUT_COLOR_LOCK) { // lock
if (hsv[2] == 0.f) hsv[2] = 0.0001f;
}
-
+
+ if(U.uiflag & USER_CONTINUOUS_MOUSE) {
+ float fac= shift ? 0.05 : 1.0f;
+ /* slow down the mouse, this is fairly picky */
+ mx = (data->dragstartx*(1.0f-fac) + mx*fac);
+ my = (data->dragstarty*(1.0f-fac) + my*fac);
+ }
+
ui_hsvcircle_vals_from_pos(hsv, hsv+1, &rect, (float)mx, (float)my);
-
+
+ if(but->flag & UI_BUT_COLOR_CUBIC)
+ hsv[1]= 1.0f - sqrt3f(1.0f - hsv[1]);
+
hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
+
+ if((but->flag & UI_BUT_VEC_SIZE_LOCK) && (rgb[0] || rgb[1] || rgb[2])) {
+ normalize_v3(rgb);
+ mul_v3_fl(rgb, but->a2);
+ }
+
ui_set_but_vectorf(but, rgb);
data->draglastx= mx;
@@ -3056,7 +3123,7 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
- if(ui_numedit_but_HSVCIRCLE(but, data, mx, my))
+ if(ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift))
ui_numedit_apply(C, block, but, data);
return WM_UI_HANDLER_BREAK;
@@ -3107,7 +3174,7 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
}
else if(event->type == MOUSEMOVE) {
if(mx!=data->draglastx || my!=data->draglasty) {
- if(ui_numedit_but_HSVCIRCLE(but, data, mx, my))
+ if(ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift))
ui_numedit_apply(C, block, but, data);
}
}
@@ -3183,24 +3250,8 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle
if(event->ctrl) {
/* insert new key on mouse location */
- if(coba->tot < MAXCOLORBAND-1) {
- float pos= ((float)(mx - but->x1))/(but->x2-but->x1);
- float col[4];
-
- do_colorband(coba, pos, col); /* executes it */
-
- coba->tot++;
- coba->cur= coba->tot-1;
-
- coba->data[coba->cur].r= col[0];
- coba->data[coba->cur].g= col[1];
- coba->data[coba->cur].b= col[2];
- coba->data[coba->cur].a= col[3];
- coba->data[coba->cur].pos= pos;
-
- ui_colorband_update(coba);
- }
-
+ float pos= ((float)(mx - but->x1))/(but->x2-but->x1);
+ colorband_element_add(coba, pos);
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else {
@@ -3460,7 +3511,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
return WM_UI_HANDLER_CONTINUE;
}
-static int in_histogram_resize_zone(uiBut *but, int x, int y)
+static int in_scope_resize_zone(uiBut *but, int x, int y)
{
// bottom corner return (x > but->x2 - SCOPE_RESIZE_PAD) && (y < but->y1 + SCOPE_RESIZE_PAD);
return (y < but->y1 + SCOPE_RESIZE_PAD);
@@ -3480,7 +3531,7 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx
dy = my - data->draglasty;
- if (in_histogram_resize_zone(but, data->dragstartx, data->dragstarty)) {
+ if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
/* resize histogram widget itself */
hist->height = (but->y2 - but->y1) + (data->dragstarty - my);
} else {
@@ -3548,6 +3599,156 @@ static int ui_do_but_HISTOGRAM(bContext *C, uiBlock *block, uiBut *but, uiHandle
return WM_UI_HANDLER_CONTINUE;
}
+static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx, int my)
+{
+ Scopes *scopes = (Scopes *)but->poin;
+ rcti rect;
+ int changed= 1;
+ float dx, dy, yfac=1.f;
+
+ rect.xmin= but->x1; rect.xmax= but->x2;
+ rect.ymin= but->y1; rect.ymax= but->y2;
+
+ dx = mx - data->draglastx;
+ dy = my - data->draglasty;
+
+
+ if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
+ /* resize waveform widget itself */
+ scopes->wavefrm_height = (but->y2 - but->y1) + (data->dragstarty - my);
+ } else {
+ /* scale waveform values */
+ yfac = scopes->wavefrm_yfac;
+ scopes->wavefrm_yfac += dy/200.0f;
+
+ CLAMP(scopes->wavefrm_yfac, 0.5f, 2.f);
+ }
+
+ data->draglastx= mx;
+ data->draglasty= my;
+
+ return changed;
+}
+
+static int ui_do_but_WAVEFORM(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, 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;
+ data->dragstarty= my;
+ 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_WAVEFORM(but, data, mx, my))
+ ui_numedit_apply(C, block, but, data);
+
+ return WM_UI_HANDLER_BREAK;
+ }
+ else if (event->type == ZEROKEY && event->val == KM_PRESS) {
+ Scopes *scopes = (Scopes *)but->poin;
+ scopes->wavefrm_yfac = 1.f;
+
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+ return WM_UI_HANDLER_BREAK;
+ }
+ }
+ else if(data->state == BUTTON_STATE_NUM_EDITING) {
+ if(event->type == ESCKEY) {
+ data->cancel= 1;
+ data->escapecancel= 1;
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
+ else if(event->type == MOUSEMOVE) {
+ if(mx!=data->draglastx || my!=data->draglasty) {
+ if(ui_numedit_but_WAVEFORM(but, data, mx, my))
+ ui_numedit_apply(C, block, but, data);
+ }
+ }
+ else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) {
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
+ return WM_UI_HANDLER_BREAK;
+ }
+
+ return WM_UI_HANDLER_CONTINUE;
+}
+
+static int ui_numedit_but_VECTORSCOPE(uiBut *but, uiHandleButtonData *data, int mx, int my)
+{
+ Scopes *scopes = (Scopes *)but->poin;
+ rcti rect;
+ int changed= 1;
+ float dx, dy;
+
+ rect.xmin= but->x1; rect.xmax= but->x2;
+ rect.ymin= but->y1; rect.ymax= but->y2;
+
+ dx = mx - data->draglastx;
+ dy = my - data->draglasty;
+
+ if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
+ /* resize vectorscope widget itself */
+ scopes->vecscope_height = (but->y2 - but->y1) + (data->dragstarty - my);
+ }
+
+ data->draglastx= mx;
+ data->draglasty= my;
+
+ return changed;
+}
+
+static int ui_do_but_VECTORSCOPE(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, 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;
+ data->dragstarty= my;
+ 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_VECTORSCOPE(but, data, mx, my))
+ ui_numedit_apply(C, block, but, data);
+
+ return WM_UI_HANDLER_BREAK;
+ }
+ }
+ else if(data->state == BUTTON_STATE_NUM_EDITING) {
+ if(event->type == ESCKEY) {
+ data->cancel= 1;
+ data->escapecancel= 1;
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
+ else if(event->type == MOUSEMOVE) {
+ if(mx!=data->draglastx || my!=data->draglasty) {
+ if(ui_numedit_but_VECTORSCOPE(but, data, mx, my))
+ ui_numedit_apply(C, block, but, data);
+ }
+ }
+ else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) {
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
+ return WM_UI_HANDLER_BREAK;
+ }
+
+ return WM_UI_HANDLER_CONTINUE;
+}
+
#ifdef INTERNATIONAL
static int ui_do_but_CHARTAB(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
@@ -4061,7 +4262,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
return WM_UI_HANDLER_BREAK;
}
/* reset to default */
- else if(event->type == ZEROKEY && event->val == KM_PRESS) {
+ else if(ELEM(event->type, ZEROKEY,PAD0) && event->val == KM_PRESS) {
if (!(ELEM3(but->type, HSVCIRCLE, HSVCUBE, HISTOGRAM)))
ui_set_but_default(C, but);
}
@@ -4132,11 +4333,18 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
case ROW:
case LISTROW:
case BUT_IMAGE:
+ case PROGRESSBAR:
retval= ui_do_but_EXIT(C, but, data, event);
break;
case HISTOGRAM:
retval= ui_do_but_HISTOGRAM(C, block, but, data, event);
break;
+ case WAVEFORM:
+ retval= ui_do_but_WAVEFORM(C, block, but, data, event);
+ break;
+ case VECTORSCOPE:
+ retval= ui_do_but_VECTORSCOPE(C, block, but, data, event);
+ break;
case TEX:
case IDPOIN:
case SEARCH_MENU:
@@ -4569,7 +4777,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
button_activate_state(C, but, BUTTON_STATE_WAIT_FLASH);
}
-static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *but, int mousemove)
+static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *but, int mousemove, int onfree)
{
uiBlock *block= but->block;
uiBut *bt;
@@ -4579,7 +4787,8 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
button_activate_state(C, but, BUTTON_STATE_EXIT);
/* apply the button action or value */
- ui_apply_button(C, block, but, data, 0);
+ if(!onfree)
+ ui_apply_button(C, block, but, data, 0);
/* if this button is in a menu, this will set the button return
* value to the button value and the menu return value to ok, the
@@ -4594,7 +4803,7 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
}
}
- if(!data->cancel) {
+ if(!onfree && !data->cancel) {
/* autokey & undo push */
ui_apply_autokey_undo(C, but);
@@ -4627,7 +4836,8 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
but->active= NULL;
but->flag &= ~(UI_ACTIVE|UI_SELECT);
but->flag |= UI_BUT_LAST_ACTIVE;
- ui_check_but(but);
+ if(!onfree)
+ ui_check_but(but);
/* adds empty mousemove in queue for re-init handler, in case mouse is
* still over a button. we cannot just check for this ourselfs because
@@ -4636,7 +4846,7 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
WM_event_add_mousemove(C);
}
-void ui_button_active_cancel(const bContext *C, uiBut *but)
+void ui_button_active_free(const bContext *C, uiBut *but)
{
uiHandleButtonData *data;
@@ -4646,7 +4856,7 @@ void ui_button_active_cancel(const bContext *C, uiBut *but)
if(but->active) {
data= but->active;
data->cancel= 1;
- button_activate_exit((bContext*)C, data, but, 0);
+ button_activate_exit((bContext*)C, data, but, 0, 1);
}
}
@@ -4712,7 +4922,7 @@ static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiBu
if(oldbut) {
data= oldbut->active;
data->cancel= 1;
- button_activate_exit(C, data, oldbut, 0);
+ button_activate_exit(C, data, oldbut, 0, 0);
}
button_activate_init(C, ar, but, type);
@@ -4870,7 +5080,7 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
postbut= data->postbut;
posttype= data->posttype;
- button_activate_exit(C, data, but, (postbut == NULL));
+ button_activate_exit(C, data, but, (postbut == NULL), 0);
/* for jumping to the next button with tab while text editing */
if(postbut)
@@ -4974,20 +5184,21 @@ static void ui_handle_button_return_submenu(bContext *C, wmEvent *event, uiBut *
if(menu->menuretval != UI_RETURN_OK)
data->cancel= 1;
- button_activate_exit(C, data, but, 1);
+ button_activate_exit(C, data, but, 1, 0);
}
else if(menu->menuretval == UI_RETURN_OUT) {
if(event->type==MOUSEMOVE && ui_mouse_inside_button(data->region, but, event->x, event->y)) {
button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT);
}
else {
- if(event->type != MOUSEMOVE) {
+ if (ISKEYBOARD(event->type)) {
+ /* keyboard menu hierarchy navigation, going back to previous level */
but->active->used_mouse= 0;
button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT);
}
else {
data->cancel= 1;
- button_activate_exit(C, data, but, 1);
+ button_activate_exit(C, data, but, 1, 0);
}
}
}
@@ -5420,8 +5631,7 @@ static int ui_handler_region(bContext *C, wmEvent *event, void *userdata)
/* either handle events for already activated button or try to activate */
but= ui_but_find_activated(ar);
- if(!but || !button_modal_state(but->active->state))
- retval= ui_handler_panel_region(C, event);
+ retval= ui_handler_panel_region(C, event);
if(retval == WM_UI_HANDLER_CONTINUE)
retval= ui_handle_list_event(C, event, ar);
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index d08ec2f92c5..499c676bf6f 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -44,12 +44,15 @@
#include "BLI_blenlib.h"
#include "BLI_storage_types.h"
+#include "DNA_brush_types.h"
+#include "DNA_object_types.h"
#include "DNA_screen_types.h"
-#include "DNA_userdef_types.h"
+
+#include "RNA_access.h"
+#include "RNA_enum_types.h"
#include "BKE_context.h"
#include "BKE_global.h"
-#include "BKE_image.h"
#include "BKE_icons.h"
#include "BKE_utildefines.h"
@@ -57,7 +60,6 @@
#include "IMB_imbuf_types.h"
#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "ED_datafiles.h"
#include "ED_render.h"
@@ -451,36 +453,76 @@ static void vicon_move_down_draw(int x, int y, int w, int h, float alpha)
glDisable(GL_LINE_SMOOTH);
}
+static void init_brush_icons()
+{
+
+#define INIT_BRUSH_ICON(icon_id, name) \
+ bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_ ##name## _png, \
+ datatoc_ ##name## _png_size, IB_rect); \
+ def_internal_icon(bbuf, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \
+ IMB_freeImBuf(bbuf);
+ // end INIT_BRUSH_ICON
+
+ ImBuf *bbuf;
+ const int w = 96;
+
+ INIT_BRUSH_ICON(ICON_BRUSH_ADD, add);
+ INIT_BRUSH_ICON(ICON_BRUSH_BLOB, blob);
+ INIT_BRUSH_ICON(ICON_BRUSH_BLUR, blur);
+ INIT_BRUSH_ICON(ICON_BRUSH_CLAY, clay);
+ INIT_BRUSH_ICON(ICON_BRUSH_CLONE, clone);
+ INIT_BRUSH_ICON(ICON_BRUSH_CREASE, crease);
+ INIT_BRUSH_ICON(ICON_BRUSH_DARKEN, darken);
+ INIT_BRUSH_ICON(ICON_BRUSH_SCULPT_DRAW, draw);
+ INIT_BRUSH_ICON(ICON_BRUSH_FILL, fill);
+ INIT_BRUSH_ICON(ICON_BRUSH_FLATTEN, flatten);
+ INIT_BRUSH_ICON(ICON_BRUSH_GRAB, grab);
+ INIT_BRUSH_ICON(ICON_BRUSH_INFLATE, inflate);
+ INIT_BRUSH_ICON(ICON_BRUSH_LAYER, layer);
+ INIT_BRUSH_ICON(ICON_BRUSH_LIGHTEN, lighten);
+ INIT_BRUSH_ICON(ICON_BRUSH_MIX, mix);
+ INIT_BRUSH_ICON(ICON_BRUSH_MULTIPLY, multiply);
+ INIT_BRUSH_ICON(ICON_BRUSH_NUDGE, nudge);
+ INIT_BRUSH_ICON(ICON_BRUSH_PINCH, pinch);
+ INIT_BRUSH_ICON(ICON_BRUSH_SCRAPE, scrape);
+ INIT_BRUSH_ICON(ICON_BRUSH_SMEAR, smear);
+ INIT_BRUSH_ICON(ICON_BRUSH_SMOOTH, smooth);
+ INIT_BRUSH_ICON(ICON_BRUSH_SNAKE_HOOK, snake_hook);
+ INIT_BRUSH_ICON(ICON_BRUSH_SOFTEN, soften);
+ INIT_BRUSH_ICON(ICON_BRUSH_SUBTRACT, subtract);
+ INIT_BRUSH_ICON(ICON_BRUSH_TEXDRAW, texdraw);
+ INIT_BRUSH_ICON(ICON_BRUSH_THUMB, thumb);
+ INIT_BRUSH_ICON(ICON_BRUSH_ROTATE, twist);
+ INIT_BRUSH_ICON(ICON_BRUSH_VERTEXDRAW, vertexdraw);
+
+#undef INIT_BRUSH_ICON
+}
+
static void init_internal_icons()
{
bTheme *btheme= U.themes.first;
ImBuf *bbuf= NULL;
int x, y, icontype;
char iconfilestr[FILE_MAXDIR+FILE_MAXFILE];
- char filenamestr[FILE_MAXFILE+16]; // 16 == strlen(".blender/icons/")+1
if ((btheme!=NULL) && (strlen(btheme->tui.iconfile) > 0)) {
-
-#ifdef WIN32
- sprintf(filenamestr, "icons/%s", btheme->tui.iconfile);
-#else
- sprintf(filenamestr, ".blender/icons/%s", btheme->tui.iconfile);
-#endif
-
- BLI_make_file_string("/", iconfilestr, BLI_gethome(), filenamestr);
-
- if (BLI_exists(iconfilestr)) {
- bbuf = IMB_loadiffname(iconfilestr, IB_rect);
- if(bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H) {
- if (G.f & G_DEBUG)
- printf("\n***WARNING***\nIcons file %s too small.\nUsing built-in Icons instead\n", iconfilestr);
- IMB_freeImBuf(bbuf);
- bbuf= NULL;
+ char *datadir= BLI_get_folder(BLENDER_DATAFILES, NULL);
+ if (datadir) {
+ BLI_make_file_string("/", iconfilestr, datadir, btheme->tui.iconfile);
+
+ if (BLI_exists(iconfilestr)) {
+ bbuf = IMB_loadiffname(iconfilestr, IB_rect);
+ if(bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H) {
+ if (G.f & G_DEBUG)
+ printf("\n***WARNING***\nIcons file %s too small.\nUsing built-in Icons instead\n", iconfilestr);
+ IMB_freeImBuf(bbuf);
+ bbuf= NULL;
+ }
}
}
}
if(bbuf==NULL)
- bbuf = IMB_ibImageFromMemory((int *)datatoc_blenderbuttons, datatoc_blenderbuttons_size, IB_rect);
+ bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_blenderbuttons, datatoc_blenderbuttons_size, IB_rect);
if(bbuf) {
/* free existing texture if any */
@@ -518,12 +560,14 @@ static void init_internal_icons()
else
icontype= ICON_TYPE_BUFFER;
- for (y=0; y<ICON_GRID_ROWS; y++) {
- for (x=0; x<ICON_GRID_COLS; x++) {
- def_internal_icon(bbuf, BIFICONID_FIRST + y*ICON_GRID_COLS + x,
- x*(ICON_GRID_W+ICON_GRID_MARGIN)+ICON_GRID_MARGIN,
- y*(ICON_GRID_H+ICON_GRID_MARGIN)+ICON_GRID_MARGIN, ICON_GRID_W,
- icontype);
+ if(bbuf) {
+ for (y=0; y<ICON_GRID_ROWS; y++) {
+ for (x=0; x<ICON_GRID_COLS; x++) {
+ def_internal_icon(bbuf, BIFICONID_FIRST + y*ICON_GRID_COLS + x,
+ x*(ICON_GRID_W+ICON_GRID_MARGIN)+ICON_GRID_MARGIN,
+ y*(ICON_GRID_H+ICON_GRID_MARGIN)+ICON_GRID_MARGIN, ICON_GRID_W,
+ icontype);
+ }
}
}
@@ -553,14 +597,14 @@ static void init_iconfile_list(struct ListBase *list)
char icondirstr[FILE_MAX];
char iconfilestr[FILE_MAX+16]; /* allow 256 chars for file+dir */
char olddir[FILE_MAX];
-
+ char *datadir= NULL;
+
list->first = list->last = NULL;
+ datadir = BLI_get_folder(BLENDER_DATAFILES, NULL);
-#ifdef WIN32
- BLI_make_file_string("/", icondirstr, BLI_gethome(), "icons");
-#else
- BLI_make_file_string("/", icondirstr, BLI_gethome(), ".blender/icons");
-#endif
+ if (!datadir) return;
+
+ BLI_make_file_string("/", icondirstr, datadir, "");
if(BLI_exists(icondirstr)==0)
return;
@@ -570,8 +614,7 @@ static void init_iconfile_list(struct ListBase *list)
if(!BLI_getwdN(olddir))
restoredir = 0;
totfile = BLI_getdir(icondirstr, &dir);
- if (restoredir && !chdir(olddir))
- ; /* fix warning about checking return value */
+ if (restoredir && !chdir(olddir)) {} /* fix warning about checking return value */
for(i=0; i<totfile; i++) {
if( (dir[i].type & S_IFREG) ) {
@@ -742,6 +785,7 @@ void UI_icons_init(int first_dyn_id)
init_iconfile_list(&iconfilelist);
BKE_icons_init(first_dyn_id);
init_internal_icons();
+ init_brush_icons();
}
/* Render size for preview images at level miplevel */
@@ -766,6 +810,7 @@ static void icon_create_mipmap(struct PreviewImage* prv_img, int miplevel)
prv_img->w[miplevel] = size;
prv_img->h[miplevel] = size;
prv_img->changed[miplevel] = 1;
+ prv_img->changed_timestamp[miplevel] = 0;
prv_img->rect[miplevel] = MEM_callocN(size*size*sizeof(unsigned int), "prv_rect");
}
}
@@ -964,6 +1009,43 @@ void ui_id_icon_render(bContext *C, ID *id, int preview)
}
}
+static int ui_id_brush_get_icon(bContext *C, ID *id, int preview)
+{
+ Brush *br = (Brush*)id;
+
+ if(br->flag & BRUSH_CUSTOM_ICON) {
+ BKE_icon_getid(id);
+ ui_id_icon_render(C, id, preview);
+ }
+ else if(!id->icon_id) {
+ /* no icon found, reset it */
+
+ /* this is not nice, should probably make
+ brushes be strictly in one paint mode only
+ to avoid this kind of thing */
+ Object *ob = CTX_data_active_object(C);
+ EnumPropertyItem *items;
+ int tool;
+
+ if(ob && (ob->mode & OB_MODE_SCULPT)) {
+ items = brush_sculpt_tool_items;
+ tool = br->sculpt_tool;
+ }
+ else if(ob && (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT))) {
+ items = brush_vertexpaint_tool_items;
+ tool = br->vertexpaint_tool;
+ }
+ else {
+ items = brush_imagepaint_tool_items;
+ tool = br->imagepaint_tool;
+ }
+
+ RNA_enum_icon_from_value(items, tool, &id->icon_id);
+ }
+
+ return id->icon_id;
+}
+
int ui_id_icon_get(bContext *C, ID *id, int preview)
{
int iconid= 0;
@@ -971,6 +1053,9 @@ int ui_id_icon_get(bContext *C, ID *id, int preview)
/* icon */
switch(GS(id->name))
{
+ case ID_BR:
+ iconid= ui_id_brush_get_icon(C, id, preview);
+ break;
case ID_MA: /* fall through */
case ID_TE: /* fall through */
case ID_IM: /* fall through */
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index f90b711cc09..84d6605651b 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -87,7 +87,8 @@ typedef enum {
UI_WTYPE_NORMAL,
UI_WTYPE_BOX,
UI_WTYPE_SCROLL,
- UI_WTYPE_LISTITEM
+ UI_WTYPE_LISTITEM,
+ UI_WTYPE_PROGRESSBAR,
} uiWidgetTypeEnum;
@@ -183,8 +184,11 @@ struct uiBut {
struct bContextStore *context;
+ /* not ysed yet, was used in 2.4x for ui_draw_pulldown_round & friends */
+ /*
void (*embossfunc)(int , int , float, float, float, float, float, int);
void (*sliderfunc)(int , float, float, float, float, float, float, int);
+ */
uiButCompleteFunc autocomplete_func;
void *autofunc_arg;
@@ -227,12 +231,12 @@ struct uiBut {
/* Operator data */
struct wmOperatorType *optype;
- int opcontext;
struct IDProperty *opproperties;
struct PointerRNA *opptr;
+ short opcontext;
/* Draggable data, type is WM_DRAG_... */
- int dragtype;
+ short dragtype;
void *dragpoin;
struct ImBuf *imb;
float imb_scale;
@@ -443,6 +447,8 @@ extern void gl_round_box_vertical_shade(int mode, float minx, float miny, float
void ui_draw_gradient(rcti *rect, float *rgb, int type, float alpha);
void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
+void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
+void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
void ui_draw_but_COLORBAND(uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
void ui_draw_but_NORMAL(uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
void ui_draw_but_CURVE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
@@ -450,7 +456,7 @@ void ui_draw_but_IMAGE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rct
/* interface_handlers.c */
extern void ui_button_activate_do(struct bContext *C, struct ARegion *ar, uiBut *but);
-extern void ui_button_active_cancel(const struct bContext *C, uiBut *but);
+extern void ui_button_active_free(const struct bContext *C, uiBut *but);
extern int ui_button_is_active(struct ARegion *ar);
/* interface_widgets.c */
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 2ae1a549db9..1d98b1f22c1 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -38,9 +38,7 @@
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_idprop.h"
-#include "BKE_library.h"
#include "BKE_screen.h"
-#include "BKE_utildefines.h"
#include "RNA_access.h"
@@ -431,18 +429,14 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon
but->type= TOG;
}
}
- else if(ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA) && len == 4) {
- but= uiDefAutoButR(block, ptr, prop, 3, "A:", 0, 0, 0, w, UI_UNIT_Y);
- if(slider && but->type==NUM)
- but->type= NUMSLI;
- }
}
uiBlockSetCurLayout(block, layout);
}
-static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, char *uiname, int x, int y, int w, int h, int icon_only)
+static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, char *uiname, int x, int y, int w, int h, int icon_only)
{
+ uiBut *but;
EnumPropertyItem *item;
const char *identifier;
char *name;
@@ -462,11 +456,14 @@ static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr,
itemw= ui_text_icon_width(block->curlayout, name, icon, 0);
if(icon && strcmp(name, "") != 0 && !icon_only)
- uiDefIconTextButR(block, ROW, 0, icon, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
+ but= uiDefIconTextButR(block, ROW, 0, icon, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
else if(icon)
- uiDefIconButR(block, ROW, 0, icon, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
+ but= uiDefIconButR(block, ROW, 0, icon, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
else
- uiDefButR(block, ROW, 0, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
+ but= uiDefButR(block, ROW, 0, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
+
+ if(ui_layout_local_dir(layout) != UI_LAYOUT_HORIZONTAL)
+ but->flag |= UI_TEXT_LEFT;
}
uiBlockSetCurLayout(block, layout);
@@ -514,7 +511,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, char *name, i
uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w-UI_UNIT_X, h);
/* BUTTONS_OT_file_browse calls uiFileBrowseContextProperty */
- but= uiDefIconButO(block, BUT, "BUTTONS_OT_file_browse", WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, "Browse for file or directory");
+ but= uiDefIconButO(block, BUT, "BUTTONS_OT_file_browse", WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL);
}
else if(subtype == PROP_DIRECTION) {
uiDefButR(block, BUT_NORMAL, 0, name, x, y, 100, 100, ptr, RNA_property_identifier(prop), index, 0, 0, -1, -1, NULL);
@@ -614,6 +611,9 @@ PointerRNA uiItemFullO(uiLayout *layout, char *idname, char *name, int icon, IDP
w= ui_text_icon_width(layout, name, icon, 0);
+ if (flag & UI_ITEM_R_NO_BG)
+ uiBlockSetEmboss(block, UI_EMBOSSN);
+
if(icon && strcmp(name, "") != 0)
but= uiDefIconTextButO(block, BUT, ot->idname, context, icon, (char*)name, 0, 0, w, UI_UNIT_Y, NULL);
else if(icon)
@@ -624,7 +624,10 @@ PointerRNA uiItemFullO(uiLayout *layout, char *idname, char *name, int icon, IDP
/* text alignment for toolbar buttons */
if((layout->root->type == UI_LAYOUT_TOOLBAR) && !icon)
but->flag |= UI_TEXT_LEFT;
-
+
+ if (flag & UI_ITEM_R_NO_BG)
+ uiBlockSetEmboss(block, UI_EMBOSS);
+
/* assign properties */
if(properties || (flag & UI_ITEM_O_RETURN_PROPS)) {
PointerRNA *opptr= uiButGetOperatorPtrRNA(but);
@@ -946,7 +949,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
}
/* expanded enum */
else if(type == PROP_ENUM && expand)
- ui_item_enum_row(layout, block, ptr, prop, name, 0, 0, w, h, icon_only);
+ ui_item_enum_expand(layout, block, ptr, prop, name, 0, 0, w, h, icon_only);
/* property with separate label */
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);
@@ -973,7 +976,7 @@ void uiItemR(uiLayout *layout, PointerRNA *ptr, char *propname, int flag, char *
if(!prop) {
ui_item_disabled(layout, propname);
- printf("uiItemR: property not found: %s\n", propname);
+ printf("uiItemR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
return;
}
@@ -986,7 +989,7 @@ void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr,
if(!prop || RNA_property_type(prop) != PROP_ENUM) {
ui_item_disabled(layout, propname);
- printf("uiItemEnumR: enum property not found: %s\n", propname);
+ printf("uiItemEnumR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
return;
}
@@ -1001,7 +1004,7 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, char *propname
if(!prop || RNA_property_type(prop) != PROP_ENUM) {
ui_item_disabled(layout, propname);
- printf("uiItemEnumR: enum property not found: %s\n", propname);
+ printf("uiItemEnumR_string: enum property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
return;
}
@@ -1105,12 +1108,30 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, char *str, ui
if(flag & PROP_ID_SELF_CHECK)
if(itemptr.data == but->rnapoin.id.data)
continue;
-
- if(RNA_struct_is_ID(itemptr.type))
- iconid= ui_id_icon_get((bContext*)C, itemptr.data, 0);
-
- name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
-
+
+ /* use filter */
+ if(RNA_property_type(but->rnaprop)==PROP_POINTER) {
+ if(RNA_property_pointer_poll(&but->rnapoin, but->rnaprop, &itemptr)==0)
+ continue;
+ }
+
+ if(itemptr.type && RNA_struct_is_ID(itemptr.type)) {
+ ID *id= itemptr.data;
+ char name_ui[32];
+
+#if 0 /* this name is used for a string comparison and can't be modified, TODO */
+ name_uiprefix_id(name_ui, id);
+#else
+ strcpy(name_ui, id->name+2);
+#endif
+ name= BLI_strdup(name_ui);
+ iconid= ui_id_icon_get((bContext*)C, id, 1);
+ }
+ else {
+ name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
+ iconid = 0;
+ }
+
if(name) {
if(BLI_strcasestr(name, str)) {
cis = MEM_callocN(sizeof(CollItemSearch), "CollectionItemSearch");
@@ -1119,9 +1140,9 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, char *str, ui
cis->iconid = iconid;
BLI_addtail(items_list, cis);
}
- }
- MEM_freeN(name);
-
+ MEM_freeN(name);
+ }
+
i++;
}
RNA_PROP_END;
@@ -1204,7 +1225,7 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, char *propname, st
prop= RNA_struct_find_property(ptr, propname);
if(!prop) {
- printf("uiItemPointerR: property not found: %s\n", propname);
+ printf("uiItemPointerR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
return;
}
@@ -1217,7 +1238,7 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, char *propname, st
searchprop= RNA_struct_find_property(searchptr, searchpropname);
if(!searchprop || RNA_property_type(searchprop) != PROP_COLLECTION) {
- printf("uiItemPointerR: search collection property not found: %s\n", searchpropname);
+ printf("uiItemPointerR: search collection property not found: %s.%s\n", RNA_struct_identifier(ptr->type), searchpropname);
return;
}
@@ -1289,8 +1310,10 @@ static void ui_item_menu(uiLayout *layout, char *name, int icon, uiMenuCreateFun
if(layout->root->type == UI_LAYOUT_HEADER)
uiBlockSetEmboss(block, UI_EMBOSS);
- else if(layout->root->type == UI_LAYOUT_PANEL)
+ else if(layout->root->type == UI_LAYOUT_PANEL) {
but->type= MENU;
+ but->flag |= UI_TEXT_LEFT;
+ }
}
void uiItemM(uiLayout *layout, bContext *C, char *menuname, char *name, int icon)
@@ -1993,6 +2016,7 @@ uiLayout *uiLayoutRow(uiLayout *layout, int align)
litem->enabled= 1;
litem->context= layout->context;
litem->space= (align)? 0: layout->root->style->buttonspacex;
+ litem->w = layout->w;
BLI_addtail(&layout->items, litem);
uiBlockSetCurLayout(layout->root->block, litem);
@@ -2012,6 +2036,7 @@ uiLayout *uiLayoutColumn(uiLayout *layout, int align)
litem->enabled= 1;
litem->context= layout->context;
litem->space= (litem->align)? 0: layout->root->style->buttonspacey;
+ litem->w = layout->w;
BLI_addtail(&layout->items, litem);
uiBlockSetCurLayout(layout->root->block, litem);
@@ -2031,6 +2056,7 @@ uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align)
flow->litem.enabled= 1;
flow->litem.context= layout->context;
flow->litem.space= (flow->litem.align)? 0: layout->root->style->columnspace;
+ flow->litem.w = layout->w;
flow->number= number;
BLI_addtail(&layout->items, flow);
@@ -2050,6 +2076,7 @@ static uiLayoutItemBx *ui_layout_box(uiLayout *layout, int type)
box->litem.enabled= 1;
box->litem.context= layout->context;
box->litem.space= layout->root->style->columnspace;
+ box->litem.w = layout->w;
BLI_addtail(&layout->items, box);
uiBlockSetCurLayout(layout->root->block, &box->litem);
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 419de8eb898..caee3c1c2fe 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -39,7 +39,6 @@
#include "BLI_math_color.h"
#include "BKE_context.h"
-#include "BKE_utildefines.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -322,6 +321,8 @@ static int copy_to_selected_list(bContext *C, PointerRNA *ptr, ListBase *lb)
*lb = CTX_data_collection_get(C, "selected_editable_bones");
else if(RNA_struct_is_a(ptr->type, &RNA_PoseBone))
*lb = CTX_data_collection_get(C, "selected_pose_bones");
+ else if(RNA_struct_is_a(ptr->type, &RNA_Sequence))
+ *lb = CTX_data_collection_get(C, "selected_editable_sequences");
else
return 0;
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index e4088a64a17..9d22f3c5212 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -43,7 +43,6 @@
#include "BKE_context.h"
#include "BKE_screen.h"
-#include "BKE_utildefines.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
@@ -285,32 +284,6 @@ void uiEndPanel(uiBlock *block, int width, int height)
}
}
-#if 0
-void uiPanelToMouse(const bContext *C, Panel *pa)
-{
- /* global control over this feature; UI_PNL_TO_MOUSE only called for hotkey panels */
- if(U.uiflag & USER_PANELPINNED);
- else if(pa->control & UI_PNL_TO_MOUSE) {
- int mx, my;
-
- mx= CTX_wm_window(C)->eventstate->x;
- my= CTX_wm_window(C)->eventstate->y;
-
- pa->ofsx= mx-pa->sizex/2;
- pa->ofsy= my-pa->sizey/2;
-
- if(pa->flag & PNL_CLOSED) pa->flag &= ~PNL_CLOSED;
- }
-
- if(pa->control & UI_PNL_UNSTOW) {
- if(pa->flag & PNL_CLOSEDY) {
- pa->flag &= ~PNL_CLOSED;
- }
- }
-}
-#endif
-
-
static void ui_offset_panel_block(uiBlock *block)
{
uiStyle *style= U.uistyles.first;
@@ -656,6 +629,10 @@ 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 */
+ if (ps1->pa->sortorder < ps2->pa->sortorder && ps1->pa->type->flag & PNL_NO_HEADER) return -1;
+
if(ps1->pa->ofsy+ps1->pa->sizey < ps2->pa->ofsy+ps2->pa->sizey) return 1;
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;
@@ -864,6 +841,8 @@ void uiEndPanels(const bContext *C, ARegion *ar)
if(firstpa)
firstpa->runtime_flag |= PNL_FIRST;
+ 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)) {
@@ -954,7 +933,7 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel)
/* this function is supposed to call general window drawing too */
/* also it supposes a block has panel, and isnt a menu */
-static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, int my)
+static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, int my, int event)
{
ScrArea *sa= CTX_wm_area(C);
ARegion *ar= CTX_wm_region(C);
@@ -966,7 +945,11 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
/* XXX weak code, currently it assumes layout style for location of widgets */
/* check open/collapsed button */
- if(block->panel->flag & PNL_CLOSEDX) {
+ if(event==RETKEY)
+ button= 1;
+ else if(event==AKEY)
+ button= 1;
+ else if(block->panel->flag & PNL_CLOSEDX) {
if(my >= block->maxy) button= 1;
}
else if(block->panel->control & UI_PNL_CLOSE) {
@@ -1019,6 +1002,9 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
}
}
+/* XXX should become modal keymap */
+/* AKey is opening/closing panels, independent of button state now */
+
int ui_handler_panel_region(bContext *C, wmEvent *event)
{
ARegion *ar= CTX_wm_region(C);
@@ -1027,11 +1013,6 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
int retval, mx, my, inside_header= 0, inside_scale= 0, inside;
retval= WM_UI_HANDLER_CONTINUE;
-
- /* buttons get priority */
- if(ui_button_is_active(ar))
- return retval;
-
for(block=ar->uiblocks.last; block; block=block->prev) {
mx= event->x;
my= event->y;
@@ -1049,7 +1030,25 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
if(block->minx <= mx && block->maxx >= mx)
if(block->miny <= my && block->maxy+PNL_HEADER >= my)
inside= 1;
-
+
+ if(inside && event->val==KM_PRESS) {
+ if(event->type == AKEY && !ELEM4(1, event->ctrl, event->oskey, event->shift, event->alt)) {
+
+ if(pa->flag & PNL_CLOSEDY) {
+ if((block->maxy <= my) && (block->maxy+PNL_HEADER >= my))
+ ui_handle_panel_header(C, block, mx, my, event->type);
+ }
+ else
+ ui_handle_panel_header(C, block, mx, my, event->type);
+
+ continue;
+ }
+ }
+
+ /* on active button, do not handle panels */
+ if(ui_button_is_active(ar))
+ continue;
+
if(inside) {
/* clicked at panel header? */
if(pa->flag & PNL_CLOSEDX) {
@@ -1066,9 +1065,16 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
}
if(event->val==KM_PRESS) {
- if(event->type == LEFTMOUSE) {
+ /* open close on header */
+ if(ELEM(event->type, RETKEY, PADENTER)) {
+ if(inside_header) {
+ ui_handle_panel_header(C, block, mx, my, RETKEY);
+ break;
+ }
+ }
+ else if(event->type == LEFTMOUSE) {
if(inside_header) {
- ui_handle_panel_header(C, block, mx, my);
+ ui_handle_panel_header(C, block, mx, my, 0);
break;
}
else if(inside_scale && !(pa->flag & PNL_CLOSED)) {
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 35add45b10a..50b85360196 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -38,11 +38,7 @@
#include "BLI_ghash.h"
#include "BKE_context.h"
-#include "BKE_icons.h"
-#include "BKE_report.h"
#include "BKE_screen.h"
-#include "BKE_texture.h"
-#include "BKE_utildefines.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -453,10 +449,10 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
data->fstyle.align= UI_STYLE_TEXT_CENTER;
uiStyleFontSet(&data->fstyle);
- h= BLF_height(data->lines[0]);
+ h= BLF_height(data->fstyle.uifont_id, data->lines[0]);
for(a=0, fontw=0, fonth=0; a<data->totline; a++) {
- w= BLF_width(data->lines[a]);
+ w= BLF_width(data->fstyle.uifont_id, data->lines[a]);
fontw= MAX2(fontw, w);
fonth += (a == 0)? h: h+5;
}
@@ -1559,12 +1555,21 @@ void ui_set_but_hsv(uiBut *but)
}
/* also used by small picker, be careful with name checks below... */
-void ui_update_block_buts_rgb(uiBlock *block, float *rgb)
+void ui_update_block_buts_rgb(uiBlock *block, float *rgb, float *rhsv)
{
uiBut *bt;
float hsv[3];
- rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
+ /* this is to keep the H and S value when V is equal to zero
+ * and we are working in HSV mode, of course!
+ */
+ if (rhsv) {
+ hsv[0]= rhsv[0];
+ hsv[1]= rhsv[1];
+ hsv[2]= rhsv[2];
+ }
+ else
+ rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
// this updates button strings, is hackish... but button pointers are on stack of caller function
for(bt= block->buttons.first; bt; bt= bt->next) {
@@ -1591,7 +1596,7 @@ void ui_update_block_buts_rgb(uiBlock *block, float *rgb)
if (rgb_gamma[1] > 1.0f) rgb_gamma[1] = modf(rgb_gamma[1], &intpart);
if (rgb_gamma[2] > 1.0f) rgb_gamma[2] = modf(rgb_gamma[2], &intpart);
- sprintf(col, "%02X%02X%02X", (unsigned int)(rgb_gamma[0]*255.0), (unsigned int)(rgb_gamma[1]*255.0), (unsigned int)(rgb_gamma[2]*255.0));
+ sprintf(col, "%02X%02X%02X", FTOCHAR(rgb_gamma[0]), FTOCHAR(rgb_gamma[1]), FTOCHAR(rgb_gamma[2]));
strcpy(bt->poin, col);
}
@@ -1630,7 +1635,7 @@ static void do_picker_rna_cb(bContext *C, void *bt1, void *unused)
if (prop) {
RNA_property_float_get_array(&ptr, prop, rgb);
- ui_update_block_buts_rgb(but->block, rgb);
+ ui_update_block_buts_rgb(but->block, rgb, NULL);
}
if(popup)
@@ -1646,7 +1651,7 @@ static void do_hsv_rna_cb(bContext *C, void *bt1, void *hsv_arg)
hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
- ui_update_block_buts_rgb(but->block, rgb);
+ ui_update_block_buts_rgb(but->block, rgb, hsv);
if(popup)
popup->menuretval= UI_RETURN_UPDATE;
@@ -1667,7 +1672,7 @@ static void do_hex_rna_cb(bContext *C, void *bt1, void *hexcl)
srgb_to_linearrgb_v3_v3(rgb, rgb);
}
- ui_update_block_buts_rgb(but->block, rgb);
+ ui_update_block_buts_rgb(but->block, rgb, NULL);
if(popup)
popup->menuretval= UI_RETURN_UPDATE;
@@ -1736,11 +1741,11 @@ static void circle_picker(uiBlock *block, PointerRNA *ptr, const char *propname)
uiBut *bt;
/* HS circle */
- bt= uiDefButR(block, HSVCIRCLE, 0, "", 0, 0, PICKER_H, PICKER_W, ptr, propname, 0, 0.0, 0.0, 0, 0, "");
+ bt= uiDefButR(block, HSVCIRCLE, 0, "", 0, 0, PICKER_H, PICKER_W, ptr, propname, 0, 0.0, 0.0, 0, 0, "Color");
uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
/* value */
- bt= uiDefButR(block, HSVCUBE, 0, "", PICKER_W+PICKER_SPACE,0,PICKER_BAR,PICKER_H, ptr, propname, 0, 0.0, 0.0, UI_GRAD_V_ALT, 0, "");
+ bt= uiDefButR(block, HSVCUBE, 0, "", PICKER_W+PICKER_SPACE,0,PICKER_BAR,PICKER_H, ptr, propname, 0, 0.0, 0.0, UI_GRAD_V_ALT, 0, "Value");
uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
}
@@ -1751,11 +1756,11 @@ static void square_picker(uiBlock *block, PointerRNA *ptr, const char *propname,
int bartype = type + 3;
/* HS square */
- bt= uiDefButR(block, HSVCUBE, 0, "", 0, PICKER_BAR+PICKER_SPACE, PICKER_TOTAL_W, PICKER_H, ptr, propname, 0, 0.0, 0.0, type, 0, "");
+ bt= uiDefButR(block, HSVCUBE, 0, "", 0, PICKER_BAR+PICKER_SPACE, PICKER_TOTAL_W, PICKER_H, ptr, propname, 0, 0.0, 0.0, type, 0, "Color");
uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
/* value */
- bt= uiDefButR(block, HSVCUBE, 0, "", 0, 0, PICKER_TOTAL_W, PICKER_BAR, ptr, propname, 0, 0.0, 0.0, bartype, 0, "");
+ bt= uiDefButR(block, HSVCUBE, 0, "", 0, 0, PICKER_TOTAL_W, PICKER_BAR, ptr, propname, 0, 0.0, 0.0, bartype, 0, "Value");
uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
}
@@ -1770,6 +1775,7 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR
static float hsv[3];
static char hexcol[128];
float rgb_gamma[3];
+ float min, max, step, precision;
const char *propname = RNA_property_identifier(prop);
width= PICKER_TOTAL_W;
@@ -1785,6 +1791,10 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR
linearrgb_to_srgb_v3_v3(rgb_gamma, rgb);
}
+ /* sneaky way to check for alpha */
+ rgb[3]= FLT_MAX;
+
+ RNA_property_float_ui_range(ptr, prop, &min, &max, &step, &precision);
RNA_property_float_get_array(ptr, prop, rgb);
rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
@@ -1818,28 +1828,37 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR
/* RGB values */
uiBlockBeginAlign(block);
- bt= uiDefButR(block, NUMSLI, 0, "R ", 0, -60, butwidth, UI_UNIT_Y, ptr, propname, 0, 0.0, 0.0, 0, 0, "");
+ bt= uiDefButR(block, NUMSLI, 0, "R ", 0, -60, butwidth, UI_UNIT_Y, ptr, propname, 0, 0.0, 0.0, 0, 3, "Red");
uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
- bt= uiDefButR(block, NUMSLI, 0, "G ", 0, -80, butwidth, UI_UNIT_Y, ptr, propname, 1, 0.0, 0.0, 0, 0, "");
+ bt= uiDefButR(block, NUMSLI, 0, "G ", 0, -80, butwidth, UI_UNIT_Y, ptr, propname, 1, 0.0, 0.0, 0, 3, "Green");
uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
- bt= uiDefButR(block, NUMSLI, 0, "B ", 0, -100, butwidth, UI_UNIT_Y, ptr, propname, 2, 0.0, 0.0, 0, 0, "");
+ bt= uiDefButR(block, NUMSLI, 0, "B ", 0, -100, butwidth, UI_UNIT_Y, ptr, propname, 2, 0.0, 0.0, 0, 3, "Blue");
uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
+
// could use uiItemFullR(col, ptr, prop, -1, 0, UI_ITEM_R_EXPAND|UI_ITEM_R_SLIDER, "", 0);
// but need to use uiButSetFunc for updating other fake buttons
/* HSV values */
uiBlockBeginAlign(block);
- bt= uiDefButF(block, NUMSLI, 0, "H ", 0, -60, butwidth, UI_UNIT_Y, hsv, 0.0, 1.0, 10, 3, "");
+ bt= uiDefButF(block, NUMSLI, 0, "H ", 0, -60, butwidth, UI_UNIT_Y, hsv, 0.0, 1.0, 10, 3, "Hue");
uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv);
- bt= uiDefButF(block, NUMSLI, 0, "S ", 0, -80, butwidth, UI_UNIT_Y, hsv+1, 0.0, 1.0, 10, 3, "");
+ bt= uiDefButF(block, NUMSLI, 0, "S ", 0, -80, butwidth, UI_UNIT_Y, hsv+1, 0.0, 1.0, 10, 3, "Saturation");
uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv);
- bt= uiDefButF(block, NUMSLI, 0, "V ", 0, -100, butwidth, UI_UNIT_Y, hsv+2, 0.0, 1.0, 10, 3, "");
+ bt= uiDefButF(block, NUMSLI, 0, "V ", 0, -100, butwidth, UI_UNIT_Y, hsv+2, 0.0, max, 10, 3, "Value");
uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv);
uiBlockEndAlign(block);
-
+
+ if(rgb[3] != FLT_MAX) {
+ bt= uiDefButR(block, NUMSLI, 0, "A ", 0, -120, butwidth, UI_UNIT_Y, ptr, propname, 3, 0.0, 0.0, 0, 0, "Alpha");
+ uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
+ }
+ else {
+ rgb[3]= 1.0f;
+ }
+
rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
-
- sprintf(hexcol, "%02X%02X%02X", (unsigned int)(rgb_gamma[0]*255.0), (unsigned int)(rgb_gamma[1]*255.0), (unsigned int)(rgb_gamma[2]*255.0));
+
+ sprintf(hexcol, "%02X%02X%02X", FTOCHAR(rgb_gamma[0]), FTOCHAR(rgb_gamma[1]), FTOCHAR(rgb_gamma[2]));
bt= uiDefBut(block, TEX, 0, "Hex: ", 0, -60, butwidth, UI_UNIT_Y, hexcol, 0, 8, 0, 0, "Hex triplet for color (#RRGGBB)");
uiButSetFunc(bt, do_hex_rna_cb, bt, hexcol);
@@ -1874,7 +1893,7 @@ static int ui_picker_small_wheel(const bContext *C, uiBlock *block, wmEvent *eve
ui_set_but_vectorf(but, col);
- ui_update_block_buts_rgb(block, col);
+ ui_update_block_buts_rgb(block, col, NULL);
if(popup)
popup->menuretval= UI_RETURN_UPDATE;
@@ -2095,13 +2114,13 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut
pup->mx= window->eventstate->x;
pup->my= window->eventstate->y;
pup->popup= 1;
+ pup->block->flag |= UI_BLOCK_NO_FLIP;
}
if(str) {
/* menu is created from a string */
pup->menu_func= ui_block_func_MENUSTR;
pup->menu_arg= str;
- // XXX pup->block->flag |= UI_BLOCK_NO_FLIP;
}
else {
/* menu is created from a callback */
@@ -2305,7 +2324,7 @@ void uiPupMenuReports(bContext *C, ReportList *reports)
ds= BLI_dynstr_new();
for(report=reports->list.first; report; report=report->next) {
- if(report->type <= reports->printlevel)
+ if(report->type < reports->printlevel)
; /* pass */
else if(report->type >= RPT_ERROR)
BLI_dynstr_appendf(ds, "Error %%i%d%%t|%s", ICON_ERROR, report->message);
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index aaebdf5693a..03676ae5e06 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -38,12 +38,8 @@
#include "BLI_rect.h"
#include "BLI_string.h"
-#include "BKE_context.h"
#include "BKE_global.h"
-#include "BKE_utildefines.h"
-#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "BLF_api.h"
@@ -147,34 +143,34 @@ void uiStyleFontDraw(uiFontStyle *fs, rcti *rect, char *str)
uiStyleFontSet(fs);
- height= BLF_height("2"); /* correct offset is on baseline, the j is below that */
+ height= BLF_height(fs->uifont_id, "2"); /* correct offset is on baseline, the j is below that */
yofs= floor( 0.5f*(rect->ymax - rect->ymin - height));
if(fs->align==UI_STYLE_TEXT_CENTER)
- xofs= floor( 0.5f*(rect->xmax - rect->xmin - BLF_width(str)));
+ xofs= floor( 0.5f*(rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str)));
else if(fs->align==UI_STYLE_TEXT_RIGHT)
- xofs= rect->xmax - rect->xmin - BLF_width(str) - 1;
+ xofs= rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str) - 1;
/* clip is very strict, so we give it some space */
- BLF_clipping(rect->xmin-1, rect->ymin-4, rect->xmax+1, rect->ymax+4);
- BLF_enable(BLF_CLIPPING);
- BLF_position(rect->xmin+xofs, rect->ymin+yofs, 0.0f);
+ BLF_clipping(fs->uifont_id, rect->xmin-1, rect->ymin-4, rect->xmax+1, rect->ymax+4);
+ BLF_enable(fs->uifont_id, BLF_CLIPPING);
+ BLF_position(fs->uifont_id, rect->xmin+xofs, rect->ymin+yofs, 0.0f);
if (fs->shadow) {
- BLF_enable(BLF_SHADOW);
- BLF_shadow(fs->shadow, fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha);
- BLF_shadow_offset(fs->shadx, fs->shady);
+ BLF_enable(fs->uifont_id, BLF_SHADOW);
+ BLF_shadow(fs->uifont_id, fs->shadow, fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha);
+ BLF_shadow_offset(fs->uifont_id, fs->shadx, fs->shady);
}
if (fs->kerning == 1)
- BLF_enable(BLF_KERNING_DEFAULT);
+ BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
- BLF_draw(str);
- BLF_disable(BLF_CLIPPING);
+ BLF_draw(fs->uifont_id, str);
+ BLF_disable(fs->uifont_id, BLF_CLIPPING);
if (fs->shadow)
- BLF_disable(BLF_SHADOW);
+ BLF_disable(fs->uifont_id, BLF_SHADOW);
if (fs->kerning == 1)
- BLF_disable(BLF_KERNING_DEFAULT);
+ BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
}
/* drawn same as above, but at 90 degree angle */
@@ -187,7 +183,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, char *str)
uiStyleFontSet(fs);
- height= BLF_height("2"); /* correct offset is on baseline, the j is below that */
+ height= BLF_height(fs->uifont_id, "2"); /* correct offset is on baseline, the j is below that */
/* becomes x-offset when rotated */
xofs= floor( 0.5f*(rect->ymax - rect->ymin - height)) + 1;
@@ -195,7 +191,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, char *str)
/* rotate counter-clockwise for now (assumes left-to-right language)*/
xofs+= height;
- yofs= BLF_width(str) + 5;
+ yofs= BLF_width(fs->uifont_id, str) + 5;
angle= 90.0f;
/* translate rect to vertical */
@@ -206,29 +202,29 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, char *str)
/* clip is very strict, so we give it some space */
/* clipping is done without rotation, so make rect big enough to contain both positions */
- BLF_clipping(txtrect.xmin-1, txtrect.ymin-yofs-xofs-4, rect->xmax+1, rect->ymax+4);
- BLF_enable(BLF_CLIPPING);
- BLF_position(txtrect.xmin+xofs, txtrect.ymax-yofs, 0.0f);
+ BLF_clipping(fs->uifont_id, txtrect.xmin-1, txtrect.ymin-yofs-xofs-4, rect->xmax+1, rect->ymax+4);
+ BLF_enable(fs->uifont_id, BLF_CLIPPING);
+ BLF_position(fs->uifont_id, txtrect.xmin+xofs, txtrect.ymax-yofs, 0.0f);
- BLF_enable(BLF_ROTATION);
- BLF_rotation(angle);
+ BLF_enable(fs->uifont_id, BLF_ROTATION);
+ BLF_rotation(fs->uifont_id, angle);
if (fs->shadow) {
- BLF_enable(BLF_SHADOW);
- BLF_shadow(fs->shadow, fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha);
- BLF_shadow_offset(fs->shadx, fs->shady);
+ BLF_enable(fs->uifont_id, BLF_SHADOW);
+ BLF_shadow(fs->uifont_id, fs->shadow, fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha);
+ BLF_shadow_offset(fs->uifont_id, fs->shadx, fs->shady);
}
if (fs->kerning == 1)
- BLF_enable(BLF_KERNING_DEFAULT);
+ BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
- BLF_draw(str);
- BLF_disable(BLF_ROTATION);
- BLF_disable(BLF_CLIPPING);
+ BLF_draw(fs->uifont_id, str);
+ BLF_disable(fs->uifont_id, BLF_ROTATION);
+ BLF_disable(fs->uifont_id, BLF_CLIPPING);
if (fs->shadow)
- BLF_disable(BLF_SHADOW);
+ BLF_disable(fs->uifont_id, BLF_SHADOW);
if (fs->kerning == 1)
- BLF_disable(BLF_KERNING_DEFAULT);
+ BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
}
/* ************** helpers ************************ */
@@ -241,13 +237,13 @@ int UI_GetStringWidth(char *str)
int width;
if (fstyle->kerning==1) /* for BLF_width */
- BLF_enable(BLF_KERNING_DEFAULT);
+ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
uiStyleFontSet(fstyle);
- width= BLF_width(str);
+ width= BLF_width(fstyle->uifont_id, str);
if (fstyle->kerning==1)
- BLF_disable(BLF_KERNING_DEFAULT);
+ BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
return width;
}
@@ -258,13 +254,13 @@ void UI_DrawString(float x, float y, char *str)
uiStyle *style= U.uistyles.first;
uiStyleFontSet(&style->widget);
- BLF_position(x, y, 0.0f);
- BLF_draw(str);
+ BLF_position(style->widget.uifont_id, x, y, 0.0f);
+ BLF_draw(style->widget.uifont_id, str);
}
/* ************** init exit ************************ */
-/* called on each .B.blend read */
+/* called on each startup.blend read */
/* reading without uifont will create one */
void uiStyleInit(void)
{
@@ -299,14 +295,13 @@ void uiStyleInit(void)
printf("uiStyleInit error, no fonts available\n");
}
else {
- BLF_set(font->blf_id);
/* ? just for speed to initialize?
* Yes, this build the glyph cache and create
* the texture.
*/
- BLF_size(11, U.dpi);
- BLF_size(12, U.dpi);
- BLF_size(14, U.dpi);
+ BLF_size(font->blf_id, 11, U.dpi);
+ BLF_size(font->blf_id, 12, U.dpi);
+ BLF_size(font->blf_id, 14, U.dpi);
}
}
@@ -319,7 +314,6 @@ void uiStyleFontSet(uiFontStyle *fs)
{
uiFont *font= uifont_to_blfont(fs->uifont_id);
- BLF_set(font->blf_id);
- BLF_size(fs->points, U.dpi);
+ BLF_size(font->blf_id, fs->points, U.dpi);
}
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 200ef1fa501..45ebc9bf136 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -35,11 +35,11 @@
#include "BKE_colortools.h"
#include "BKE_context.h"
-#include "BKE_icons.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
-#include "BKE_utildefines.h"
+#include "BKE_texture.h"
+#include "BKE_report.h"
#include "ED_screen.h"
#include "ED_render.h"
@@ -52,6 +52,8 @@
#include "UI_interface.h"
#include "interface_intern.h"
+#include "BLF_api.h"
+
void ui_template_fix_linking()
{
}
@@ -67,64 +69,6 @@ void uiTemplateHeader(uiLayout *layout, bContext *C, int menus)
else ED_area_header_switchbutton(C, block, 0);
}
-/********************** DopeSheet Filter Template *************************/
-
-void uiTemplateDopeSheetFilter(uiLayout *layout, bContext *C, PointerRNA *ptr)
-{
- Main *mainptr= CTX_data_main(C);
- ScrArea *sa= CTX_wm_area(C);
- uiLayout *row= layout;
- short nlaActive= ((sa) && (sa->spacetype==SPACE_NLA));
-
- /* more 'generic' filtering options */
- row= uiLayoutRow(layout, 1);
-
- uiItemR(row, ptr, "only_selected", 0, "", 0);
- uiItemR(row, ptr, "display_transforms", 0, "", 0); // xxx: include in another position instead?
-
- if (nlaActive)
- uiItemR(row, ptr, "include_missing_nla", 0, "", 0);
-
- /* datatype based - only available datatypes are shown */
- row= uiLayoutRow(layout, 1);
-
- uiItemR(row, ptr, "display_scene", 0, "", 0);
- uiItemR(row, ptr, "display_world", 0, "", 0);
- uiItemR(row, ptr, "display_node", 0, "", 0);
-
- if (mainptr && mainptr->mesh.first)
- uiItemR(row, ptr, "display_mesh", 0, "", 0);
- if (mainptr && mainptr->key.first)
- uiItemR(row, ptr, "display_shapekeys", 0, "", 0);
- if (mainptr && mainptr->mat.first)
- uiItemR(row, ptr, "display_material", 0, "", 0);
- if (mainptr && mainptr->lamp.first)
- uiItemR(row, ptr, "display_lamp", 0, "", 0);
- if (mainptr && mainptr->tex.first)
- uiItemR(row, ptr, "display_texture", 0, "", 0);
- if (mainptr && mainptr->camera.first)
- uiItemR(row, ptr, "display_camera", 0, "", 0);
- if (mainptr && mainptr->curve.first)
- uiItemR(row, ptr, "display_curve", 0, "", 0);
- if (mainptr && mainptr->mball.first)
- uiItemR(row, ptr, "display_metaball", 0, "", 0);
- if (mainptr && mainptr->armature.first)
- uiItemR(row, ptr, "display_armature", 0, "", 0);
- if (mainptr && mainptr->particle.first)
- uiItemR(row, ptr, "display_particle", 0, "", 0);
-
- /* group-based filtering (only when groups are available */
- if (mainptr && mainptr->group.first) {
- row= uiLayoutRow(layout, 1);
-
- uiItemR(row, ptr, "only_group_objects", 0, "", 0);
-
- /* if enabled, show the group selection field too */
- if (RNA_boolean_get(ptr, "only_group_objects"))
- uiItemR(row, ptr, "filtering_group", 0, "", 0);
- }
-}
-
/********************** Search Callbacks *************************/
typedef struct TemplateID {
@@ -163,15 +107,26 @@ static void id_search_cb(const bContext *C, void *arg_template, char *str, uiSea
for(id= lb->first; id; id= id->next) {
if(!((flag & PROP_ID_SELF_CHECK) && id == id_from)) {
- /* hide dot-datablocks */
+ /* use filter */
+ if(RNA_property_type(template->prop)==PROP_POINTER) {
+ PointerRNA ptr;
+ RNA_id_pointer_create(id, &ptr);
+ if(RNA_property_pointer_poll(&template->ptr, template->prop, &ptr)==0)
+ continue;
+ }
+
+ /* hide dot-datablocks, but only if filter does not force it visible */
if(U.uiflag & USER_HIDE_DOT)
if ((id->name[2]=='.') && (str[0] != '.'))
continue;
if(BLI_strcasestr(id->name+2, str)) {
- iconid= ui_id_icon_get((bContext*)C, id, 0);
-
- if(!uiSearchItemAdd(items, id->name+2, id, iconid))
+ char name_ui[32];
+ name_uiprefix_id(name_ui, id);
+
+ iconid= ui_id_icon_get((bContext*)C, id, 1);
+
+ if(!uiSearchItemAdd(items, name_ui, id, iconid))
break;
}
}
@@ -418,13 +373,17 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
if(!id_copy(id, NULL, 1 /* test only */) || (idfrom && idfrom->lib))
uiButSetFlag(but, UI_BUT_DISABLED);
}
+
+ if(id->lib == NULL && !(ELEM4(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT))) {
+ uiDefButR(block, TOG, 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;
if(newop) {
- but= uiDefIconTextButO(block, BUT, newop, WM_OP_EXEC_DEFAULT, ICON_ZOOMIN, (id)? "": "New", 0, 0, w, UI_UNIT_Y, NULL);
+ but= uiDefIconTextButO(block, BUT, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN, (id)? "": "New", 0, 0, w, UI_UNIT_Y, NULL);
uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
}
else {
@@ -481,7 +440,7 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, char
prop= RNA_struct_find_property(ptr, propname);
if(!prop || RNA_property_type(prop) != PROP_POINTER) {
- printf("uiTemplateID: pointer property not found: %s\n", propname);
+ printf("uiTemplateID: pointer property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
return;
}
@@ -490,7 +449,7 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, char
template->prop= prop;
template->prv_rows = prv_rows;
template->prv_cols = prv_cols;
-
+
if(newop)
flag |= UI_ID_ADD_NEW;
if(openop)
@@ -508,7 +467,6 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, char
}
MEM_freeN(template);
-
}
void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop)
@@ -543,11 +501,11 @@ void uiTemplateAnyID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propn
propType= RNA_struct_find_property(ptr, proptypename);
if (!propID || RNA_property_type(propID) != PROP_POINTER) {
- printf("uiTemplateAnyID: pointer property not found: %s\n", propname);
+ printf("uiTemplateAnyID: pointer property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
return;
}
if (!propType || RNA_property_type(propType) != PROP_ENUM) {
- printf("uiTemplateAnyID: pointer-type property not found: %s\n", proptypename);
+ printf("uiTemplateAnyID: pointer-type property not found: %s.%s\n", RNA_struct_identifier(ptr->type), proptypename);
return;
}
@@ -586,7 +544,7 @@ void uiTemplatePathBuilder(uiLayout *layout, bContext *C, PointerRNA *ptr, char
/* check that properties are valid */
propPath= RNA_struct_find_property(ptr, propname);
if (!propPath || RNA_property_type(propPath) != PROP_STRING) {
- printf("uiTemplatePathBuilder: path property not found: %s\n", propname);
+ printf("uiTemplatePathBuilder: path property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
return;
}
@@ -608,12 +566,8 @@ void uiTemplatePathBuilder(uiLayout *layout, bContext *C, PointerRNA *ptr, char
#include "DNA_object_force.h"
#include "BKE_depsgraph.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_global.h"
#include "BKE_modifier.h"
-#include "BKE_object.h"
#include "BKE_particle.h"
-#include "BKE_report.h"
#include "ED_util.h"
@@ -675,13 +629,13 @@ static int modifier_can_delete(ModifierData *md)
return 1;
}
-static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, ModifierData *md, int index, int cageIndex, int lastCageIndex, int compact)
+static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, ModifierData *md, int index, int cageIndex, int lastCageIndex)
{
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
PointerRNA ptr;
uiBut *but;
uiBlock *block;
- uiLayout *box, *column, *row, *col;
+ uiLayout *box, *column, *row;
uiLayout *result= NULL;
int isVirtual = (md->mode & eModifierMode_Virtual);
char str[128];
@@ -709,65 +663,31 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, Modif
}
else {
/* REAL MODIFIER */
- uiLayout *split;
-
- split = uiLayoutSplit(box, 0.16, 0);
-
- col= uiLayoutColumn(split, 0);
- row = uiLayoutRow(col, 1);
-
+ row = uiLayoutRow(box, 0);
block = uiLayoutGetBlock(row);
uiBlockSetEmboss(block, UI_EMBOSSN);
-
/* Open/Close ................................. */
- uiItemR(row, &ptr, "expanded", 0, "", 0);
+ uiItemR(row, &ptr, "show_expanded", 0, "", 0);
/* modifier-type icon */
uiItemL(row, "", RNA_struct_ui_icon(ptr.type));
-
uiBlockSetEmboss(block, UI_EMBOSS);
-
- /* 'Middle Column' ............................
- * - first row is the name of the modifier
- * - second row is the visibility settings, since the layouts were not wide enough to show all
- */
- col= uiLayoutColumn(split, 0);
-
- row= uiLayoutRow(col, 0);
- uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND);
-
- block = uiLayoutGetBlock(row);
-
/* modifier name */
uiItemR(row, &ptr, "name", 0, "", 0);
- if (compact) {
- /* insert delete button at end of top row before splitting to second line */
- uiBlockSetEmboss(block, UI_EMBOSSN);
- if (modifier_can_delete(md))
- uiItemO(row, "", ICON_X, "OBJECT_OT_modifier_remove");
- uiBlockSetEmboss(block, UI_EMBOSS);
-
- split = uiLayoutSplit(box, 0.17, 0);
- col= uiLayoutColumn(split, 0);
- uiItemL(col, "", 0);
- col= uiLayoutColumn(split, 0);
- row = uiLayoutRow(col, 1);
- }
-
/* mode enabling buttons */
uiBlockBeginAlign(block);
/* Softbody not allowed in this situation, enforce! */
if ( ((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect))
&& (md->type!=eModifierType_Surface) )
{
- uiItemR(row, &ptr, "render", 0, "", 0);
- uiItemR(row, &ptr, "realtime", 0, "", 0);
+ uiItemR(row, &ptr, "show_render", 0, "", 0);
+ uiItemR(row, &ptr, "show_viewport", 0, "", 0);
if (mti->flags & eModifierTypeFlag_SupportsEditmode)
- uiItemR(row, &ptr, "editmode", 0, "", 0);
+ uiItemR(row, &ptr, "show_in_editmode", 0, "", 0);
}
if ((ob->type==OB_MESH) && modifier_couldBeCage(scene, md) && (index <= lastCageIndex))
{
@@ -785,12 +705,10 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, Modif
uiItemO(row, "", ICON_TRIA_DOWN, "OBJECT_OT_modifier_move_down");
uiBlockEndAlign(block);
- if(!compact) {
- uiBlockSetEmboss(block, UI_EMBOSSN);
- if (modifier_can_delete(md))
- uiItemO(row, "", ICON_X, "OBJECT_OT_modifier_remove");
- uiBlockSetEmboss(block, UI_EMBOSS);
- }
+ uiBlockSetEmboss(block, UI_EMBOSSN);
+ if (modifier_can_delete(md))
+ uiItemO(row, "", ICON_X, "OBJECT_OT_modifier_remove");
+ uiBlockSetEmboss(block, UI_EMBOSS);
}
@@ -815,6 +733,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, Modif
}
}
else {
+ uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT);
uiItemEnumO(row, "OBJECT_OT_modifier_apply", "Apply", 0, "apply_as", MODIFIER_APPLY_DATA);
if (modifier_sameTopology(md))
@@ -824,7 +743,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, Modif
uiBlockClearButLock(block);
uiBlockSetButLock(block, ob && ob->id.lib, ERROR_LIBDATA_MESSAGE);
- if (!ELEM4(md->type, eModifierType_Fluidsim, eModifierType_Softbody, eModifierType_ParticleSystem, eModifierType_Cloth))
+ if (!ELEM5(md->type, eModifierType_Fluidsim, eModifierType_Softbody, eModifierType_ParticleSystem, eModifierType_Cloth, eModifierType_Smoke))
uiItemO(row, "Copy", 0, "OBJECT_OT_modifier_copy");
}
@@ -843,7 +762,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, Modif
return result;
}
-uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr, int compact)
+uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
Scene *scene = CTX_data_scene(C);
Object *ob;
@@ -874,7 +793,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr, int
for(i=0; vmd; i++, vmd=vmd->next) {
if(md == vmd)
- return draw_modifier(layout, scene, ob, md, i, cageIndex, lastCageIndex, compact);
+ return draw_modifier(layout, scene, ob, md, i, cageIndex, lastCageIndex);
else if(vmd->mode & eModifierMode_Virtual)
i--;
}
@@ -900,6 +819,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr, int
void do_constraint_panels(bContext *C, void *arg, int event)
{
+ Main *bmain= CTX_data_main(C);
Scene *scene= CTX_data_scene(C);
Object *ob= CTX_data_active_object(C);
@@ -911,7 +831,7 @@ void do_constraint_panels(bContext *C, void *arg, int event)
break; // no handling
case B_CONSTRAINT_CHANGETARGET:
if (ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels
- DAG_scene_sort(scene);
+ DAG_scene_sort(bmain, scene);
break;
default:
break;
@@ -938,88 +858,15 @@ static void constraint_active_func(bContext *C, void *ob_v, void *con_v)
ED_object_constraint_set_active(ob_v, con_v);
}
-
-/* some commonly used macros in the constraints drawing code */
-#define is_armature_target(target) (target && target->type==OB_ARMATURE)
-#define is_armature_owner(ob) ((ob->type == OB_ARMATURE) && (ob->mode & OB_MODE_POSE))
-#define is_geom_target(target) (target && (ELEM(target->type, OB_MESH, OB_LATTICE)) )
-
-/* Helper function for draw constraint - draws constraint space stuff
- * This function should not be called if no menus are required
- * owner/target: -1 = don't draw menu; 0= not posemode, 1 = posemode
- */
-static void draw_constraint_spaceselect (uiBlock *block, bConstraint *con, short xco, short yco, short owner, short target)
-{
- short tarx, ownx, iconx;
- short bwidth;
- short iconwidth = 20;
-
- /* calculate sizes and placement of menus */
- if (owner == -1) {
- bwidth = 125;
- tarx = 120;
- ownx = 0;
- }
- else if (target == -1) {
- bwidth = 125;
- tarx = 0;
- ownx = 120;
- }
- else {
- bwidth = 100;
- tarx = 85;
- iconx = tarx + bwidth + 5;
- ownx = tarx + bwidth + iconwidth + 10;
- }
-
-
- uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Convert:", xco, yco, 80,18, NULL, 0.0, 0.0, 0.0, 0.0, "");
-
- /* Target-Space */
- if (target == 1) {
- uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Target Space %t|World Space %x0|Pose Space %x2|Local with Parent %x3|Local Space %x1",
- tarx, yco, bwidth, 18, &con->tarspace, 0, 0, 0, 0, "Choose space that target is evaluated in");
- }
- else if (target == 0) {
- uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Target Space %t|World Space %x0|Local (Without Parent) Space %x1",
- tarx, yco, bwidth, 18, &con->tarspace, 0, 0, 0, 0, "Choose space that target is evaluated in");
- }
-
- if ((target != -1) && (owner != -1))
- uiDefIconBut(block, LABEL, 0, ICON_ARROW_LEFTRIGHT,
- iconx, yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "");
-
- /* Owner-Space */
- if (owner == 1) {
- uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Owner Space %t|World Space %x0|Pose Space %x2|Local with Parent %x3|Local Space %x1",
- ownx, yco, bwidth, 18, &con->ownspace, 0, 0, 0, 0, "Choose space that owner is evaluated in");
- }
- else if (owner == 0) {
- uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Owner Space %t|World Space %x0|Local (Without Parent) Space %x1",
- ownx, yco, bwidth, 18, &con->ownspace, 0, 0, 0, 0, "Choose space that owner is evaluated in");
- }
-}
-
-static void test_obpoin_but(bContext *C, char *name, ID **idpp)
-{
- ID *id= BLI_findstring(&CTX_data_main(C)->object, name, offsetof(ID, name) + 2);
- *idpp= id; /* can be NULL */
-
- if(id)
- id_lib_extern(id); /* checks lib data, sets correct flag for saving then */
-}
-
/* draw panel showing settings for a constraint */
static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
{
bPoseChannel *pchan= get_active_posechannel(ob);
bConstraintTypeInfo *cti;
uiBlock *block;
- uiLayout *result= NULL, *col, *box, *row, *subrow;
- uiBut *but;
+ uiLayout *result= NULL, *col, *box, *row;
PointerRNA ptr;
char typestr[32];
- short width = 265;
short proxy_protected, xco=0, yco=0;
int rb_col;
@@ -1052,38 +899,30 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
uiLayoutSetContextPointer(col, "constraint", &ptr);
box= uiLayoutBox(col);
- row= uiLayoutRow(box, 0);
-
+ row = uiLayoutRow(box, 0);
block= uiLayoutGetBlock(box);
- subrow= uiLayoutRow(row, 0);
- uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_LEFT);
-
/* Draw constraint header */
- uiBlockSetEmboss(block, UI_EMBOSSN);
/* rounded header */
rb_col= (con->flag & CONSTRAINT_ACTIVE)?50:20;
-
+
/* open/close */
- uiItemR(subrow, &ptr, "expanded", UI_ITEM_R_ICON_ONLY, "", 0);
-
- /* name */
+ uiBlockSetEmboss(block, UI_EMBOSSN);
+ uiItemR(row, &ptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", 0);
uiBlockSetEmboss(block, UI_EMBOSS);
/* XXX if (con->flag & CONSTRAINT_DISABLE)
uiBlockSetCol(block, TH_REDALERT);*/
+ /* name */
uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, xco+10, yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
-
+
if(proxy_protected == 0) {
- uiItemR(subrow, &ptr, "name", 0, "", 0);
+ uiItemR(row, &ptr, "name", 0, "", 0);
}
else
- uiItemL(subrow, con->name, 0);
-
- subrow= uiLayoutRow(row, 0);
- uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT);
+ uiItemL(row, con->name, 0);
/* proxy-protected constraints cannot be edited, so hide up/down + close buttons */
if (proxy_protected) {
@@ -1118,30 +957,32 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
show_upbut= ((prev_proxylock == 0) && (con->prev));
show_downbut= (con->next) ? 1 : 0;
+ uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT);
+
+ /* up/down */
if (show_upbut || show_downbut) {
uiBlockBeginAlign(block);
- uiBlockSetEmboss(block, UI_EMBOSS);
+ if (show_upbut)
+ uiItemO(row, "", ICON_TRIA_UP, "CONSTRAINT_OT_move_up");
- if (show_upbut)
- uiDefIconButO(block, BUT, "CONSTRAINT_OT_move_up", WM_OP_INVOKE_DEFAULT, ICON_TRIA_UP, xco+width-50, yco, 16, 18, "Move constraint up in constraint stack");
-
- if (show_downbut)
- uiDefIconButO(block, BUT, "CONSTRAINT_OT_move_down", WM_OP_INVOKE_DEFAULT, ICON_TRIA_DOWN, xco+width-50+18, yco, 16, 18, "Move constraint down in constraint stack");
+ if (show_downbut)
+ uiItemO(row, "", ICON_TRIA_DOWN, "CONSTRAINT_OT_move_down");
uiBlockEndAlign(block);
}
-
+
+ /* enabled */
+ uiItemR(row, &ptr, "mute", 0, "", 0);
+
/* Close 'button' - emboss calls here disable drawing of 'button' behind X */
uiBlockSetEmboss(block, UI_EMBOSSN);
- uiDefIconButBitS(block, ICONTOGN, CONSTRAINT_OFF, B_CONSTRAINT_TEST, ICON_CHECKBOX_DEHLT, xco+243, yco, 19, 19, &con->flag, 0.0, 0.0, 0.0, 0.0, "enable/disable constraint");
-
- uiDefIconButO(block, BUT, "CONSTRAINT_OT_delete", WM_OP_INVOKE_DEFAULT, ICON_X, xco+262, yco, 19, 19, "Delete constraint");
+ uiItemO(row, "", ICON_X, "CONSTRAINT_OT_delete");
uiBlockSetEmboss(block, UI_EMBOSS);
}
-
+
/* Set but-locks for protected settings (magic numbers are used here!) */
if (proxy_protected)
uiBlockSetButLock(block, 1, "Cannot edit Proxy-Protected Constraint");
-
+
/* Draw constraint data */
if ((con->flag & CONSTRAINT_EXPAND) == 0) {
(yco) -= 21;
@@ -1149,101 +990,9 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
else {
box= uiLayoutBox(col);
block= uiLayoutAbsoluteBlock(box);
-
- switch (con->type) {
-#ifndef DISABLE_PYTHON
- case CONSTRAINT_TYPE_PYTHON:
- {
- bPythonConstraint *data = con->data;
- bConstraintTarget *ct;
- // uiBut *but2;
- int tarnum, theight;
- // static int pyconindex=0;
- // char *menustr;
-
- theight = (data->tarnum)? (data->tarnum * 38) : (38);
-
- uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Script:", xco+60, yco-24, 55, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
-
- /* do the scripts menu */
- /* XXX menustr = buildmenu_pyconstraints(data->text, &pyconindex);
- but2 = uiDefButI(block, MENU, B_CONSTRAINT_TEST, menustr,
- xco+120, yco-24, 150, 20, &pyconindex,
- 0, 0, 0, 0, "Set the Script Constraint to use");
- uiButSetFunc(but2, validate_pyconstraint_cb, data, &pyconindex);
- MEM_freeN(menustr); */
-
- /* draw target(s) */
- if (data->flag & PYCON_USETARGETS) {
- /* Draw target parameters */
- for (ct=data->targets.first, tarnum=1; ct; ct=ct->next, tarnum++) {
- char tarstr[32];
- short yoffset= ((tarnum-1) * 38);
-
- /* target label */
- sprintf(tarstr, "Target %d:", tarnum);
- uiDefBut(block, LABEL, B_CONSTRAINT_TEST, tarstr, xco+45, yco-(48+yoffset), 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
-
- /* target space-selector - per target */
- if (is_armature_target(ct->tar)) {
- uiDefButS(block, MENU, B_CONSTRAINT_TEST, "Target Space %t|World Space %x0|Pose Space %x3|Local with Parent %x4|Local Space %x1",
- xco+10, yco-(66+yoffset), 100, 18, &ct->space, 0, 0, 0, 0, "Choose space that target is evaluated in");
- }
- else {
- uiDefButS(block, MENU, B_CONSTRAINT_TEST, "Target Space %t|World Space %x0|Local (Without Parent) Space %x1",
- xco+10, yco-(66+yoffset), 100, 18, &ct->space, 0, 0, 0, 0, "Choose space that target is evaluated in");
- }
-
- uiBlockBeginAlign(block);
- /* target object */
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-(48+yoffset), 150, 18, &ct->tar, "Target Object");
-
- /* subtarget */
- if (is_armature_target(ct->tar)) {
- but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-(66+yoffset),150,18, &ct->subtarget, 0, 24, 0, 0, "Subtarget Bone");
- //uiButSetCompleteFunc(but, autocomplete_bone, (void *)ct->tar);
- }
- else if (is_geom_target(ct->tar)) {
- but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+120, yco-(66+yoffset),150,18, &ct->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
- //uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)ct->tar);
- }
- else {
- strcpy(ct->subtarget, "");
- }
- uiBlockEndAlign(block);
- }
- }
- else {
- /* Draw indication that no target needed */
- uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+60, yco-48, 55, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
- uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Not Applicable", xco+120, yco-48, 150, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
- }
-
- /* settings */
- uiBlockBeginAlign(block);
- but=uiDefBut(block, BUT, B_CONSTRAINT_TEST, "Options", xco, yco-(52+theight), (width/2),18, NULL, 0, 24, 0, 0, "Change some of the constraint's settings.");
- // XXX uiButSetFunc(but, BPY_pyconstraint_settings, data, NULL);
-
- but=uiDefBut(block, BUT, B_CONSTRAINT_TEST, "Refresh", xco+((width/2)+10), yco-(52+theight), (width/2),18, NULL, 0, 24, 0, 0, "Force constraint to refresh it's settings");
- uiBlockEndAlign(block);
-
- /* constraint space settings */
- draw_constraint_spaceselect(block, con, xco, yco-(73+theight), is_armature_owner(ob), -1);
- }
- break;
-#endif
-
- case CONSTRAINT_TYPE_NULL:
- {
- uiItemL(box, "", 0);
- }
- break;
- default:
- result= box;
- break;
+ result= box;
}
- }
-
+
/* clear any locks set up for proxies/lib-linking */
uiBlockClearButLock(block);
@@ -1286,7 +1035,6 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
-#include "DNA_texture_types.h"
#include "DNA_world_types.h"
#define B_MATPRV 1
@@ -1386,7 +1134,6 @@ void uiTemplatePreview(uiLayout *layout, ID *id, ID *parent, MTex *slot)
/********************** ColorRamp Template **************************/
-#include "BKE_texture.h"
typedef struct RNAUpdateCb {
PointerRNA ptr;
@@ -1405,60 +1152,51 @@ static void rna_update_cb(bContext *C, void *arg_cb, void *arg_unused)
#define B_BANDCOL 1
-static int vergcband(const void *a1, const void *a2)
-{
- const CBData *x1=a1, *x2=a2;
-
- if( x1->pos > x2->pos ) return 1;
- else if( x1->pos < x2->pos) return -1;
- return 0;
-}
-
-static void colorband_pos_cb(bContext *C, void *cb_v, void *coba_v)
+static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v)
{
ColorBand *coba= coba_v;
- int a;
-
- if(coba->tot<2) return;
+ float pos= 0.5f;
- for(a=0; a<coba->tot; a++) coba->data[a].cur= a;
- qsort(coba->data, coba->tot, sizeof(CBData), vergcband);
- for(a=0; a<coba->tot; a++) {
- if(coba->data[a].cur==coba->cur) {
- coba->cur= a;
- break;
- }
+ if(coba->tot > 1) {
+ if(coba->cur > 0) pos= (coba->data[coba->cur-1].pos + coba->data[coba->cur].pos) * 0.5f;
+ else pos= (coba->data[coba->cur+1].pos + coba->data[coba->cur].pos) * 0.5f;
}
- rna_update_cb(C, cb_v, NULL);
+ if(colorband_element_add(coba, pos)) {
+ rna_update_cb(C, cb_v, NULL);
+ ED_undo_push(C, "Add colorband");
+ }
}
-static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v)
+static void colorband_del_cb(bContext *C, void *cb_v, void *coba_v)
{
ColorBand *coba= coba_v;
- if(coba->tot < MAXCOLORBAND-1) coba->tot++;
- coba->cur= coba->tot-1;
-
- colorband_pos_cb(C, cb_v, coba_v);
-
- ED_undo_push(C, "Add colorband");
+ if(colorband_element_remove(coba, coba->cur)) {
+ ED_undo_push(C, "Delete colorband");
+ rna_update_cb(C, cb_v, NULL);
+ }
}
-static void colorband_del_cb(bContext *C, void *cb_v, void *coba_v)
+static void colorband_flip_cb(bContext *C, void *cb_v, void *coba_v)
{
+ CBData data_tmp[MAXCOLORBAND];
+
ColorBand *coba= coba_v;
int a;
- if(coba->tot<2) return;
-
- for(a=coba->cur; a<coba->tot; a++) {
- coba->data[a]= coba->data[a+1];
+ for(a=0; a<coba->tot; a++) {
+ data_tmp[a]= coba->data[coba->tot - (a + 1)];
}
- if(coba->cur) coba->cur--;
- coba->tot--;
+ for(a=0; a<coba->tot; a++) {
+ data_tmp[a].pos = 1.0f - data_tmp[a].pos;
+ coba->data[a]= data_tmp[a];
+ }
+
+ /* may as well flip the cur*/
+ coba->cur= coba->tot - (coba->cur + 1);
- ED_undo_push(C, "Delete colorband");
+ ED_undo_push(C, "Flip colorband");
rna_update_cb(C, cb_v, NULL);
}
@@ -1473,12 +1211,17 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand
if(coba==NULL) return;
- bt= uiDefBut(block, BUT, 0, "Add", 0+xoffs,100+yoffs,50,20, 0, 0, 0, 0, 0, "Add a new color stop to the colorband");
+ bt= uiDefBut(block, BUT, 0, "Add", 0+xoffs,100+yoffs,40,20, 0, 0, 0, 0, 0, "Add a new color stop to the colorband");
uiButSetNFunc(bt, colorband_add_cb, MEM_dupallocN(cb), coba);
- bt= uiDefBut(block, BUT, 0, "Delete", 60+xoffs,100+yoffs,50,20, 0, 0, 0, 0, 0, "Delete the active position");
+ bt= uiDefBut(block, BUT, 0, "Delete", 45+xoffs,100+yoffs,45,20, 0, 0, 0, 0, 0, "Delete the active position");
uiButSetNFunc(bt, colorband_del_cb, MEM_dupallocN(cb), coba);
+
+ /* XXX, todo for later - convert to operator - campbell */
+ bt= uiDefBut(block, BUT, 0, "F", 95+xoffs,100+yoffs,20,20, 0, 0, 0, 0, 0, "Flip colorband");
+ uiButSetNFunc(bt, colorband_flip_cb, MEM_dupallocN(cb), coba);
+
uiDefButS(block, NUM, 0, "", 120+xoffs,100+yoffs,80, 20, &coba->cur, 0.0, (float)(MAX2(0, coba->tot-1)), 0, 0, "Choose active color stop");
bt= uiDefButS(block, MENU, 0, "Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4",
@@ -1489,6 +1232,8 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand
bt= uiDefBut(block, BUT_COLORBAND, 0, "", xoffs,65+yoffs,300,30, coba, 0, 0, 0, 0, "");
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+
+
if(coba->tot) {
CBData *cbd= coba->data + coba->cur;
@@ -1511,8 +1256,10 @@ static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand
uiBlockBeginAlign(block);
bt= uiDefBut(block, BUT, 0, "Add", xs,butr->ymin+20.0f,2.0f*unit,20, NULL, 0, 0, 0, 0, "Add a new color stop to the colorband");
uiButSetNFunc(bt, colorband_add_cb, MEM_dupallocN(cb), coba);
- bt= uiDefBut(block, BUT, 0, "Delete", xs+2.0f*unit,butr->ymin+20.0f,2.0f*unit,20, NULL, 0, 0, 0, 0, "Delete the active position");
+ bt= uiDefBut(block, BUT, 0, "Delete", xs+2.0f*unit,butr->ymin+20.0f,1.5f*unit,20, NULL, 0, 0, 0, 0, "Delete the active position");
uiButSetNFunc(bt, colorband_del_cb, MEM_dupallocN(cb), coba);
+ bt= uiDefBut(block, BUT, 0, "F", xs+3.5f*unit,butr->ymin+20.0f,0.5f*unit,20, NULL, 0, 0, 0, 0, "Flip the color ramp");
+ uiButSetNFunc(bt, colorband_flip_cb, MEM_dupallocN(cb), coba);
uiBlockEndAlign(block);
if(coba->tot) {
@@ -1596,12 +1343,85 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, char *propname, int
block= uiLayoutAbsoluteBlock(layout);
//colorband_buttons_layout(layout, block, cptr.data, &rect, !expand, cb);
-
+
hist = (Histogram *)cptr.data;
+
+ hist->height= (hist->height<=0)?100:hist->height;
+
+ bt= uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, hist->height, hist, 0, 0, 0, 0, "");
+ uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+
+ MEM_freeN(cb);
+}
+
+/********************* Waveform Template ************************/
+
+void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, char *propname, int expand)
+{
+ PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
+ PointerRNA cptr;
+ RNAUpdateCb *cb;
+ uiBlock *block;
+ uiBut *bt;
+ Scopes *scopes;
+ rctf rect;
+
+ if(!prop || RNA_property_type(prop) != PROP_POINTER)
+ return;
+
+ cptr= RNA_property_pointer_get(ptr, prop);
+ if(!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes))
+ return;
+ scopes = (Scopes *)cptr.data;
+
+ cb= MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
+ cb->ptr= *ptr;
+ cb->prop= prop;
+
+ rect.xmin= 0; rect.xmax= 200;
+ rect.ymin= 0; rect.ymax= 190;
+
+ block= uiLayoutAbsoluteBlock(layout);
+
+ scopes->wavefrm_height= (scopes->wavefrm_height<=0)?100:scopes->wavefrm_height;
+
+ bt= uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, scopes->wavefrm_height, scopes, 0, 0, 0, 0, "");
+
+ MEM_freeN(cb);
+}
+
+/********************* Vectorscope Template ************************/
+
+void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, char *propname, int expand)
+{
+ PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
+ PointerRNA cptr;
+ RNAUpdateCb *cb;
+ uiBlock *block;
+ uiBut *bt;
+ Scopes *scopes;
+ rctf rect;
+
+ if(!prop || RNA_property_type(prop) != PROP_POINTER)
+ return;
+
+ cptr= RNA_property_pointer_get(ptr, prop);
+ if(!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes))
+ return;
+ scopes = (Scopes *)cptr.data;
+
+ cb= MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
+ cb->ptr= *ptr;
+ cb->prop= prop;
- hist->height= (hist->height==0)?100:hist->height;
+ rect.xmin= 0; rect.xmax= 200;
+ rect.ymin= 0; rect.ymax= 190;
- bt= uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, hist->height, hist, 0, 0, 0, 0, "");
+ block= uiLayoutAbsoluteBlock(layout);
+
+ scopes->vecscope_height= (scopes->vecscope_height<=0)?100:scopes->vecscope_height;
+
+ bt= uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, scopes->vecscope_height, scopes, 0, 0, 0, 0, "");
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
MEM_freeN(cb);
@@ -1609,7 +1429,6 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, char *propname, int
/********************* CurveMapping Template ************************/
-#include "BKE_colortools.h"
static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void *unused)
{
@@ -1718,7 +1537,7 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event)
switch(event) {
case 0: /* reset */
- curvemap_reset(cuma, &cumap->clipr, cumap->preset);
+ curvemap_reset(cuma, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE);
curvemapping_changed(cumap, 0);
break;
case 1:
@@ -1798,7 +1617,7 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v)
cumap->preset = CURVE_PRESET_LINE;
for(a=0; a<CM_TOT; a++)
- curvemap_reset(cumap->cm+a, &cumap->clipr, cumap->preset);
+ 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;
@@ -1963,62 +1782,44 @@ void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, char *propname, i
#define WHEEL_SIZE 100
-void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, char *propname, int value_slider, int lock)
+void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, char *propname, int value_slider, int lock, int lock_luminosity, int cubic)
{
PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
uiBlock *block= uiLayoutGetBlock(layout);
uiLayout *col, *row;
+ uiBut *but;
float softmin, softmax, step, precision;
if (!prop) {
- printf("uiTemplateColorWheel: property not found: %s\n", propname);
+ printf("uiTemplateColorWheel: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
return;
}
-
+
RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision);
col = uiLayoutColumn(layout, 0);
row= uiLayoutRow(col, 1);
- uiDefButR(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, propname, -1, 0.0, 0.0, 0, lock, "");
-
- uiItemS(row);
-
- if (value_slider)
- uiDefButR(block, HSVCUBE, 0, "", WHEEL_SIZE+6, 0, 14, WHEEL_SIZE, ptr, propname, -1, softmin, softmax, 9, 0, "");
+ but= uiDefButR(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, propname, -1, 0.0, 0.0, 0, 0, "");
- /* maybe a switch for this?
- row= uiLayoutRow(col, 0);
- if(ELEM(RNA_property_subtype(prop), PROP_COLOR, PROP_COLOR_GAMMA) && RNA_property_array_length(ptr, prop) == 4) {
- but= uiDefAutoButR(block, ptr, prop, 3, "A:", 0, 0, 0, WHEEL_SIZE+20, UI_UNIT_Y);
+ if(lock) {
+ but->flag |= UI_BUT_COLOR_LOCK;
}
- */
-
-}
+ if(lock_luminosity) {
+ float color[4]; /* incase of alpha */
+ but->flag |= UI_BUT_VEC_SIZE_LOCK;
+ RNA_property_float_get_array(ptr, prop, color);
+ but->a2= len_v3(color);
+ }
-/********************* TriColor (ThemeWireColorSet) Template ************************/
-
-void uiTemplateTriColorSet(uiLayout *layout, PointerRNA *ptr, char *propname)
-{
- PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
- uiLayout *row;
- PointerRNA csPtr;
+ if(cubic)
+ but->flag |= UI_BUT_COLOR_CUBIC;
- if (!prop) {
- printf("uiTemplateTriColorSet: property not found: %s\n", propname);
- return;
- }
-
- /* we lay out the data in a row as 3 color swatches */
- row= uiLayoutRow(layout, 1);
-
- /* nselected, selected, active color swatches */
- csPtr= RNA_property_pointer_get(ptr, prop);
+ uiItemS(row);
- uiItemR(row, &csPtr, "normal", 0, "", 0);
- uiItemR(row, &csPtr, "selected", 0, "", 0);
- uiItemR(row, &csPtr, "active", 0, "", 0);
+ if (value_slider)
+ uiDefButR(block, HSVCUBE, 0, "", WHEEL_SIZE+6, 0, 14, WHEEL_SIZE, ptr, propname, -1, softmin, softmax, 9, 0, "");
}
/********************* Layer Buttons Template ************************/
@@ -2058,7 +1859,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, char *propname,
prop= RNA_struct_find_property(ptr, propname);
if (!prop) {
- printf("uiTemplateLayer: layers property not found: %s\n", propname);
+ printf("uiTemplateLayer: layers property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
return;
}
@@ -2077,7 +1878,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, char *propname,
if(used_ptr && used_propname) {
used_prop= RNA_struct_find_property(used_ptr, used_propname);
if (!used_prop) {
- printf("uiTemplateLayer: used layers property not found: %s\n", used_propname);
+ printf("uiTemplateLayer: used layers property not found: %s.%s\n", RNA_struct_identifier(ptr->type), used_propname);
return;
}
@@ -2163,12 +1964,6 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
/* list item behind label & other buttons */
sub= uiLayoutRow(overlap, 0);
- if(itemptr->type == &RNA_ShapeKey) {
- ob= (Object*)activeptr->data;
- if(ob->mode == OB_MODE_EDIT && !(ob->type == OB_MESH))
- uiLayoutSetEnabled(sub, 0);
- }
-
but= uiDefButR(block, LISTROW, 0, "", 0,0, UI_UNIT_X*10,UI_UNIT_Y, activeptr, activepropname, 0, 0, i, 0, 0, "");
uiButSetFlag(but, UI_BUT_NO_TOOLTIP);
@@ -2197,7 +1992,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
else if(RNA_struct_is_a(itemptr->type, &RNA_SceneRenderLayer)) {
uiItemL(sub, name, icon);
uiBlockSetEmboss(block, UI_EMBOSS);
- uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "enabled", 0, 0, 0, 0, 0, NULL);
+ uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "use", 0, 0, 0, 0, 0, NULL);
}
else if(itemptr->type == &RNA_ShapeKey) {
ob= (Object*)activeptr->data;
@@ -2252,14 +2047,14 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propna
if(ptr->data) {
prop= RNA_struct_find_property(ptr, propname);
if(!prop) {
- printf("uiTemplateList: property not found: %s\n", propname);
+ printf("uiTemplateList: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
return;
}
}
activeprop= RNA_struct_find_property(activeptr, activepropname);
if(!activeprop) {
- printf("uiTemplateList: property not found: %s\n", activepropname);
+ printf("uiTemplateList: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), activepropname);
return;
}
@@ -2456,6 +2251,7 @@ void uiTemplateOperatorSearch(uiLayout *layout)
#define B_STOPRENDER 1
#define B_STOPCAST 2
#define B_STOPANIM 3
+#define B_STOPCOMPO 4
static void do_running_jobs(bContext *C, void *arg, int event)
{
@@ -2464,11 +2260,14 @@ static void do_running_jobs(bContext *C, void *arg, int event)
G.afbreek= 1;
break;
case B_STOPCAST:
- WM_jobs_stop(CTX_wm_manager(C), CTX_wm_screen(C));
+ WM_jobs_stop(CTX_wm_manager(C), CTX_wm_screen(C), NULL);
break;
case B_STOPANIM:
WM_operator_name_call(C, "SCREEN_OT_animation_play", WM_OP_INVOKE_SCREEN, NULL);
break;
+ case B_STOPCOMPO:
+ WM_jobs_stop(CTX_wm_manager(C), CTX_wm_area(C), NULL);
+ break;
}
}
@@ -2477,15 +2276,36 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
bScreen *screen= CTX_wm_screen(C);
Scene *scene= CTX_data_scene(C);
wmWindowManager *wm= CTX_wm_manager(C);
+ ScrArea *sa= CTX_wm_area(C);
uiBlock *block;
-
+ void *owner;
+ int handle_event;
+
block= uiLayoutGetBlock(layout);
uiBlockSetCurLayout(block, layout);
uiBlockSetHandleFunc(block, do_running_jobs, NULL);
- if(WM_jobs_test(wm, scene))
- uiDefIconTextBut(block, BUT, B_STOPRENDER, ICON_CANCEL, "Render", 0,0,75,UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "Stop rendering");
+ if(sa->spacetype==SPACE_NODE) {
+ owner = sa;
+ handle_event= B_STOPCOMPO;
+ } else {
+ owner = scene;
+ handle_event= B_STOPRENDER;
+ }
+
+ if(WM_jobs_test(wm, owner)) {
+ uiLayout *abs;
+
+ abs = uiLayoutAbsolute(layout, 0);
+
+ uiDefIconBut(block, BUT, handle_event, ICON_PANEL_CLOSE,
+ 0, UI_UNIT_Y*0.1, UI_UNIT_X*0.8, UI_UNIT_Y*0.8, NULL, 0.0f, 0.0f, 0, 0, "Stop this job");
+ uiDefBut(block, PROGRESSBAR, 0, WM_jobs_name(wm, owner),
+ UI_UNIT_X, 0, 100, UI_UNIT_Y, NULL, 0.0f, 0.0f, WM_jobs_progress(wm, owner), 0, "Progress");
+
+ uiLayoutRow(layout, 0);
+ }
if(WM_jobs_test(wm, screen))
uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_CANCEL, "Capture", 0,0,85,UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "Stop screencast");
if(screen->animtimer)
@@ -2494,43 +2314,55 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
/************************* Reports for Last Operator Template **************************/
-void uiTemplateReportsBanner(uiLayout *layout, bContext *C, wmOperator *op)
+void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
{
- ReportList *reports = op->reports;
- uiLayout *box;
+ ReportList *reports = CTX_wm_reports(C);
+ Report *report= BKE_reports_last_displayable(reports);
+ ReportTimerInfo *rti;
- /* sanity checks */
- if (ELEM(NULL, op, reports)) {
- printf("uiTemplateReportsBanner: no operator with reports!\n");
- return;
- }
+ uiLayout *abs;
+ uiBlock *block;
+ uiBut *but;
+ uiStyle *style= U.uistyles.first;
+ int width;
+ float hsv[3];
+
+ /* if the report display has timed out, don't show */
+ if (!reports->reporttimer) return;
+
+ rti= (ReportTimerInfo *)reports->reporttimer->customdata;
+
+ if (!rti || rti->widthfac==0.0 || !report) return;
+
+ abs = uiLayoutAbsolute(layout, 0);
+ block= uiLayoutGetBlock(abs);
+
+ rgb_to_hsv(rti->col[0], rti->col[1], rti->col[2], hsv+0, hsv+1, hsv+2);
+
+ width = BLF_width(style->widget.uifont_id, report->message);
+ width = MIN2(rti->widthfac*width, width);
+ width = MAX2(width, 10);
/* make a box around the report to make it stand out */
- box = uiLayoutBox(layout);
- uiLayoutSetScaleY(box, 0.48); /* experimentally determined value to reduce execessive padding... */
+ uiBlockBeginAlign(block);
+ but= uiDefBut(block, ROUNDBOX, 0, "", 0, 0, UI_UNIT_X+10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
+ copy_v3_v3(but->hsv, hsv); /* set the report's bg colour in but->hsv - ROUNDBOX feature */
- /* if more than one report, we need to show the popup when user clicks on the temp label... */
- if (reports->list.first != reports->list.last) {
- int numReports = BLI_countlist(&reports->list);
- char buf[64];
-
- // XXX: we need uiItem* to return uiBut pointer so that we can use it to set callbacks
- // used to call uiPupMenuReports... as alternative, we could fall back to the "old ways"
- //sprintf(buf, "Last Operator had %d errors. Click to see more...", numReports);
- sprintf(buf, "Last Operator had %d errors", numReports);
- uiItemL(box, buf, ICON_INFO);
- }
- else {
- /* single report, so show report directly */
- // XXX: what if the report is too long? should we truncate the text?
- Report *report= (Report *)reports->list.first;
-
- if(report->type >= RPT_ERROR)
- uiItemL(box, report->message, ICON_ERROR);
- else if(report->type >= RPT_WARNING)
- uiItemL(box, report->message, ICON_ERROR);
- else if(report->type >= RPT_INFO)
- uiItemL(box, report->message, ICON_INFO);
- }
+ but= uiDefBut(block, ROUNDBOX, 0, "", UI_UNIT_X+10, 0, UI_UNIT_X+width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
+ but->hsv[0] = but->hsv[1] = 0.0; /* set a greyscale bg colour in but->hsv - ROUNDBOX feature */
+ but->hsv[2] = rti->greyscale;
+ uiBlockEndAlign(block);
+
+
+ /* icon and report message on top */
+ if(report->type & RPT_ERROR_ALL)
+ uiDefIconBut(block, LABEL, 0, ICON_ERROR, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
+ else if(report->type & RPT_WARNING_ALL)
+ uiDefIconBut(block, LABEL, 0, ICON_ERROR, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
+ else if(report->type & RPT_INFO_ALL)
+ uiDefIconBut(block, LABEL, 0, ICON_INFO, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
+
+ uiDefBut(block, LABEL, 0, report->message, UI_UNIT_X+10, 0, UI_UNIT_X+width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
+
}
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 1c75a05e084..32ede75c20d 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -28,7 +28,6 @@
#include <stdlib.h>
#include <string.h>
-#include "MEM_guardedalloc.h"
#include "DNA_screen_types.h"
#include "DNA_userdef_types.h"
@@ -39,7 +38,6 @@
#include "BKE_context.h"
#include "BKE_curve.h"
-#include "BKE_global.h"
#include "BKE_utildefines.h"
#include "RNA_access.h"
@@ -283,10 +281,10 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl
float maxxi= maxx - 1.0f;
float minyi= miny + 1.0f;
float maxyi= maxy - 1.0f;
- float facxi= 1.0f/(maxxi-minxi); /* for uv */
- float facyi= 1.0f/(maxyi-minyi);
+ float facxi= (maxxi!=minxi) ? 1.0f/(maxxi-minxi) : 0.0f; /* for uv, can divide by zero */
+ float facyi= (maxyi!=minyi) ? 1.0f/(maxyi-minyi) : 0.0f;
int a, tot= 0, minsize;
-
+
minsize= MIN2(rect->xmax-rect->xmin, rect->ymax-rect->ymin);
if(2.0f*rad > minsize)
@@ -608,14 +606,67 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
/* backdrop non AA */
if(wtb->inner) {
if(wcol->shaded==0) {
-
- /* filled center, solid */
- glColor4ubv((unsigned char*)wcol->inner);
- glBegin(GL_POLYGON);
- for(a=0; a<wtb->totvert; a++)
- glVertex2fv(wtb->inner_v[a]);
- glEnd();
+ if (wcol->alpha_check) {
+ GLubyte checker_stipple_sml[32*32/8] =
+ {
+ 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, \
+ 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, \
+ 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, \
+ 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, \
+ 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, \
+ 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, \
+ 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, \
+ 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, \
+ };
+
+ float x_mid= 0.0f; /* used for dumb clamping of values */
+
+ /* dark checkers */
+ glColor4ub(100, 100, 100, 255);
+ glBegin(GL_POLYGON);
+ for(a=0; a<wtb->totvert; a++) {
+ glVertex2fv(wtb->inner_v[a]);
+ }
+ glEnd();
+
+ /* light checkers */
+ glEnable(GL_POLYGON_STIPPLE);
+ glColor4ub(160, 160, 160, 255);
+ glPolygonStipple(checker_stipple_sml);
+ glBegin(GL_POLYGON);
+ for(a=0; a<wtb->totvert; a++) {
+ glVertex2fv(wtb->inner_v[a]);
+ }
+ glEnd();
+ glDisable(GL_POLYGON_STIPPLE);
+
+ /* alpha fill */
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glColor4ubv((unsigned char*)wcol->inner);
+ glBegin(GL_POLYGON);
+ for(a=0; a<wtb->totvert; a++) {
+ glVertex2fv(wtb->inner_v[a]);
+ x_mid += wtb->inner_v[a][0];
+ }
+ x_mid /= wtb->totvert;
+ glEnd();
+
+ /* 1/2 solid color */
+ glColor4ub(wcol->inner[0], wcol->inner[1], wcol->inner[2], 255);
+ glBegin(GL_POLYGON);
+ for(a=0; a<wtb->totvert; a++)
+ glVertex2f(MIN2(wtb->inner_v[a][0], x_mid), wtb->inner_v[a][1]);
+ glEnd();
+ }
+ else {
+ /* simple fill */
+ glColor4ubv((unsigned char*)wcol->inner);
+ glBegin(GL_POLYGON);
+ for(a=0; a<wtb->totvert; a++)
+ glVertex2fv(wtb->inner_v[a]);
+ glEnd();
+ }
}
else {
char col1[4], col2[4];
@@ -694,11 +745,10 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
static void widget_draw_preview(BIFIconID icon, float aspect, float alpha, rcti *rect)
{
int w, h, x, y, size;
-
- /* only display previews for actual preview images .. ? */
- if (icon < BIFICONID_LAST)
+
+ if(!icon)
return;
-
+
w = rect->xmax - rect->xmin;
h = rect->ymax - rect->ymin;
size = MIN2(w, h);
@@ -813,15 +863,15 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
uiStyleFontSet(fstyle);
if (fstyle->kerning==1) /* for BLF_width */
- BLF_enable(BLF_KERNING_DEFAULT);
+ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
- but->strwidth= BLF_width(but->drawstr);
+ but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr);
but->ofs= 0;
while(but->strwidth > okwidth ) {
but->ofs++;
- but->strwidth= BLF_width(but->drawstr+but->ofs);
+ but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs);
/* textbut exception */
if(but->editstr && but->pos != -1) {
@@ -842,7 +892,7 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
}
if (fstyle->kerning==1)
- BLF_disable(BLF_KERNING_DEFAULT);
+ BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
}
static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
@@ -856,9 +906,9 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
uiStyleFontSet(fstyle);
if (fstyle->kerning==1) /* for BLF_width */
- BLF_enable(BLF_KERNING_DEFAULT);
+ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
- but->strwidth= BLF_width(but->drawstr);
+ but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr);
but->ofs= 0;
/* find the space after ':' separator */
@@ -873,7 +923,7 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
memmove(cp2-1, cp2, strlen(cp2)+1);
cp2--;
- but->strwidth= BLF_width(but->drawstr+but->ofs);
+ but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs);
if(but->strwidth < 10) break;
}
@@ -882,7 +932,7 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
while ((but->strwidth > okwidth) && (but->ofs < 2))
{
but->ofs++;
- but->strwidth= BLF_width(but->drawstr+but->ofs);
+ but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs);
if(but->strwidth < 10) break;
}
@@ -895,12 +945,12 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
but->drawstr[ pos-1 ] = 0;
pos--;
- but->strwidth= BLF_width(but->drawstr+but->ofs);
+ but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs);
if(but->strwidth < 10) break;
}
if (fstyle->kerning==1)
- BLF_disable(BLF_KERNING_DEFAULT);
+ BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
}
@@ -917,7 +967,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
fstyle->align= UI_STYLE_TEXT_CENTER;
if (fstyle->kerning==1) /* for BLF_width */
- BLF_enable(BLF_KERNING_DEFAULT);
+ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
/* text button selection and cursor */
if(but->editstr && but->pos != -1) {
@@ -935,7 +985,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
ch= but->drawstr[selsta_tmp];
but->drawstr[selsta_tmp]= 0;
- selsta_draw = BLF_width(but->drawstr+but->ofs);
+ selsta_draw = BLF_width(fstyle->uifont_id, but->drawstr+but->ofs);
but->drawstr[selsta_tmp]= ch;
} else
@@ -944,7 +994,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
ch= but->drawstr[selend_tmp];
but->drawstr[selend_tmp]= 0;
- selwidth_draw = BLF_width(but->drawstr+but->ofs);
+ selwidth_draw = BLF_width(fstyle->uifont_id, but->drawstr+but->ofs);
but->drawstr[selend_tmp]= ch;
@@ -959,7 +1009,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
ch= but->drawstr[pos];
but->drawstr[pos]= 0;
- t= BLF_width(but->drawstr+but->ofs) / but->aspect;
+ t= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs) / but->aspect;
but->drawstr[pos]= ch;
}
@@ -971,7 +1021,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
}
if (fstyle->kerning == 1)
- BLF_disable(BLF_KERNING_DEFAULT);
+ BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
// ui_rasterpos_safe(x, y, but->aspect);
// if(but->type==IDPOIN) transopts= 0; // no translation, of course!
@@ -1276,6 +1326,19 @@ static struct uiWidgetColors wcol_scroll= {
5, -5
};
+static struct uiWidgetColors wcol_progress= {
+ {0, 0, 0, 255},
+ {190, 190, 190, 255},
+ {100, 100, 100, 180},
+ {68, 68, 68, 255},
+
+ {0, 0, 0, 255},
+ {255, 255, 255, 255},
+
+ 0,
+ 0, 0
+};
+
static struct uiWidgetColors wcol_list_item= {
{0, 0, 0, 255},
{0, 0, 0, 0},
@@ -1322,6 +1385,7 @@ void ui_widget_color_init(ThemeUI *tui)
tui->wcol_box= wcol_box;
tui->wcol_scroll= wcol_scroll;
tui->wcol_list_item= wcol_list_item;
+ tui->wcol_progress= wcol_progress;
tui->wcol_state= wcol_state;
}
@@ -1574,6 +1638,10 @@ void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect)
float centx, centy, radius;
float rgb[3], hsv[3], hsvo[3], col[3], colcent[3];
int a, tot= 32;
+ int color_profile = but->block->color_profile;
+
+ if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
+ color_profile = BLI_PR_NONE;
radstep= 2.0f*M_PI/(float)tot;
centx= (float)(rect->xmin + rect->xmax)/2;
@@ -1589,10 +1657,13 @@ void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect)
rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
copy_v3_v3(hsvo, hsv);
- /* exception: if 'lock' is set (stored in but->a2),
+ /* exception: if 'lock' is set
* lock the value of the color wheel to 1.
* Useful for color correction tools where you're only interested in hue. */
- if (but->a2) hsv[2] = 1.f;
+ if (but->flag & UI_BUT_COLOR_LOCK)
+ hsv[2] = 1.f;
+ else if (color_profile)
+ hsv[2] = linearrgb_to_srgb(hsv[2]);
hsv_to_rgb(0.f, 0.f, hsv[2], colcent, colcent+1, colcent+2);
@@ -1607,6 +1678,8 @@ void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect)
float co= cos(ang);
ui_hsvcircle_vals_from_pos(hsv, hsv+1, rect, centx + co*radius, centy + si*radius);
+ CLAMP(hsv[2], 0.0f, 1.0f); /* for display only */
+
hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2);
glColor3fv(col);
glVertex2f( centx + co*radius, centy + si*radius);
@@ -1621,14 +1694,19 @@ void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect)
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH );
glColor3ubv((unsigned char*)wcol->outline);
- glutil_draw_lined_arc(0.0f, M_PI*2.0, radius, tot);
+ glutil_draw_lined_arc(0.0f, M_PI*2.0, radius, tot + 1);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH );
glPopMatrix();
/* cursor */
ang= 2.0f*M_PI*hsvo[0] + 0.5f*M_PI;
- radius= hsvo[1]*radius;
+
+ if(but->flag & UI_BUT_COLOR_CUBIC)
+ radius= (1.0f - pow(1.0f - hsvo[1], 3.0f)) *radius;
+ else
+ radius= hsvo[1] * radius;
+
ui_hsv_cursor(centx + cos(-ang)*radius, centy + sin(-ang)*radius);
}
@@ -1813,11 +1891,8 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect)
float rgb[3], hsv[3], v, range;
int color_profile = but->block->color_profile;
- if (but->rnaprop) {
- if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) {
- color_profile = BLI_PR_NONE;
- }
- }
+ if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
+ color_profile = BLI_PR_NONE;
ui_get_but_vectorf(but, rgb);
rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
@@ -1954,6 +2029,7 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat
uiWidgetBase wtb;
float rad;
int horizontal;
+ short outline=0;
widget_init(&wtb);
@@ -1995,6 +2071,10 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat
/* draw */
wtb.emboss= 0; /* only emboss once */
+ /* exception for progress bar */
+ if (state & UI_SCROLL_NO_OUTLINE)
+ SWAP(short, outline, wtb.outline);
+
round_box_edges(&wtb, 15, slider, rad);
if(state & UI_SCROLL_ARROWS) {
@@ -2013,6 +2093,9 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat
}
}
widgetbase_draw(&wtb, wcol);
+
+ if (state & UI_SCROLL_NO_OUTLINE)
+ SWAP(short, outline, wtb.outline);
}
}
@@ -2077,9 +2160,35 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
uiWidgetScrollDraw(wcol, rect, &rect1, state);
}
-static void widget_link(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
+static void widget_progressbar(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
{
+ rcti rect_prog = *rect, rect_bar = *rect;
+ float value = but->a1;
+ float w, min;
+
+ /* make the progress bar a proportion of the original height */
+ /* hardcoded 4px high for now */
+ rect_prog.ymax = rect_prog.ymin + 4;
+ rect_bar.ymax = rect_bar.ymin + 4;
+
+ w = value * (rect_prog.xmax - rect_prog.xmin);
+
+ /* ensure minimium size */
+ min= rect_prog.ymax - rect_prog.ymin;
+ w = MAX2(w, min);
+
+ rect_bar.xmax = rect_bar.xmin + w;
+
+ uiWidgetScrollDraw(wcol, &rect_prog, &rect_bar, UI_SCROLL_NO_OUTLINE);
+
+ /* raise text a bit */
+ rect->ymin += 6;
+ rect->xmin -= 6;
+}
+static void widget_link(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
+{
+
if(but->flag & UI_SELECT) {
rcti rectlink;
@@ -2094,7 +2203,6 @@ static void widget_link(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state,
}
}
-
static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
{
uiWidgetBase wtb, wtb1;
@@ -2161,9 +2269,15 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
float col[4];
int color_profile = but->block->color_profile;
+ col[3]= 1.0f;
+
if (but->rnaprop) {
if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
color_profile = BLI_PR_NONE;
+
+ if(RNA_property_array_length(&but->rnapoin, but->rnaprop)==4) {
+ col[3]= RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3);
+ }
}
widget_init(&wtb);
@@ -2179,8 +2293,10 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
wcol->inner[0]= FTOCHAR(col[0]);
wcol->inner[1]= FTOCHAR(col[1]);
wcol->inner[2]= FTOCHAR(col[2]);
+ wcol->inner[3]= FTOCHAR(col[3]);
wcol->shaded = 0;
-
+ wcol->alpha_check = (wcol->inner[3] < 255);
+
widgetbase_draw(&wtb, wcol);
}
@@ -2318,6 +2434,36 @@ static void widget_radiobut(uiWidgetColors *wcol, rcti *rect, int state, int rou
}
+static void widget_box(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
+{
+ uiWidgetBase wtb;
+ char old_col[3];
+
+ widget_init(&wtb);
+
+ VECCOPY(old_col, wcol->inner);
+
+ /* abuse but->hsv - if it's non-zero, use this colour as the box's background */
+ if ((but->hsv[0] != 0.0) || (but->hsv[1] != 0.0) || (but->hsv[2] != 0.0)) {
+ float rgb[3];
+ hsv_to_rgb(but->hsv[0], but->hsv[1], but->hsv[2], rgb+0, rgb+1, rgb+2);
+ wcol->inner[0] = rgb[0] * 255;
+ wcol->inner[1] = rgb[1] * 255;
+ wcol->inner[2] = rgb[2] * 255;
+ }
+
+ /* half rounded */
+ round_box_edges(&wtb, roundboxalign, rect, 4.0f);
+
+ widgetbase_draw(&wtb, wcol);
+
+ /* store the box bg as gl clearcolor, to retrieve later when drawing semi-transparent rects
+ * over the top to indicate disabled buttons */
+ glClearColor(wcol->inner[0]/255.0, wcol->inner[1]/255.0, wcol->inner[2]/255.0, 1.0);
+
+ VECCOPY(wcol->inner, old_col);
+}
+
static void widget_but(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
{
uiWidgetBase wtb;
@@ -2384,10 +2530,11 @@ static void widget_disabled(rcti *rect)
/* can't use theme TH_BACK or TH_PANEL... undefined */
glGetFloatv(GL_COLOR_CLEAR_VALUE, col);
glColor4f(col[0], col[1], col[2], 0.5f);
+
/* need -1 and +1 to make it work right for aligned buttons,
* but problem may be somewhere else? */
- glRectf(rect->xmin-1, rect->ymin, rect->xmax, rect->ymax+1);
-
+ glRectf(rect->xmin-1, rect->ymin-1, rect->xmax, rect->ymax+1);
+
glDisable(GL_BLEND);
}
@@ -2504,6 +2651,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
break;
case UI_WTYPE_BOX:
+ wt.custom= widget_box;
wt.wcol_theme= &btheme->tui.wcol_box;
break;
@@ -2523,6 +2671,11 @@ 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;
+ break;
}
return &wt;
@@ -2727,9 +2880,22 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
ui_draw_but_HISTOGRAM(ar, but, &tui->wcol_regular, rect);
break;
+ case WAVEFORM:
+ ui_draw_but_WAVEFORM(ar, but, &tui->wcol_regular, rect);
+ break;
+
+ case VECTORSCOPE:
+ ui_draw_but_VECTORSCOPE(ar, but, &tui->wcol_regular, rect);
+ break;
+
case BUT_CURVE:
ui_draw_but_CURVE(ar, but, &tui->wcol_regular, rect);
break;
+
+ case PROGRESSBAR:
+ wt= widget_type(UI_WTYPE_PROGRESSBAR);
+ fstyle= &style->widgetlabel;
+ break;
case SCROLL:
wt= widget_type(UI_WTYPE_SCROLL);
@@ -2813,7 +2979,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, char *name, int iconid,
cpoin= strchr(name, '|');
if(cpoin) {
*cpoin= 0;
- rect->xmax -= BLF_width(cpoin+1) + 10;
+ rect->xmax -= BLF_width(fstyle->uifont_id, cpoin+1) + 10;
}
glColor3ubv((unsigned char*)wt->wcol.text);
@@ -2856,8 +3022,8 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, char *name, int iconi
glColor3ubv((unsigned char*)wt->wcol.text_sel);
trect.xmin += 0;
- trect.xmax = trect.xmin + BLF_width(name) + 10;
+ trect.xmax = trect.xmin + BLF_width(fstyle->uifont_id, name) + 10;
trect.ymin += 10;
- trect.ymax = trect.ymin + BLF_height(name);
+ trect.ymax = trect.ymin + BLF_height(fstyle->uifont_id, name);
uiStyleFontDraw(fstyle, &trect, name);
}
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index dcfbc94798b..c250cdb1284 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -34,10 +34,6 @@
#include <stdlib.h>
#include <string.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include "MEM_guardedalloc.h"
@@ -275,6 +271,8 @@ char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
cp= ts->edge_seam; break;
case TH_EDGE_SHARP:
cp= ts->edge_sharp; break;
+ case TH_EDGE_CREASE:
+ cp= ts->edge_crease; break;
case TH_EDITMESH_ACTIVE:
cp= ts->editmesh_active; break;
case TH_EDGE_FACESEL:
@@ -311,6 +309,8 @@ char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
cp= ts->nurb_sel_vline; break;
case TH_ACTIVE_SPLINE:
cp= ts->act_spline; break;
+ case TH_LASTSEL_POINT:
+ cp= ts->lastsel_point; break;
case TH_HANDLE_FREE:
cp= ts->handle_free; break;
case TH_HANDLE_AUTO:
@@ -532,6 +532,7 @@ void ui_theme_init_default(void)
SETCOL(btheme->tv3d.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
SETCOL(btheme->tv3d.act_spline, 0xdb, 0x25, 0x12, 255);
+ SETCOL(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255);
SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255);
SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80); // alpha 80 is not meant editable, used for wire+action draw
@@ -942,6 +943,14 @@ void UI_GetColorPtrBlendShade3ubv(char *cp1, char *cp2, char *col, float fac, in
col[2] = b;
}
+void UI_ThemeClearColor(int colorid)
+{
+ float col[3];
+
+ UI_GetThemeColor3fv(colorid, col);
+ glClearColor(col[0], col[1], col[2], 0.0);
+}
+
void UI_make_axis_color(char *src_col, char *dst_col, char axis)
{
switch(axis)
@@ -970,6 +979,7 @@ void UI_make_axis_color(char *src_col, char *dst_col, char axis)
/* patching UserDef struct and Themes */
void init_userdef_do_versions(void)
{
+ Main *bmain= G.main;
// countall();
/* the UserDef struct is not corrected with do_versions() .... ugh! */
@@ -988,9 +998,13 @@ void init_userdef_do_versions(void)
strcpy(U.tempdir, tmp?tmp:"/tmp/");
}
+ if (U.autokey_mode == 0) {
+ /* 'add/replace' but not on */
+ U.autokey_mode = 2;
+ }
if (U.savetime <= 0) {
U.savetime = 1;
-// XXX error(".B.blend is buggy, please consider removing it.\n");
+// XXX error("startup.blend is buggy, please consider removing it.\n");
}
/* transform widget settings */
if(U.tw_hotspot==0) {
@@ -1004,18 +1018,18 @@ void init_userdef_do_versions(void)
if(U.flag & USER_CUSTOM_RANGE)
vDM_ColorBand_store(&U.coba_weight); /* signal for derivedmesh to use colorband */
- if (G.main->versionfile <= 191) {
+ if (bmain->versionfile <= 191) {
strcpy(U.plugtexdir, U.textudir);
strcpy(U.sounddir, "/");
}
/* patch to set Dupli Armature */
- if (G.main->versionfile < 220) {
+ if (bmain->versionfile < 220) {
U.dupflag |= USER_DUP_ARM;
}
/* added seam, normal color, undo */
- if (G.main->versionfile <= 234) {
+ if (bmain->versionfile <= 234) {
bTheme *btheme;
U.uiflag |= USER_GLOBALUNDO;
@@ -1038,12 +1052,12 @@ void init_userdef_do_versions(void)
}
}
}
- if (G.main->versionfile <= 235) {
+ if (bmain->versionfile <= 235) {
/* illegal combo... */
if (U.flag & USER_LMOUSESELECT)
U.flag &= ~USER_TWOBUTTONMOUSE;
}
- if (G.main->versionfile <= 236) {
+ if (bmain->versionfile <= 236) {
bTheme *btheme;
/* new space type */
for(btheme= U.themes.first; btheme; btheme= btheme->next) {
@@ -1060,7 +1074,7 @@ void init_userdef_do_versions(void)
}
}
}
- if (G.main->versionfile <= 237) {
+ if (bmain->versionfile <= 237) {
bTheme *btheme;
/* bone colors */
for(btheme= U.themes.first; btheme; btheme= btheme->next) {
@@ -1071,7 +1085,7 @@ void init_userdef_do_versions(void)
}
}
}
- if (G.main->versionfile <= 238) {
+ if (bmain->versionfile <= 238) {
bTheme *btheme;
/* bone colors */
for(btheme= U.themes.first; btheme; btheme= btheme->next) {
@@ -1082,7 +1096,7 @@ void init_userdef_do_versions(void)
}
}
}
- if (G.main->versionfile <= 239) {
+ if (bmain->versionfile <= 239) {
bTheme *btheme;
for(btheme= U.themes.first; btheme; btheme= btheme->next) {
@@ -1096,7 +1110,7 @@ void init_userdef_do_versions(void)
}
if(U.obcenter_dia==0) U.obcenter_dia= 6;
}
- if (G.main->versionfile <= 241) {
+ if (bmain->versionfile <= 241) {
bTheme *btheme;
for(btheme= U.themes.first; btheme; btheme= btheme->next) {
/* Node editor theme, check for alpha==0 is safe, then color was never set */
@@ -1129,7 +1143,7 @@ void init_userdef_do_versions(void)
}
/* set defaults for 3D View rotating axis indicator */
- /* since size can't be set to 0, this indicates it's not saved in .B.blend */
+ /* 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;
@@ -1137,7 +1151,7 @@ void init_userdef_do_versions(void)
}
}
- if (G.main->versionfile <= 242) {
+ if (bmain->versionfile <= 242) {
bTheme *btheme;
for(btheme= U.themes.first; btheme; btheme= btheme->next) {
@@ -1155,11 +1169,11 @@ void init_userdef_do_versions(void)
}
}
}
- if (G.main->versionfile <= 243) {
+ if (bmain->versionfile <= 243) {
/* set default number of recently-used files (if not set) */
if (U.recent_files == 0) U.recent_files = 10;
}
- if (G.main->versionfile < 245 || (G.main->versionfile == 245 && G.main->subversionfile < 3)) {
+ if (bmain->versionfile < 245 || (bmain->versionfile == 245 && bmain->subversionfile < 3)) {
bTheme *btheme;
for(btheme= U.themes.first; btheme; btheme= btheme->next) {
SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
@@ -1167,7 +1181,7 @@ void init_userdef_do_versions(void)
if(U.coba_weight.tot==0)
init_colorband(&U.coba_weight, 1);
}
- if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 11)) {
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) {
bTheme *btheme;
for (btheme= U.themes.first; btheme; btheme= btheme->next) {
/* these should all use the same colour */
@@ -1180,7 +1194,7 @@ void init_userdef_do_versions(void)
SETCOL(btheme->ttime.cframe, 0x60, 0xc0, 0x40, 255);
}
}
- if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 13)) {
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 13)) {
bTheme *btheme;
for (btheme= U.themes.first; btheme; btheme= btheme->next) {
/* action channel groups (recolor anyway) */
@@ -1253,10 +1267,10 @@ void init_userdef_do_versions(void)
}
}
}
- if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 16)) {
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 16)) {
U.flag |= USER_ADD_VIEWALIGNED|USER_ADD_EDITMODE;
}
- if ((G.main->versionfile < 247) || (G.main->versionfile == 247 && G.main->subversionfile <= 2)) {
+ if ((bmain->versionfile < 247) || (bmain->versionfile == 247 && bmain->subversionfile <= 2)) {
bTheme *btheme;
/* adjust themes */
@@ -1278,7 +1292,7 @@ void init_userdef_do_versions(void)
SETCOL(btheme->tseq.vertex_select, col[0], col[1], col[2], 255);
}
}
- if (G.main->versionfile < 250) {
+ if (bmain->versionfile < 250) {
bTheme *btheme;
for(btheme= U.themes.first; btheme; btheme= btheme->next) {
@@ -1319,7 +1333,7 @@ void init_userdef_do_versions(void)
U.ipo_new= BEZT_IPO_BEZ;
}
- if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 1)) {
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) {
bTheme *btheme;
for(btheme= U.themes.first; btheme; btheme= btheme->next) {
@@ -1342,7 +1356,7 @@ void init_userdef_do_versions(void)
}
}
- if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 3)) {
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 3)) {
/* new audio system */
if(U.audiochannels == 0)
U.audiochannels = 2;
@@ -1360,10 +1374,10 @@ void init_userdef_do_versions(void)
U.audiorate = 44100;
}
- if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 5))
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 5))
U.gameflags |= USER_DISABLE_VBO;
- if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 8)) {
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) {
wmKeyMap *km;
for(km=U.keymaps.first; km; km=km->next) {
@@ -1403,16 +1417,16 @@ void init_userdef_do_versions(void)
strcpy(km->idname, "Property Editor");
}
}
- if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 16)) {
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 16)) {
if(U.wmdrawmethod == USER_DRAW_TRIPLE)
U.wmdrawmethod = USER_DRAW_AUTOMATIC;
}
- if (G.main->versionfile < 252 || (G.main->versionfile == 252 && G.main->subversionfile < 3)) {
+ if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 3)) {
if (U.flag & USER_LMOUSESELECT)
U.flag &= ~USER_TWOBUTTONMOUSE;
}
- if (G.main->versionfile < 252 || (G.main->versionfile == 252 && G.main->subversionfile < 4)) {
+ if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 4)) {
bTheme *btheme;
/* default new handle type is auto handles */
@@ -1440,9 +1454,42 @@ void init_userdef_do_versions(void)
SETCOL(btheme->tipo.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
SETCOL(btheme->tipo.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
SETCOL(btheme->tipo.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
+
+ /* edge crease */
+ SETCOLF(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0);
}
}
+ if (bmain->versionfile <= 252) {
+ bTheme *btheme;
+ /* init new curve colors */
+ for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+ if (btheme->tv3d.lastsel_point[3] == 0)
+ SETCOL(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255);
+ }
+ }
+ if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
+ bTheme *btheme;
+
+ /* interface_widgets.c */
+ struct uiWidgetColors wcol_progress= {
+ {0, 0, 0, 255},
+ {190, 190, 190, 255},
+ {100, 100, 100, 180},
+ {68, 68, 68, 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;
+ }
+ }
/* GL Texture Garbage Collection (variable abused above!) */
if (U.textimeout == 0) {
@@ -1475,6 +1522,3 @@ void init_userdef_do_versions(void)
// XXX reset_autosave();
}
-
-
-
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index d41317f7078..14ec7c6d0d6 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -44,7 +44,6 @@
#include "WM_api.h"
#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "BLF_api.h"
@@ -1314,6 +1313,13 @@ void UI_view2d_constant_grid_draw(const bContext *C, View2D *v2d)
glEnd();
}
+/* the price we pay for not exposting structs :( */
+void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy)
+{
+ *r_dx= grid->dx;
+ *r_dy= grid->dy;
+}
+
/* free temporary memory used for drawing grid */
void UI_view2d_grid_free(View2DGrid *grid)
{
@@ -1389,6 +1395,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
/* scroller 'button' extents */
totsize= v2d->tot.xmax - v2d->tot.xmin;
scrollsize= (float)(hor.xmax - hor.xmin);
+ if(totsize==0.0f) totsize = 1.0f; /* avoid divide by zero */
fac1= (v2d->cur.xmin - v2d->tot.xmin) / totsize;
if(fac1<=0.0f)
@@ -1429,6 +1436,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
/* scroller 'button' extents */
totsize= v2d->tot.ymax - v2d->tot.ymin;
scrollsize= (float)(vert.ymax - vert.ymin);
+ if(totsize==0.0f) totsize = 1.0f; /* avoid divide by zero */
fac1= (v2d->cur.ymin- v2d->tot.ymin) / totsize;
if(fac1<=0.0f)
@@ -1702,8 +1710,9 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
/* draw vertical steps */
if (dfac > 0.0f) {
- BLF_default_rotation(90.0f);
-
+ BLF_rotation_default(90.0f);
+ BLF_enable_default(BLF_ROTATION);
+
for (; fac < vert.ymax-10; fac+= dfac, val += grid->dy) {
/* make prints look nicer for scrollers */
@@ -1713,7 +1722,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
scroll_printstr(vs, scene, (float)(vert.xmax)-2.0f, fac, val, grid->powery, vs->yunits, 'v');
}
- BLF_default_rotation(0.0f);
+ BLF_disable_default(BLF_ROTATION);
}
}
}
@@ -2053,12 +2062,10 @@ void UI_view2d_text_cache_draw(ARegion *ar)
yofs= ceil( 0.5f*(v2s->rect.ymax - v2s->rect.ymin - BLF_height_default("28")));
if(yofs<1) yofs= 1;
- BLF_clipping(v2s->rect.xmin-4, v2s->rect.ymin-4, v2s->rect.xmax+4, v2s->rect.ymax+4);
- BLF_enable(BLF_CLIPPING);
-
+ BLF_clipping_default(v2s->rect.xmin-4, v2s->rect.ymin-4, v2s->rect.xmax+4, v2s->rect.ymax+4);
+ BLF_enable_default(BLF_CLIPPING);
BLF_draw_default(v2s->rect.xmin+xofs, v2s->rect.ymin+yofs, 0.0f, v2s->str);
-
- BLF_disable(BLF_CLIPPING);
+ BLF_disable_default(BLF_CLIPPING);
}
}
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 8e760a7501c..de1b26e987b 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -34,7 +34,6 @@
#include "BLI_blenlib.h"
#include "BKE_context.h"
-#include "BKE_utildefines.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -42,7 +41,6 @@
#include "WM_api.h"
#include "WM_types.h"
-#include "BIF_gl.h"
#include "ED_screen.h"
@@ -151,7 +149,8 @@ static void view_pan_apply(bContext *C, wmOperator *op)
WM_event_add_mousemove(C);
/* exceptions */
- if(vpd->sa->spacetype==SPACE_OUTLINER) {
+ if (vpd->sa->spacetype==SPACE_OUTLINER) {
+ /* don't rebuild full tree, since we're just changing our view */
SpaceOops *soops= vpd->sa->spacedata.first;
soops->storeflag |= SO_TREESTORE_REDRAW;
}
@@ -292,7 +291,7 @@ void VIEW2D_OT_pan(wmOperatorType *ot)
ot->modal= view_pan_modal;
ot->cancel= view_pan_cancel;
- /* operator is repeatable */
+ /* operator is modal */
ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
/* rna - must keep these in sync with the other operators */
@@ -339,9 +338,6 @@ void VIEW2D_OT_scroll_right(wmOperatorType *ot)
/* api callbacks */
ot->exec= view_scrollright_exec;
- /* operator is repeatable */
- // ot->flag= OPTYPE_REGISTER;
-
/* 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);
@@ -386,9 +382,6 @@ void VIEW2D_OT_scroll_left(wmOperatorType *ot)
/* api callbacks */
ot->exec= view_scrollleft_exec;
- /* operator is repeatable */
- // ot->flag= OPTYPE_REGISTER;
-
/* 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);
@@ -432,9 +425,6 @@ void VIEW2D_OT_scroll_down(wmOperatorType *ot)
/* api callbacks */
ot->exec= view_scrolldown_exec;
- /* operator is repeatable */
- // ot->flag= OPTYPE_REGISTER;
-
/* 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);
@@ -479,9 +469,6 @@ void VIEW2D_OT_scroll_up(wmOperatorType *ot)
/* api callbacks */
ot->exec= view_scrollup_exec;
- /* operator is repeatable */
- // ot->flag= OPTYPE_REGISTER;
-
/* 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);
@@ -569,11 +556,12 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
float dx, dy, facx, facy;
/* 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
+ */
facx= RNA_float_get(op->ptr, "zoomfacx");
facy= RNA_float_get(op->ptr, "zoomfacy");
- if(facx >= 0.0f) {
+ if (facx >= 0.0f) {
dx= (v2d->cur.xmax - v2d->cur.xmin) * facx;
dy= (v2d->cur.ymax - v2d->cur.ymin) * facy;
}
@@ -588,16 +576,17 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
v2d->cur.xmax -= 2*dx;
}
else if (v2d->keepofs & V2D_KEEPOFS_X) {
- if(v2d->align & V2D_ALIGN_NO_POS_X)
+ if (v2d->align & V2D_ALIGN_NO_POS_X)
v2d->cur.xmin += 2*dx;
else
v2d->cur.xmax -= 2*dx;
}
else {
- if(U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
+ if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / (v2d->cur.xmax-v2d->cur.xmin);
float mval_faci = 1.0 - mval_fac;
float ofs= (mval_fac * dx) - (mval_faci * dx);
+
v2d->cur.xmin += ofs + dx;
v2d->cur.xmax += ofs - dx;
}
@@ -612,19 +601,21 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
v2d->cur.ymax -= 2*dy;
}
else if (v2d->keepofs & V2D_KEEPOFS_Y) {
- if(v2d->align & V2D_ALIGN_NO_POS_Y)
+ if (v2d->align & V2D_ALIGN_NO_POS_Y)
v2d->cur.ymin += 2*dy;
else
v2d->cur.ymax -= 2*dy;
}
else {
- if(U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
+ if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
float mval_fac = (vzd->my_2d - v2d->cur.ymin) / (v2d->cur.ymax-v2d->cur.ymin);
float mval_faci = 1.0 - mval_fac;
float ofs= (mval_fac * dy) - (mval_faci * dy);
+
v2d->cur.ymin += ofs + dy;
v2d->cur.ymax += ofs - dy;
- } else {
+ }
+ else {
v2d->cur.ymin += dy;
v2d->cur.ymax -= dy;
}
@@ -679,9 +670,13 @@ static int view_zoomin_invoke(bContext *C, wmOperator *op, wmEvent *event)
vzd= op->customdata;
- if(U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
+ if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
ARegion *ar= CTX_wm_region(C);
- UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin, &vzd->mx_2d, &vzd->my_2d);
+
+ /* store initial mouse position (in view space) */
+ UI_view2d_region_to_view(&ar->v2d,
+ event->x - ar->winrct.xmin, event->y - ar->winrct.ymin,
+ &vzd->mx_2d, &vzd->my_2d);
}
return view_zoomin_exec(C, op);
@@ -699,9 +694,6 @@ void VIEW2D_OT_zoom_in(wmOperatorType *ot)
ot->exec= view_zoomin_exec;
ot->poll= view_zoom_poll;
- /* operator is repeatable */
- // ot->flag= OPTYPE_REGISTER;
-
/* rna - must keep these in sync with the other operators */
RNA_def_float(ot->srna, "zoomfacx", 0, -FLT_MAX, FLT_MAX, "Zoom Factor X", "", -FLT_MAX, FLT_MAX);
RNA_def_float(ot->srna, "zoomfacy", 0, -FLT_MAX, FLT_MAX, "Zoom Factor Y", "", -FLT_MAX, FLT_MAX);
@@ -737,7 +729,11 @@ static int view_zoomout_invoke(bContext *C, wmOperator *op, wmEvent *event)
if(U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
ARegion *ar= CTX_wm_region(C);
- UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin, &vzd->mx_2d, &vzd->my_2d);
+
+ /* store initial mouse position (in view space) */
+ UI_view2d_region_to_view(&ar->v2d,
+ event->x - ar->winrct.xmin, event->y - ar->winrct.ymin,
+ &vzd->mx_2d, &vzd->my_2d);
}
return view_zoomout_exec(C, op);
@@ -755,9 +751,6 @@ void VIEW2D_OT_zoom_out(wmOperatorType *ot)
ot->exec= view_zoomout_exec;
ot->poll= view_zoom_poll;
- /* operator is repeatable */
- // ot->flag= OPTYPE_REGISTER;
-
/* rna - must keep these in sync with the other operators */
RNA_def_float(ot->srna, "zoomfacx", 0, -FLT_MAX, FLT_MAX, "Zoom Factor X", "", -FLT_MAX, FLT_MAX);
RNA_def_float(ot->srna, "zoomfacy", 0, -FLT_MAX, FLT_MAX, "Zoom Factor Y", "", -FLT_MAX, FLT_MAX);
@@ -789,10 +782,11 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
v2d->cur.xmax -= 2*dx;
}
else {
- if(U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
+ if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / (v2d->cur.xmax-v2d->cur.xmin);
float mval_faci = 1.0 - mval_fac;
float ofs= (mval_fac * dx) - (mval_faci * dx);
+
v2d->cur.xmin += ofs + dx;
v2d->cur.xmax += ofs - dx;
}
@@ -807,10 +801,11 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
v2d->cur.ymax -= 2*dy;
}
else {
- if(U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
+ if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
float mval_fac = (vzd->my_2d - v2d->cur.ymin) / (v2d->cur.ymax-v2d->cur.ymin);
float mval_faci = 1.0 - mval_fac;
float ofs= (mval_fac * dy) - (mval_faci * dy);
+
v2d->cur.ymin += ofs + dy;
v2d->cur.ymax += ofs - dy;
}
@@ -871,7 +866,8 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event)
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->x - event->prevx);
dx= fac * (v2d->cur.xmax - v2d->cur.xmin) / 10.0f;
dy= fac * (v2d->cur.ymax - v2d->cur.ymin) / 10.0f;
@@ -890,9 +886,13 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event)
RNA_float_set(op->ptr, "deltax", 0);
RNA_float_set(op->ptr, "deltay", 0);
- if(U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
+ if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
ARegion *ar= CTX_wm_region(C);
- UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin, &vzd->mx_2d, &vzd->my_2d);
+
+ /* store initial mouse position (in view space) */
+ UI_view2d_region_to_view(&ar->v2d,
+ event->x - ar->winrct.xmin, event->y - ar->winrct.ymin,
+ &vzd->mx_2d, &vzd->my_2d);
}
if (v2d->keepofs & V2D_LOCKOFS_X)
@@ -1014,7 +1014,7 @@ void VIEW2D_OT_zoom(wmOperatorType *ot)
ot->poll= view_zoom_poll;
/* operator is repeatable */
- // ot->flag= OPTYPE_REGISTER|OPTYPE_BLOCKING;
+ // ot->flag= OPTYPE_BLOCKING;
/* rna - must keep these in sync with the other operators */
RNA_def_float(ot->srna, "deltax", 0, -FLT_MAX, FLT_MAX, "Delta X", "", -FLT_MAX, FLT_MAX);
@@ -1145,6 +1145,8 @@ typedef struct v2dScrollerMove {
float fac; /* view adjustment factor, based on size of region */
float delta; /* amount moved by mouse on axis of interest */
+ float scrollbarwidth; /* width of the scrollbar itself, used for page up/down clicks */
+
int lastx, lasty; /* previous mouse coordinates (in screen coordinates) for determining movement */
} v2dScrollerMove;
@@ -1164,19 +1166,21 @@ struct View2DScrollers {
enum {
SCROLLHANDLE_MIN= -1,
SCROLLHANDLE_BAR,
- SCROLLHANDLE_MAX
+ SCROLLHANDLE_MAX,
+ SCROLLHANDLE_MIN_OUTSIDE,
+ SCROLLHANDLE_MAX_OUTSIDE
} eV2DScrollerHandle_Zone;
/* ------------------------ */
/* check if mouse is within scroller handle
* - mouse = relevant mouse coordinate in region space
- * - sc_min, sc_max = extents of scroller
- * - sh_min, sh_max = positions of scroller handles
+ * - sc_min, sc_max = extents of scroller 'groove' (potential available space for scroller)
+ * - sh_min, sh_max = positions of scrollbar handles
*/
static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_min, int sh_max)
{
- short in_min, in_max, in_view=1;
+ short in_min, in_max, in_bar, out_min, out_max, in_view=1;
/* firstly, check if
* - 'bubble' fills entire scroller
@@ -1198,17 +1202,24 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_
}
/* 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)) );
in_min= ( (mouse <= (sh_min + V2D_SCROLLER_HANDLE_SIZE)) && (mouse >= (sh_min - V2D_SCROLLER_HANDLE_SIZE)) );
+ 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);
- /* check if overlap --> which means user clicked on bar, as bar is within handles region */
- if (in_max && in_min)
+ if (in_bar)
return SCROLLHANDLE_BAR;
else if (in_max)
return SCROLLHANDLE_MAX;
else if (in_min)
return SCROLLHANDLE_MIN;
-
+ else if (out_min)
+ 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;
}
@@ -1248,14 +1259,14 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
vsm->fac= (v2d->tot.xmax - v2d->tot.xmin) / mask_size;
/* get 'zone' (i.e. which part of scroller is activated) */
- if (v2d->keepzoom & V2D_LOCKZOOM_X) {
+ vsm->zone= mouse_in_scroller_handle(x, 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;
}
- else {
- /* check which handle we're in */
- vsm->zone= mouse_in_scroller_handle(x, v2d->hor.xmin, v2d->hor.xmax, scrollers->hor_min, scrollers->hor_max);
- }
+
+ vsm->scrollbarwidth = scrollers->hor_max - scrollers->hor_min;
}
else {
/* vertical scroller - calculate adjustment factor first */
@@ -1263,14 +1274,14 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
vsm->fac= (v2d->tot.ymax - v2d->tot.ymin) / mask_size;
/* get 'zone' (i.e. which part of scroller is activated) */
- if (v2d->keepzoom & V2D_LOCKZOOM_Y) {
+ vsm->zone= mouse_in_scroller_handle(y, 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;
}
- else {
- /* check which handle we're in */
- vsm->zone= mouse_in_scroller_handle(y, v2d->vert.ymin, v2d->vert.ymax, scrollers->vert_min, scrollers->vert_max);
- }
+
+ vsm->scrollbarwidth = scrollers->vert_max - scrollers->vert_min;
}
UI_view2d_scrollers_free(scrollers);
@@ -1320,8 +1331,11 @@ static void scroller_activate_apply(bContext *C, wmOperator *op)
if ((vsm->scroller == 'v') && !(v2d->keepzoom & V2D_LOCKZOOM_Y))
v2d->cur.ymax += temp;
break;
-
- default: /* SCROLLHANDLE_BAR */
+
+ case SCROLLHANDLE_MIN_OUTSIDE:
+ case SCROLLHANDLE_MAX_OUTSIDE:
+ case SCROLLHANDLE_BAR:
+ default:
/* only move view on an axis if panning is allowed */
if ((vsm->scroller == 'h') && !(v2d->keepofs & V2D_LOCKOFS_X)) {
v2d->cur.xmin += temp;
@@ -1332,6 +1346,7 @@ static void scroller_activate_apply(bContext *C, wmOperator *op)
v2d->cur.ymax += temp;
}
break;
+
}
/* validate that view is in valid configuration after this operation */
@@ -1353,7 +1368,7 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, wmEvent *event)
case MOUSEMOVE:
{
/* calculate new delta transform, then store mouse-coordinates for next-time */
- if (vsm->zone != SCROLLHANDLE_MIN) {
+ if (ELEM(vsm->zone, SCROLLHANDLE_BAR, SCROLLHANDLE_MAX)) {
/* if using bar (i.e. 'panning') or 'max' zoom widget */
switch (vsm->scroller) {
case 'h': /* horizontal scroller - so only horizontal movement ('cur' moves opposite to mouse) */
@@ -1364,7 +1379,7 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, wmEvent *event)
break;
}
}
- else {
+ else if (vsm->zone == SCROLLHANDLE_MIN) {
/* using 'min' zoom widget */
switch (vsm->scroller) {
case 'h': /* horizontal scroller - so only horizontal movement ('cur' moves with mouse) */
@@ -1386,8 +1401,23 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, wmEvent *event)
case LEFTMOUSE:
if (event->val==KM_RELEASE) {
- scroller_activate_exit(C, op);
- return OPERATOR_FINISHED;
+ /* single-click was in empty space outside bubble, so scroll by 1 'page' */
+ if (ELEM(vsm->zone, SCROLLHANDLE_MIN_OUTSIDE, SCROLLHANDLE_MAX_OUTSIDE)) {
+ if (vsm->zone == SCROLLHANDLE_MIN_OUTSIDE)
+ vsm->delta = -vsm->scrollbarwidth * 0.8;
+ else if (vsm->zone == SCROLLHANDLE_MAX_OUTSIDE)
+ vsm->delta = vsm->scrollbarwidth * 0.8;
+
+ 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);
+ return OPERATOR_FINISHED;
+ }
}
break;
}
@@ -1502,7 +1532,7 @@ static int reset_exec(bContext *C, wmOperator *op)
v2d->cur.ymax= v2d->cur.ymin + winy;
/* align */
- if(v2d->align) {
+ if (v2d->align) {
/* 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)) {
v2d->cur.xmax= 0.0f;
@@ -1545,9 +1575,6 @@ void VIEW2D_OT_reset(wmOperatorType *ot)
/* api callbacks */
ot->exec= reset_exec;
ot->poll= view2d_poll;
-
- /* flags */
- // ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
/* ********************************************************* */