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
path: root/source
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2018-07-02 17:48:18 +0300
committerJulian Eisel <eiseljulian@gmail.com>2018-07-02 17:56:54 +0300
commitbea364fe2a37222fc8737afdb508ca81e1b89e68 (patch)
tree3002dbb7be5056b9364d2e34d787e2b776e6aee7 /source
parent878b09562cd5617dea32dbc354ebb484def99f8b (diff)
Fix: Global area edges couldn't call right click menu to join/split
Operators ignored edges along the screen-layout bounds. They should've ignored those along window bounds instead. Although the global areas can not be joined/split, the adjacent areas can. So the menu should still be shown. Had to change the return value of area joining operator, so that an error report can show up when trying to join over a global area edge. Think this is fine to do, but you never know with such stuff. Preferably we'd gray out the "Join Area" item in the menu when clicking on the edge of a global area. Unfotunately the operator uses coordinates passed as operator properties to find the right edge/areas, which we cannot access from the poll callback.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_screen.h1
-rw-r--r--source/blender/blenkernel/intern/screen.c14
-rw-r--r--source/blender/editors/screen/screen_ops.c33
3 files changed, 32 insertions, 16 deletions
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index b6ddb8f57be..861b47aebc6 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -333,6 +333,7 @@ struct ARegion *BKE_area_find_region_active_win(struct ScrArea *sa);
struct ARegion *BKE_area_find_region_xy(struct ScrArea *sa, const int regiontype, int x, int y);
struct ScrArea *BKE_screen_find_area_from_space(struct bScreen *sc, struct SpaceLink *sl) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2);
struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype, const short min);
+struct ScrArea *BKE_screen_area_map_find_area_xy(const struct ScrAreaMap *areamap, const int spacetype, int x, int y);
struct ScrArea *BKE_screen_find_area_xy(struct bScreen *sc, const int spacetype, int x, int y);
unsigned int BKE_screen_view3d_layer_active_ex(
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 4a840b5ffbe..1c8a93981c7 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -748,19 +748,21 @@ ScrArea *BKE_screen_find_big_area(bScreen *sc, const int spacetype, const short
return big;
}
-ScrArea *BKE_screen_find_area_xy(bScreen *sc, const int spacetype, int x, int y)
+ScrArea *BKE_screen_area_map_find_area_xy(const ScrAreaMap *areamap, const int spacetype, int x, int y)
{
- ScrArea *sa, *sa_found = NULL;
-
- for (sa = sc->areabase.first; sa; sa = sa->next) {
+ for (ScrArea *sa = areamap->areabase.first; sa; sa = sa->next) {
if (BLI_rcti_isect_pt(&sa->totrct, x, y)) {
if ((spacetype == SPACE_TYPE_ANY) || (sa->spacetype == spacetype)) {
- sa_found = sa;
+ return sa;
}
break;
}
}
- return sa_found;
+ return NULL;
+}
+ScrArea *BKE_screen_find_area_xy(bScreen *sc, const int spacetype, int x, int y)
+{
+ return BKE_screen_area_map_find_area_xy(AREAMAP_FROM_SCREEN(sc), spacetype, x, y);
}
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index f449272bc72..188592d6129 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -1899,7 +1899,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
else {
ScrEdge *actedge;
- rcti screen_rect;
+ rcti window_rect;
int event_co[2];
/* retrieve initial mouse coord, so we can find the active edge */
@@ -1910,10 +1910,10 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
copy_v2_v2_int(event_co, &event->x);
}
- WM_window_screen_rect_calc(win, &screen_rect);
+ WM_window_rect_calc(win, &window_rect);
actedge = screen_geom_area_map_find_active_scredge(
- AREAMAP_FROM_SCREEN(sc), &screen_rect, event_co[0], event_co[1]);
+ AREAMAP_FROM_SCREEN(sc), &window_rect, event_co[0], event_co[1]);
if (actedge == NULL) {
return OPERATOR_CANCELLED;
}
@@ -2894,6 +2894,8 @@ static void area_join_draw_cb(const struct wmWindow *UNUSED(win), void *userdata
/* XXX todo: find edge based on (x,y) and set other area? */
static int area_join_init(bContext *C, wmOperator *op)
{
+ const wmWindow *win = CTX_wm_window(C);
+ bScreen *screen = CTX_wm_screen(C);
ScrArea *sa1, *sa2;
sAreaJoinData *jd = NULL;
int x1, y1;
@@ -2906,10 +2908,21 @@ static int area_join_init(bContext *C, wmOperator *op)
x2 = RNA_int_get(op->ptr, "max_x");
y2 = RNA_int_get(op->ptr, "max_y");
- sa1 = BKE_screen_find_area_xy(CTX_wm_screen(C), SPACE_TYPE_ANY, x1, y1);
- sa2 = BKE_screen_find_area_xy(CTX_wm_screen(C), SPACE_TYPE_ANY, x2, y2);
- if (sa1 == NULL || sa2 == NULL || sa1 == sa2)
+ sa1 = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, x1, y1);
+ if (sa1 == NULL) {
+ sa1 = BKE_screen_area_map_find_area_xy(&win->global_areas, SPACE_TYPE_ANY, x1, y1);
+ }
+ sa2 = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, x2, y2);
+ if (sa2 == NULL) {
+ sa2 = BKE_screen_area_map_find_area_xy(&win->global_areas, SPACE_TYPE_ANY, x2, y2);
+ }
+ if ((sa1 && ED_area_is_global(sa1)) || (sa2 && ED_area_is_global(sa2))) {
+ BKE_report(op->reports, RPT_ERROR, "Global areas (Top Bar, Status Bar) do not support joining");
+ return 0;
+ }
+ else if (sa1 == NULL || sa2 == NULL || sa1 == sa2) {
return 0;
+ }
/* do areas share an edge? */
if (sa1->v1 == sa2->v1 || sa1->v1 == sa2->v2 || sa1->v1 == sa2->v3 || sa1->v1 == sa2->v4) shared++;
@@ -3008,7 +3021,7 @@ static int area_join_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if (!area_join_init(C, op))
- return OPERATOR_PASS_THROUGH;
+ return OPERATOR_CANCELLED;
/* add temp handler */
WM_event_add_modal_handler(C, op);
@@ -3141,10 +3154,10 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
uiLayout *layout;
PointerRNA ptr;
ScrEdge *actedge;
- rcti screen_rect;
+ rcti window_rect;
- WM_window_screen_rect_calc(win, &screen_rect);
- actedge = screen_geom_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(sc), &screen_rect, event->x, event->y);
+ WM_window_rect_calc(win, &window_rect);
+ actedge = screen_geom_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(sc), &window_rect, event->x, event->y);
if (actedge == NULL) return OPERATOR_CANCELLED;