Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/screen_geometry.c
| Show First 20 Lines • Show All 298 Lines • ▼ Show 20 Lines | void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen) | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * \return 0 if no split is possible, otherwise the screen-coordinate at which to split. | * \return 0 if no split is possible, otherwise the screen-coordinate at which to split. | ||||
| */ | */ | ||||
| short screen_geom_find_area_split_point(const ScrArea *area, | short screen_geom_find_area_split_point(const ScrArea *area, | ||||
| const rcti *window_rect, | const rcti *window_rect, | ||||
| char dir, | const eScreenAxis dir_axis, | ||||
| float fac) | float fac) | ||||
| { | { | ||||
| const int cur_area_width = screen_geom_area_width(area); | const int cur_area_width = screen_geom_area_width(area); | ||||
| const int cur_area_height = screen_geom_area_height(area); | const int cur_area_height = screen_geom_area_height(area); | ||||
| const short area_min_x = AREAMINX; | const short area_min_x = AREAMINX; | ||||
| const short area_min_y = ED_area_headersize(); | const short area_min_y = ED_area_headersize(); | ||||
| /* area big enough? */ | /* area big enough? */ | ||||
| if ((dir == 'v') && (cur_area_width <= 2 * area_min_x)) { | if (dir_axis == SCREEN_AXIS_V) { | ||||
| if (cur_area_width <= 2 * area_min_x) { | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| if ((dir == 'h') && (cur_area_height <= 2 * area_min_y)) { | } | ||||
| else if (dir_axis == SCREEN_AXIS_H) { | |||||
| if (cur_area_height <= 2 * area_min_y) { | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| } | |||||
| /* to be sure */ | /* to be sure */ | ||||
| CLAMP(fac, 0.0f, 1.0f); | CLAMP(fac, 0.0f, 1.0f); | ||||
| if (dir == 'h') { | if (dir_axis == SCREEN_AXIS_H) { | ||||
| short y = area->v1->vec.y + round_fl_to_short(fac * cur_area_height); | short y = area->v1->vec.y + round_fl_to_short(fac * cur_area_height); | ||||
| int area_min = area_min_y; | int area_min = area_min_y; | ||||
| if (area->v1->vec.y > window_rect->ymin) { | if (area->v1->vec.y > window_rect->ymin) { | ||||
| area_min += U.pixelsize; | area_min += U.pixelsize; | ||||
| } | } | ||||
| if (area->v2->vec.y < (window_rect->ymax - 1)) { | if (area->v2->vec.y < (window_rect->ymax - 1)) { | ||||
| Show All 33 Lines | |||||
| /** | /** | ||||
| * Select all edges that are directly or indirectly connected to \a edge. | * Select all edges that are directly or indirectly connected to \a edge. | ||||
| */ | */ | ||||
| void screen_geom_select_connected_edge(const wmWindow *win, ScrEdge *edge) | void screen_geom_select_connected_edge(const wmWindow *win, ScrEdge *edge) | ||||
| { | { | ||||
| bScreen *screen = WM_window_get_active_screen(win); | bScreen *screen = WM_window_get_active_screen(win); | ||||
| /* 'dir' is the direction of EDGE */ | /* 'dir_axis' is the direction of EDGE */ | ||||
| char dir; | eScreenAxis dir_axis; | ||||
| if (edge->v1->vec.x == edge->v2->vec.x) { | if (edge->v1->vec.x == edge->v2->vec.x) { | ||||
| dir = 'v'; | dir_axis = SCREEN_AXIS_V; | ||||
| } | } | ||||
| else { | else { | ||||
| dir = 'h'; | dir_axis = SCREEN_AXIS_H; | ||||
| } | } | ||||
| ED_screen_verts_iter(win, screen, sv) | ED_screen_verts_iter(win, screen, sv) | ||||
| { | { | ||||
| sv->flag = 0; | sv->flag = 0; | ||||
| } | } | ||||
| edge->v1->flag = 1; | edge->v1->flag = 1; | ||||
| edge->v2->flag = 1; | edge->v2->flag = 1; | ||||
| /* select connected, only in the right direction */ | /* select connected, only in the right direction */ | ||||
| bool oneselected = true; | bool oneselected = true; | ||||
| while (oneselected) { | while (oneselected) { | ||||
| oneselected = false; | oneselected = false; | ||||
| LISTBASE_FOREACH (ScrEdge *, se, &screen->edgebase) { | LISTBASE_FOREACH (ScrEdge *, se, &screen->edgebase) { | ||||
| if (se->v1->flag + se->v2->flag == 1) { | if (se->v1->flag + se->v2->flag == 1) { | ||||
| if (dir == 'h') { | if (dir_axis == SCREEN_AXIS_H) { | ||||
| if (se->v1->vec.y == se->v2->vec.y) { | if (se->v1->vec.y == se->v2->vec.y) { | ||||
| se->v1->flag = se->v2->flag = 1; | se->v1->flag = se->v2->flag = 1; | ||||
| oneselected = true; | oneselected = true; | ||||
| } | } | ||||
| } | } | ||||
| if (dir == 'v') { | else if (dir_axis == SCREEN_AXIS_V) { | ||||
| if (se->v1->vec.x == se->v2->vec.x) { | if (se->v1->vec.x == se->v2->vec.x) { | ||||
| se->v1->flag = se->v2->flag = 1; | se->v1->flag = se->v2->flag = 1; | ||||
| oneselected = true; | oneselected = true; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||