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:
authorSeverin <eiseljulian@gmail.com>2019-01-04 23:40:16 +0300
committerJulian Eisel <eiseljulian@gmail.com>2019-01-05 00:18:23 +0300
commita77b63c56943ebd0046f738e6abbea4c85dc65b6 (patch)
tree173dddb28838298d2319f4f062586ba8985728c1 /source/blender/editors
parent4b486eaec9763108fd471b7705133c45116df966 (diff)
UI: Preferences Redesign Part 2
(Part 1 was 00963afc14978b) Does the following changes visible to users: * Use panels and sub-panels for more structured & logical grouping * Re-organized options more logically than before (see images in D4148) * Use flow layout (single column by default). * New layout uses horizontal margin if there's enough space. * Change size of Preferences window to suit new layout. * Move keymap related options from "Input" into own section. * Own, left-bottom aligned region for Save Preferences button. * Adjustments of names, tooltips & icons. * Move buttons from header into the main region (except editor switch). * Hide Preferences header when opened in temporary window. * Use full area width for header. * Don't use slider but regular number widget for UI scale. * Gray out animation player path option if player isn't "Custom" Internal changes: * Rearrange RNA properties to match changed UI structure. * Introduces new "EXECUTE" region type, see reasoning in D3982. * Changes to panel layout and AZone code for dynamic panel region. * Bumps subversion and does versioning for new regions. RNA changes are documented in the release notes: https://wiki.blender.org/wiki/Reference/Release_Notes/2.80/Python_API/Preferences_API Design & implementation mostly done by @billreynish and myself. I recommend checking out the screenshots posted by William: https://developer.blender.org/D4148#93787 Reviewed By: brecht Maniphest Tasks: T54115 Differential Revision: https://developer.blender.org/D4148
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/ED_screen.h2
-rw-r--r--source/blender/editors/interface/interface_layout.c4
-rw-r--r--source/blender/editors/interface/interface_ops.c2
-rw-r--r--source/blender/editors/interface/interface_panel.c2
-rw-r--r--source/blender/editors/interface/resources.c2
-rw-r--r--source/blender/editors/screen/area.c70
-rw-r--r--source/blender/editors/screen/screen_edit.c4
-rw-r--r--source/blender/editors/screen/screen_intern.h1
-rw-r--r--source/blender/editors/screen/screen_ops.c51
-rw-r--r--source/blender/editors/space_userpref/space_userpref.c43
10 files changed, 105 insertions, 76 deletions
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 4adf040f1ea..9ad4c06dee6 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -143,7 +143,7 @@ void ED_area_tag_redraw_no_rebuild(ScrArea *sa);
void ED_area_tag_redraw_regiontype(ScrArea *sa, int type);
void ED_area_tag_refresh(ScrArea *sa);
void ED_area_do_refresh(struct bContext *C, ScrArea *sa);
-void ED_area_azones_update(ScrArea *sa, const int mouse_xy[]);
+struct AZone *ED_area_azones_update(ScrArea *sa, const int mouse_xy[]);
void ED_area_status_text(ScrArea *sa, const char *str);
void ED_area_newspace(struct bContext *C, ScrArea *sa, int type, const bool skip_ar_exit);
void ED_area_prevspace(struct bContext *C, ScrArea *sa);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 45c0498cda6..09033a5f56d 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -658,7 +658,6 @@ static void ui_item_enum_expand_exec(
uiLayout *layout_radial = NULL;
const EnumPropertyItem *item, *item_array;
const char *name;
- char group_name[UI_MAX_NAME_STR];
int itemw, icon, value;
bool free;
bool radial = (layout->root->type == UI_LAYOUT_PIEMENU);
@@ -703,8 +702,7 @@ static void ui_item_enum_expand_exec(
if (!is_first) {
uiItemS(block->curlayout);
}
- BLI_snprintf(group_name, sizeof(group_name), "%s:", item->name);
- uiItemL(block->curlayout, group_name, item->icon);
+ uiItemL(block->curlayout, item->name, item->icon);
}
else if (radial && layout_radial) {
uiItemS(layout_radial);
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 1cb9f156eeb..484debf554c 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -1345,7 +1345,7 @@ static int edittranslation_exec(bContext *C, wmOperator *op)
if (!BLI_is_dir(root)) {
BKE_report(
op->reports, RPT_ERROR,
- "Please set your User Preferences' 'Translation Branches "
+ "Please set your Preferences' 'Translation Branches "
"Directory' path to a valid directory");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 610c0d33bc9..469720c2d30 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -147,7 +147,7 @@ static int panel_aligned(ScrArea *sa, ARegion *ar)
return BUT_VERTICAL;
else if (sa->spacetype == SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW)
return BUT_VERTICAL;
- else if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS, RGN_TYPE_HUD, RGN_TYPE_NAV_BAR))
+ else if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS, RGN_TYPE_HUD, RGN_TYPE_NAV_BAR, RGN_TYPE_EXECUTE))
return BUT_VERTICAL;
return 0;
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index fc761cedb8e..d7451b0d0e4 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -183,6 +183,8 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
cp = ts->header;
else if (theme_regionid == RGN_TYPE_NAV_BAR)
cp = ts->navigation_bar;
+ else if (theme_regionid == RGN_TYPE_EXECUTE)
+ cp = ts->execution_buts;
else
cp = ts->button;
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 47c44468bc7..34a20c8ccf7 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -187,52 +187,6 @@ void ED_area_do_refresh(bContext *C, ScrArea *sa)
}
/**
- * Action zones are only updated if the mouse is inside of them, but in some cases (currently only fullscreen icon)
- * it might be needed to update their properties and redraw if the mouse isn't inside.
- */
-void ED_area_azones_update(ScrArea *sa, const int mouse_xy[2])
-{
- AZone *az;
- bool changed = false;
-
- for (az = sa->actionzones.first; az; az = az->next) {
- if (az->type == AZONE_FULLSCREEN) {
- /* only if mouse is not hovering the azone */
- if (BLI_rcti_isect_pt_v(&az->rect, mouse_xy) == false) {
- az->alpha = 0.0f;
- changed = true;
-
- /* can break since currently only this is handled here */
- break;
- }
- }
- else if (az->type == AZONE_REGION_SCROLL) {
- /* only if mouse is not hovering the azone */
- if (BLI_rcti_isect_pt_v(&az->rect, mouse_xy) == false) {
- View2D *v2d = &az->ar->v2d;
-
- if (az->direction == AZ_SCROLL_VERT) {
- az->alpha = v2d->alpha_vert = 0;
- changed = true;
- }
- else if (az->direction == AZ_SCROLL_HOR) {
- az->alpha = v2d->alpha_hor = 0;
- changed = true;
- }
- else {
- BLI_assert(0);
- }
- }
- }
- }
-
- if (changed) {
- sa->flag &= ~AREA_FLAG_ACTIONZONES_UPDATE;
- ED_area_tag_redraw_no_rebuild(sa);
- }
-}
-
-/**
* \brief Corner widget use for quitting fullscreen.
*/
static void area_draw_azone_fullscreen(short x1, short y1, short x2, short y2, float alpha)
@@ -412,18 +366,11 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar)
}
else if (az->type == AZONE_FULLSCREEN) {
area_draw_azone_fullscreen(az->x1, az->y1, az->x2, az->y2, az->alpha);
-
- if (az->alpha != 0.0f) {
- area_azone_tag_update(sa);
- }
- }
- else if (az->type == AZONE_REGION_SCROLL) {
- if (az->alpha != 0.0f) {
- area_azone_tag_update(sa);
- }
- /* Don't draw this azone. */
}
}
+ if (!IS_EQF(az->alpha, 0.0f) && ELEM(az->type, AZONE_FULLSCREEN, AZONE_REGION_SCROLL)) {
+ area_azone_tag_update(sa);
+ }
}
GPU_matrix_pop();
@@ -1605,6 +1552,7 @@ void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *ar
if (!(area->flag & AREA_FLAG_REGION_SIZE_UPDATE)) {
return;
}
+ const bScreen *screen = WM_window_get_active_screen(win);
WM_window_rect_calc(win, &window_rect);
area_calc_totrct(area, &window_rect);
@@ -1614,6 +1562,9 @@ void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *ar
overlap_rect = rect;
region_rect_recursive(area, area->regionbase.first, &rect, &overlap_rect, 0);
+ /* Dynamically sized regions may have changed region sizes, so we have to force azone update. */
+ area_azone_initialize(win, screen, area);
+
for (ARegion *ar = area->regionbase.first; ar; ar = ar->next) {
region_subwindow(ar);
@@ -1621,7 +1572,11 @@ void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *ar
if (ar->type->init) {
ar->type->init(wm, ar);
}
+
+ /* Some AZones use View2D data which is only updated in region init, so call that first! */
+ region_azones_add(screen, area, ar, ar->alignment & ~RGN_SPLIT_PREV);
}
+ ED_area_azones_update(area, &win->eventstate->x);
area->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE;
}
@@ -2386,6 +2341,9 @@ void ED_region_panels_draw(const bContext *C, ARegion *ar)
/* set the view */
UI_view2d_view_ortho(v2d);
+ /* View2D matrix might have changed due to dynamic sized regions. */
+ UI_blocklist_update_window_matrix(C, &ar->uiblocks);
+
/* draw panels */
UI_panels_draw(C, ar);
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 62d60c39c0c..7e6e31d339d 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -639,7 +639,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
ED_screen_areas_iter(win, scr, area_iter) {
if (xy[0] > area_iter->totrct.xmin && xy[0] < area_iter->totrct.xmax) {
if (xy[1] > area_iter->totrct.ymin && xy[1] < area_iter->totrct.ymax) {
- if (ED_area_actionzone_refresh_xy(area_iter, xy) == NULL) {
+ if (ED_area_azones_update(area_iter, xy) == NULL) {
sa = area_iter;
break;
}
@@ -1251,7 +1251,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
for (ar = newa->regionbase.first; ar; ar = ar->next) {
ar->flagfullscreen = ar->flag;
- if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_HEADER, RGN_TYPE_TOOLS, RGN_TYPE_NAV_BAR)) {
+ if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_HEADER, RGN_TYPE_TOOLS, RGN_TYPE_NAV_BAR, RGN_TYPE_EXECUTE)) {
ar->flag |= RGN_FLAG_HIDDEN;
}
}
diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h
index 7722f2c9fcc..5f36f4a06ab 100644
--- a/source/blender/editors/screen/screen_intern.h
+++ b/source/blender/editors/screen/screen_intern.h
@@ -57,7 +57,6 @@ int screen_area_join(struct bContext *C, bScreen *scr, ScrArea *sa1, Scr
int area_getorientation(ScrArea *sa, ScrArea *sb);
struct AZone *ED_area_actionzone_find_xy(ScrArea *sa, const int xy[2]);
-struct AZone *ED_area_actionzone_refresh_xy(ScrArea *sa, const int xy[2]);
/* screen_geometry.c */
int screen_geom_area_height(const ScrArea *area);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index d41bf8d937b..62b4db94937 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -798,6 +798,32 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo
}
}
}
+ else if (!test_only && !IS_EQF(az->alpha, 0.0f)) {
+ bool changed = false;
+
+ if (az->type == AZONE_FULLSCREEN) {
+ az->alpha = 0.0f;
+ changed = true;
+ }
+ else if (az->type == AZONE_REGION_SCROLL) {
+ if (az->direction == AZ_SCROLL_VERT) {
+ az->alpha = az->ar->v2d.alpha_vert = 0;
+ changed = true;
+ }
+ else if (az->direction == AZ_SCROLL_HOR) {
+ az->alpha = az->ar->v2d.alpha_hor = 0;
+ changed = true;
+ }
+ else {
+ BLI_assert(0);
+ }
+ }
+
+ if (changed) {
+ sa->flag &= ~AREA_FLAG_ACTIONZONES_UPDATE;
+ ED_area_tag_redraw_no_rebuild(sa);
+ }
+ }
}
return az;
@@ -808,7 +834,7 @@ AZone *ED_area_actionzone_find_xy(ScrArea *sa, const int xy[2])
return area_actionzone_refresh_xy(sa, xy, true);
}
-AZone *ED_area_actionzone_refresh_xy(ScrArea *sa, const int xy[2])
+AZone *ED_area_azones_update(ScrArea *sa, const int xy[2])
{
return area_actionzone_refresh_xy(sa, xy, false);
}
@@ -2382,8 +2408,12 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (!(rmd->ar->flag & RGN_FLAG_HIDDEN))
region_scale_toggle_hidden(C, rmd);
}
- else if (rmd->ar->flag & RGN_FLAG_HIDDEN)
+ else if (rmd->ar->flag & RGN_FLAG_HIDDEN) {
region_scale_toggle_hidden(C, rmd);
+ }
+ else if (rmd->ar->flag & RGN_FLAG_DYNAMIC_SIZE) {
+ rmd->ar->sizex = rmd->origval;
+ }
}
else {
int maxsize = region_scale_get_maxsize(rmd);
@@ -2411,10 +2441,15 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (!(rmd->ar->flag & RGN_FLAG_HIDDEN))
region_scale_toggle_hidden(C, rmd);
}
- else if (maxsize > 0 && (rmd->ar->sizey > maxsize))
+ else if (maxsize > 0 && (rmd->ar->sizey > maxsize)) {
rmd->ar->sizey = maxsize;
- else if (rmd->ar->flag & RGN_FLAG_HIDDEN)
+ }
+ else if (rmd->ar->flag & RGN_FLAG_HIDDEN) {
region_scale_toggle_hidden(C, rmd);
+ }
+ else if (rmd->ar->flag & RGN_FLAG_DYNAMIC_SIZE) {
+ rmd->ar->sizey = rmd->origval;
+ }
}
ED_area_tag_redraw(rmd->sa);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
@@ -4349,11 +4384,15 @@ static void SCREEN_OT_back_to_previous(struct wmOperatorType *ot)
static int userpref_show_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- int sizex = (800 + UI_NAVIGATION_REGION_WIDTH) * UI_DPI_FAC;
- int sizey = 500 * UI_DPI_FAC;
+ int sizex = (500 + UI_NAVIGATION_REGION_WIDTH) * UI_DPI_FAC;
+ int sizey = 520 * UI_DPI_FAC;
/* changes context! */
if (WM_window_open_temp(C, event->x, event->y, sizex, sizey, WM_WINDOW_USERPREFS) != NULL) {
+ /* The header only contains the editor switcher and looks empty. So hiding in the temp window makes sense. */
+ ScrArea *area = CTX_wm_area(C);
+ ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_HEADER);
+ region->flag |= RGN_FLAG_HIDDEN;
return OPERATOR_FINISHED;
}
else {
diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c
index a0a263cb5de..497cca22ba6 100644
--- a/source/blender/editors/space_userpref/space_userpref.c
+++ b/source/blender/editors/space_userpref/space_userpref.c
@@ -61,6 +61,14 @@ static SpaceLink *userpref_new(const ScrArea *UNUSED(area), const Scene *UNUSED(
spref = MEM_callocN(sizeof(SpaceUserPref), "inituserpref");
spref->spacetype = SPACE_USERPREF;
+ /* header */
+ ar = MEM_callocN(sizeof(ARegion), "header for userpref");
+
+ BLI_addtail(&spref->regionbase, ar);
+ ar->regiontype = RGN_TYPE_HEADER;
+ /* Ignore user preference "USER_HEADER_BOTTOM" here (always show bottom for new types). */
+ ar->alignment = RGN_ALIGN_BOTTOM;
+
/* navigation region */
ar = MEM_callocN(sizeof(ARegion), "navigation region for userpref");
@@ -68,13 +76,13 @@ static SpaceLink *userpref_new(const ScrArea *UNUSED(area), const Scene *UNUSED(
ar->regiontype = RGN_TYPE_NAV_BAR;
ar->alignment = RGN_ALIGN_LEFT;
- /* header */
- ar = MEM_callocN(sizeof(ARegion), "header for userpref");
+ /* execution region */
+ ar = MEM_callocN(sizeof(ARegion), "execution region for userpref");
BLI_addtail(&spref->regionbase, ar);
- ar->regiontype = RGN_TYPE_HEADER;
- /* Ignore user preference "USER_HEADER_BOTTOM" here (always show bottom for new types). */
- ar->alignment = RGN_ALIGN_BOTTOM;
+ ar->regiontype = RGN_TYPE_EXECUTE;
+ ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
+ ar->flag |= RGN_FLAG_DYNAMIC_SIZE;
/* main region */
ar = MEM_callocN(sizeof(ARegion), "main region for userpref");
@@ -159,6 +167,13 @@ static void userpref_navigation_region_draw(const bContext *C, ARegion *ar)
ED_region_panels(C, ar);
}
+/* add handlers, stuff you only do once or on area/region changes */
+static void userpref_execute_region_init(wmWindowManager *wm, ARegion *ar)
+{
+ ED_region_panels_init(wm, ar);
+ ar->v2d.keepzoom |= V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y;
+}
+
static void userpref_main_region_listener(
wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene))
@@ -186,6 +201,13 @@ static void userpref_navigation_region_listener(
/* context changes */
}
+static void userpref_execute_region_listener(
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
+ wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene))
+{
+ /* context changes */
+}
+
/* only called once, from space/spacetypes.c */
void ED_spacetype_userpref(void)
{
@@ -234,6 +256,17 @@ void ED_spacetype_userpref(void)
BLI_addhead(&st->regiontypes, art);
+ /* regions: execution window */
+ art = MEM_callocN(sizeof(ARegionType), "spacetype userpref region");
+ art->regionid = RGN_TYPE_EXECUTE;
+ art->init = userpref_execute_region_init;
+ art->layout = ED_region_panels_layout;
+ art->draw = ED_region_panels_draw;
+ art->listener = userpref_execute_region_listener;
+ art->keymapflag = ED_KEYMAP_UI;
+
+ BLI_addhead(&st->regiontypes, art);
+
BKE_spacetype_register(st);
}