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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/screen/area.c')
-rw-r--r--source/blender/editors/screen/area.c142
1 files changed, 103 insertions, 39 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 79d6b845361..3511480821a 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -409,6 +409,7 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar)
if (!sa)
return;
+ glLineWidth(1.0f);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -501,7 +502,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
/* note; this sets state, so we can use wmOrtho and friends */
wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct, scissor_pad);
- wmOrtho2_region_ui(ar);
+ wmOrtho2_region_pixelspace(ar);
UI_SetTheme(sa ? sa->spacetype : 0, at->regionid);
@@ -1338,7 +1339,7 @@ static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
/* used for area initialize below */
-static void region_subwindow(wmWindow *win, ARegion *ar)
+static void region_subwindow(wmWindow *win, ARegion *ar, bool activate)
{
bool hidden = (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) != 0;
@@ -1350,10 +1351,12 @@ static void region_subwindow(wmWindow *win, ARegion *ar)
wm_subwindow_close(win, ar->swinid);
ar->swinid = 0;
}
- else if (ar->swinid == 0)
- ar->swinid = wm_subwindow_open(win, &ar->winrct);
- else
- wm_subwindow_position(win, ar->swinid, &ar->winrct);
+ else if (ar->swinid == 0) {
+ ar->swinid = wm_subwindow_open(win, &ar->winrct, activate);
+ }
+ else {
+ wm_subwindow_position(win, ar->swinid, &ar->winrct, activate);
+ }
}
static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *handlers, int flag)
@@ -1456,7 +1459,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
/* region windows, default and own handlers */
for (ar = sa->regionbase.first; ar; ar = ar->next) {
- region_subwindow(win, ar);
+ region_subwindow(win, ar, false);
if (ar->swinid) {
/* default region handlers */
@@ -1497,13 +1500,23 @@ void ED_region_update_rect(bContext *C, ARegion *ar)
void ED_region_init(bContext *C, ARegion *ar)
{
// ARegionType *at = ar->type;
-
+
/* refresh can be called before window opened */
- region_subwindow(CTX_wm_window(C), ar);
-
+ region_subwindow(CTX_wm_window(C), ar, false);
+
region_update_rect(ar);
}
+void ED_region_cursor_set(wmWindow *win, ScrArea *sa, ARegion *ar)
+{
+ if (ar && sa && ar->type && ar->type->cursor) {
+ ar->type->cursor(win, sa, ar);
+ }
+ else {
+ WM_cursor_set(win, CURSOR_STD);
+ }
+}
+
/* for quick toggle, can skip fades */
void region_toggle_hidden(bContext *C, ARegion *ar, const bool do_fade)
{
@@ -1608,15 +1621,31 @@ void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2)
ED_area_tag_refresh(sa2);
}
-void ED_area_newspace(bContext *C, ScrArea *sa, int type)
+/**
+ * \param skip_ar_exit Skip calling area exit callback. Set for opening temp spaces.
+ */
+void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exit)
{
if (sa->spacetype != type) {
SpaceType *st;
SpaceLink *slold;
SpaceLink *sl;
+ /* store sa->type->exit callback */
+ void *sa_exit = sa->type ? sa->type->exit : NULL;
+
+ /* in some cases (opening temp space) we don't want to
+ * call area exit callback, so we temporarily unset it */
+ if (skip_ar_exit && sa->type) {
+ sa->type->exit = NULL;
+ }
ED_area_exit(C, sa);
+ /* restore old area exit callback */
+ if (skip_ar_exit && sa->type) {
+ sa->type->exit = sa_exit;
+ }
+
st = BKE_spacetype_from_id(type);
slold = sa->spacedata.first;
@@ -1683,12 +1712,12 @@ void ED_area_prevspace(bContext *C, ScrArea *sa)
SpaceLink *sl = sa->spacedata.first;
if (sl && sl->next) {
- /* workaround for case of double prevspace, render window
- * with a file browser on top of it */
- if (sl->next->spacetype == SPACE_FILE && sl->next->next)
- ED_area_newspace(C, sa, sl->next->next->spacetype);
- else
- ED_area_newspace(C, sa, sl->next->spacetype);
+ ED_area_newspace(C, sa, sl->next->spacetype, false);
+
+ /* keep old spacedata but move it to end, so calling
+ * ED_area_prevspace once more won't open it again */
+ BLI_remlink(&sa->spacedata, sl);
+ BLI_addtail(&sa->spacedata, sl);
}
else {
/* no change */
@@ -1734,7 +1763,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c
int redo;
int scroll;
- bool use_category_tabs = (ar->regiontype == RGN_TYPE_TOOLS); /* XXX, should use some better check? */
+ bool use_category_tabs = (ELEM(ar->regiontype, RGN_TYPE_TOOLS, RGN_TYPE_UI)); /* XXX, should use some better check? */
/* offset panels for small vertical tab area */
const char *category = NULL;
const int category_tabs_width = UI_PANEL_CATEGORY_MARGIN_WIDTH;
@@ -1940,6 +1969,8 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c
glClear(GL_COLOR_BUFFER_BIT);
}
+ /* reset line width for drawing tabs */
+ glLineWidth(1.0f);
/* set the view */
UI_view2d_view_ortho(v2d);
@@ -2083,9 +2114,9 @@ static const char *meta_data_list[] =
{
"File",
"Strip",
- "Note",
"Date",
"RenderTime",
+ "Note",
"Marker",
"Time",
"Frame",
@@ -2106,7 +2137,15 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const
short i;
int len;
const float height = BLF_height_max(fontid);
- const float vertical_offset = height + (0.1f * U.widget_unit);
+ const float margin = height / 8;
+ const float vertical_offset = (height + margin);
+
+ /* values taking margins into account */
+ const float descender = BLF_descender(fontid);
+ const float xmin = (rect->xmin + margin);
+ const float xmax = (rect->xmax - margin);
+ const float ymin = (rect->ymin + margin) - descender;
+ const float ymax = (rect->ymax - margin) - descender;
if (is_top) {
for (i = 0; i < 4; i++) {
@@ -2115,8 +2154,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const
bool do_newline = false;
len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[0]);
if (metadata_is_valid(ibuf, temp_str, 0, len)) {
- BLF_position(fontid, rect->xmin + (0.2f * U.widget_unit),
- rect->ymax - vertical_offset, 0.0f);
+ BLF_position(fontid, xmin, ymax - vertical_offset, 0.0f);
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
do_newline = true;
}
@@ -2124,30 +2162,40 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const
len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[1]);
if (metadata_is_valid(ibuf, temp_str, 1, len)) {
line_width = BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
- BLF_position(fontid, rect->xmax - line_width - (0.2f * U.widget_unit),
- rect->ymax - vertical_offset, 0.0f);
+ BLF_position(fontid, xmax - line_width, ymax - vertical_offset, 0.0f);
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
do_newline = true;
}
if (do_newline)
ofs_y += vertical_offset;
- }
- else if (i == 1) {
+ } /* Strip */
+ else if (i == 1 || i == 2) {
len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
- BLF_position(fontid, rect->xmin + (0.2f * U.widget_unit),
- rect->ymax - vertical_offset - ofs_y, 0.0f);
+ BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f);
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
ofs_y += vertical_offset;
}
+ } /* Note (wrapped) */
+ else if (i == 3) {
+ len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
+ if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
+ struct ResultBLF info;
+ BLF_enable(fontid, BLF_WORD_WRAP);
+ BLF_wordwrap(fontid, ibuf->x - (margin * 2));
+ BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f);
+ BLF_draw_ex(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX, &info);
+ BLF_wordwrap(fontid, 0);
+ BLF_disable(fontid, BLF_WORD_WRAP);
+ ofs_y += vertical_offset * info.lines;
+ }
}
else {
len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
line_width = BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
- BLF_position(fontid, rect->xmax - line_width - (0.2f * U.widget_unit),
- rect->ymax - vertical_offset - ofs_y, 0.0f);
+ BLF_position(fontid, xmax - line_width, ymax - vertical_offset - ofs_y, 0.0f);
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
ofs_y += vertical_offset;
}
@@ -2159,8 +2207,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const
for (i = 5; i < 10; i++) {
len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i]);
if (metadata_is_valid(ibuf, temp_str, i, len)) {
- BLF_position(fontid, rect->xmin + (0.2f * U.widget_unit) + ofs_x,
- rect->ymin + (0.3f * U.widget_unit), 0.0f);
+ BLF_position(fontid, xmin + ofs_x, ymin, 0.0f);
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
ofs_x += BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX) + UI_UNIT_X;
@@ -2171,9 +2218,10 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const
static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
{
+ const float height = BLF_height_max(fontid);
+ const float margin = (height / 8);
char str[MAX_METADATA_STR] = "";
short i, count = 0;
- const float height = BLF_height_max(fontid) + 0.1f * U.widget_unit;
if (is_top) {
if (metadata_is_valid(ibuf, str, 0, 0) || metadata_is_valid(ibuf, str, 1, 0)) {
@@ -2181,7 +2229,23 @@ static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
}
for (i = 2; i < 5; i++) {
if (metadata_is_valid(ibuf, str, i, 0)) {
- count++;
+ if (i == 4) {
+ struct {
+ struct ResultBLF info;
+ rctf rect;
+ } wrap;
+
+ BLF_enable(fontid, BLF_WORD_WRAP);
+ BLF_wordwrap(fontid, ibuf->x - (margin * 2));
+ BLF_boundbox_ex(fontid, str, sizeof(str), &wrap.rect, &wrap.info);
+ BLF_wordwrap(fontid, 0);
+ BLF_disable(fontid, BLF_WORD_WRAP);
+
+ count += wrap.info.lines;
+ }
+ else {
+ count++;
+ }
}
}
}
@@ -2194,7 +2258,7 @@ static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
}
if (count) {
- return (height * count + (0.1f * U.widget_unit));
+ return (height + margin) * count;
}
return 0;
@@ -2202,7 +2266,7 @@ static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
#undef MAX_METADATA_STR
-void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, rctf frame, float zoomx, float zoomy)
+void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy)
{
float box_y;
rctf rect;
@@ -2218,7 +2282,7 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, rctf frame, float
glTranslatef(x, y, 0.0f);
glScalef(zoomx, zoomy, 1.0f);
- BLF_size(blf_mono_font, style->widgetlabel.points * 1.5f, U.dpi);
+ BLF_size(blf_mono_font, style->widgetlabel.points * 1.5f * U.pixelsize, U.dpi);
/* *** upper box*** */
@@ -2229,7 +2293,7 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, rctf frame, float
UI_ThemeColor(TH_METADATA_BG);
/* set up rect */
- BLI_rctf_init(&rect, frame.xmin, frame.xmax, frame.ymax, frame.ymax + box_y);
+ BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymax, frame->ymax + box_y);
/* draw top box */
glRectf(rect.xmin, rect.ymin, rect.xmax, rect.ymax);
@@ -2251,7 +2315,7 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, rctf frame, float
UI_ThemeColor(TH_METADATA_BG);
/* set up box rect */
- BLI_rctf_init(&rect, frame.xmin, frame.xmax, frame.ymin - box_y, frame.ymin);
+ BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymin - box_y, frame->ymin);
/* draw top box */
glRectf(rect.xmin, rect.ymin, rect.xmax, rect.ymax);