diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-11-30 10:03:10 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-11-30 10:03:10 +0400 |
commit | 3612a8d3d4605cac1988d58b8af561e69f4130ab (patch) | |
tree | d17140e64c962897b50c77d4e52388aa0442f2a1 /source/blender/editors | |
parent | 377d5232d4465ca23b06b6550c78b2fe1a697532 (diff) |
Deduplicate code used for drawing text information at the top of space region.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_screen.h | 1 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 35 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_draw.c | 25 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_draw.c | 21 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 20 |
5 files changed, 41 insertions, 61 deletions
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 05537004927..e0ff5cddf85 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -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); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index f7fe98edf02..7aacd9f7b86 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -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)); +} diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index a53da4ce006..3f9ec3f3c82 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -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, diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 77ac577792c..dc712e286a1 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -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); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 9899d2e5fa4..3f979787a1f 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -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() */ |