Deduplicate code used for drawing text information at the top of space region.

This commit is contained in:
Sergey Sharybin 2011-11-30 06:03:10 +00:00
parent 377d5232d4
commit 3612a8d3d4
5 changed files with 41 additions and 61 deletions

@ -65,6 +65,7 @@ void ED_region_header_init(struct ARegion *ar);
void ED_region_header(const struct bContext *C, struct ARegion *ar);
void ED_region_toggle_hidden(struct bContext *C, struct ARegion *ar);
void region_scissor_winrct(struct ARegion *ar, struct rcti *winrct);
void ED_region_info_draw(struct ARegion *ar, const char *text, int block, float alpha);
/* spaces */
void ED_spacetypes_init(void);

@ -1776,3 +1776,38 @@ int ED_area_headersize(void)
{
return UI_UNIT_Y+6;
}
void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha)
{
const int header_height = 18;
uiStyle *style= UI_GetStyle();
int fontid= style->widget.uifont_id;
rcti rect;
BLF_size(fontid, 11.0f, 72);
/* background box */
rect= ar->winrct;
rect.xmin= 0;
rect.ymin= ar->winrct.ymax - ar->winrct.ymin - header_height;
if(block) {
rect.xmax= ar->winrct.xmax - ar->winrct.xmin;
}
else {
rect.xmax= rect.xmin + BLF_width(fontid, text) + 24;
}
rect.ymax= ar->winrct.ymax - ar->winrct.ymin;
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0.0f, 0.0f, 0.0f, alpha);
glRecti(rect.xmin, rect.ymin, rect.xmax+1, rect.ymax+1);
glDisable(GL_BLEND);
/* text */
UI_ThemeColor(TH_TEXT_HI);
BLF_position(fontid, 12, rect.ymin + 5, 0.0f);
BLF_draw(fontid, text, strlen(text));
}

@ -204,29 +204,8 @@ static void draw_movieclip_notes(SpaceClip *sc, ARegion *ar)
strcpy(str, "Locked");
}
if(str[0]) {
uiStyle *style= UI_GetStyle();
int fontid= style->widget.uifont_id;
int fontwidth;
BLF_size(fontid, 11.0f, 72);
if(block)
fontwidth= ar->winx;
else
fontwidth= BLF_width(fontid, str);
glEnable(GL_BLEND);
glColor4f(0.0f, 0.0f, 0.0f, 0.6f);
glRecti(0, ar->winy-17, fontwidth+12, ar->winy);
glColor3f(1.0f, 1.0f, 1.0f);
BLF_position(fontid, 6.0f, ar->winy-13.0f, 0.0f);
BLF_draw(fontid, str, strlen(str));
glDisable(GL_BLEND);
}
if(str[0])
ED_region_info_draw(ar, str, block, 0.6f);
}
static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf,

@ -63,6 +63,7 @@
#include "ED_gpencil.h"
#include "ED_image.h"
#include "ED_screen.h"
#include "UI_interface.h"
#include "UI_resources.h"
@ -99,29 +100,11 @@ static void image_verify_buffer_float(Image *ima, ImBuf *ibuf, int color_manage)
static void draw_render_info(Scene *scene, Image *ima, ARegion *ar)
{
RenderResult *rr;
rcti rect;
float colf[3];
rr= BKE_image_acquire_renderresult(scene, ima);
if(rr && rr->text) {
rect= ar->winrct;
rect.xmin= 0;
rect.ymin= ar->winrct.ymax - ar->winrct.ymin - HEADER_HEIGHT;
rect.xmax= ar->winrct.xmax - ar->winrct.xmin;
rect.ymax= ar->winrct.ymax - ar->winrct.ymin;
/* clear header rect */
UI_GetThemeColor3fv(TH_BACK, colf);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glColor4f(colf[0]+0.1f, colf[1]+0.1f, colf[2]+0.1f, 0.5f);
glRecti(rect.xmin, rect.ymin, rect.xmax, rect.ymax+1);
glDisable(GL_BLEND);
UI_ThemeColor(TH_TEXT_HI);
UI_DrawString(12, rect.ymin + 5, rr->text);
ED_region_info_draw(ar, rr->text, 1, 0.25);
}
BKE_image_release_renderresult(scene, ima);

@ -2647,28 +2647,10 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar)
static void view3d_main_area_draw_engine_info(RegionView3D *rv3d, ARegion *ar)
{
rcti rect;
const int header_height = 18;
if(!rv3d->render_engine || !rv3d->render_engine->text)
return;
/* background box */
rect= ar->winrct;
rect.xmin= 0;
rect.ymin= ar->winrct.ymax - ar->winrct.ymin - header_height;
rect.xmax= ar->winrct.xmax - ar->winrct.xmin;
rect.ymax= ar->winrct.ymax - ar->winrct.ymin;
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0.0f, 0.0f, 0.0f, 0.25f);
glRecti(rect.xmin, rect.ymin, rect.xmax+1, rect.ymax+1);
glDisable(GL_BLEND);
/* text */
UI_ThemeColor(TH_TEXT_HI);
UI_DrawString(12, rect.ymin + 5, rv3d->render_engine->text);
ED_region_info_draw(ar, rv3d->render_engine->text, 1, 0.25);
}
/* warning: this function has duplicate drawing in ED_view3d_draw_offscreen() */