This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/editors/interface/interface_style.c

591 lines
16 KiB
C
Raw Normal View History

/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
2010-02-12 13:34:04 +00:00
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*/
/** \file
* \ingroup edinterface
2011-02-27 20:29:51 +00:00
*/
#include <limits.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "DNA_screen_types.h"
#include "DNA_userdef_types.h"
#include "BLI_listbase.h"
#include "BLI_rect.h"
#include "BLI_string.h"
2011-09-27 19:04:27 +00:00
#include "BLI_utildefines.h"
#include "BKE_global.h"
#include "BLF_api.h"
2014-11-28 15:50:43 +01:00
#ifdef WITH_INTERNATIONAL
# include "BLT_translation.h"
2014-11-28 15:50:43 +01:00
#endif
#include "UI_interface.h"
#include "ED_datafiles.h"
#include "interface_intern.h"
#ifdef WIN32
# include "BLI_math_base.h" /* M_PI */
#endif
/* style + theme + layout-engine = UI */
2015-05-31 14:20:03 +10:00
/**
* This is a complete set of layout rules, the 'state' of the Layout
* Engine. Multiple styles are possible, defined via C or Python. Styles
* get a name, and will typically get activated per region type, like
* "Header", or "Listview" or "Toolbar". Properties of Style definitions
* are:
*
* - default column properties, internal spacing, aligning, min/max width
* - button alignment rules (for groups)
* - label placement rules
* - internal labeling or external labeling default
* - default minimum widths for buttons/labels (in amount of characters)
* - font types, styles and relative sizes for Panel titles, labels, etc.
*/
/* ********************************************** */
static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id)
{
2012-03-30 01:51:25 +00:00
uiStyle *style = MEM_callocN(sizeof(uiStyle), "new style");
BLI_addtail(styles, style);
BLI_strncpy(style->name, name, MAX_STYLE_NAME);
2012-03-30 01:51:25 +00:00
style->panelzoom = 1.0; /* unused */
style->paneltitle.uifont_id = uifont_id;
style->paneltitle.points = 12;
style->paneltitle.kerning = 1;
style->paneltitle.shadow = 3;
2012-03-30 01:51:25 +00:00
style->paneltitle.shadx = 0;
style->paneltitle.shady = -1;
style->paneltitle.shadowalpha = 0.5f;
style->paneltitle.shadowcolor = 0.0f;
2012-03-30 01:51:25 +00:00
style->grouplabel.uifont_id = uifont_id;
style->grouplabel.points = 12;
style->grouplabel.kerning = 1;
style->grouplabel.shadow = 3;
style->grouplabel.shadx = 0;
style->grouplabel.shady = -1;
style->grouplabel.shadowalpha = 0.5f;
style->grouplabel.shadowcolor = 0.0f;
2012-03-30 01:51:25 +00:00
style->widgetlabel.uifont_id = uifont_id;
style->widgetlabel.points = 11;
style->widgetlabel.kerning = 1;
style->widgetlabel.shadow = 3;
style->widgetlabel.shadx = 0;
style->widgetlabel.shady = -1;
style->widgetlabel.shadowalpha = 0.5f;
style->widgetlabel.shadowcolor = 0.0f;
2012-03-30 01:51:25 +00:00
style->widget.uifont_id = uifont_id;
style->widget.points = 11;
style->widget.kerning = 1;
style->widget.shadow = 1;
style->widget.shady = -1;
style->widget.shadowalpha = 0.5f;
style->widget.shadowcolor = 0.0f;
2012-03-30 01:51:25 +00:00
style->columnspace = 8;
style->templatespace = 5;
style->boxspace = 5;
style->buttonspacex = 8;
style->buttonspacey = 2;
style->panelspace = 8;
style->panelouter = 4;
return style;
}
static uiFont *uifont_to_blfont(int id)
{
2012-03-30 01:51:25 +00:00
uiFont *font = U.uifonts.first;
2012-03-30 01:51:25 +00:00
for (; font; font = font->next) {
if (font->uifont_id == id) {
return font;
}
}
return U.uifonts.first;
}
/* *************** draw ************************ */
void UI_fontstyle_draw_ex(
const uiFontStyle *fs, const rcti *rect, const char *str, const uchar col[4],
const struct uiFontStyleDraw_Params *fs_params,
size_t len, float *r_xofs, float *r_yofs)
{
2012-03-30 01:51:25 +00:00
int xofs = 0, yofs;
int font_flag = BLF_CLIPPING;
UI_fontstyle_set(fs);
/* set the flag */
if (fs->shadow) {
font_flag |= BLF_SHADOW;
const float shadow_color[4] = {fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha};
BLF_shadow(fs->uifont_id, fs->shadow, shadow_color);
BLF_shadow_offset(fs->uifont_id, fs->shadx, fs->shady);
}
if (fs->kerning == 1) {
font_flag |= BLF_KERNING_DEFAULT;
}
if (fs_params->word_wrap == 1) {
font_flag |= BLF_WORD_WRAP;
}
BLF_enable(fs->uifont_id, font_flag);
if (fs_params->word_wrap == 1) {
/* draw from boundbox top */
yofs = BLI_rcti_size_y(rect) - BLF_height_max(fs->uifont_id);
}
else {
/* draw from boundbox center */
float height = BLF_ascender(fs->uifont_id) + BLF_descender(fs->uifont_id);
yofs = ceil(0.5f * (BLI_rcti_size_y(rect) - height));
}
if (fs_params->align == UI_STYLE_TEXT_CENTER) {
xofs = floor(0.5f * (BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str, len)));
}
else if (fs_params->align == UI_STYLE_TEXT_RIGHT) {
xofs = BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str, len);
}
yofs = MAX2(0, yofs);
xofs = MAX2(0, xofs);
BLF_clipping(fs->uifont_id, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
2012-03-30 01:51:25 +00:00
BLF_position(fs->uifont_id, rect->xmin + xofs, rect->ymin + yofs, 0.0f);
BLF_color4ubv(fs->uifont_id, col);
BLF_draw(fs->uifont_id, str, len);
BLF_disable(fs->uifont_id, font_flag);
2012-03-30 01:51:25 +00:00
*r_xofs = xofs;
*r_yofs = yofs;
}
void UI_fontstyle_draw(
const uiFontStyle *fs, const rcti *rect, const char *str, const uchar col[4],
const struct uiFontStyleDraw_Params *fs_params)
{
float xofs, yofs;
UI_fontstyle_draw_ex(
fs, rect, str, col, fs_params,
BLF_DRAW_STR_DUMMY_MAX, &xofs, &yofs);
}
/* drawn same as above, but at 90 degree angle */
2019-01-04 11:05:53 +11:00
void UI_fontstyle_draw_rotated(const uiFontStyle *fs, const rcti *rect, const char *str, const uchar col[4])
{
float height;
int xofs, yofs;
float angle;
rcti txtrect;
UI_fontstyle_set(fs);
height = BLF_ascender(fs->uifont_id) + BLF_descender(fs->uifont_id);
/* becomes x-offset when rotated */
xofs = ceil(0.5f * (BLI_rcti_size_y(rect) - height));
/* ignore UI_STYLE, always aligned to top */
/* rotate counter-clockwise for now (assumes left-to-right language)*/
2012-03-30 01:51:25 +00:00
xofs += height;
yofs = BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX) + 5;
2015-01-31 17:23:30 +11:00
angle = M_PI_2;
/* translate rect to vertical */
txtrect.xmin = rect->xmin - BLI_rcti_size_y(rect);
txtrect.ymin = rect->ymin - BLI_rcti_size_x(rect);
txtrect.xmax = rect->xmin;
txtrect.ymax = rect->ymin;
/* clip is very strict, so we give it some space */
/* clipping is done without rotation, so make rect big enough to contain both positions */
2012-03-30 01:51:25 +00:00
BLF_clipping(fs->uifont_id, txtrect.xmin - 1, txtrect.ymin - yofs - xofs - 4, rect->xmax + 1, rect->ymax + 4);
BugFix: [#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders Blenfont was not thread safe, that is why one thread can change the font properties (size, dpi, color, etc) at the same time that the stamp draw on the image, and then the problem. To make blenfont thread safe I have to change two important things: 1) Every BLF_* function take one argument, the font id. 2) We have two new function to make font "thread safe": BLF_load_unique BLF_load_mem_unique This two function are for case like stamp, that need and own font that don't share the glyph cache, so can draw without problem in a different thread. Why the BLF_*_unique function ? Because blenfont keep only one copy of a font and keep a list of "glyph cache". Every glyph cache have size and dpi, so if two different thread access the same font at the same time, they can change value and finish with something like the stamp problem. Why don't remove the glyph cache ? Because if we do that, we finish with a font object for every size and dpi, and the stamp is really a special case that happen in the rendering process, so I really thing is better keep the glyph cache and make this two new function to handle this special case. (When I say "font object" I mean have the same freetype font multiple times just to have differents size and dpi) As Matt point we still can have one case that two thread access the BLF_*_unique function at the same time, but I am looking to fix this with some class of thread lock. For now I test and work fine, so if some one found problem, please let me know. Campbell I have to change the python api (python/generic/blf_api.c) to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
BLF_enable(fs->uifont_id, BLF_CLIPPING);
2012-03-30 01:51:25 +00:00
BLF_position(fs->uifont_id, txtrect.xmin + xofs, txtrect.ymax - yofs, 0.0f);
BugFix: [#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders Blenfont was not thread safe, that is why one thread can change the font properties (size, dpi, color, etc) at the same time that the stamp draw on the image, and then the problem. To make blenfont thread safe I have to change two important things: 1) Every BLF_* function take one argument, the font id. 2) We have two new function to make font "thread safe": BLF_load_unique BLF_load_mem_unique This two function are for case like stamp, that need and own font that don't share the glyph cache, so can draw without problem in a different thread. Why the BLF_*_unique function ? Because blenfont keep only one copy of a font and keep a list of "glyph cache". Every glyph cache have size and dpi, so if two different thread access the same font at the same time, they can change value and finish with something like the stamp problem. Why don't remove the glyph cache ? Because if we do that, we finish with a font object for every size and dpi, and the stamp is really a special case that happen in the rendering process, so I really thing is better keep the glyph cache and make this two new function to handle this special case. (When I say "font object" I mean have the same freetype font multiple times just to have differents size and dpi) As Matt point we still can have one case that two thread access the BLF_*_unique function at the same time, but I am looking to fix this with some class of thread lock. For now I test and work fine, so if some one found problem, please let me know. Campbell I have to change the python api (python/generic/blf_api.c) to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
BLF_enable(fs->uifont_id, BLF_ROTATION);
BLF_rotation(fs->uifont_id, angle);
BLF_color4ubv(fs->uifont_id, col);
if (fs->shadow) {
BugFix: [#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders Blenfont was not thread safe, that is why one thread can change the font properties (size, dpi, color, etc) at the same time that the stamp draw on the image, and then the problem. To make blenfont thread safe I have to change two important things: 1) Every BLF_* function take one argument, the font id. 2) We have two new function to make font "thread safe": BLF_load_unique BLF_load_mem_unique This two function are for case like stamp, that need and own font that don't share the glyph cache, so can draw without problem in a different thread. Why the BLF_*_unique function ? Because blenfont keep only one copy of a font and keep a list of "glyph cache". Every glyph cache have size and dpi, so if two different thread access the same font at the same time, they can change value and finish with something like the stamp problem. Why don't remove the glyph cache ? Because if we do that, we finish with a font object for every size and dpi, and the stamp is really a special case that happen in the rendering process, so I really thing is better keep the glyph cache and make this two new function to handle this special case. (When I say "font object" I mean have the same freetype font multiple times just to have differents size and dpi) As Matt point we still can have one case that two thread access the BLF_*_unique function at the same time, but I am looking to fix this with some class of thread lock. For now I test and work fine, so if some one found problem, please let me know. Campbell I have to change the python api (python/generic/blf_api.c) to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
BLF_enable(fs->uifont_id, BLF_SHADOW);
const float shadow_color[4] = {fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha};
BLF_shadow(fs->uifont_id, fs->shadow, shadow_color);
BugFix: [#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders Blenfont was not thread safe, that is why one thread can change the font properties (size, dpi, color, etc) at the same time that the stamp draw on the image, and then the problem. To make blenfont thread safe I have to change two important things: 1) Every BLF_* function take one argument, the font id. 2) We have two new function to make font "thread safe": BLF_load_unique BLF_load_mem_unique This two function are for case like stamp, that need and own font that don't share the glyph cache, so can draw without problem in a different thread. Why the BLF_*_unique function ? Because blenfont keep only one copy of a font and keep a list of "glyph cache". Every glyph cache have size and dpi, so if two different thread access the same font at the same time, they can change value and finish with something like the stamp problem. Why don't remove the glyph cache ? Because if we do that, we finish with a font object for every size and dpi, and the stamp is really a special case that happen in the rendering process, so I really thing is better keep the glyph cache and make this two new function to handle this special case. (When I say "font object" I mean have the same freetype font multiple times just to have differents size and dpi) As Matt point we still can have one case that two thread access the BLF_*_unique function at the same time, but I am looking to fix this with some class of thread lock. For now I test and work fine, so if some one found problem, please let me know. Campbell I have to change the python api (python/generic/blf_api.c) to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
BLF_shadow_offset(fs->uifont_id, fs->shadx, fs->shady);
}
2019-03-25 10:15:20 +11:00
if (fs->kerning == 1) {
BugFix: [#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders Blenfont was not thread safe, that is why one thread can change the font properties (size, dpi, color, etc) at the same time that the stamp draw on the image, and then the problem. To make blenfont thread safe I have to change two important things: 1) Every BLF_* function take one argument, the font id. 2) We have two new function to make font "thread safe": BLF_load_unique BLF_load_mem_unique This two function are for case like stamp, that need and own font that don't share the glyph cache, so can draw without problem in a different thread. Why the BLF_*_unique function ? Because blenfont keep only one copy of a font and keep a list of "glyph cache". Every glyph cache have size and dpi, so if two different thread access the same font at the same time, they can change value and finish with something like the stamp problem. Why don't remove the glyph cache ? Because if we do that, we finish with a font object for every size and dpi, and the stamp is really a special case that happen in the rendering process, so I really thing is better keep the glyph cache and make this two new function to handle this special case. (When I say "font object" I mean have the same freetype font multiple times just to have differents size and dpi) As Matt point we still can have one case that two thread access the BLF_*_unique function at the same time, but I am looking to fix this with some class of thread lock. For now I test and work fine, so if some one found problem, please let me know. Campbell I have to change the python api (python/generic/blf_api.c) to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
2019-03-25 10:15:20 +11:00
}
BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
BugFix: [#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders Blenfont was not thread safe, that is why one thread can change the font properties (size, dpi, color, etc) at the same time that the stamp draw on the image, and then the problem. To make blenfont thread safe I have to change two important things: 1) Every BLF_* function take one argument, the font id. 2) We have two new function to make font "thread safe": BLF_load_unique BLF_load_mem_unique This two function are for case like stamp, that need and own font that don't share the glyph cache, so can draw without problem in a different thread. Why the BLF_*_unique function ? Because blenfont keep only one copy of a font and keep a list of "glyph cache". Every glyph cache have size and dpi, so if two different thread access the same font at the same time, they can change value and finish with something like the stamp problem. Why don't remove the glyph cache ? Because if we do that, we finish with a font object for every size and dpi, and the stamp is really a special case that happen in the rendering process, so I really thing is better keep the glyph cache and make this two new function to handle this special case. (When I say "font object" I mean have the same freetype font multiple times just to have differents size and dpi) As Matt point we still can have one case that two thread access the BLF_*_unique function at the same time, but I am looking to fix this with some class of thread lock. For now I test and work fine, so if some one found problem, please let me know. Campbell I have to change the python api (python/generic/blf_api.c) to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
BLF_disable(fs->uifont_id, BLF_ROTATION);
BLF_disable(fs->uifont_id, BLF_CLIPPING);
2019-03-25 10:15:20 +11:00
if (fs->shadow) {
BugFix: [#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders Blenfont was not thread safe, that is why one thread can change the font properties (size, dpi, color, etc) at the same time that the stamp draw on the image, and then the problem. To make blenfont thread safe I have to change two important things: 1) Every BLF_* function take one argument, the font id. 2) We have two new function to make font "thread safe": BLF_load_unique BLF_load_mem_unique This two function are for case like stamp, that need and own font that don't share the glyph cache, so can draw without problem in a different thread. Why the BLF_*_unique function ? Because blenfont keep only one copy of a font and keep a list of "glyph cache". Every glyph cache have size and dpi, so if two different thread access the same font at the same time, they can change value and finish with something like the stamp problem. Why don't remove the glyph cache ? Because if we do that, we finish with a font object for every size and dpi, and the stamp is really a special case that happen in the rendering process, so I really thing is better keep the glyph cache and make this two new function to handle this special case. (When I say "font object" I mean have the same freetype font multiple times just to have differents size and dpi) As Matt point we still can have one case that two thread access the BLF_*_unique function at the same time, but I am looking to fix this with some class of thread lock. For now I test and work fine, so if some one found problem, please let me know. Campbell I have to change the python api (python/generic/blf_api.c) to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
BLF_disable(fs->uifont_id, BLF_SHADOW);
2019-03-25 10:15:20 +11:00
}
if (fs->kerning == 1) {
BugFix: [#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders Blenfont was not thread safe, that is why one thread can change the font properties (size, dpi, color, etc) at the same time that the stamp draw on the image, and then the problem. To make blenfont thread safe I have to change two important things: 1) Every BLF_* function take one argument, the font id. 2) We have two new function to make font "thread safe": BLF_load_unique BLF_load_mem_unique This two function are for case like stamp, that need and own font that don't share the glyph cache, so can draw without problem in a different thread. Why the BLF_*_unique function ? Because blenfont keep only one copy of a font and keep a list of "glyph cache". Every glyph cache have size and dpi, so if two different thread access the same font at the same time, they can change value and finish with something like the stamp problem. Why don't remove the glyph cache ? Because if we do that, we finish with a font object for every size and dpi, and the stamp is really a special case that happen in the rendering process, so I really thing is better keep the glyph cache and make this two new function to handle this special case. (When I say "font object" I mean have the same freetype font multiple times just to have differents size and dpi) As Matt point we still can have one case that two thread access the BLF_*_unique function at the same time, but I am looking to fix this with some class of thread lock. For now I test and work fine, so if some one found problem, please let me know. Campbell I have to change the python api (python/generic/blf_api.c) to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
2019-03-25 10:15:20 +11:00
}
}
/**
* Similar to #UI_fontstyle_draw
* but ignore alignment, shadow & no clipping rect.
*
* For drawing on-screen labels.
*/
2019-01-04 11:05:53 +11:00
void UI_fontstyle_draw_simple(const uiFontStyle *fs, float x, float y, const char *str, const uchar col[4])
{
2019-03-25 10:15:20 +11:00
if (fs->kerning == 1) {
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
2019-03-25 10:15:20 +11:00
}
UI_fontstyle_set(fs);
BLF_position(fs->uifont_id, x, y, 0.0f);
BLF_color4ubv(fs->uifont_id, col);
BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
2019-03-25 10:15:20 +11:00
if (fs->kerning == 1) {
BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
2019-03-25 10:15:20 +11:00
}
}
/**
* Same as #UI_fontstyle_draw but draw a colored backdrop.
*/
void UI_fontstyle_draw_simple_backdrop(
const uiFontStyle *fs, float x, float y, const char *str,
const float col_fg[4], const float col_bg[4])
{
2019-03-25 10:15:20 +11:00
if (fs->kerning == 1) {
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
2019-03-25 10:15:20 +11:00
}
UI_fontstyle_set(fs);
{
const float width = BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
const float height = BLF_height_max(fs->uifont_id);
const float decent = BLF_descender(fs->uifont_id);
const float margin = height / 4.0f;
/* backdrop */
float color[4] = { col_bg[0], col_bg[1], col_bg[2], 0.5f };
UI_draw_roundbox_corner_set(UI_CNR_ALL);
2018-11-21 06:21:58 +11:00
UI_draw_roundbox_aa(
true,
x - margin,
(y + decent) - margin,
x + width + margin,
(y + decent) + height + margin,
margin, color);
}
BLF_position(fs->uifont_id, x, y, 0.0f);
BLF_color4fv(fs->uifont_id, col_fg);
BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
2019-03-25 10:15:20 +11:00
if (fs->kerning == 1) {
BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
2019-03-25 10:15:20 +11:00
}
}
/* ************** helpers ************************ */
2011-07-29 17:42:53 +00:00
/* XXX: read a style configure */
uiStyle *UI_style_get(void)
{
#if 0
uiStyle *style = NULL;
/* offset is two struct uiStyle pointers */
style = BLI_findstring(&U.uistyles, "Unifont Style", sizeof(style) * 2);
return (style != NULL) ? style : U.uistyles.first;
#else
return U.uistyles.first;
#endif
}
Holiday coding log :) Nice formatted version (pictures soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability Short list of main changes: - Transparent region option (over main region), added code to blend in/out such panels. - Min size window now 640 x 480 - Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake. - Macbook retina support, use command line --no-native-pixels to disable it - Timeline Marker label was drawing wrong - Trackpad and magic mouse: supports zoom (hold ctrl) - Fix for splash position: removed ghost function and made window size update after creation immediate - Fast undo buffer save now adds UI as well. Could be checked for regular file save even... Quit.blend and temp file saving use this now. - Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)" - New Userpref option "Keep Session" - this always saves quit.blend, and loads on start. This allows keeping UI and data without actual saves, until you actually save. When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header) - Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. - User preferences (themes, keymaps, user settings) now can be saved as a separate file. Old option is called "Save Startup File" the new one "Save User Settings". To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still. - OSX: fixed bug that stopped giving mouse events outside window. This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
/* for drawing, scaled with DPI setting */
uiStyle *UI_style_get_dpi(void)
Holiday coding log :) Nice formatted version (pictures soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability Short list of main changes: - Transparent region option (over main region), added code to blend in/out such panels. - Min size window now 640 x 480 - Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake. - Macbook retina support, use command line --no-native-pixels to disable it - Timeline Marker label was drawing wrong - Trackpad and magic mouse: supports zoom (hold ctrl) - Fix for splash position: removed ghost function and made window size update after creation immediate - Fast undo buffer save now adds UI as well. Could be checked for regular file save even... Quit.blend and temp file saving use this now. - Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)" - New Userpref option "Keep Session" - this always saves quit.blend, and loads on start. This allows keeping UI and data without actual saves, until you actually save. When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header) - Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. - User preferences (themes, keymaps, user settings) now can be saved as a separate file. Old option is called "Save Startup File" the new one "Save User Settings". To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still. - OSX: fixed bug that stopped giving mouse events outside window. This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
{
uiStyle *style = UI_style_get();
Holiday coding log :) Nice formatted version (pictures soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability Short list of main changes: - Transparent region option (over main region), added code to blend in/out such panels. - Min size window now 640 x 480 - Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake. - Macbook retina support, use command line --no-native-pixels to disable it - Timeline Marker label was drawing wrong - Trackpad and magic mouse: supports zoom (hold ctrl) - Fix for splash position: removed ghost function and made window size update after creation immediate - Fast undo buffer save now adds UI as well. Could be checked for regular file save even... Quit.blend and temp file saving use this now. - Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)" - New Userpref option "Keep Session" - this always saves quit.blend, and loads on start. This allows keeping UI and data without actual saves, until you actually save. When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header) - Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. - User preferences (themes, keymaps, user settings) now can be saved as a separate file. Old option is called "Save Startup File" the new one "Save User Settings". To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still. - OSX: fixed bug that stopped giving mouse events outside window. This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
static uiStyle _style;
Holiday coding log :) Nice formatted version (pictures soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability Short list of main changes: - Transparent region option (over main region), added code to blend in/out such panels. - Min size window now 640 x 480 - Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake. - Macbook retina support, use command line --no-native-pixels to disable it - Timeline Marker label was drawing wrong - Trackpad and magic mouse: supports zoom (hold ctrl) - Fix for splash position: removed ghost function and made window size update after creation immediate - Fast undo buffer save now adds UI as well. Could be checked for regular file save even... Quit.blend and temp file saving use this now. - Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)" - New Userpref option "Keep Session" - this always saves quit.blend, and loads on start. This allows keeping UI and data without actual saves, until you actually save. When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header) - Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. - User preferences (themes, keymaps, user settings) now can be saved as a separate file. Old option is called "Save Startup File" the new one "Save User Settings". To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still. - OSX: fixed bug that stopped giving mouse events outside window. This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
_style = *style;
Holiday coding log :) Nice formatted version (pictures soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability Short list of main changes: - Transparent region option (over main region), added code to blend in/out such panels. - Min size window now 640 x 480 - Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake. - Macbook retina support, use command line --no-native-pixels to disable it - Timeline Marker label was drawing wrong - Trackpad and magic mouse: supports zoom (hold ctrl) - Fix for splash position: removed ghost function and made window size update after creation immediate - Fast undo buffer save now adds UI as well. Could be checked for regular file save even... Quit.blend and temp file saving use this now. - Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)" - New Userpref option "Keep Session" - this always saves quit.blend, and loads on start. This allows keeping UI and data without actual saves, until you actually save. When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header) - Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. - User preferences (themes, keymaps, user settings) now can be saved as a separate file. Old option is called "Save Startup File" the new one "Save User Settings". To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still. - OSX: fixed bug that stopped giving mouse events outside window. This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
_style.paneltitle.shadx = (short)(UI_DPI_FAC * _style.paneltitle.shadx);
_style.paneltitle.shady = (short)(UI_DPI_FAC * _style.paneltitle.shady);
Holiday coding log :) Nice formatted version (pictures soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability Short list of main changes: - Transparent region option (over main region), added code to blend in/out such panels. - Min size window now 640 x 480 - Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake. - Macbook retina support, use command line --no-native-pixels to disable it - Timeline Marker label was drawing wrong - Trackpad and magic mouse: supports zoom (hold ctrl) - Fix for splash position: removed ghost function and made window size update after creation immediate - Fast undo buffer save now adds UI as well. Could be checked for regular file save even... Quit.blend and temp file saving use this now. - Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)" - New Userpref option "Keep Session" - this always saves quit.blend, and loads on start. This allows keeping UI and data without actual saves, until you actually save. When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header) - Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. - User preferences (themes, keymaps, user settings) now can be saved as a separate file. Old option is called "Save Startup File" the new one "Save User Settings". To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still. - OSX: fixed bug that stopped giving mouse events outside window. This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
_style.grouplabel.shadx = (short)(UI_DPI_FAC * _style.grouplabel.shadx);
_style.grouplabel.shady = (short)(UI_DPI_FAC * _style.grouplabel.shady);
Holiday coding log :) Nice formatted version (pictures soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability Short list of main changes: - Transparent region option (over main region), added code to blend in/out such panels. - Min size window now 640 x 480 - Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake. - Macbook retina support, use command line --no-native-pixels to disable it - Timeline Marker label was drawing wrong - Trackpad and magic mouse: supports zoom (hold ctrl) - Fix for splash position: removed ghost function and made window size update after creation immediate - Fast undo buffer save now adds UI as well. Could be checked for regular file save even... Quit.blend and temp file saving use this now. - Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)" - New Userpref option "Keep Session" - this always saves quit.blend, and loads on start. This allows keeping UI and data without actual saves, until you actually save. When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header) - Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. - User preferences (themes, keymaps, user settings) now can be saved as a separate file. Old option is called "Save Startup File" the new one "Save User Settings". To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still. - OSX: fixed bug that stopped giving mouse events outside window. This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
_style.widgetlabel.shadx = (short)(UI_DPI_FAC * _style.widgetlabel.shadx);
_style.widgetlabel.shady = (short)(UI_DPI_FAC * _style.widgetlabel.shady);
Holiday coding log :) Nice formatted version (pictures soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability Short list of main changes: - Transparent region option (over main region), added code to blend in/out such panels. - Min size window now 640 x 480 - Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake. - Macbook retina support, use command line --no-native-pixels to disable it - Timeline Marker label was drawing wrong - Trackpad and magic mouse: supports zoom (hold ctrl) - Fix for splash position: removed ghost function and made window size update after creation immediate - Fast undo buffer save now adds UI as well. Could be checked for regular file save even... Quit.blend and temp file saving use this now. - Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)" - New Userpref option "Keep Session" - this always saves quit.blend, and loads on start. This allows keeping UI and data without actual saves, until you actually save. When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header) - Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. - User preferences (themes, keymaps, user settings) now can be saved as a separate file. Old option is called "Save Startup File" the new one "Save User Settings". To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still. - OSX: fixed bug that stopped giving mouse events outside window. This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
_style.columnspace = (short)(UI_DPI_FAC * _style.columnspace);
_style.templatespace = (short)(UI_DPI_FAC * _style.templatespace);
_style.boxspace = (short)(UI_DPI_FAC * _style.boxspace);
_style.buttonspacex = (short)(UI_DPI_FAC * _style.buttonspacex);
_style.buttonspacey = (short)(UI_DPI_FAC * _style.buttonspacey);
_style.panelspace = (short)(UI_DPI_FAC * _style.panelspace);
_style.panelouter = (short)(UI_DPI_FAC * _style.panelouter);
Holiday coding log :) Nice formatted version (pictures soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability Short list of main changes: - Transparent region option (over main region), added code to blend in/out such panels. - Min size window now 640 x 480 - Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake. - Macbook retina support, use command line --no-native-pixels to disable it - Timeline Marker label was drawing wrong - Trackpad and magic mouse: supports zoom (hold ctrl) - Fix for splash position: removed ghost function and made window size update after creation immediate - Fast undo buffer save now adds UI as well. Could be checked for regular file save even... Quit.blend and temp file saving use this now. - Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)" - New Userpref option "Keep Session" - this always saves quit.blend, and loads on start. This allows keeping UI and data without actual saves, until you actually save. When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header) - Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. - User preferences (themes, keymaps, user settings) now can be saved as a separate file. Old option is called "Save Startup File" the new one "Save User Settings". To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still. - OSX: fixed bug that stopped giving mouse events outside window. This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
return &_style;
}
int UI_fontstyle_string_width(const uiFontStyle *fs, const char *str)
{
int width;
2019-03-25 10:15:20 +11:00
if (fs->kerning == 1) {
/* for BLF_width */
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
2019-03-25 10:15:20 +11:00
}
UI_fontstyle_set(fs);
width = BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
2019-03-25 10:15:20 +11:00
if (fs->kerning == 1) {
BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
2019-03-25 10:15:20 +11:00
}
return width;
}
int UI_fontstyle_height_max(const uiFontStyle *fs)
{
UI_fontstyle_set(fs);
return BLF_height_max(fs->uifont_id);
}
/* ************** init exit ************************ */
/* called on each startup.blend read */
/* reading without uifont will create one */
void uiStyleInit(void)
{
uiFont *font;
2012-03-30 01:51:25 +00:00
uiStyle *style = U.uistyles.first;
int monofont_size = datatoc_bmonofont_ttf_size;
2019-01-04 11:05:53 +11:00
uchar *monofont_ttf = (uchar *)datatoc_bmonofont_ttf;
/* recover from uninitialized dpi */
2019-03-25 10:15:20 +11:00
if (U.dpi == 0) {
2012-03-30 01:51:25 +00:00
U.dpi = 72;
2019-03-25 10:15:20 +11:00
}
CLAMP(U.dpi, 48, 144);
for (font = U.uifonts.first; font; font = font->next) {
BLF_unload_id(font->blf_id);
}
2015-12-01 16:57:52 +11:00
if (blf_mono_font != -1) {
BLF_unload_id(blf_mono_font);
blf_mono_font = -1;
}
if (blf_mono_font_render != -1) {
BLF_unload_id(blf_mono_font_render);
blf_mono_font_render = -1;
}
font = U.uifonts.first;
/* default builtin */
2012-03-30 01:51:25 +00:00
if (font == NULL) {
font = MEM_callocN(sizeof(uiFont), "ui font");
BLI_addtail(&U.uifonts, font);
}
if (U.font_path_ui[0]) {
BLI_strncpy(font->filename, U.font_path_ui, sizeof(font->filename));
font->uifont_id = UIFONT_CUSTOM1;
}
else {
BLI_strncpy(font->filename, "default", sizeof(font->filename));
2012-03-30 01:51:25 +00:00
font->uifont_id = UIFONT_DEFAULT;
}
2012-03-30 01:51:25 +00:00
for (font = U.uifonts.first; font; font = font->next) {
2012-03-30 01:51:25 +00:00
if (font->uifont_id == UIFONT_DEFAULT) {
#ifdef WITH_INTERNATIONAL
2012-03-30 01:51:25 +00:00
int font_size = datatoc_bfont_ttf_size;
2019-01-04 11:05:53 +11:00
uchar *font_ttf = (uchar *)datatoc_bfont_ttf;
static int last_font_size = 0;
/* use unicode font for translation */
if (U.transopts & USER_DOTRANSLATE) {
2012-03-30 01:51:25 +00:00
font_ttf = BLF_get_unifont(&font_size);
if (!font_ttf) {
/* fall back if not found */
2012-03-30 01:51:25 +00:00
font_size = datatoc_bfont_ttf_size;
2019-01-04 11:05:53 +11:00
font_ttf = (uchar *)datatoc_bfont_ttf;
}
}
/* relload only if needed */
if (last_font_size != font_size) {
BLF_unload("default");
last_font_size = font_size;
}
2012-03-30 01:51:25 +00:00
font->blf_id = BLF_load_mem("default", font_ttf, font_size);
#else
2019-01-04 11:05:53 +11:00
font->blf_id = BLF_load_mem("default", (uchar *)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
#endif
}
else {
2012-03-30 01:51:25 +00:00
font->blf_id = BLF_load(font->filename);
if (font->blf_id == -1) {
2019-01-04 11:05:53 +11:00
font->blf_id = BLF_load_mem("default", (uchar *)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
}
}
BLF_default_set(font->blf_id);
if (font->blf_id == -1) {
2019-03-25 10:15:20 +11:00
if (G.debug & G_DEBUG) {
printf("%s: error, no fonts available\n", __func__);
2019-03-25 10:15:20 +11:00
}
}
else {
/* ? just for speed to initialize?
* Yes, this build the glyph cache and create
* the texture.
*/
Holiday coding log :) Nice formatted version (pictures soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability Short list of main changes: - Transparent region option (over main region), added code to blend in/out such panels. - Min size window now 640 x 480 - Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake. - Macbook retina support, use command line --no-native-pixels to disable it - Timeline Marker label was drawing wrong - Trackpad and magic mouse: supports zoom (hold ctrl) - Fix for splash position: removed ghost function and made window size update after creation immediate - Fast undo buffer save now adds UI as well. Could be checked for regular file save even... Quit.blend and temp file saving use this now. - Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)" - New Userpref option "Keep Session" - this always saves quit.blend, and loads on start. This allows keeping UI and data without actual saves, until you actually save. When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header) - Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. - User preferences (themes, keymaps, user settings) now can be saved as a separate file. Old option is called "Save Startup File" the new one "Save User Settings". To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still. - OSX: fixed bug that stopped giving mouse events outside window. This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
BLF_size(font->blf_id, 11 * U.pixelsize, U.dpi);
BLF_size(font->blf_id, 12 * U.pixelsize, U.dpi);
BLF_size(font->blf_id, 14 * U.pixelsize, U.dpi);
}
}
2012-03-30 01:51:25 +00:00
if (style == NULL) {
ui_style_new(&U.uistyles, "Default Style", UIFONT_DEFAULT);
}
#ifdef WITH_INTERNATIONAL
/* use unicode font for text editor and interactive console */
if (U.transopts & USER_DOTRANSLATE) {
monofont_ttf = BLF_get_unifont_mono(&monofont_size);
if (!monofont_ttf) {
/* fall back if not found */
monofont_size = datatoc_bmonofont_ttf_size;
2019-01-04 11:05:53 +11:00
monofont_ttf = (uchar *)datatoc_bmonofont_ttf;
}
}
#endif
/* XXX, this should be moved into a style,
* but for now best only load the monospaced font once. */
2015-12-01 16:57:52 +11:00
BLI_assert(blf_mono_font == -1);
if (U.font_path_ui_mono[0]) {
blf_mono_font = BLF_load_unique(U.font_path_ui_mono);
}
if (blf_mono_font == -1) {
blf_mono_font = BLF_load_mem_unique("monospace", monofont_ttf, monofont_size);
2015-12-01 16:57:52 +11:00
}
Holiday coding log :) Nice formatted version (pictures soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability Short list of main changes: - Transparent region option (over main region), added code to blend in/out such panels. - Min size window now 640 x 480 - Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake. - Macbook retina support, use command line --no-native-pixels to disable it - Timeline Marker label was drawing wrong - Trackpad and magic mouse: supports zoom (hold ctrl) - Fix for splash position: removed ghost function and made window size update after creation immediate - Fast undo buffer save now adds UI as well. Could be checked for regular file save even... Quit.blend and temp file saving use this now. - Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)" - New Userpref option "Keep Session" - this always saves quit.blend, and loads on start. This allows keeping UI and data without actual saves, until you actually save. When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header) - Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. - User preferences (themes, keymaps, user settings) now can be saved as a separate file. Old option is called "Save Startup File" the new one "Save User Settings". To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still. - OSX: fixed bug that stopped giving mouse events outside window. This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
BLF_size(blf_mono_font, 12 * U.pixelsize, 72);
/* Set default flags based on UI preferences (not render fonts) */
{
2018-11-21 06:21:58 +11:00
int flag_disable = (
BLF_MONOCHROME |
BLF_HINTING_NONE |
BLF_HINTING_SLIGHT |
BLF_HINTING_FULL);
int flag_enable = 0;
if (U.text_render & USER_TEXT_HINTING_NONE) {
flag_enable |= BLF_HINTING_NONE;
}
else if (U.text_render & USER_TEXT_HINTING_SLIGHT) {
flag_enable |= BLF_HINTING_SLIGHT;
}
else if (U.text_render & USER_TEXT_HINTING_FULL) {
flag_enable |= BLF_HINTING_FULL;
}
if (U.text_render & USER_TEXT_DISABLE_AA) {
flag_enable |= BLF_MONOCHROME;
}
for (font = U.uifonts.first; font; font = font->next) {
if (font->blf_id != -1) {
BLF_disable(font->blf_id, flag_disable);
BLF_enable(font->blf_id, flag_enable);
}
}
if (blf_mono_font != -1) {
BLF_disable(blf_mono_font, flag_disable);
BLF_enable(blf_mono_font, flag_enable);
}
}
/**
* Second for rendering else we get threading problems,
*
* \note This isn't good that the render font depends on the preferences,
* keep for now though, since without this there is no way to display many unicode chars.
*/
2019-03-25 10:15:20 +11:00
if (blf_mono_font_render == -1) {
blf_mono_font_render = BLF_load_mem_unique("monospace", monofont_ttf, monofont_size);
2019-03-25 10:15:20 +11:00
}
2014-04-20 22:05:05 +10:00
BLF_size(blf_mono_font_render, 12 * U.pixelsize, 72);
}
void UI_fontstyle_set(const uiFontStyle *fs)
{
2012-03-30 01:51:25 +00:00
uiFont *font = uifont_to_blfont(fs->uifont_id);
Holiday coding log :) Nice formatted version (pictures soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability Short list of main changes: - Transparent region option (over main region), added code to blend in/out such panels. - Min size window now 640 x 480 - Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake. - Macbook retina support, use command line --no-native-pixels to disable it - Timeline Marker label was drawing wrong - Trackpad and magic mouse: supports zoom (hold ctrl) - Fix for splash position: removed ghost function and made window size update after creation immediate - Fast undo buffer save now adds UI as well. Could be checked for regular file save even... Quit.blend and temp file saving use this now. - Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)" - New Userpref option "Keep Session" - this always saves quit.blend, and loads on start. This allows keeping UI and data without actual saves, until you actually save. When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header) - Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. - User preferences (themes, keymaps, user settings) now can be saved as a separate file. Old option is called "Save Startup File" the new one "Save User Settings". To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still. - OSX: fixed bug that stopped giving mouse events outside window. This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
BLF_size(font->blf_id, fs->points * U.pixelsize, U.dpi);
}