1
1

Compare commits

...

37 Commits

Author SHA1 Message Date
Julian Eisel
0775680e4d Merge branch 'master' into UI-graphical-redesign
Conflicts:
	source/blender/blenkernel/BKE_blender.h
	source/blender/blenloader/intern/versioning_270.c
	source/blender/editors/interface/interface.c
	source/blender/editors/interface/interface_handlers.c
	source/blender/editors/interface/interface_intern.h
	source/blender/editors/interface/resources.c
2015-10-21 17:30:35 +02:00
Julian Eisel
4ade467fc6 Merge branch 'master' into UI-graphical-redesign
Conflicts:
	source/blender/blenkernel/BKE_blender.h
	source/blender/blenloader/intern/versioning_270.c
	source/blender/editors/interface/resources.c
	source/blender/makesdna/DNA_userdef_types.h
2015-08-01 21:06:58 +02:00
Julian Eisel
7759782ee7 Merge branch 'master' into UI-graphical-redesign
Conflicts:
	source/blender/blenkernel/BKE_blender.h
	source/blender/editors/interface/resources.c
2015-06-23 06:33:50 +02:00
Julian Eisel
ab9eee4bfb Merge branch 'master' into UI-graphical-redesign 2015-06-10 15:27:58 +02:00
Julian Eisel
e0b92ca72b Minor theme change 2015-06-10 01:38:44 +02:00
Julian Eisel
131caabfdb Add an "Interface Style" theme option for flat vs. classic drawing
Adds an "Interface Style" menu containing the items "Flat" (default) and
"Classic". The classic option basically brings back widget outlines,
emboss, shading and old checkbox design.

Open design question:
Currently widget outlines, emboss and shading is hardcoded disabled for
the "Flat" option. Meaning that tweaks to their theme options don't have
any effect. I think it should be fine to just disable the theme buttons
for this, but I'm all ears for better approaches.

Requested by @campbellbarton and @ton
2015-06-09 23:54:33 +02:00
Julian Eisel
a638db50ca Draw widget boxes antialiased 2015-06-09 01:47:20 +02:00
Julian Eisel
60ec6a5419 Better drawing for checkboxes (perfectly round + anti-aliasing) 2015-06-09 00:31:28 +02:00
Julian Eisel
a05cbcfa7c Merge branch 'master' into UI-graphical-redesign 2015-06-08 23:40:18 +02:00
Julian Eisel
c5d4607792 Add widget rollover feedback by implementing a Sub-Button pipeline
As pretty much agreed on in T38070, this implements widget-rollover for
better visual feedback.
The added Sub-Button pipeline should provide us a solid base for future
ideas like using Sub-Buttons to trigger operators (thinking of 'X'-icons
within tabs or menus e.g.), open popups/menus, provide better cursor
feedback, etc. They are basically independent buttons within buttons.

https://developer.blender.org/F187781
2015-06-08 23:39:19 +02:00
Julian Eisel
97c12109ec Merge branch 'master' into UI-graphical-redesign 2015-06-06 15:37:52 +02:00
Julian Eisel
fa7188c7da Fix Clip Editor not using correct scrollbars in Graph/Dopesheet view 2015-06-06 12:19:14 +02:00
Julian Eisel
980820124a Merge branch 'master' into UI-graphical-redesign 2015-06-05 22:55:12 +02:00
Julian Eisel
f3f65f38b7 A first Menu/Popup redesign
Based on this mockup by @venomgfx: http://wiki.blender.org/index.php/
User:Venomgfx/User_Interface#Menu_Item_.26_Menu_Back

Main changes:
* Draw background for menu title in a different color (currently
hardcoded darker) instead of using a separation line
* Align submenu triangle icons vertically and add some extra space for
them so that they are not squashed in to the line (means shortcut text
is now always vertically aligned as well)
* More modern submenu triangle icon drawing
* Draw separation lines a bit more visible
* Don't add extra icon padding if the menu doesn't contain any icons
(text in menus often used to have some padding on the left so that the
text is nicely aligned even when some entries had icons in front of it.
This is all fine but wasn't needed/looked weird if there isn't any menu
entry with an icon at all - e.g. 3D View "Select" menu, most of the RMB-
menus)
* Cleanup

Screenshots:
* https://developer.blender.org/F185706
* https://developer.blender.org/F185707
* https://developer.blender.org/F185708
2015-06-05 22:54:18 +02:00
Julian Eisel
868b1e3032 Use left aligned text for icon buttons 2015-06-04 18:37:27 +02:00
Julian Eisel
700c8c691c Merge branch 'master' into UI-graphical-redesign 2015-06-04 17:22:24 +02:00
Julian Eisel
c6801d7cdd Use thinner scrollbars for UILists as well
Todo: With the current default theme scrollbars are hard to see, we
could do better but that's for later.
2015-06-03 17:00:28 +02:00
Julian Eisel
2524b2b5b9 Adjust some theme colors
And the usual minor cleanup
2015-06-03 16:43:32 +02:00
Julian Eisel
271b53fa57 Cleanup: Use existing methods to init new/changed theme options
Think this is the way we should actually do this.
2015-06-03 15:01:36 +02:00
Julian Eisel
029bc907dd Fix panels being highlighted while dragging another panel over them 2015-06-03 12:54:09 +02:00
Julian Eisel
96e7a92a23 Redesign area/region edges
Mainly removed unnecessarily drawn edges and doubled line thickness for
area edges to clearly separate areas from regions.

For now I've added a theme option to control the color of the area
edges, we can check later if it's worth keeping it, but IMHO it's quite
important to have this controllable.
2015-06-03 12:32:38 +02:00
Julian Eisel
fa85fd2b6a Don't draw widget outlines (for most widgets)
As proposed in T38037 this removes the outlines from widgets (except of
toggle buttons like layers and color buttons for now) to simplify/
flatten the look of the UI.

This needs some more polish and we could even remove the outline drawing
code completely instead of just disabling it, but I first want to get
overall design approval.
2015-06-02 22:46:52 +02:00
Julian Eisel
cddab657e8 Increase default DPI to 78, decrease default font sizes to 10
NOTE: These changes might be controversial, but it's a good chance to
test this.

Also further changes to default font drawing plus a bit of cleanup.
2015-06-02 20:04:36 +02:00
Julian Eisel
9de6520251 Flatify the UI!
By disabling shaded drawing for all widgets
2015-06-02 19:26:38 +02:00
Julian Eisel
f4b3975d65 Make scrollbars thinner! (And draw them without outline)
Scrollbars with units printed on them stay the same size.
2015-06-02 19:02:24 +02:00
Julian Eisel
bd11884d16 Merge branch 'master' into UI-graphical-redesign 2015-06-02 17:50:04 +02:00
Julian Eisel
a05c604880 Redesign panel headers + minor tweaks + minor cleanup
Currently looking like this: https://developer.blender.org/F183457

Design was worked out together with @plyczkowski
2015-06-02 17:49:00 +02:00
Julian Eisel
2e917e67d4 Panel mouse hover feedback
* Highlight hovered panel
* Only draw drag widget on hover
2015-05-31 17:19:09 +02:00
Julian Eisel
667718bc7f Some cleanup to make code a bit easier to read ;) 2015-05-31 16:31:49 +02:00
Julian Eisel
04f11fb12e Adjust new panel design to work fine with recent panel drawing fix 2015-05-31 15:27:25 +02:00
Julian Eisel
2487ee35a8 Merge branch 'master' into UI-graphical-redesign 2015-05-31 14:37:10 +02:00
Julian Eisel
6272babfba Remove panel emboss
Don't like it after using it a bit :S
2015-05-30 21:01:46 +02:00
Julian Eisel
0dd2ed3c6c Merge branch 'master' into UI-graphical-redesign
Conflicts:
	source/blender/editors/interface/interface_widgets.c
2015-05-30 20:40:30 +02:00
Julian Eisel
b3587b8aa2 A first panel redesign
Looking like this now: https://developer.blender.org/F182118

Based on this mockup by @venomgfx: https://dev-files.blender.org/file/
data/sgkm33r4yxspq3gzy2dl/PHID-FILE-xzedfbwhq5tdx4w7jgcw/
blender_ui_drag_widget_gone_padding.png
2015-05-30 20:30:42 +02:00
Julian Eisel
d031455395 Theme option to change widget corner roundness (per widget type)
Original patch by @venomgfx, updated and made a few minor changes.
2015-05-29 21:10:53 +02:00
Julian Eisel
ebfe499e10 Merge branch 'master' into UI-graphical-redesign 2015-05-29 15:04:28 +02:00
Julian Eisel
0fdac7ca7b Make checkbox widgets rounded 2015-05-29 14:56:44 +02:00
33 changed files with 1316 additions and 466 deletions

View File

@@ -626,6 +626,8 @@ class USERPREF_PT_theme(Panel):
subsub.active = widget_style.show_shaded
subsub.prop(widget_style, "shadetop")
subsub.prop(widget_style, "shadedown")
subsub = colsub.column(align=True)
subsub.prop(widget_style, "roundness")
layout.separator()
@@ -686,6 +688,14 @@ class USERPREF_PT_theme(Panel):
col = split.column()
ui = theme.user_interface
row = col.row()
subsplit = row.split(percentage=0.47)
subsplit.prop(ui, "interface_style")
col.separator()
col.separator()
col.separator()
col.label(text="Regular:")
self._theme_widget_style(col, ui.wcol_regular)
@@ -800,6 +810,7 @@ class USERPREF_PT_theme(Panel):
colsub = padding.column()
colsub = padding.column()
colsub.row().prop(ui, "widget_emboss")
colsub.row().prop(ui, "area_edges")
col.separator()
col.separator()

View File

@@ -1345,7 +1345,8 @@ class VIEW3D_MT_object_specials(Menu):
props.input_scale = 0.05
props.header_text = "Clip End: %.2f"
layout.separator()
if obj.type in {'CAMERA', 'CURVE', 'FONT', 'EMPTY', 'LAMP'}:
layout.separator()
props = layout.operator("object.isolate_type_render")
props = layout.operator("object.hide_render_clear_all")

View File

@@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 276
#define BLENDER_SUBVERSION 1
#define BLENDER_SUBVERSION 2
/* Several breakages with 270, e.g. constraint deg vs rad */
#define BLENDER_MINVERSION 270
#define BLENDER_MINSUBVERSION 5

View File

@@ -868,4 +868,47 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
}
{
bScreen *screen;
for (screen = main->screen.first; screen; screen = screen->id.next) {
ScrArea *sa;
for (sa = screen->areabase.first; sa; sa = sa->next) {
const char needed_type = (sa->spacetype == SPACE_CLIP) ? RGN_TYPE_PREVIEW : RGN_TYPE_WINDOW;
ARegion *ar = BKE_area_find_region_type(sa, needed_type);
SpaceLink *sl;
if (ar == NULL)
continue;
for (sl = sa->spacedata.first; sl; sl = sl->next) {
switch (sl->spacetype) {
case SPACE_TIME:
case SPACE_ACTION:
case SPACE_NLA:
ar->v2d.flag |= V2D_USES_UNITS_HORIZONTAL;
break;
case SPACE_IPO:
case SPACE_SEQ:
ar->v2d.flag |= (V2D_USES_UNITS_HORIZONTAL | V2D_USES_UNITS_VERTICAL);
break;
case SPACE_CLIP:
{
SpaceClip *sc = (SpaceClip *)sl;
if (sc->view == SC_VIEW_DOPESHEET) {
ar->v2d.flag |= V2D_USES_UNITS_HORIZONTAL;
}
else if (sc->view == SC_VIEW_GRAPH) {
ar->v2d.flag |= (V2D_USES_UNITS_HORIZONTAL | V2D_USES_UNITS_VERTICAL);
}
break;
}
default:
break;
}
}
}
}
}
}

View File

@@ -52,6 +52,8 @@
*/
void BLO_update_defaults_userpref_blend(void)
{
uiStyle *style;
/* defaults from T37518 */
U.uiflag |= USER_ZBUF_CURSOR;
@@ -60,6 +62,13 @@ void BLO_update_defaults_userpref_blend(void)
U.versions = 1;
U.savetime = 2;
U.dpi = 78;
for (style = U.uistyles.first; style; style = style->next) {
style->paneltitle.points = style->widgetlabel.points = style->widget.points = 10;
style->paneltitle.shadow = style->widgetlabel.shadow = 0;
}
}
/**

View File

@@ -164,7 +164,9 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U
*/
if (strstr(op->idname, "assign")) {
uiItemIntO(layout, "New Group", ICON_NONE, op->idname, "type", 0);
uiItemS(layout);
if (!BLI_listbase_is_empty(&pose->agroups)) {
uiItemS(layout);
}
}
/* add entries for each group */

View File

@@ -133,8 +133,9 @@ enum {
/* block->flag bits 14-17 are identical to but->drawflag bits */
#define UI_BLOCK_LIST_ITEM (1 << 19)
#define UI_BLOCK_RADIAL (1 << 20)
#define UI_BLOCK_LIST_ITEM (1 << 19)
#define UI_BLOCK_RADIAL (1 << 20)
#define UI_BLOCK_HAS_SUBMENU (1 << 21) /* the block has at least one button leading to a submenu */
/* uiPopupBlockHandle->menuretval */
#define UI_RETURN_CANCEL (1 << 0) /* cancel all menus cascading */
@@ -179,11 +180,13 @@ enum {
UI_BUT_TIP_FORCE = (1 << 28), /* force show tooltips when holding option/alt if U's USER_TOOLTIPS is off */
UI_BUT_TEXTEDIT_UPDATE = (1 << 29), /* when widget is in textedit mode, update value on each char stroke */
UI_BUT_SEARCH_UNLINK = (1 << 30), /* show unlink for search button */
UI_BUT_MENU_TITLE = (1 << 31), /* title of a menu - XXX maybe new BTYPE? */
};
#define UI_PANEL_WIDTH 340
#define UI_COMPACT_PANEL_WIDTH 160
#define UI_PANEL_MARGIN (U.widget_unit * 0.25f)
#define UI_PANEL_CATEGORY_MARGIN_WIDTH (U.widget_unit * 1.0f)
/* but->drawflag - these flags should only affect how the button is drawn. */
@@ -632,6 +635,7 @@ int UI_icon_from_report_type(int type);
uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip);
uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip);
uiBut *uiDefMenuTitleBut(uiBlock *block, const char *str);
uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip);
uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, int x, int y, short width, short height, const char *tip);

View File

@@ -55,6 +55,9 @@ enum {
TH_REDALERT,
TH_THEMEUI,
TH_AREA_EDGES,
// common colors among spaces
TH_BACK,

View File

@@ -103,8 +103,10 @@ enum eView2D_Gridlines {
/* ------ Defines for Scrollers ----- */
/* scroller area */
#define V2D_SCROLL_HEIGHT (0.85f * U.widget_unit)
#define V2D_SCROLL_WIDTH (0.85f * U.widget_unit)
#define V2D_SCROLL_HEIGHT (0.50f * U.widget_unit)
#define V2D_SCROLL_WIDTH (0.50f * U.widget_unit)
#define V2D_SCROLL_HEIGHT_TEXT (0.85f * U.widget_unit)
#define V2D_SCROLL_WIDTH_TEXT (0.85f * U.widget_unit)
/* scroller 'handles' hotspot radius for mouse */
#define V2D_SCROLLER_HANDLE_SIZE (0.6f * U.widget_unit)

View File

@@ -161,6 +161,13 @@ void ui_block_to_window_rctf(const ARegion *ar, uiBlock *block, rctf *rct_dst, c
ui_block_to_window_fl(ar, block, &rct_dst->xmax, &rct_dst->ymax);
}
void ui_block_to_window_rcti(const ARegion *ar, uiBlock *block, rcti *rct_dst, const rcti *rct_src)
{
*rct_dst = *rct_src;
ui_block_to_window(ar, block, &rct_dst->xmin, &rct_dst->ymin);
ui_block_to_window(ar, block, &rct_dst->xmax, &rct_dst->ymax);
}
void ui_window_to_block_fl(const ARegion *ar, uiBlock *block, float *x, float *y) /* for mouse cursor */
{
float a, b, c, d, e, f, px, py;
@@ -1327,6 +1334,43 @@ static void ui_but_to_pixelrect(rcti *rect, const ARegion *ar, uiBlock *block, u
BLI_rcti_translate(rect, -ar->winrct.xmin, -ar->winrct.ymin);
}
/* project a rcti to pixels in regionspace */
void ui_rcti_to_pixelrect(const ARegion *ar, uiBlock *block, rcti *rct_dst, const rcti *rct_src)
{
rcti rect;
ui_block_to_window_rcti(ar, block, &rect, rct_src);
rect.xmin -= ar->winrct.xmin;
rect.ymin -= ar->winrct.ymin;
rect.xmax -= ar->winrct.xmin;
rect.ymax -= ar->winrct.ymin;
rct_dst->xmin = iroundf(rect.xmin);
rct_dst->ymin = iroundf(rect.ymin);
rct_dst->xmax = iroundf(rect.xmax);
rct_dst->ymax = iroundf(rect.ymax);
}
/* project a rctf to pixels in regionspace */
void ui_rctf_to_pixelrect(const ARegion *ar, uiBlock *block, rctf *rct_dst, const rctf *rct_src)
{
rctf rect;
ui_block_to_window_rctf(ar, block, &rect, rct_src);
rect.xmin -= ar->winrct.xmin;
rect.ymin -= ar->winrct.ymin;
rect.xmax -= ar->winrct.xmin;
rect.ymax -= ar->winrct.ymin;
rct_dst->xmin = floorf(rect.xmin);
rct_dst->ymin = floorf(rect.ymin);
rct_dst->xmax = floorf(rect.xmax);
rct_dst->ymax = floorf(rect.ymax);
}
/* uses local copy of style, to scale things down, and allow widgets to change stuff */
void UI_block_draw(const bContext *C, uiBlock *block)
{
@@ -2564,6 +2608,10 @@ static void ui_but_free(const bContext *C, uiBut *but)
MEM_freeN(but->dragpoin);
}
if ((BLI_listbase_is_empty(&but->subbuts)) == false) {
BLI_freelistN(&but->subbuts);
}
BLI_assert(UI_butstore_is_registered(but->block, but) == false);
MEM_freeN(but);
@@ -3154,6 +3202,26 @@ void ui_block_cm_to_display_space_range(uiBlock *block, float *min, float *max)
*max = max_fff(UNPACK3(pixel));
}
static uiSubBut *ui_def_subbut(
uiBut *but, const int type,
uiSubButAlign alignment,
const int width, const int height)
{
uiSubBut *sbut = MEM_callocN(sizeof(uiSubBut), "uiSubBut");
sbut->type = type;
sbut->align = alignment;
sbut->width = width;
sbut->height = height;
/* sbut->rect is calculated later */
BLI_addtail(&but->subbuts, sbut);
return sbut;
}
/**
* \brief ui_def_but is the function that draws many button types
*
@@ -3268,6 +3336,13 @@ static uiBut *ui_def_but(
}
}
if (but->type == UI_BTYPE_NUM) {
const int sbut_width = MIN2(width / 3, height);
ui_def_subbut(but, UI_SBUT_TYPE_VAL_DECREASE, UI_SBUT_ALIGN_LEFT, sbut_width, height);
ui_def_subbut(but, UI_SBUT_TYPE_VAL_INCREASE, UI_SBUT_ALIGN_RIGHT, sbut_width, height);
}
/* keep track of UI_interface.h */
if (ELEM(but->type,
UI_BTYPE_BLOCK, UI_BTYPE_BUT, UI_BTYPE_LABEL,
@@ -4310,6 +4385,17 @@ uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char
return but;
}
uiBut *uiDefMenuTitleBut(uiBlock *block, const char *str)
{
uiBut *but = ui_def_but(block, UI_BTYPE_LABEL, 0, str, 0, 0, UI_MENU_TITLE_WIDTH, UI_MENU_TITLE_HEIGHT,
NULL, 0.0, 0.0, 0.0, 0.0, "");
but->flag |= UI_BUT_MENU_TITLE;
ui_but_update(but);
return but;
}
uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip)
{
uiBut *but = ui_def_but(block, UI_BTYPE_PULLDOWN, 0, str, x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip);

View File

@@ -384,6 +384,7 @@ static bool ui_but_contains_pt(uiBut *but, float mx, float my);
static bool ui_but_contains_point_px(ARegion *ar, uiBut *but, int x, int y);
static uiBut *ui_but_find_mouse_over_ex(ARegion *ar, const int x, const int y, const bool labeledit);
static uiBut *ui_but_find_mouse_over(ARegion *ar, const wmEvent *event);
static uiSubBut *ui_subbut_find_mouse_over(ARegion *ar, uiBut *but, const int mouse_xy[2]);
static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonActivateType type);
static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState state);
static void button_activate_exit(
@@ -4266,68 +4267,8 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
}
if (click) {
/* we can click on the side arrows to increment/decrement,
* or click inside to edit the value directly */
float tempf, softmin, softmax;
float handlewidth;
int temp;
softmin = but->softmin;
softmax = but->softmax;
handlewidth = min_ff(BLI_rctf_size_x(&but->rect) / 3, BLI_rctf_size_y(&but->rect));
if (!ui_but_is_float(but)) {
if (mx < (but->rect.xmin + handlewidth)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
temp = (int)data->value - 1;
if (temp >= softmin && temp <= softmax)
data->value = (double)temp;
else
data->cancel = true;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else if (mx > (but->rect.xmax - handlewidth)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
temp = (int)data->value + 1;
if (temp >= softmin && temp <= softmax)
data->value = (double)temp;
else
data->cancel = true;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
}
}
else {
if (mx < (but->rect.xmin + handlewidth)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
tempf = (float)data->value - (UI_PRECISION_FLOAT_SCALE * but->a1);
if (tempf < softmin) tempf = softmin;
data->value = tempf;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else if (mx > but->rect.xmax - handlewidth) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
tempf = (float)data->value + (UI_PRECISION_FLOAT_SCALE * but->a1);
if (tempf > softmax) tempf = softmax;
data->value = tempf;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
}
}
/* start textediting - clicking to increase/decrease numbers is handled via sub-buttons */
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
retval = WM_UI_HANDLER_BREAK;
}
@@ -4337,6 +4278,40 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
return retval;
}
static int ui_do_subbut_NUM(bContext *C, uiBut *but, const uiSubBut *sbut, const wmEvent *event)
{
uiHandleButtonData *data = but->active;
const float softmin = but->softmin;
const float softmax = but->softmax;
const bool is_float = ui_but_is_float(but);
const bool increase = (sbut->type == UI_SBUT_TYPE_VAL_INCREASE);
float tempf;
int temp;
if (event->type != LEFTMOUSE || event->val != KM_RELEASE || data->dragchange)
return WM_UI_HANDLER_CONTINUE;
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
if (is_float) {
tempf = (float)data->value + (increase ? 0.01f : -0.01f) * but->a1;
CLAMP(tempf, softmin, softmax);
data->value = tempf;
}
else {
temp = (int)data->value + (increase ? 1 : -1);
if (IN_RANGE_INCL(temp, softmin, softmax))
data->value = (double)temp;
else
data->cancel = true;
}
button_activate_state(C, but, BUTTON_STATE_EXIT);
/* always break */
return WM_UI_HANDLER_BREAK;
}
static bool ui_numedit_but_SLI(
uiBut *but, uiHandleButtonData *data,
int mx, const bool is_horizontal,
@@ -6502,6 +6477,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
uiPopupMenu *pup;
uiLayout *layout;
bool is_array, is_array_component;
bool is_first_item = true; /* will the next added item be the first menu entry? */
uiStringInfo label = {BUT_GET_LABEL, NULL};
/* if ((but->rnapoin.data && but->rnaprop) == 0 && but->optype == NULL)*/
@@ -6524,6 +6500,9 @@ static bool ui_but_menu(bContext *C, uiBut *but)
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
/* adds a separator if it wouldn't be the first item (after title) */
#define ADD_SEPARATOR_CONDITIONAL if (is_first_item == false) uiItemS(layout);
if (but->rnapoin.data && but->rnaprop) {
PointerRNA *ptr = &but->rnapoin;
PropertyRNA *prop = but->rnaprop;
@@ -6563,7 +6542,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
/* keyframe settings */
uiItemS(layout);
is_first_item = false;
}
else if (but->flag & UI_BUT_DRIVEN) {
/* pass */
@@ -6579,6 +6558,8 @@ static bool ui_but_menu(bContext *C, uiBut *but)
uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframe"),
ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 1);
}
is_first_item = false;
}
if ((but->flag & UI_BUT_ANIMATED) && (but->rnapoin.type != &RNA_NlaStrip)) {
@@ -6592,11 +6573,13 @@ static bool ui_but_menu(bContext *C, uiBut *but)
uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"),
ICON_NONE, "ANIM_OT_keyframe_clear_button", "all", 1);
}
is_first_item = false;
}
/* Drivers */
if (but->flag & UI_BUT_DRIVEN) {
uiItemS(layout);
ADD_SEPARATOR_CONDITIONAL
if (is_array_component) {
uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Drivers"),
@@ -6615,12 +6598,14 @@ static bool ui_but_menu(bContext *C, uiBut *but)
uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"),
ICON_NONE, "ANIM_OT_paste_driver_button");
}
is_first_item = false;
}
else if (but->flag & (UI_BUT_ANIMATED_KEY | UI_BUT_ANIMATED)) {
/* pass */
}
else if (is_anim) {
uiItemS(layout);
ADD_SEPARATOR_CONDITIONAL
if (is_array_component) {
uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Drivers"),
@@ -6637,12 +6622,14 @@ static bool ui_but_menu(bContext *C, uiBut *but)
uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"),
ICON_NONE, "ANIM_OT_paste_driver_button");
}
is_first_item = false;
}
/* Keying Sets */
/* TODO: check on modifyability of Keying Set when doing this */
if (is_anim) {
uiItemS(layout);
ADD_SEPARATOR_CONDITIONAL
if (is_array_component) {
uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add All to Keying Set"),
@@ -6658,10 +6645,12 @@ static bool ui_but_menu(bContext *C, uiBut *but)
uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Keying Set"),
ICON_NONE, "ANIM_OT_keyingset_button_remove");
}
is_first_item = false;
}
uiItemS(layout);
ADD_SEPARATOR_CONDITIONAL
/* Property Operators */
/* Copy Property Value
@@ -6729,6 +6718,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
"please use User Preferences otherwise"));
UI_but_flag_enable(but2, UI_BUT_DISABLED);
}
is_first_item = false;
}
/* only show 'add' if there's a suitable key map for it to go in */
else if (WM_keymap_guess_opname(C, but->optype->idname)) {
@@ -6736,11 +6726,15 @@ static bool ui_but_menu(bContext *C, uiBut *but)
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Shortcut"),
0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
UI_but_func_set(but2, popup_add_shortcut_func, but, NULL);
is_first_item = false;
}
uiItemS(layout);
ADD_SEPARATOR_CONDITIONAL
}
#undef ADD_SEPARATOR_CONDITIONAL
/* Show header tools for header buttons. */
if (ui_block_is_menu(but->block) == false) {
ARegion *ar = CTX_wm_region(C);
@@ -6785,8 +6779,33 @@ static bool ui_but_menu(bContext *C, uiBut *but)
return true;
}
static int ui_do_but_subbut(bContext *C, uiBut *but, uiSubBut *sbut, const wmEvent *event)
{
int retval = WM_UI_HANDLER_CONTINUE;
BLI_assert(sbut->is_hovered);
switch (but->type) {
case UI_BTYPE_NUM:
retval = ui_do_subbut_NUM(C, but, sbut, event);
break;
default:
break;
}
if (retval == WM_UI_HANDLER_BREAK) {
BLI_assert(ui_but_contains_point_px(CTX_wm_region(C), but, event->x, event->y));
button_activate_exit(C, but, but->active, true, false);
/* reactivate highlight state */
button_activate_init(C, CTX_wm_region(C), but, BUTTON_ACTIVATE_OVER);
}
return retval;
}
static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *event)
{
uiSubBut *sbut;
uiHandleButtonData *data;
int retval;
@@ -6930,6 +6949,16 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
}
}
sbut = ui_subbut_find_mouse_over(CTX_wm_region(C), but, &event->x);
if (sbut) {
retval = ui_do_but_subbut(C, but, sbut, event);
if (retval == WM_UI_HANDLER_BREAK) {
return retval;
}
}
switch (but->type) {
case UI_BTYPE_BUT:
retval = ui_do_but_BUT(C, but, data, event);
@@ -7408,6 +7437,25 @@ static uiBut *ui_but_find_mouse_over(ARegion *ar, const wmEvent *event)
}
static uiSubBut *ui_subbut_find_mouse_over(ARegion *ar, uiBut *but, const int mouse_xy[2])
{
uiSubBut *sbut;
float mx = mouse_xy[0];
float my = mouse_xy[1];
BLI_assert(ui_but_contains_point_px(ar, but, UNPACK2(mouse_xy)));
ui_window_to_block_fl(ar, but->block, &mx, &my);
for (sbut = but->subbuts.first; sbut; sbut = sbut->next) {
if (BLI_rcti_isect_x(&sbut->rect, mx)) {
return sbut;
}
}
return NULL;
}
static uiBut *ui_list_find_mouse_over_ex(ARegion *ar, int x, int y)
{
uiBlock *block;
@@ -8095,6 +8143,31 @@ static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiBu
/************ handle events for an activated button ***********/
static void ui_handle_but_subbuts(ARegion *ar, uiBut *but, const int mouse_xy[2])
{
uiSubBut *sbut = ui_subbut_find_mouse_over(ar, but, mouse_xy);
bool changed = false;
if (sbut) {
if (sbut->is_hovered == false) {
sbut->is_hovered = true;
changed = true;
}
}
else {
for (sbut = but->subbuts.first; sbut; sbut = sbut->next) {
if (sbut->is_hovered) {
sbut->is_hovered = false;
changed = true;
}
}
}
if (changed) {
ED_region_tag_redraw(ar);
}
}
static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
{
uiHandleButtonData *data = but->active;
@@ -8141,6 +8214,10 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
button_tooltip_timer_reset(C, but);
}
if (BLI_listbase_is_empty(&but->subbuts) == false) {
ui_handle_but_subbuts(ar, but, &event->x);
}
break;
}
case TIMER:
@@ -8807,7 +8884,7 @@ static int ui_handle_menu_event(
/* check if mouse is inside block */
inside = BLI_rctf_isect_pt(&block->rect, mx, my);
inside_title = inside && ((my + (UI_UNIT_Y * 1.5f)) > block->rect.ymax);
inside_title = inside && ((my + UI_MENU_TITLE_HEIGHT) > block->rect.ymax);
/* if there's an active modal button, don't check events or outside, except for search menu */
but = ui_but_find_active_in_region(ar);

View File

@@ -101,6 +101,11 @@ typedef enum {
UI_WTYPE_PROGRESSBAR,
} uiWidgetTypeEnum;
/* general menu defines */
#define UI_MENU_TITLE_WIDTH (short)(UI_UNIT_X * 5.0f)
#define UI_MENU_TITLE_HEIGHT (short)(UI_UNIT_Y * 1.1f)
#define UI_MENU_SUBMENU_PADDING (10 * UI_DPI_FAC) /* some extra padding added to menus containing submenu icons */
/* menu scrolling */
#define UI_MENU_SCROLL_ARROW 12
#define UI_MENU_SCROLL_MOUSE (UI_MENU_SCROLL_ARROW + 2)
@@ -121,6 +126,18 @@ enum {
/* warn: rest of uiBut->flag in UI_interface.h */
};
/* uiSubBut->type */
typedef enum uiSubButType {
UI_SBUT_TYPE_VAL_DECREASE,
UI_SBUT_TYPE_VAL_INCREASE,
} uiSubButType;
/* uiSubBut->align */
typedef enum uiSubButAlign {
UI_SBUT_ALIGN_LEFT,
UI_SBUT_ALIGN_RIGHT,
} uiSubButAlign;
/* some buttons display icons only under special conditions
* (e.g. 'x' icon in search menu) - used with ui_but_icon_extra_get */
typedef enum uiButExtraIconType {
@@ -204,8 +221,23 @@ typedef struct {
ListBase lines;
} uiLink;
typedef struct uiSubBut {
struct uiSubBut *next, *prev;
uiSubButType type;
uiSubButAlign align; /* alignment within but */
int width, height;
rcti rect; /* block relative coords */
bool is_hovered; /* could be made into flag */
} uiSubBut;
struct uiBut {
struct uiBut *next, *prev;
ListBase subbuts;
int flag, drawflag;
eButType type;
eButPointerType pointype;
@@ -446,11 +478,14 @@ extern bool ui_block_is_pie_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT;
extern void ui_block_to_window_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y);
extern void ui_block_to_window(const struct ARegion *ar, uiBlock *block, int *x, int *y);
extern void ui_block_to_window_rctf(const struct ARegion *ar, uiBlock *block, rctf *rct_dst, const rctf *rct_src);
extern void ui_block_to_window_rcti(const ARegion *ar, uiBlock *block, rcti *rct_dst, const rcti *rct_src);
extern void ui_window_to_block_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y);
extern void ui_window_to_block(const struct ARegion *ar, uiBlock *block, int *x, int *y);
extern void ui_window_to_region(const ARegion *ar, int *x, int *y);
extern void ui_region_to_window(const struct ARegion *ar, int *x, int *y);
extern void ui_region_winrct_get_no_margin(const struct ARegion *ar, struct rcti *r_rect);
extern void ui_rcti_to_pixelrect(const ARegion *ar, uiBlock *block, rcti *rct_dst, const rcti *rct_src);
extern void ui_rctf_to_pixelrect(const ARegion *ar, uiBlock *block, rctf *rct_dst, const rctf *rct_src);
extern double ui_but_value_get(uiBut *but);
extern void ui_but_value_set(uiBut *but, double value);

View File

@@ -281,12 +281,40 @@ static void ui_item_position(uiItem *item, int x, int y, int w, int h)
{
if (item->type == ITEM_BUTTON) {
uiButtonItem *bitem = (uiButtonItem *)item;
uiBut *but = bitem->but;
but->rect.xmin = x;
but->rect.ymin = y;
but->rect.xmax = x + w;
but->rect.ymax = y + h;
/* set subbut sizes */
if (BLI_listbase_is_empty(&but->subbuts) == false) {
uiSubBut *sbut;
for (sbut = but->subbuts.first; sbut; sbut = sbut->next) {
if (sbut->align == UI_SBUT_ALIGN_LEFT) {
sbut->rect.xmin = but->rect.xmin - 2; /* - 2 looks a bit better */
sbut->rect.xmax = sbut->rect.xmin + sbut->width;
}
else if (sbut->align == UI_SBUT_ALIGN_RIGHT) {
sbut->rect.xmax = but->rect.xmax + 4; /* + 4 looks a bit better */
sbut->rect.xmin = but->rect.xmax - sbut->width;
}
else {
BLI_assert(0);
}
sbut->rect.ymin = but->rect.ymin + (U.pixelsize - 1.0f);
sbut->rect.ymax = sbut->rect.ymin + sbut->height;
if (but->block->panel) {
uiStyle *style = UI_style_get_dpi();
sbut->rect.ymin += (but->block->panel->sizey - style->panelspace);
sbut->rect.ymax += (but->block->panel->sizey - style->panelspace);
}
}
}
bitem->but->rect.xmin = x;
bitem->but->rect.ymin = y;
bitem->but->rect.xmax = x + w;
bitem->but->rect.ymax = y + h;
ui_but_update(bitem->but); /* for strlen */
}
else {

View File

@@ -427,16 +427,43 @@ void UI_draw_icon_tri(float x, float y, char dir)
}
}
/* triangle 'icon' inside rect */
static void ui_draw_tria_rect(const rctf *rect, char dir)
static void ui_draw_tria_rect(const rctf *rect, const bool is_closed)
{
if (dir == 'h') {
const float col_tint = 50;
const int px = (int)UI_DPI_FAC;
float col[3];
/* XXX ensure contrast */
UI_GetThemeColorShade3fv(TH_TITLE, col_tint, col);
/* color for shadow drawing */
glColor4f(0.0f, 0.0f, 0.0f, 0.3f);
if (is_closed) {
float half = 0.5f * BLI_rctf_size_y(rect);
ui_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, rect->ymax, rect->xmax, rect->ymin + half);
/* draw shadow first */
ui_draw_anti_tria(rect->xmin + px, rect->ymin - px,
rect->xmin + px, rect->ymax - px,
rect->xmax + px, rect->ymin + half - px);
glColor3fv(col);
ui_draw_anti_tria(rect->xmin, rect->ymin,
rect->xmin, rect->ymax,
rect->xmax, rect->ymin + half);
}
else {
float half = 0.5f * BLI_rctf_size_x(rect);
ui_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, rect->ymax, rect->xmin + half, rect->ymin);
float half = 0.5f * BLI_rctf_size_y(rect);
/* draw shadow first */
ui_draw_anti_tria(rect->xmin + px, rect->ymax - px,
rect->xmax + px, rect->ymax - px,
rect->xmin + half + px, rect->ymin - px);
glColor3fv(col);
ui_draw_anti_tria(rect->xmin, rect->ymax,
rect->xmax, rect->ymax,
rect->xmin + half, rect->ymin);
}
}
@@ -462,9 +489,7 @@ static void ui_draw_anti_x(float x1, float y1, float x2, float y2)
/* x 'icon' for panel header */
static void ui_draw_x_icon(float x, float y)
{
ui_draw_anti_x(x, y, x + 9.375f, y + 9.375f);
}
#define PNL_ICON UI_UNIT_X /* could be UI_UNIT_Y too */
@@ -492,86 +517,133 @@ static void ui_draw_panel_scalewidget(const rcti *rect)
fdrawline(xmin + dx, ymin + 1, xmax, ymax - dy + 1);
glDisable(GL_BLEND);
}
static void ui_draw_panel_dragwidget(const rctf *rect)
{
unsigned char col_back[3], col_high[3], col_dark[3];
const int col_tint = 84;
const int col_tint = 60;
const int px = (int)U.pixelsize;
const int px = (int)UI_DPI_FAC;
const int px_zoom = max_ii(iroundf(BLI_rctf_size_y(rect) / 22.0f), 1);
const int box_margin = max_ii(iroundf((float)(px_zoom * 2.0f)), px);
const int box_size = max_ii(iroundf((BLI_rctf_size_y(rect) / 8.0f) - px), px);
const int box_rows = 4;
const int x_min = rect->xmin;
const int y_min = rect->ymin;
const int y_ofs = max_ii(iroundf(BLI_rctf_size_y(rect) / 3.0f), px);
const int x_ofs = y_ofs;
int i_x, i_y;
const int y_ofs = (BLI_rctf_size_y(rect) / box_rows) - (box_margin * 0.5f);
int i;
UI_GetThemeColor3ubv(UI_GetThemeValue(TH_PANEL_SHOW_HEADER) ? TH_PANEL_HEADER : TH_PANEL_BACK, col_back);
UI_GetColorPtrShade3ubv(col_back, col_high, col_tint);
UI_GetColorPtrShade3ubv(col_back, col_dark, -col_tint);
UI_GetColorPtrShade3ubv(col_back, col_high, col_tint);
UI_GetColorPtrShade3ubv(col_back, col_dark, -(col_tint * 0.4));
/* draw multiple boxes */
for (i_x = 0; i_x < 4; i_x++) {
for (i_y = 0; i_y < 2; i_y++) {
const int x_co = (x_min + x_ofs) + (i_x * (box_size + box_margin));
const int y_co = (y_min + y_ofs) + (i_y * (box_size + box_margin));
for (i = 0; i < box_rows; i++) {
const int y_co = (y_min + y_ofs) + (i * (box_size + box_margin));
glColor3ubv(col_dark);
glRectf(x_co - box_size, y_co - px_zoom, x_co, (y_co + box_size) - px_zoom);
glColor3ubv(col_high);
glRectf(x_co - box_size, y_co, x_co, y_co + box_size);
}
glColor3ubv(col_dark);
glRectf(x_min - box_size + px_zoom, y_co - px_zoom, x_min + px_zoom, (y_co + box_size) - px_zoom);
glColor3ubv(col_high);
glRectf(x_min - box_size, y_co, x_min, y_co + box_size);
}
}
static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, const rcti *rect, char dir)
static void ui_draw_aligned_panel_header(
const uiStyle *style, const uiBlock *block,
const rcti *rect, const char dir)
{
Panel *panel = block->panel;
rcti hrect;
int pnl_icons;
const Panel *panel = block->panel;
const int px = (int)UI_DPI_FAC;
const char *activename = panel->drawname[0] ? panel->drawname : panel->panelname;
rcti hrect;
/* + 0.001f to avoid flirting with float inaccuracy */
if (panel->control & UI_PNL_CLOSE)
pnl_icons = (panel->labelofs + 2 * PNL_ICON + 5) / block->aspect + 0.001f;
else
pnl_icons = (panel->labelofs + PNL_ICON + 5) / block->aspect + 0.001f;
/* active tab */
/* draw text label */
UI_ThemeColor(TH_TITLE);
hrect = *rect;
if (dir == 'h') {
hrect.xmin = rect->xmin + pnl_icons;
hrect.ymin += 2.0f / block->aspect;
hrect.xmin = rect->xmin + BLI_rcti_size_y(rect);
hrect.ymin += (2.0f / block->aspect) * px;
UI_fontstyle_draw(&style->paneltitle, &hrect, activename);
}
else {
/* ignore 'pnl_icons', otherwise the text gets offset horizontally
* + 0.001f to avoid flirting with float inaccuracy
*/
hrect.xmin = rect->xmin + (PNL_ICON + 5) / block->aspect + 0.001f;
hrect.xmin = rect->xmin + ((PNL_HEADER - 1) / block->aspect);
UI_fontstyle_draw_rotated(&style->paneltitle, &hrect, activename);
}
}
static void ui_draw_panel_shadow(
const rctf shadowrect, const float aspect,
const float alpha_fac, const bool is_selected)
{
float alpha_fac_tmp = 0.2f * alpha_fac;
const int px = MAX2(iroundf(UI_DPI_FAC * (1 / aspect)), 1);
short shadow_ofs = is_selected ? 2.0f * px : 1.0f * px;
glEnable(GL_BLEND);
if (is_selected) {
/* draw a big soft shadow while dragging */
UI_draw_box_shadow(alpha_fac * 255, shadowrect.xmin, shadowrect.ymin, shadowrect.xmax, shadowrect.ymax);
}
else {
short i;
/* draw a soft 2px shadow */
for (i = 0; i < 2; i++) {
glColor4f(0.0f, 0.0f, 0.0f, alpha_fac_tmp);
glRectf(shadowrect.xmin + shadow_ofs, shadowrect.ymin - shadow_ofs,
shadowrect.xmax + shadow_ofs, shadowrect.ymax - shadow_ofs);
shadow_ofs += px;
alpha_fac_tmp *= 0.5f;
}
}
glDisable(GL_BLEND);
}
static void panel_boundbox_get(
const uiBlock *block, const Panel *pa,
const rcti *blockrect, const rcti *headrect,
rctf *r_bounds)
{
const int xmax = (pa->flag & PNL_CLOSEDX) ? (blockrect->xmin + (PNL_HEADER / block->aspect)) : blockrect->xmax;
const int ymin = (pa->flag & PNL_CLOSED) ? headrect->ymin : blockrect->ymin;
BLI_rctf_init(r_bounds, blockrect->xmin, xmax, ymin, headrect->ymax);
}
/* panel integrated in buttonswindow, tool/property lists etc */
void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, const bool show_pin)
void ui_draw_aligned_panel(
uiStyle *style, uiBlock *block,
const rcti *rect,
const bool show_pin)
{
Panel *panel = block->panel;
rctf fullrect, itemrect;
rcti headrect;
rctf itemrect;
int ofsx;
const bool is_selected = (panel->flag & PNL_SELECT) ? true : false;
const float alpha_fac = is_selected ? 0.7f : 1.0f;
/* panel states */
const bool is_inside = ELEM(panel->mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER);
const bool is_closed_xy = (panel->flag & PNL_CLOSED) ? true : false;
const bool is_closed_x = (panel->flag & PNL_CLOSEDX) ? true : false;
const bool is_closed_y = (panel->flag & PNL_CLOSEDY) ? true : false;
/* theme options */
const bool draw_header = UI_GetThemeValue(TH_PANEL_SHOW_HEADER);
const bool draw_back = UI_GetThemeValue(TH_PANEL_SHOW_BACK);
if (panel->paneltab) return;
if (panel->type && (panel->type->flag & PNL_NO_HEADER)) return;
@@ -581,20 +653,45 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
headrect.ymin = headrect.ymax;
headrect.ymax = headrect.ymin + floor(PNL_HEADER / block->aspect + 0.001f);
/* set fullrect */
panel_boundbox_get(block, panel, rect, &headrect, &fullrect);
if (draw_header == false && is_closed_xy) {
/* skip */
}
/* draw panel shadow */
else if (draw_header || draw_back) {
rctf shadowrect = fullrect;
/* adjust shadowrect for special case: draw background but not header */
if (draw_back && !draw_header) {
shadowrect.ymax = rect->ymax;
}
ui_draw_panel_shadow(shadowrect, block->aspect, alpha_fac, is_selected);
}
{
float minx = rect->xmin;
float maxx = is_closed_x ? (minx + PNL_HEADER / block->aspect) : rect->xmax;
float maxx = is_closed_x ? (minx + (PNL_HEADER / block->aspect)) : rect->xmax;
float y = headrect.ymax;
glEnable(GL_BLEND);
if (UI_GetThemeValue(TH_PANEL_SHOW_HEADER)) {
/* draw with background color */
UI_ThemeColor4(TH_PANEL_HEADER);
glRectf(minx, headrect.ymin + 1, maxx, y);
if (draw_header) {
float col[3];
fdrawline(minx, y, maxx, y);
fdrawline(minx, y, maxx, y);
if (is_inside) {
/* highlight if mouse is inside */
UI_GetThemeColorShade3fv(TH_PANEL_HEADER, 7, col);
}
else {
UI_GetThemeColor3fv(TH_PANEL_HEADER, col);
}
/* draw with background color */
glColor4f(UNPACK3(col), alpha_fac);
glRectf(minx, headrect.ymin, maxx, y);
}
else if (!(panel->runtime_flag & PNL_FIRST)) {
/* draw embossed separator */
@@ -622,24 +719,24 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
#endif
{
glEnable(GL_BLEND);
UI_icon_draw_aspect(headrect.xmax - ((PNL_ICON * 2.2f) / block->aspect), headrect.ymin + (5.0f / block->aspect),
UI_icon_draw_aspect(headrect.xmax - ((PNL_ICON * 1.8f) / block->aspect), headrect.ymin + (5.0f / block->aspect),
(panel->flag & PNL_PIN) ? ICON_PINNED : ICON_UNPINNED,
(block->aspect / UI_DPI_FAC), 1.0f);
glDisable(GL_BLEND);
}
/* horizontal title */
if (is_closed_x == false) {
/* horizontal title */
ui_draw_aligned_panel_header(style, block, &headrect, 'h');
/* itemrect smaller */
itemrect.xmax = headrect.xmax - 5.0f / block->aspect;
itemrect.xmin = itemrect.xmax - BLI_rcti_size_y(&headrect);
itemrect.ymin = headrect.ymin;
itemrect.ymax = headrect.ymax;
/* drag widget */
if (is_inside) {
BLI_rctf_rcti_copy(&itemrect, &headrect);
/* itemrect smaller */
itemrect.xmin = itemrect.xmax - (5.0f / block->aspect);
BLI_rctf_scale(&itemrect, 0.7f);
ui_draw_panel_dragwidget(&itemrect);
ui_draw_panel_dragwidget(&itemrect);
}
}
/* if the panel is minimized vertically:
@@ -654,21 +751,23 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
}
/* an open panel */
else {
/* in some occasions, draw a border */
if (panel->flag & PNL_SELECT) {
if (panel->control & UI_PNL_SOLID) UI_draw_roundbox_corner_set(UI_CNR_ALL);
else UI_draw_roundbox_corner_set(UI_CNR_NONE);
UI_ThemeColorShade(TH_BACK, -120);
UI_draw_roundbox_unfilled(0.5f + rect->xmin, 0.5f + rect->ymin, 0.5f + rect->xmax, 0.5f + headrect.ymax + 1, 8);
}
/* panel backdrop */
if (UI_GetThemeValue(TH_PANEL_SHOW_BACK)) {
if (draw_back) {
/* draw with background color */
float col[3];
if (is_inside) {
/* highlight if mouse is inside */
UI_GetThemeColorShade3fv(TH_PANEL_BACK, 7, col);
}
else {
UI_GetThemeColor3fv(TH_PANEL_BACK, col);
}
glEnable(GL_BLEND);
UI_ThemeColor4(TH_PANEL_BACK);
glColor4f(UNPACK3(col), alpha_fac);
glRecti(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
glDisable(GL_BLEND);
}
if (panel->control & UI_PNL_SCALE)
@@ -684,23 +783,14 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
ofsx = 22;
}
/* draw collapse icon */
UI_ThemeColor(TH_TITLE);
/* itemrect smaller */
itemrect.xmin = headrect.xmin + 5.0f / block->aspect;
itemrect.xmin = headrect.xmin + (is_closed_x ? (1.0f / block->aspect) : (3.0f / block->aspect));
itemrect.xmax = itemrect.xmin + BLI_rcti_size_y(&headrect);
itemrect.ymin = headrect.ymin;
itemrect.ymax = headrect.ymax;
BLI_rctf_scale(&itemrect, 0.35f);
if (is_closed_y)
ui_draw_tria_rect(&itemrect, 'h');
else if (is_closed_x)
ui_draw_tria_rect(&itemrect, 'h');
else
ui_draw_tria_rect(&itemrect, 'v');
ui_draw_tria_rect(&itemrect, is_closed_xy);
(void)ofsx;
}
@@ -851,8 +941,9 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
/* no smart other default start loc! this keeps switching f5/f6/etc compatible */
ps = panelsort;
ps->pa->ofsx = 0;
ps->pa->ofsy = -get_panel_size_y(ps->pa);
ps->pa->ofsx = UI_PANEL_MARGIN;
/* offset first panel, but not for properties editor, there is already some space making this look odd */
ps->pa->ofsy = -(get_panel_size_y(ps->pa) + (sa->spacetype == SPACE_BUTS ? 0 : UI_PANEL_MARGIN));
if (has_category_tabs) {
if (align == BUT_VERTICAL) {
@@ -865,10 +956,10 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
if (align == BUT_VERTICAL) {
psnext->pa->ofsx = ps->pa->ofsx;
psnext->pa->ofsy = get_panel_real_ofsy(ps->pa) - get_panel_size_y(psnext->pa);
psnext->pa->ofsy = get_panel_real_ofsy(ps->pa) - get_panel_size_y(psnext->pa) - UI_PANEL_MARGIN;
}
else {
psnext->pa->ofsx = get_panel_real_ofsx(ps->pa);
psnext->pa->ofsx = get_panel_real_ofsx(ps->pa) + UI_PANEL_MARGIN * 2;
psnext->pa->ofsy = ps->pa->ofsy + get_panel_size_y(ps->pa) - get_panel_size_y(psnext->pa);
}
}
@@ -1312,17 +1403,17 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
int align = panel_aligned(sa, ar), button = 0;
rctf rect_drag, rect_pin;
float rect_leftmost;
float collapse_xmax;
/* drag and pin rect's */
rect_drag = block->rect;
rect_drag.xmin = block->rect.xmax - (PNL_ICON * 1.5f);
rect_drag.xmin = block->rect.xmax - (PNL_ICON * 0.8f);
rect_pin = rect_drag;
if (show_pin) {
BLI_rctf_translate(&rect_pin, -PNL_ICON, 0.0f);
}
rect_leftmost = rect_pin.xmin;
collapse_xmax = rect_pin.xmin;
/* mouse coordinates in panel space! */
@@ -1345,7 +1436,7 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
if (mx <= block->rect.xmax - 8 - PNL_ICON) button = 2;
//else if (mx <= block->rect.xmin + 10 + 2 * PNL_ICON + 2) button = 1;
}
else if (mx < rect_leftmost) {
else if (mx < collapse_xmax) {
button = 1;
}
@@ -1903,13 +1994,21 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons
}
}
/* do a first iteration over all panels to see if we have one that is already being dragged */
for (block = ar->uiblocks.last; block; block = block->prev) {
if (block->panel && block->panel->flag & PNL_SELECT) {
/* don't handle any further interaction while a panel
* is dragged (which is handled separately) */
retval = WM_UI_HANDLER_BREAK;
break;
}
}
if (retval == WM_UI_HANDLER_BREAK) {
return retval;
}
for (block = ar->uiblocks.last; block; block = block->prev) {
uiPanelMouseState mouse_state;
mx = event->x;
my = event->y;
ui_window_to_block(ar, block, &mx, &my);
@@ -1922,10 +2021,22 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons
if (pa->type && pa->type->flag & PNL_NO_HEADER) /* XXX - accessed freed panels when scripts reload, need to fix. */
continue;
mouse_state = ui_panel_mouse_state_get(block, pa, mx, my);
pa->mouse_state = ui_panel_mouse_state_get(block, pa, mx, my);
/* some special redrawing (skipped if area is already tagged for redraw) */
if (event->type == MOUSEMOVE && ar->do_draw == 0) {
int mx_prev = event->prevx;
int my_prev = event->prevy;
ui_window_to_block(ar, block, &mx_prev, &my_prev);
/* redraw if mouse state has changed for mouse hover feedback */
if (pa->mouse_state != ui_panel_mouse_state_get(block, pa, mx_prev, my_prev)) {
ED_region_tag_redraw(ar);
}
}
/* XXX hardcoded key warning */
if (ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER) && event->val == KM_PRESS) {
if (ELEM(pa->mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER) && event->val == KM_PRESS) {
if (event->type == AKEY && ((event->ctrl + event->oskey + event->shift + event->alt) == 0)) {
if (pa->flag & PNL_CLOSEDY) {
@@ -1944,13 +2055,13 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons
if (ui_but_is_active(ar))
continue;
if (ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER)) {
if (ELEM(pa->mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER)) {
if (event->val == KM_PRESS) {
/* open close on header */
if (ELEM(event->type, RETKEY, PADENTER)) {
if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) {
if (pa->mouse_state == PANEL_MOUSE_INSIDE_HEADER) {
ui_handle_panel_header(C, block, mx, my, RETKEY, event->ctrl, event->shift);
retval = WM_UI_HANDLER_BREAK;
break;
@@ -1960,12 +2071,12 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons
/* all inside clicks should return in break - overlapping/float panels */
retval = WM_UI_HANDLER_BREAK;
if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) {
if (pa->mouse_state == PANEL_MOUSE_INSIDE_HEADER) {
ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift);
retval = WM_UI_HANDLER_BREAK;
break;
}
else if ((mouse_state == PANEL_MOUSE_INSIDE_SCALE) && !(pa->flag & PNL_CLOSED)) {
else if ((pa->mouse_state == PANEL_MOUSE_INSIDE_SCALE) && !(pa->flag & PNL_CLOSED)) {
panel_activate_state(C, pa, PANEL_STATE_DRAG_SCALE);
retval = WM_UI_HANDLER_BREAK;
break;
@@ -1973,7 +2084,7 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons
}
else if (event->type == RIGHTMOUSE) {
if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) {
if (pa->mouse_state == PANEL_MOUSE_INSIDE_HEADER) {
ui_panel_menu(C, ar, block->panel);
retval = WM_UI_HANDLER_BREAK;
break;

View File

@@ -1402,6 +1402,10 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
for (bt = block->buttons.first; bt; bt = bt->next) {
BLI_rctf_union(&block->rect, &bt->rect);
if (UNLIKELY(block->flag & UI_BLOCK_HAS_SUBMENU)) {
bt->rect.xmax += UI_MENU_SUBMENU_PADDING;
}
}
}
else {
@@ -1409,8 +1413,12 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
block->rect.xmin = block->rect.ymin = 0;
block->rect.xmax = block->rect.ymax = 20;
}
if (block->flag & UI_BLOCK_HAS_SUBMENU) {
block->rect.xmax += UI_MENU_SUBMENU_PADDING;
}
}
/* aspect = (float)(BLI_rcti_size_x(&block->rect) + 4);*/ /*UNUSED*/
ui_block_to_window_rctf(butregion, but->block, &block->rect, &block->rect);
@@ -1478,35 +1486,41 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
if (dir2 == UI_DIR_DOWN && down == 0) dir2 = UI_DIR_UP;
}
if (dir1 == UI_DIR_LEFT) {
xof = butrct.xmin - block->rect.xmax;
if (dir2 == UI_DIR_UP) yof = butrct.ymin - block->rect.ymin - center - MENU_PADDING;
else yof = butrct.ymax - block->rect.ymax + center + MENU_PADDING;
}
else if (dir1 == UI_DIR_RIGHT) {
xof = butrct.xmax - block->rect.xmin;
if (dir2 == UI_DIR_UP) yof = butrct.ymin - block->rect.ymin - center - MENU_PADDING;
else yof = butrct.ymax - block->rect.ymax + center + MENU_PADDING;
}
else if (dir1 == UI_DIR_UP) {
yof = butrct.ymax - block->rect.ymin;
if (dir2 == UI_DIR_RIGHT) xof = butrct.xmax - block->rect.xmax;
else xof = butrct.xmin - block->rect.xmin;
/* changed direction? */
if ((dir1 & block->direction) == 0) {
UI_block_order_flip(block);
}
}
else if (dir1 == UI_DIR_DOWN) {
yof = butrct.ymin - block->rect.ymax;
if (dir2 == UI_DIR_RIGHT) xof = butrct.xmax - block->rect.xmax;
else xof = butrct.xmin - block->rect.xmin;
/* changed direction? */
if ((dir1 & block->direction) == 0) {
UI_block_order_flip(block);
}
#define RECTS_BUT_BLOCK_DIFF(member) (butrct.member - block->rect.member)
switch (dir1) {
case UI_DIR_LEFT:
xof = butrct.xmin - block->rect.xmax;
if (dir2 == UI_DIR_UP) yof = RECTS_BUT_BLOCK_DIFF(ymin) - center - MENU_PADDING;
else yof = RECTS_BUT_BLOCK_DIFF(ymax) + center + MENU_PADDING;
break;
case UI_DIR_RIGHT:
xof = butrct.xmax - block->rect.xmin;
if (dir2 == UI_DIR_UP) yof = RECTS_BUT_BLOCK_DIFF(ymin) - center - MENU_PADDING;
else yof = RECTS_BUT_BLOCK_DIFF(ymax) + center + MENU_PADDING;
break;
case UI_DIR_UP:
yof = iroundf(butrct.ymax - block->rect.ymin - (2.0f * U.pixelsize));
if (dir2 == UI_DIR_RIGHT) xof = RECTS_BUT_BLOCK_DIFF(xmax);
else xof = RECTS_BUT_BLOCK_DIFF(xmin);
/* changed direction? */
if ((dir1 & block->direction) == 0) {
UI_block_order_flip(block);
}
break;
case UI_DIR_DOWN:
yof = iroundf(butrct.ymin - block->rect.ymax + (2.0f * U.pixelsize));
if (dir2 == UI_DIR_RIGHT) xof = RECTS_BUT_BLOCK_DIFF(xmax);
else xof = RECTS_BUT_BLOCK_DIFF(xmin);
/* changed direction? */
if ((dir1 & block->direction) == 0) {
UI_block_order_flip(block);
}
break;
}
#undef RECTS_BUT_BLOCK_DIFF
/* and now we handle the exception; no space below or to top */
if (top == 0 && down == 0) {
if (dir1 == UI_DIR_LEFT || dir1 == UI_DIR_RIGHT) {
@@ -2700,14 +2714,15 @@ uiPopupMenu *UI_popup_menu_begin(bContext *C, const char *title, int icon)
if (icon) {
BLI_snprintf(titlestr, sizeof(titlestr), " %s", title);
uiDefIconTextBut(pup->block, UI_BTYPE_LABEL, 0, icon, titlestr, 0, 0, 200, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
but = uiDefIconTextBut(pup->block, UI_BTYPE_LABEL, 0, icon, titlestr, 0, 0,
UI_MENU_TITLE_WIDTH, UI_MENU_TITLE_HEIGHT, NULL,
0.0, 0.0, 0, 0, "");
but->flag |= UI_BUT_MENU_TITLE;
}
else {
but = uiDefBut(pup->block, UI_BTYPE_LABEL, 0, title, 0, 0, 200, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
but = uiDefMenuTitleBut(pup->block, title);
but->drawflag = UI_BUT_TEXT_LEFT;
}
uiItemS(pup->layout);
}
return pup;

View File

@@ -79,6 +79,8 @@
#include "UI_interface.h"
#include "UI_interface_icons.h"
#include "UI_view2d.h"
#include "interface_intern.h"
void UI_template_fix_linking(void)
@@ -3122,7 +3124,7 @@ void uiTemplateList(
/* add scrollbar */
if (len > layoutdata.visual_items) {
col = uiLayoutColumn(row, false);
uiDefButI(block, UI_BTYPE_SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * dyn_data->visual_height,
uiDefButI(block, UI_BTYPE_SCROLL, 0, "", 0, 0, V2D_SCROLL_WIDTH, UI_UNIT_Y * dyn_data->visual_height,
&ui_list->list_scroll, 0, dyn_data->height - dyn_data->visual_height,
dyn_data->visual_height, 0, "");
}
@@ -3211,7 +3213,7 @@ void uiTemplateList(
/* add scrollbar */
if (len > layoutdata.visual_items) {
/* col = */ uiLayoutColumn(row, false);
uiDefButI(block, UI_BTYPE_SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * dyn_data->visual_height,
uiDefButI(block, UI_BTYPE_SCROLL, 0, "", 0, 0, V2D_SCROLL_WIDTH, UI_UNIT_Y * dyn_data->visual_height,
&ui_list->list_scroll, 0, dyn_data->height - dyn_data->visual_height,
dyn_data->visual_height, 0, "");
}

File diff suppressed because it is too large Load Diff

View File

@@ -171,6 +171,10 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
}
switch (colorid) {
case TH_AREA_EDGES:
cp = btheme->tui.area_edges;
break;
case TH_BACK:
if (theme_regionid == RGN_TYPE_WINDOW)
cp = ts->back;
@@ -798,6 +802,11 @@ static void ui_theme_init_new_do(ThemeSpace *ts)
rgba_char_args_set(ts->tab_inactive, 83, 83, 83, 255);
rgba_char_args_set(ts->tab_back, 64, 64, 64, 255);
rgba_char_args_set(ts->tab_outline, 60, 60, 60, 255);
/* XXX maybe remove show_back/show_header options? */
ts->panelcolors.show_back = ts->panelcolors.show_header = true;
rgba_char_args_set(ts->panelcolors.back, 128, 128, 128, 255);
rgba_char_args_set(ts->panelcolors.header, 97, 97, 97, 255);
}
static void ui_theme_init_new(bTheme *btheme)
@@ -846,7 +855,9 @@ void ui_theme_init_default(void)
/* UI buttons */
ui_widget_color_init(&btheme->tui);
rgba_char_args_set_fl(btheme->tui.area_edges, 0.15f, 0.15f, 0.15f, 1.0f);
btheme->tui.iconfile[0] = 0;
btheme->tui.panel.show_back = false;
btheme->tui.panel.show_header = false;
@@ -870,10 +881,6 @@ void ui_theme_init_default(void)
ui_theme_init_new(btheme);
/* space view3d */
btheme->tv3d.panelcolors.show_back = false;
btheme->tv3d.panelcolors.show_header = false;
rgba_char_args_set_fl(btheme->tv3d.panelcolors.back, 0.45, 0.45, 0.45, 0.5);
rgba_char_args_set_fl(btheme->tv3d.panelcolors.header, 0, 0, 0, 0.01);
rgba_char_args_set_fl(btheme->tv3d.back, 0.225, 0.225, 0.225, 1.0);
rgba_char_args_set(btheme->tv3d.text, 0, 0, 0, 255);
rgba_char_args_set(btheme->tv3d.text_hi, 255, 255, 255, 255);
@@ -2646,6 +2653,26 @@ void init_userdef_do_versions(void)
}
}
if (U.versionfile < 276 || (U.versionfile == 276 && U.subversionfile < 2)) {
bTheme *btheme;
ThemeSpace *ts;
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
for (ts = UI_THEMESPACE_START(btheme); ts != UI_THEMESPACE_END(btheme); ts++) {
/* XXX maybe remove show_back/show_header options? */
ts->panelcolors.show_back = ts->panelcolors.show_header = true;
rgba_char_args_set(ts->panelcolors.back, 128, 128, 128, 255);
rgba_char_args_set(ts->panelcolors.header, 97, 97, 97, 255);
}
rgba_char_args_set_fl(btheme->tui.area_edges, 0.10f, 0.10f, 0.10f, 1.0f);
btheme->tui.interface_style = TH_IFACE_STYLE_FLAT;
ui_widget_color_init(&btheme->tui);
}
}
if (U.pixelsize == 0.0f)
U.pixelsize = 1.0f;

View File

@@ -152,18 +152,21 @@ static void view2d_masks(View2D *v2d, bool check_scrollers)
* - if they overlap, they must not occupy the corners (which are reserved for other widgets)
*/
if (scroll) {
const int scroll_width = (v2d->flag & V2D_USES_UNITS_VERTICAL) ? V2D_SCROLL_WIDTH_TEXT : V2D_SCROLL_WIDTH;
const int scroll_height = (v2d->flag & V2D_USES_UNITS_HORIZONTAL) ? V2D_SCROLL_HEIGHT_TEXT : V2D_SCROLL_HEIGHT;
/* vertical scroller */
if (scroll & V2D_SCROLL_LEFT) {
/* on left-hand edge of region */
v2d->vert = v2d->mask;
v2d->vert.xmax = V2D_SCROLL_WIDTH;
v2d->vert.xmax = scroll_width;
v2d->mask.xmin = v2d->vert.xmax + 1;
}
else if (scroll & V2D_SCROLL_RIGHT) {
/* on right-hand edge of region */
v2d->vert = v2d->mask;
v2d->vert.xmax++; /* one pixel extra... was leaving a minor gap... */
v2d->vert.xmin = v2d->vert.xmax - V2D_SCROLL_WIDTH;
v2d->vert.xmin = v2d->vert.xmax - scroll_width;
v2d->mask.xmax = v2d->vert.xmin - 1;
}
@@ -171,13 +174,13 @@ static void view2d_masks(View2D *v2d, bool check_scrollers)
if (scroll & (V2D_SCROLL_BOTTOM)) {
/* on bottom edge of region */
v2d->hor = v2d->mask;
v2d->hor.ymax = V2D_SCROLL_HEIGHT;
v2d->hor.ymax = scroll_height;
v2d->mask.ymin = v2d->hor.ymax + 1;
}
else if (scroll & V2D_SCROLL_TOP) {
/* on upper edge of region */
v2d->hor = v2d->mask;
v2d->hor.ymin = v2d->hor.ymax - V2D_SCROLL_HEIGHT;
v2d->hor.ymin = v2d->hor.ymax - scroll_height;
v2d->mask.ymax = v2d->hor.ymin - 1;
}

View File

@@ -78,33 +78,31 @@ extern void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3,
static void region_draw_emboss(const ARegion *ar, const rcti *scirct)
{
rcti rect;
if (!ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_PROPS))
return;
/* translate scissor rect to region space */
rect.xmin = scirct->xmin - ar->winrct.xmin;
rect.ymin = scirct->ymin - ar->winrct.ymin;
rect.xmax = scirct->xmax - ar->winrct.xmin;
rect.ymax = scirct->ymax - ar->winrct.ymin;
/* set transp line */
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* right */
glColor4ub(0, 0, 0, 30);
sdrawline(rect.xmax, rect.ymin, rect.xmax, rect.ymax);
/* bottom */
glColor4ub(0, 0, 0, 30);
sdrawline(rect.xmin, rect.ymin, rect.xmax, rect.ymin);
/* top */
glColor4ub(255, 255, 255, 30);
sdrawline(rect.xmin, rect.ymax, rect.xmax, rect.ymax);
glColor4ub(0, 0, 0, 50);
/* bottom */
if (ar->alignment == RGN_ALIGN_TOP) {
sdrawline(rect.xmin, rect.ymin, rect.xmax, rect.ymin);
}
/* top */
else {
BLI_assert(ar->alignment == RGN_ALIGN_BOTTOM);
sdrawline(rect.xmin, rect.ymax, rect.xmax, rect.ymax);
}
/* left */
glColor4ub(255, 255, 255, 30);
sdrawline(rect.xmin, rect.ymin, rect.xmin, rect.ymax);
glDisable(GL_BLEND);
}
@@ -1729,7 +1727,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c
Panel *panel;
View2D *v2d = &ar->v2d;
View2DScrollers *scrollers;
int x, y, xco, yco, w, em, triangle;
int x, y, xco, yco, w, em;
bool is_context_new = 0;
int redo;
int scroll;
@@ -1818,7 +1816,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c
em = (ar->type->prefsizex) ? 10 : 20;
}
w -= margin_x;
w -= margin_x + UI_PANEL_MARGIN * 2.0f;
/* create panels */
UI_panels_begin(C, ar);
@@ -1842,24 +1840,28 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c
block = UI_block_begin(C, ar, pt->idname, UI_EMBOSS);
panel = UI_panel_begin(sa, ar, block, pt, panel, &open);
/* bad fixed values */
triangle = (int)(UI_UNIT_Y * 1.1f);
if (pt->draw_header && !(pt->flag & PNL_NO_HEADER) && (open || vertical)) {
const int ar_x = (int)BLI_rctf_size_x(&ar->v2d.cur);
const int ofs_x = iroundf(MIN2(UI_UNIT_X * 0.6f, ar_x * 0.1f));
/* using panel->sizex causes too much jittering */
const int panel_sizex = ar_x - (int)(UI_PANEL_MARGIN * 2.0f);
/* for enabled buttons */
panel->layout = UI_block_layout(
block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER,
triangle, (UI_UNIT_Y * 1.1f) + style->panelspace, UI_UNIT_Y, 1, 0, style);
uiLayout *row;
uiLayout *layout = UI_block_layout(
block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
-ofs_x, (UI_UNIT_Y * 1.1f) + style->panelspace,
panel_sizex, 1, 0, style);
row = uiLayoutRow(layout, 1);
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT);
panel->layout = row;
pt->draw_header(C, panel);
UI_block_layout_resolve(block, &xco, &yco);
panel->labelofs = xco - triangle;
panel->layout = NULL;
}
else {
panel->labelofs = 0;
}
if (open) {
short panelContext;

View File

@@ -64,6 +64,7 @@
#include "ED_render.h"
#include "UI_interface.h"
#include "UI_resources.h"
/* XXX actually should be not here... solve later */
#include "wm_subwindow.h"
@@ -1011,47 +1012,38 @@ static void scrarea_draw_shape_light(ScrArea *sa, char UNUSED(dir))
glDisable(GL_BLEND);
}
static void drawscredge_area_draw(int sizex, int sizey, int x1, int y1, int x2, int y2, int a)
static void drawscredge_area_draw(int sizex, int sizey, int x1, int y1, int x2, int y2)
{
/* right border area */
if (x2 < sizex - 1)
sdrawline(x2 + a, y1, x2 + a, y2);
sdrawline(x2, y1, x2, y2);
/* left border area */
if (x1 > 0) /* otherwise it draws the emboss of window over */
sdrawline(x1 + a, y1, x1 + a, y2);
sdrawline(x1, y1, x1, y2);
/* top border area */
if (y2 < sizey - 1)
sdrawline(x1, y2 + a, x2, y2 + a);
sdrawline(x1, y2, x2, y2);
/* bottom border area */
if (y1 > 0)
sdrawline(x1, y1 + a, x2, y1 + a);
sdrawline(x1, y1, x2, y1);
}
/** screen edges drawing **/
static void drawscredge_area(ScrArea *sa, int sizex, int sizey, int center)
static void drawscredge_area(ScrArea *sa, int sizex, int sizey)
{
short x1 = sa->v1->vec.x;
short y1 = sa->v1->vec.y;
short x2 = sa->v3->vec.x;
short y2 = sa->v3->vec.y;
if (center == 0) {
if (U.pixelsize > 1.0f) {
glColor3ub(0x50, 0x50, 0x50);
glLineWidth((2.0f * U.pixelsize) - 1);
drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, 0);
glLineWidth(1.0f);
}
}
else {
glColor3ub(0, 0, 0);
drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, 0);
}
glLineWidth(UI_DPI_FAC * 2.0f);
UI_ThemeColor(TH_AREA_EDGES);
drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2);
glLineWidth(1.0f);
}
/* ****************** EXPORTED API TO OTHER MODULES *************************** */
@@ -1134,10 +1126,8 @@ void ED_screen_draw(wmWindow *win)
if (sa->flag & AREA_FLAG_DRAWJOINFROM) sa1 = sa;
if (sa->flag & AREA_FLAG_DRAWJOINTO) sa2 = sa;
if (sa->flag & (AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V)) sa3 = sa;
drawscredge_area(sa, winsize_x, winsize_y, 0);
drawscredge_area(sa, winsize_x, winsize_y);
}
for (sa = win->screen->areabase.first; sa; sa = sa->next)
drawscredge_area(sa, winsize_x, winsize_y, 1);
/* blended join arrow */
if (sa1 && sa2) {

View File

@@ -118,7 +118,7 @@ static SpaceLink *action_new(const bContext *C)
ar->v2d.keepzoom = V2D_LOCKZOOM_Y;
ar->v2d.keepofs = V2D_KEEPOFS_Y;
ar->v2d.align = V2D_ALIGN_NO_POS_Y;
ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
ar->v2d.flag = (V2D_VIEWSYNC_AREA_VERTICAL | V2D_USES_UNITS_HORIZONTAL);
return (SpaceLink *)saction;
}

View File

@@ -104,7 +104,7 @@ static void init_preview_region(const bContext *C, ARegion *ar)
ar->v2d.keepzoom = V2D_LOCKZOOM_Y;
ar->v2d.keepofs = V2D_KEEPOFS_Y;
ar->v2d.align = V2D_ALIGN_NO_POS_Y;
ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
ar->v2d.flag = (V2D_VIEWSYNC_AREA_VERTICAL | V2D_USES_UNITS_HORIZONTAL);
}
else {
ar->v2d.tot.xmin = 0.0f;
@@ -128,7 +128,7 @@ static void init_preview_region(const bContext *C, ARegion *ar)
ar->v2d.keepzoom = 0;
ar->v2d.keepofs = 0;
ar->v2d.align = 0;
ar->v2d.flag = 0;
ar->v2d.flag = (V2D_USES_UNITS_HORIZONTAL | V2D_USES_UNITS_VERTICAL);
ar->v2d.keeptot = 0;
}
@@ -143,8 +143,8 @@ static void reinit_preview_region(const bContext *C, ARegion *ar)
init_preview_region(C, ar);
}
else {
if (ar->v2d.flag & V2D_VIEWSYNC_AREA_VERTICAL)
init_preview_region(C, ar);
/* XXX check with sergey */
init_preview_region(C, ar);
}
}

View File

@@ -156,6 +156,7 @@ static SpaceLink *graph_new(const bContext *C)
ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL);
ar->v2d.flag |= (V2D_USES_UNITS_HORIZONTAL | V2D_USES_UNITS_VERTICAL);
ar->v2d.keeptot = 0;

View File

@@ -292,9 +292,7 @@ static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *
Image *image = image_p;
int slot;
uiDefBut(block, UI_BTYPE_LABEL, 0, IFACE_("Slot"),
0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
uiItemS(layout);
uiDefMenuTitleBut(block, IFACE_("Slot"));
slot = IMA_MAX_RENDER_SLOT;
while (slot--) {
@@ -346,9 +344,7 @@ static void ui_imageuser_layer_menu(bContext *UNUSED(C), uiLayout *layout, void
UI_block_layout_set_current(block, layout);
uiLayoutColumn(layout, false);
uiDefBut(block, UI_BTYPE_LABEL, 0, IFACE_("Layer"),
0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
uiItemS(layout);
uiDefMenuTitleBut(block, IFACE_("Layer"));
nr = BLI_listbase_count(&rr->layers) - 1;
fake_name = ui_imageuser_layer_fake_name(rr);
@@ -413,10 +409,7 @@ static void ui_imageuser_pass_menu(bContext *UNUSED(C), uiLayout *layout, void *
UI_block_layout_set_current(block, layout);
uiLayoutColumn(layout, false);
uiDefBut(block, UI_BTYPE_LABEL, 0, IFACE_("Pass"),
0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
uiItemS(layout);
uiDefMenuTitleBut(block, IFACE_("Pass"));
nr = 0;
fake_name = ui_imageuser_pass_fake_name(rl);
@@ -472,10 +465,7 @@ static void ui_imageuser_view_menu_rr(bContext *UNUSED(C), uiLayout *layout, voi
UI_block_layout_set_current(block, layout);
uiLayoutColumn(layout, false);
uiDefBut(block, UI_BTYPE_LABEL, 0, IFACE_("View"),
0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
uiItemS(layout);
uiDefMenuTitleBut(block, IFACE_("View"));
nr = (rr ? BLI_listbase_count(&rr->views) : 0) - 1;
for (rview = rr ? rr->views.last : NULL; rview; rview = rview->prev, nr--) {
@@ -498,10 +488,7 @@ static void ui_imageuser_view_menu_multiview(bContext *UNUSED(C), uiLayout *layo
UI_block_layout_set_current(block, layout);
uiLayoutColumn(layout, false);
uiDefBut(block, UI_BTYPE_LABEL, 0, IFACE_("View"),
0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
uiItemS(layout);
uiDefMenuTitleBut(block, IFACE_("View"));
nr = BLI_listbase_count(&image->views) - 1;
for (iv = image->views.last; iv; iv = iv->prev, nr--) {

View File

@@ -2236,7 +2236,6 @@ static int nla_fmodifier_add_invoke(bContext *C, wmOperator *UNUSED(op), const w
/* add entry to add this type of modifier */
uiItemEnumO(layout, "NLA_OT_fmodifier_add", fmi->name, 0, "type", i);
}
uiItemS(layout);
UI_popup_menu_end(C, pup);

View File

@@ -158,7 +158,7 @@ static SpaceLink *nla_new(const bContext *C)
ar->v2d.keepzoom = V2D_LOCKZOOM_Y;
ar->v2d.keepofs = V2D_KEEPOFS_Y;
ar->v2d.align = V2D_ALIGN_NO_POS_Y;
ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
ar->v2d.flag = (V2D_VIEWSYNC_AREA_VERTICAL | V2D_USES_UNITS_HORIZONTAL);
return (SpaceLink *)snla;
}

View File

@@ -190,6 +190,7 @@ static SpaceLink *sequencer_new(const bContext *C)
ar->v2d.keepzoom = 0;
ar->v2d.keeptot = 0;
ar->v2d.align = V2D_ALIGN_NO_NEG_Y;
ar->v2d.flag |= (V2D_USES_UNITS_HORIZONTAL | V2D_USES_UNITS_VERTICAL);
return (SpaceLink *)sseq;
}

View File

@@ -675,6 +675,7 @@ static SpaceLink *time_new(const bContext *C)
ar->v2d.align |= V2D_ALIGN_NO_NEG_Y;
ar->v2d.keepofs |= V2D_LOCKOFS_Y;
ar->v2d.keepzoom |= V2D_LOCKZOOM_Y;
ar->v2d.flag |= V2D_USES_UNITS_HORIZONTAL;
return (SpaceLink *)stime;

View File

@@ -102,9 +102,9 @@ typedef struct Panel { /* the part from uiBlock that needs saved in file */
char panelname[64], tabname[64]; /* defined as UI_MAX_NAME_STR */
char drawname[64]; /* panelname is identifier for restoring location */
int ofsx, ofsy, sizex, sizey;
short labelofs, pad;
short flag, runtime_flag;
short control;
short mouse_state; /* is mouse inside header/content/...? */
short control, pad;
short snap;
int sortorder; /* panels are aligned according to increasing sortorder */
struct Panel *paneltab; /* this panel is tabbed in *paneltab */

View File

@@ -129,7 +129,9 @@ typedef struct uiWidgetColors {
char text_sel[4];
short shaded;
short shadetop, shadedown;
short alpha_check;
short pad;
float roundness;
short alpha_check, pad2;
} uiWidgetColors;
typedef struct uiWidgetStateColors {
@@ -169,6 +171,11 @@ typedef struct ThemeUI {
uiPanelColors panel; /* depricated, but we keep it for do_versions (2.66.1) */
short interface_style; /* flat/classic - don't confuse with uiStyle */
short pad2;
char area_edges[4];
char widget_emboss[4];
/* fac: 0 - 1 for blend factor, width in pixels */
@@ -902,6 +909,11 @@ typedef enum eOpensubdiv_Computee_Type {
USER_OPENSUBDIV_COMPUTE_GLSL_COMPUTE = 6,
} eOpensubdiv_Computee_Type;
typedef enum eTheme_InterfaceStyle {
TH_IFACE_STYLE_CLASSIC = 0,
TH_IFACE_STYLE_FLAT = 1,
} eTheme_InterfaceStyle;
#ifdef __cplusplus
}
#endif

View File

@@ -114,6 +114,9 @@ typedef struct View2D {
#define V2D_PIXELOFS_Y (1<<3)
/* view settings need to be set still... */
#define V2D_IS_INITIALISED (1<<10)
/* for screens that need to draw units on top of the scroller */
#define V2D_USES_UNITS_VERTICAL (1 << 11)
#define V2D_USES_UNITS_HORIZONTAL (1 << 12)
/* scroller flags for View2D (v2d->scroll) */
/* left scrollbar */

View File

@@ -909,6 +909,11 @@ static void rna_def_userdef_theme_ui_wcol(BlenderRNA *brna)
RNA_def_property_range(prop, -100, 100);
RNA_def_property_ui_text(prop, "Shade Down", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "roundness", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_range(prop, 0.1f, 0.5f);
RNA_def_property_ui_text(prop, "Roundness", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
}
static void rna_def_userdef_theme_ui_wcol_state(BlenderRNA *brna)
@@ -967,10 +972,12 @@ static void rna_def_userdef_theme_ui_panel(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Theme Panel Color", "Theme settings for panel colors");
prop = RNA_def_property(srna, "header", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Header", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "back", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Background", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
@@ -1014,6 +1021,12 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
static EnumPropertyItem interface_style_items[] = {
{TH_IFACE_STYLE_CLASSIC, "CLASSIC", 0, "Classic", "Use a classic interface drawing style"},
{TH_IFACE_STYLE_FLAT, "FLAT", 0, "Flat", "Use a flat interface drawing style"},
{0, NULL, 0, NULL, NULL}
};
rna_def_userdef_theme_ui_wcol(brna);
rna_def_userdef_theme_ui_wcol_state(brna);
rna_def_userdef_theme_ui_panel(brna);
@@ -1119,6 +1132,18 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "State Colors", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "interface_style", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "interface_style");
RNA_def_property_enum_items(prop, interface_style_items);
RNA_def_property_ui_text(prop, "Interface Style", "Adjusts the interface drawing for different styles");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "area_edges", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "area_edges");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Area Edges", "Color of the 1px separator between areas");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "menu_shadow_fac", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_ui_text(prop, "Menu Shadow Strength", "Blending factor for menu shadows");
RNA_def_property_range(prop, 0.01f, 1.0f);