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:
authorHarley Acheson <harley.acheson@gmail.com>2022-09-07 18:05:04 +0300
committerHarley Acheson <harley.acheson@gmail.com>2022-09-07 18:06:29 +0300
commite53405bf15aa6d386e83ce6daa5b6248690122c9 (patch)
tree6e64fa586547bcce38d9275ea4488c25741ff008
parent67dcdebb3a7cc057fe73079fc038f9264326daea (diff)
UI: Small Adjustments to Event Icons
Minor adjustments to event icons required after recent font changes. See D15582 for more details and examples. Differential Revision: https://developer.blender.org/D15582 Reviewed by Brecht Van Lommel
-rw-r--r--source/blender/editors/interface/interface_icons_event.c100
1 files changed, 39 insertions, 61 deletions
diff --git a/source/blender/editors/interface/interface_icons_event.c b/source/blender/editors/interface/interface_icons_event.c
index 6ad5fe805ab..e892a989191 100644
--- a/source/blender/editors/interface/interface_icons_event.c
+++ b/source/blender/editors/interface/interface_icons_event.c
@@ -60,10 +60,8 @@
#include "interface_intern.h"
-static void icon_draw_rect_input_text(const rctf *rect,
- const float color[4],
- const char *str,
- float font_size)
+static void icon_draw_rect_input_text(
+ const rctf *rect, const float color[4], const char *str, float font_size, float v_offset)
{
BLF_batch_draw_flush();
const int font_id = BLF_default();
@@ -71,21 +69,9 @@ static void icon_draw_rect_input_text(const rctf *rect,
BLF_size(font_id, font_size * U.pixelsize, U.dpi);
float width, height;
BLF_width_and_height(font_id, str, BLF_DRAW_STR_DUMMY_MAX, &width, &height);
- const float x = rect->xmin + (((rect->xmax - rect->xmin) - width) / 2.0f);
- const float y = rect->ymin + (((rect->ymax - rect->ymin) - height) / 2.0f);
- BLF_position(font_id, x, y, 0.0f);
- BLF_draw(font_id, str, BLF_DRAW_STR_DUMMY_MAX);
- BLF_batch_draw_flush();
-}
-
-static void icon_draw_rect_input_symbol(const rctf *rect, const float color[4], const char *str)
-{
- BLF_batch_draw_flush();
- const int font_id = blf_mono_font;
- BLF_color4fv(font_id, color);
- BLF_size(font_id, 19.0f * U.pixelsize, U.dpi);
- const float x = rect->xmin + (2.0f * U.pixelsize);
- const float y = rect->ymin + (1.0f * U.pixelsize);
+ const float x = trunc(rect->xmin + (((rect->xmax - rect->xmin) - width) / 2.0f));
+ const float y = rect->ymin + (((rect->ymax - rect->ymin) - height) / 2.0f) +
+ (v_offset * U.dpi_fac);
BLF_position(font_id, x, y, 0.0f);
BLF_draw(font_id, str, BLF_DRAW_STR_DUMMY_MAX);
BLF_batch_draw_flush();
@@ -99,20 +85,17 @@ void icon_draw_rect_input(float x,
short event_type,
short UNUSED(event_value))
{
+ rctf rect = {
+ .xmin = (int)x - U.pixelsize,
+ .xmax = (int)(x + w + U.pixelsize),
+ .ymin = (int)(y),
+ .ymax = (int)(y + h),
+ };
float color[4];
GPU_line_width(1.0f);
UI_GetThemeColor4fv(TH_TEXT, color);
UI_draw_roundbox_corner_set(UI_CNR_ALL);
- UI_draw_roundbox_aa(
- &(const rctf){
- .xmin = (int)x - U.pixelsize,
- .xmax = (int)(x + w),
- .ymin = (int)y,
- .ymax = (int)(y + h),
- },
- false,
- 3.0f * U.pixelsize,
- color);
+ UI_draw_roundbox_aa(&rect, false, 3.0f * U.pixelsize, color);
const enum {
UNIX,
@@ -129,94 +112,89 @@ void icon_draw_rect_input(float x,
#endif
;
- const rctf rect = {
- .xmin = x,
- .ymin = y,
- .xmax = x + w,
- .ymax = y + h,
- };
-
if ((event_type >= EVT_AKEY) && (event_type <= EVT_ZKEY)) {
const char str[2] = {'A' + (event_type - EVT_AKEY), '\0'};
- icon_draw_rect_input_text(&rect, color, str, 13.0f);
+ icon_draw_rect_input_text(&rect, color, str, 13.0f, 0.0f);
}
- else if ((event_type >= EVT_F1KEY) && (event_type <= EVT_F12KEY)) {
+ else if ((event_type >= EVT_F1KEY) && (event_type <= EVT_F24KEY)) {
char str[4];
SNPRINTF(str, "F%d", 1 + (event_type - EVT_F1KEY));
- icon_draw_rect_input_text(&rect, color, str, event_type > EVT_F9KEY ? 8.0f : 10.0f);
+ icon_draw_rect_input_text(&rect, color, str, event_type > EVT_F9KEY ? 8.5f : 11.5f, 0.0f);
}
else if (event_type == EVT_LEFTSHIFTKEY) { /* Right Shift has already been converted to left. */
- icon_draw_rect_input_symbol(&rect, color, (const char[]){0xe2, 0x87, 0xa7, 0x0});
+ icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x87, 0xa7, 0x0}, 16.0f, 0.0f);
}
else if (event_type == EVT_LEFTCTRLKEY) { /* Right Shift has already been converted to left. */
if (platform == MACOS) {
- icon_draw_rect_input_symbol(&rect, color, (const char[]){0xe2, 0x8c, 0x83, 0x0});
+ icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x8c, 0x83, 0x0}, 21.0f, -8.0f);
}
else {
- icon_draw_rect_input_text(&rect, color, "Ctrl", 9.0f);
+ icon_draw_rect_input_text(&rect, color, "Ctrl", 9.0f, 0.0f);
}
}
else if (event_type == EVT_LEFTALTKEY) { /* Right Alt has already been converted to left. */
if (platform == MACOS) {
- icon_draw_rect_input_symbol(&rect, color, (const char[]){0xe2, 0x8c, 0xa5, 0x0});
+ icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x8c, 0xa5, 0x0}, 13.0f, 0.0f);
}
else {
- icon_draw_rect_input_text(&rect, color, "Alt", 10.0f);
+ icon_draw_rect_input_text(&rect, color, "Alt", 10.0f, 0.0f);
}
}
else if (event_type == EVT_OSKEY) {
if (platform == MACOS) {
- icon_draw_rect_input_symbol(&rect, color, (const char[]){0xe2, 0x8c, 0x98, 0x0});
+ icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x8c, 0x98, 0x0}, 16.0f, 0.0f);
}
else if (platform == MSWIN) {
- icon_draw_rect_input_symbol(&rect, color, (const char[]){0xe2, 0x9d, 0x96, 0x0});
+ icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x9d, 0x96, 0x0}, 16.0f, 0.0f);
}
else {
- icon_draw_rect_input_text(&rect, color, "OS", 10.0f);
+ icon_draw_rect_input_text(&rect, color, "OS", 10.0f, 0.0f);
}
}
else if (event_type == EVT_DELKEY) {
- icon_draw_rect_input_text(&rect, color, "Del", 9.0f);
+ icon_draw_rect_input_text(&rect, color, "Del", 9.0f, 0.0f);
}
else if (event_type == EVT_TABKEY) {
- icon_draw_rect_input_symbol(&rect, color, (const char[]){0xe2, 0xad, 0xbe, 0x0});
+ icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0xad, 0xbe, 0x0}, 18.0f, -1.5f);
}
else if (event_type == EVT_HOMEKEY) {
- icon_draw_rect_input_text(&rect, color, "Home", 6.0f);
+ icon_draw_rect_input_text(&rect, color, "Home", 6.0f, 0.0f);
}
else if (event_type == EVT_ENDKEY) {
- icon_draw_rect_input_text(&rect, color, "End", 8.0f);
+ icon_draw_rect_input_text(&rect, color, "End", 8.0f, 0.0f);
}
else if (event_type == EVT_RETKEY) {
- icon_draw_rect_input_symbol(&rect, color, (const char[]){0xe2, 0x8f, 0x8e, 0x0});
+ icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x8f, 0x8e, 0x0}, 17.0f, -1.0f);
}
else if (event_type == EVT_ESCKEY) {
if (platform == MACOS) {
- icon_draw_rect_input_symbol(&rect, color, (const char[]){0xe2, 0x8e, 0x8b, 0x0});
+ icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x8e, 0x8b, 0x0}, 21.0f, -1.0f);
}
else {
- icon_draw_rect_input_text(&rect, color, "Esc", 8.0f);
+ icon_draw_rect_input_text(&rect, color, "Esc", 8.5f, 0.0f);
}
}
else if (event_type == EVT_PAGEUPKEY) {
- icon_draw_rect_input_text(&rect, color, (const char[]){'P', 0xe2, 0x86, 0x91, 0x0}, 8.0f);
+ icon_draw_rect_input_text(
+ &rect, color, (const char[]){'P', 0xe2, 0x86, 0x91, 0x0}, 12.0f, 0.0f);
}
else if (event_type == EVT_PAGEDOWNKEY) {
- icon_draw_rect_input_text(&rect, color, (const char[]){'P', 0xe2, 0x86, 0x93, 0x0}, 8.0f);
+ icon_draw_rect_input_text(
+ &rect, color, (const char[]){'P', 0xe2, 0x86, 0x93, 0x0}, 12.0f, 0.0f);
}
else if (event_type == EVT_LEFTARROWKEY) {
- icon_draw_rect_input_symbol(&rect, color, (const char[]){0xe2, 0x86, 0x90, 0x0});
+ icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x86, 0x90, 0x0}, 18.0f, -1.5f);
}
else if (event_type == EVT_UPARROWKEY) {
- icon_draw_rect_input_symbol(&rect, color, (const char[]){0xe2, 0x86, 0x91, 0x0});
+ icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x86, 0x91, 0x0}, 16.0f, 0.0f);
}
else if (event_type == EVT_RIGHTARROWKEY) {
- icon_draw_rect_input_symbol(&rect, color, (const char[]){0xe2, 0x86, 0x92, 0x0});
+ icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x86, 0x92, 0x0}, 18.0f, -1.5f);
}
else if (event_type == EVT_DOWNARROWKEY) {
- icon_draw_rect_input_symbol(&rect, color, (const char[]){0xe2, 0x86, 0x93, 0x0});
+ icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x86, 0x93, 0x0}, 16.0f, 0.0f);
}
else if (event_type == EVT_SPACEKEY) {
- icon_draw_rect_input_symbol(&rect, color, (const char[]){0xe2, 0x90, 0xa3, 0x0});
+ icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x90, 0xa3, 0x0}, 20.0f, 2.0f);
}
}