2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2011-10-23 17:52:20 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2009-03-25 16:58:42 +00:00
|
|
|
*
|
|
|
|
* 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.
|
2009-03-25 16:58:42 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/interface/interface_widgets.c
|
|
|
|
* \ingroup edinterface
|
|
|
|
*/
|
|
|
|
|
2009-03-25 16:58:42 +00:00
|
|
|
#include <limits.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2010-10-17 08:59:23 +00:00
|
|
|
#include <assert.h>
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
#include "DNA_brush_types.h"
|
2009-03-25 16:58:42 +00:00
|
|
|
#include "DNA_screen_types.h"
|
2009-04-09 18:11:18 +00:00
|
|
|
#include "DNA_userdef_types.h"
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2009-03-25 16:58:42 +00:00
|
|
|
#include "BLI_rect.h"
|
2010-12-14 02:38:29 +00:00
|
|
|
#include "BLI_string.h"
|
2012-03-22 09:20:22 +00:00
|
|
|
#include "BLI_string_utf8.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
#include "BKE_context.h"
|
|
|
|
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
2009-04-10 14:06:24 +00:00
|
|
|
#include "BLF_api.h"
|
|
|
|
|
2009-03-25 16:58:42 +00:00
|
|
|
#include "UI_interface.h"
|
|
|
|
#include "UI_interface_icons.h"
|
|
|
|
|
|
|
|
#include "interface_intern.h"
|
|
|
|
|
2015-12-25 22:57:50 +01:00
|
|
|
#include "GPU_basic_shader.h"
|
2018-03-29 03:21:03 +02:00
|
|
|
#include "GPU_batch.h"
|
2016-08-20 15:40:08 -04:00
|
|
|
#include "GPU_immediate.h"
|
2017-04-05 18:30:14 +10:00
|
|
|
#include "GPU_immediate_util.h"
|
2017-02-20 21:21:04 +01:00
|
|
|
#include "GPU_matrix.h"
|
2015-12-25 22:57:50 +01:00
|
|
|
|
2014-12-07 00:58:17 +01:00
|
|
|
#ifdef WITH_INPUT_IME
|
|
|
|
# include "WM_types.h"
|
|
|
|
#endif
|
|
|
|
|
2013-12-18 17:11:38 +11:00
|
|
|
/* icons are 80% of height of button (16 pixels inside 20 height) */
|
|
|
|
#define ICON_SIZE_FROM_BUTRECT(rect) (0.8f * BLI_rcti_size_y(rect))
|
|
|
|
|
2017-11-04 14:10:04 +11:00
|
|
|
/* Button state argument shares bits with 'uiBut.flag'.
|
|
|
|
* reuse flags that aren't needed for drawing to avoid collision. */
|
2017-11-02 04:30:07 +11:00
|
|
|
enum {
|
|
|
|
/* Show that holding the button opens a menu. */
|
2017-11-04 14:10:04 +11:00
|
|
|
UI_STATE_HOLD_ACTION = UI_BUT_UPDATE_DELAY,
|
|
|
|
UI_STATE_TEXT_INPUT = UI_BUT_UNDO,
|
2018-04-22 13:57:50 +02:00
|
|
|
UI_STATE_ACTIVE_LEFT = UI_BUT_VALUE_CLEAR,
|
|
|
|
UI_STATE_ACTIVE_RIGHT = UI_BUT_TEXTEDIT_UPDATE,
|
2017-11-02 04:30:07 +11:00
|
|
|
|
2018-04-22 13:57:50 +02:00
|
|
|
UI_STATE_FLAGS_ALL = (UI_STATE_HOLD_ACTION |
|
|
|
|
UI_STATE_TEXT_INPUT |
|
|
|
|
UI_STATE_ACTIVE_LEFT |
|
|
|
|
UI_STATE_ACTIVE_RIGHT),
|
2017-11-04 14:10:04 +11:00
|
|
|
};
|
|
|
|
/* Prevent accidental use. */
|
|
|
|
#define UI_BUT_UPDATE_DELAY ((void)0)
|
|
|
|
#define UI_BUT_UNDO ((void)0)
|
2017-11-03 00:22:59 +11:00
|
|
|
|
2018-03-29 03:21:03 +02:00
|
|
|
|
2009-03-25 16:58:42 +00:00
|
|
|
/* ************** widget base functions ************** */
|
2015-05-31 14:20:03 +10:00
|
|
|
/**
|
2012-03-03 16:31:46 +00:00
|
|
|
* - in: roundbox codes for corner types and radius
|
2015-05-31 14:20:03 +10:00
|
|
|
* - return: array of `[size][2][x, y]` points, the edges of the roundbox, + UV coords
|
2012-03-03 16:31:46 +00:00
|
|
|
*
|
|
|
|
* - draw black box with alpha 0 on exact button boundbox
|
2015-04-13 16:56:43 -04:00
|
|
|
* - for every AA step:
|
2012-03-03 16:31:46 +00:00
|
|
|
* - draw the inner part for a round filled box, with color blend codes or texture coords
|
|
|
|
* - draw outline in outline color
|
|
|
|
* - draw outer part, bottom half, extruded 1 pixel to bottom, for emboss shadow
|
|
|
|
* - draw extra decorations
|
|
|
|
* - draw background color box with alpha 1 on exact button boundbox
|
2009-03-25 16:58:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* fill this struct with polygon info to draw AA'ed */
|
|
|
|
/* it has outline, back, and two optional tria meshes */
|
|
|
|
|
|
|
|
typedef struct uiWidgetTrias {
|
2011-09-10 01:39:21 +00:00
|
|
|
unsigned int tot;
|
2018-04-01 11:49:15 +02:00
|
|
|
int type;
|
|
|
|
float size, center[2];
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2013-05-08 12:56:11 +00:00
|
|
|
float vec[16][2];
|
2013-04-30 01:51:25 +00:00
|
|
|
const unsigned int (*index)[3];
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
} uiWidgetTrias;
|
|
|
|
|
2011-09-09 13:10:18 +00:00
|
|
|
/* max as used by round_box__edges */
|
2018-03-29 03:21:03 +02:00
|
|
|
/* Make sure to change widget_base_vert.glsl accordingly. */
|
2011-09-09 13:10:18 +00:00
|
|
|
#define WIDGET_CURVE_RESOLU 9
|
2012-03-30 01:51:25 +00:00
|
|
|
#define WIDGET_SIZE_MAX (WIDGET_CURVE_RESOLU * 4)
|
2011-09-09 13:10:18 +00:00
|
|
|
|
2009-03-25 16:58:42 +00:00
|
|
|
typedef struct uiWidgetBase {
|
2018-03-29 03:21:03 +02:00
|
|
|
/* TODO remove these completely */
|
2009-03-25 16:58:42 +00:00
|
|
|
int totvert, halfwayvert;
|
2011-09-09 13:10:18 +00:00
|
|
|
float outer_v[WIDGET_SIZE_MAX][2];
|
|
|
|
float inner_v[WIDGET_SIZE_MAX][2];
|
|
|
|
float inner_uv[WIDGET_SIZE_MAX][2];
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2018-03-29 03:21:03 +02:00
|
|
|
bool draw_inner, draw_outline, draw_emboss;
|
2009-04-02 18:16:15 +00:00
|
|
|
|
2009-03-25 16:58:42 +00:00
|
|
|
uiWidgetTrias tria1;
|
|
|
|
uiWidgetTrias tria2;
|
2018-03-29 03:21:03 +02:00
|
|
|
|
|
|
|
/* Widget shader parameters, must match the shader layout. */
|
2018-04-05 18:51:08 +02:00
|
|
|
uiWidgetBaseParameters uniform_params;
|
2009-03-25 16:58:42 +00:00
|
|
|
} uiWidgetBase;
|
|
|
|
|
2015-05-31 14:20:03 +10:00
|
|
|
/** uiWidgetType: for time being only for visual appearance,
|
2012-03-03 16:31:46 +00:00
|
|
|
* later, a handling callback can be added too
|
|
|
|
*/
|
2009-04-02 15:01:11 +00:00
|
|
|
typedef struct uiWidgetType {
|
|
|
|
|
|
|
|
/* pointer to theme color definition */
|
|
|
|
uiWidgetColors *wcol_theme;
|
2009-07-12 02:06:15 +00:00
|
|
|
uiWidgetStateColors *wcol_state;
|
2009-04-02 15:01:11 +00:00
|
|
|
|
|
|
|
/* converted colors for state */
|
|
|
|
uiWidgetColors wcol;
|
|
|
|
|
|
|
|
void (*state)(struct uiWidgetType *, int state);
|
|
|
|
void (*draw)(uiWidgetColors *, rcti *, int state, int roundboxalign);
|
2009-04-02 18:16:15 +00:00
|
|
|
void (*custom)(uiBut *, uiWidgetColors *, rcti *, int state, int roundboxalign);
|
2013-12-07 15:47:57 +11:00
|
|
|
void (*text)(uiFontStyle *, uiWidgetColors *, uiBut *, rcti *);
|
2009-04-02 15:01:11 +00:00
|
|
|
|
|
|
|
} uiWidgetType;
|
|
|
|
|
|
|
|
|
|
|
|
/* *********************** draw data ************************** */
|
|
|
|
|
2013-04-30 01:51:25 +00:00
|
|
|
static const float cornervec[WIDGET_CURVE_RESOLU][2] = {
|
2012-05-20 19:49:27 +00:00
|
|
|
{0.0, 0.0}, {0.195, 0.02}, {0.383, 0.067},
|
|
|
|
{0.55, 0.169}, {0.707, 0.293}, {0.831, 0.45},
|
|
|
|
{0.924, 0.617}, {0.98, 0.805}, {1.0, 1.0}
|
|
|
|
};
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2018-04-20 15:15:10 +02:00
|
|
|
|
|
|
|
const float ui_pixel_jitter[UI_PIXEL_AA_JITTER][2] = {
|
2012-03-30 01:51:25 +00:00
|
|
|
{ 0.468813, -0.481430}, {-0.155755, -0.352820},
|
|
|
|
{ 0.219306, -0.238501}, {-0.393286, -0.110949},
|
|
|
|
{-0.024699, 0.013908}, { 0.343805, 0.147431},
|
|
|
|
{-0.272855, 0.269918}, { 0.095909, 0.388710}
|
|
|
|
};
|
2018-04-20 15:15:10 +02:00
|
|
|
#define WIDGET_AA_JITTER UI_PIXEL_AA_JITTER
|
|
|
|
#define jit ui_pixel_jitter
|
2012-03-30 01:51:25 +00:00
|
|
|
|
2017-11-02 05:48:14 +11:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Shape Preset Data
|
|
|
|
* \{ */
|
|
|
|
|
|
|
|
static const float g_shape_preset_number_arrow_vert[3][2] = {
|
2012-03-30 01:51:25 +00:00
|
|
|
{-0.352077, 0.532607}, {-0.352077, -0.549313}, {0.330000, -0.008353}
|
|
|
|
};
|
2017-11-02 05:48:14 +11:00
|
|
|
static const uint g_shape_preset_number_arrow_face[1][3] = {
|
2012-03-30 01:51:25 +00:00
|
|
|
{0, 1, 2}
|
|
|
|
};
|
|
|
|
|
2017-11-02 05:48:14 +11:00
|
|
|
static const float g_shape_preset_scroll_circle_vert[16][2] = {
|
2012-03-30 01:51:25 +00:00
|
|
|
{0.382684, 0.923879}, {0.000001, 1.000000}, {-0.382683, 0.923880}, {-0.707107, 0.707107},
|
|
|
|
{-0.923879, 0.382684}, {-1.000000, 0.000000}, {-0.923880, -0.382684}, {-0.707107, -0.707107},
|
|
|
|
{-0.382683, -0.923880}, {0.000000, -1.000000}, {0.382684, -0.923880}, {0.707107, -0.707107},
|
|
|
|
{0.923880, -0.382684}, {1.000000, -0.000000}, {0.923880, 0.382683}, {0.707107, 0.707107}
|
|
|
|
};
|
2017-11-02 05:48:14 +11:00
|
|
|
static const uint g_shape_preset_scroll_circle_face[14][3] = {
|
2012-03-30 01:51:25 +00:00
|
|
|
{0, 1, 2}, {2, 0, 3}, {3, 0, 15}, {3, 15, 4}, {4, 15, 14}, {4, 14, 5}, {5, 14, 13}, {5, 13, 6},
|
|
|
|
{6, 13, 12}, {6, 12, 7}, {7, 12, 11}, {7, 11, 8}, {8, 11, 10}, {8, 10, 9}
|
|
|
|
};
|
|
|
|
|
2017-11-02 05:48:14 +11:00
|
|
|
static const float g_shape_preset_menu_arrow_vert[6][2] = {
|
2012-06-05 21:54:21 +00:00
|
|
|
{-0.33, 0.16}, {0.33, 0.16}, {0, 0.82},
|
|
|
|
{0, -0.82}, {-0.33, -0.16}, {0.33, -0.16}
|
|
|
|
};
|
2017-11-02 05:48:14 +11:00
|
|
|
static const uint g_shape_preset_menu_arrow_face[2][3] = {{2, 0, 1}, {3, 5, 4}};
|
2012-05-22 15:50:13 +00:00
|
|
|
|
2017-11-02 05:48:14 +11:00
|
|
|
static const float g_shape_preset_checkmark_vert[6][2] = {
|
2012-03-30 01:51:25 +00:00
|
|
|
{-0.578579, 0.253369}, {-0.392773, 0.412794}, {-0.004241, -0.328551},
|
|
|
|
{-0.003001, 0.034320}, {1.055313, 0.864744}, {0.866408, 1.026895}
|
|
|
|
};
|
|
|
|
|
2017-11-02 05:48:14 +11:00
|
|
|
static const uint g_shape_preset_checkmark_face[4][3] = {
|
2012-03-30 01:51:25 +00:00
|
|
|
{3, 2, 4}, {3, 4, 5}, {1, 0, 3}, {0, 2, 3}
|
|
|
|
};
|
|
|
|
|
2018-04-25 21:24:55 +02:00
|
|
|
#define OY (-0.2 / 2)
|
|
|
|
#define SC (0.35 * 2)
|
2017-11-02 05:48:14 +11:00
|
|
|
static const float g_shape_preset_hold_action_vert[6][2] = {
|
2017-11-02 04:30:07 +11:00
|
|
|
{-0.5 + SC, 1.0 + OY}, {0.5, 1.0 + OY}, {0.5, 0.0 + OY + SC},
|
|
|
|
};
|
2017-11-02 05:48:14 +11:00
|
|
|
static const uint g_shape_preset_hold_action_face[2][3] = {{2, 0, 1}, {3, 5, 4}};
|
2017-11-02 04:30:07 +11:00
|
|
|
#undef OY
|
|
|
|
#undef SC
|
|
|
|
|
2017-11-02 05:48:14 +11:00
|
|
|
/** \} */
|
|
|
|
|
2018-03-29 03:21:03 +02:00
|
|
|
/* **************** Batch creations ****************** */
|
|
|
|
/**
|
|
|
|
* In order to speed up UI drawing we create some batches that are then
|
|
|
|
* modified by specialized shaders to draw certain elements really fast.
|
|
|
|
* TODO: find a better place. Maybe it's own file?
|
|
|
|
**/
|
2018-04-01 11:50:30 +02:00
|
|
|
|
2018-04-01 11:49:15 +02:00
|
|
|
/* offset in triavec[] in shader per type */
|
2018-04-15 21:32:04 +02:00
|
|
|
static const int tria_ofs[ROUNDBOX_TRIA_MAX] = {
|
|
|
|
[ROUNDBOX_TRIA_NONE] = 0,
|
|
|
|
[ROUNDBOX_TRIA_ARROWS] = 0,
|
|
|
|
[ROUNDBOX_TRIA_SCROLL] = 6,
|
|
|
|
[ROUNDBOX_TRIA_MENU] = 22,
|
|
|
|
[ROUNDBOX_TRIA_CHECK] = 28,
|
|
|
|
[ROUNDBOX_TRIA_HOLD_ACTION_ARROW] = 34,
|
|
|
|
};
|
|
|
|
static const int tria_vcount[ROUNDBOX_TRIA_MAX] = {
|
|
|
|
[ROUNDBOX_TRIA_NONE] = 0,
|
|
|
|
[ROUNDBOX_TRIA_ARROWS] = 3,
|
|
|
|
[ROUNDBOX_TRIA_SCROLL] = 16,
|
|
|
|
[ROUNDBOX_TRIA_MENU] = 3,
|
|
|
|
[ROUNDBOX_TRIA_CHECK] = 6,
|
|
|
|
[ROUNDBOX_TRIA_HOLD_ACTION_ARROW] = 3,
|
|
|
|
};
|
2018-04-01 11:49:15 +02:00
|
|
|
|
2018-03-29 03:21:03 +02:00
|
|
|
static struct {
|
2018-04-05 18:51:08 +02:00
|
|
|
Gwn_Batch *roundbox_widget[ROUNDBOX_TRIA_MAX];
|
|
|
|
|
|
|
|
Gwn_Batch *roundbox_simple;
|
|
|
|
Gwn_Batch *roundbox_simple_aa;
|
|
|
|
Gwn_Batch *roundbox_simple_outline;
|
2018-04-06 10:09:23 +02:00
|
|
|
Gwn_Batch *roundbox_shadow;
|
2018-03-29 03:21:03 +02:00
|
|
|
|
|
|
|
Gwn_VertFormat format;
|
|
|
|
uint vflag_id;
|
2018-04-01 11:49:15 +02:00
|
|
|
} g_ui_batch_cache = {{0}};
|
2018-03-29 03:21:03 +02:00
|
|
|
|
|
|
|
static Gwn_VertFormat *vflag_format(void)
|
|
|
|
{
|
|
|
|
if (g_ui_batch_cache.format.attrib_ct == 0) {
|
|
|
|
Gwn_VertFormat *format = &g_ui_batch_cache.format;
|
|
|
|
g_ui_batch_cache.vflag_id = GWN_vertformat_attr_add(format, "vflag", GWN_COMP_U32, 1, GWN_FETCH_INT);
|
|
|
|
}
|
|
|
|
return &g_ui_batch_cache.format;
|
|
|
|
}
|
|
|
|
|
2018-03-29 16:35:45 +02:00
|
|
|
#define INNER 0
|
|
|
|
#define OUTLINE 1
|
|
|
|
#define EMBOSS 2
|
|
|
|
#define NO_AA WIDGET_AA_JITTER
|
|
|
|
|
|
|
|
static void set_roundbox_vertex_data(
|
|
|
|
Gwn_VertBufRaw *vflag_step, uint32_t d)
|
|
|
|
{
|
|
|
|
uint32_t *data = GWN_vertbuf_raw_step(vflag_step);
|
|
|
|
*data = d;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t set_roundbox_vertex(
|
2018-03-29 03:21:03 +02:00
|
|
|
Gwn_VertBufRaw *vflag_step,
|
2018-03-29 16:35:45 +02:00
|
|
|
int corner_id, int corner_v, int jit_v, bool inner, bool emboss, int color)
|
2018-03-29 03:21:03 +02:00
|
|
|
{
|
|
|
|
uint32_t *data = GWN_vertbuf_raw_step(vflag_step);
|
|
|
|
*data = corner_id;
|
|
|
|
*data |= corner_v << 2;
|
|
|
|
*data |= jit_v << 6;
|
2018-03-29 16:35:45 +02:00
|
|
|
*data |= color << 12;
|
2018-03-29 03:21:03 +02:00
|
|
|
*data |= (inner) ? (1 << 10) : 0; /* is inner vert */
|
|
|
|
*data |= (emboss) ? (1 << 11) : 0; /* is emboss vert */
|
2018-03-29 16:35:45 +02:00
|
|
|
return *data;
|
2018-03-29 03:21:03 +02:00
|
|
|
}
|
|
|
|
|
2018-04-01 11:49:15 +02:00
|
|
|
static uint32_t set_tria_vertex(
|
|
|
|
Gwn_VertBufRaw *vflag_step,
|
|
|
|
int tria_type, int tria_v, int tria_id, int jit_v)
|
|
|
|
{
|
|
|
|
uint32_t *data = GWN_vertbuf_raw_step(vflag_step);
|
|
|
|
if (ELEM(tria_type, ROUNDBOX_TRIA_ARROWS, ROUNDBOX_TRIA_MENU)) {
|
|
|
|
tria_v += tria_id * 3;
|
|
|
|
}
|
|
|
|
*data = tria_ofs[tria_type] + tria_v;
|
|
|
|
*data |= jit_v << 6;
|
|
|
|
*data |= (tria_id == 0) ? (1 << 10) : 0; /* is first tria */
|
|
|
|
*data |= 1 << 14; /* is tria vert */
|
|
|
|
return *data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void roundbox_batch_add_tria(Gwn_VertBufRaw *vflag_step, int tria, uint32_t last_data)
|
|
|
|
{
|
2018-04-15 21:14:10 +02:00
|
|
|
const int tria_num = ELEM(tria, ROUNDBOX_TRIA_CHECK, ROUNDBOX_TRIA_HOLD_ACTION_ARROW) ? 1 : 2;
|
2018-04-01 11:49:15 +02:00
|
|
|
/* for each tria */
|
|
|
|
for (int t = 0; t < tria_num; ++t) {
|
|
|
|
for (int j = 0; j < WIDGET_AA_JITTER; j++) {
|
|
|
|
/* restart */
|
|
|
|
set_roundbox_vertex_data(vflag_step, last_data);
|
|
|
|
set_tria_vertex(vflag_step, tria, 0, t, j);
|
|
|
|
for (int v = 0; v < tria_vcount[tria]; v++) {
|
|
|
|
last_data = set_tria_vertex(vflag_step, tria, v, t, j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-05 18:51:08 +02:00
|
|
|
Gwn_Batch *ui_batch_roundbox_widget_get(int tria)
|
2018-03-29 03:21:03 +02:00
|
|
|
{
|
2018-04-05 18:51:08 +02:00
|
|
|
if (g_ui_batch_cache.roundbox_widget[tria] == NULL) {
|
2018-03-29 16:35:45 +02:00
|
|
|
uint32_t last_data;
|
2018-03-29 03:21:03 +02:00
|
|
|
Gwn_VertBufRaw vflag_step;
|
|
|
|
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(vflag_format());
|
2018-03-29 16:35:45 +02:00
|
|
|
int vcount = WIDGET_SIZE_MAX; /* inner */
|
|
|
|
vcount += 2; /* restart */
|
|
|
|
vcount += ((WIDGET_SIZE_MAX + 1) * 2) * WIDGET_AA_JITTER; /* outline (edges) */
|
|
|
|
vcount += 2; /* restart */
|
|
|
|
vcount += ((WIDGET_CURVE_RESOLU * 2) * 2) * WIDGET_AA_JITTER; /* emboss */
|
2018-04-01 11:49:15 +02:00
|
|
|
if (tria) {
|
|
|
|
vcount += (tria_vcount[tria] + 2) * WIDGET_AA_JITTER; /* tria1 */
|
2018-04-15 21:14:10 +02:00
|
|
|
if (!ELEM(tria, ROUNDBOX_TRIA_CHECK, ROUNDBOX_TRIA_HOLD_ACTION_ARROW)) {
|
2018-04-01 11:49:15 +02:00
|
|
|
vcount += (tria_vcount[tria] + 2) * WIDGET_AA_JITTER; /* tria2 */
|
|
|
|
}
|
|
|
|
}
|
2018-03-29 16:35:45 +02:00
|
|
|
GWN_vertbuf_data_alloc(vbo, vcount);
|
2018-03-29 03:21:03 +02:00
|
|
|
GWN_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step);
|
2018-03-29 16:35:45 +02:00
|
|
|
/* Inner */
|
|
|
|
for (int c1 = 0, c2 = 3; c1 < 2; c1++, c2--) {
|
|
|
|
for (int a1 = 0, a2 = WIDGET_CURVE_RESOLU -1; a2 >= 0; a1++, a2--) {
|
|
|
|
last_data = set_roundbox_vertex(&vflag_step, c1, a1, NO_AA, true, false, INNER);
|
|
|
|
last_data = set_roundbox_vertex(&vflag_step, c2, a2, NO_AA, true, false, INNER);
|
2018-03-29 03:21:03 +02:00
|
|
|
}
|
|
|
|
}
|
2018-03-29 16:35:45 +02:00
|
|
|
/* restart */
|
|
|
|
set_roundbox_vertex_data(&vflag_step, last_data);
|
|
|
|
set_roundbox_vertex(&vflag_step, 0, 0, 0, true, false, OUTLINE);
|
|
|
|
/* Outlines */
|
2018-03-29 03:21:03 +02:00
|
|
|
for (int j = 0; j < WIDGET_AA_JITTER; j++) {
|
|
|
|
for (int c = 0; c < 4; c++) {
|
|
|
|
for (int a = 0; a < WIDGET_CURVE_RESOLU; a++) {
|
2018-03-29 16:35:45 +02:00
|
|
|
set_roundbox_vertex(&vflag_step, c, a, j, true, false, OUTLINE);
|
|
|
|
set_roundbox_vertex(&vflag_step, c, a, j, false, false, OUTLINE);
|
2018-03-29 03:21:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Close the loop. */
|
2018-03-29 16:35:45 +02:00
|
|
|
set_roundbox_vertex(&vflag_step, 0, 0, j, true, false, OUTLINE);
|
|
|
|
last_data = set_roundbox_vertex(&vflag_step, 0, 0, j, false, false, OUTLINE);
|
2018-03-29 03:21:03 +02:00
|
|
|
}
|
2018-03-29 16:35:45 +02:00
|
|
|
/* restart */
|
|
|
|
set_roundbox_vertex_data(&vflag_step, last_data);
|
|
|
|
set_roundbox_vertex(&vflag_step, 0, 0, 0, false, false, EMBOSS);
|
|
|
|
/* Emboss */
|
2018-04-01 11:49:15 +02:00
|
|
|
bool rev = false; /* go back and forth : avoid degenerate triangle (but beware of backface cull) */
|
2018-03-29 03:21:03 +02:00
|
|
|
for (int j = 0; j < WIDGET_AA_JITTER; j++, rev = !rev) {
|
|
|
|
for (int c = (rev) ? 1 : 0; (rev) ? c >= 0 : c < 2; (rev) ? c-- : c++) {
|
|
|
|
int sta = (rev) ? WIDGET_CURVE_RESOLU - 1 : 0;
|
|
|
|
int end = WIDGET_CURVE_RESOLU;
|
|
|
|
for (int a = sta; (rev) ? a >= 0 : a < end; (rev) ? a-- : a++) {
|
2018-03-29 16:35:45 +02:00
|
|
|
set_roundbox_vertex(&vflag_step, c, a, j, false, false, EMBOSS);
|
2018-04-01 11:49:15 +02:00
|
|
|
last_data = set_roundbox_vertex(&vflag_step, c, a, j, false, true, EMBOSS);
|
2018-03-29 03:21:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-04-01 11:49:15 +02:00
|
|
|
if (tria) {
|
|
|
|
roundbox_batch_add_tria(&vflag_step, tria, last_data);
|
|
|
|
}
|
2018-04-05 18:51:08 +02:00
|
|
|
g_ui_batch_cache.roundbox_widget[tria] = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO);
|
|
|
|
gpu_batch_presets_register(g_ui_batch_cache.roundbox_widget[tria]);
|
2018-03-29 03:21:03 +02:00
|
|
|
}
|
2018-04-05 18:51:08 +02:00
|
|
|
return g_ui_batch_cache.roundbox_widget[tria];
|
|
|
|
}
|
|
|
|
|
|
|
|
Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased)
|
|
|
|
{
|
|
|
|
Gwn_Batch **batch = NULL;
|
|
|
|
|
|
|
|
if (filled) {
|
|
|
|
if (antialiased)
|
|
|
|
batch = &g_ui_batch_cache.roundbox_simple_aa;
|
|
|
|
else
|
|
|
|
batch = &g_ui_batch_cache.roundbox_simple;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (antialiased)
|
|
|
|
BLI_assert(0); /* Use GL_LINE_SMOOTH instead!!: */
|
|
|
|
else
|
|
|
|
batch = &g_ui_batch_cache.roundbox_simple_outline;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*batch == NULL) {
|
|
|
|
uint32_t last_data;
|
|
|
|
Gwn_VertBufRaw vflag_step;
|
|
|
|
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(vflag_format());
|
|
|
|
int vcount = WIDGET_SIZE_MAX;
|
|
|
|
vcount += (filled) ? 2 : 0;
|
|
|
|
vcount *= (antialiased) ? WIDGET_AA_JITTER : 1;
|
|
|
|
GWN_vertbuf_data_alloc(vbo, vcount);
|
|
|
|
GWN_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step);
|
|
|
|
|
|
|
|
if (filled) {
|
|
|
|
for (int j = 0; j < WIDGET_AA_JITTER; j++) {
|
|
|
|
if (!antialiased) {
|
|
|
|
j = NO_AA;
|
|
|
|
}
|
|
|
|
/* restart */
|
|
|
|
set_roundbox_vertex(&vflag_step, 0, 0, j, true, false, INNER);
|
|
|
|
for (int c1 = 0, c2 = 3; c1 < 2; c1++, c2--) {
|
|
|
|
for (int a1 = 0, a2 = WIDGET_CURVE_RESOLU -1; a2 >= 0; a1++, a2--) {
|
|
|
|
last_data = set_roundbox_vertex(&vflag_step, c1, a1, j, true, false, INNER);
|
|
|
|
last_data = set_roundbox_vertex(&vflag_step, c2, a2, j, true, false, INNER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* restart */
|
|
|
|
set_roundbox_vertex_data(&vflag_step, last_data);
|
|
|
|
if (!antialiased) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*batch = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (int j = 0; j < WIDGET_AA_JITTER; j++) {
|
|
|
|
if (!antialiased) {
|
|
|
|
j = NO_AA;
|
|
|
|
}
|
|
|
|
for (int c = 0; c < 4; c++) {
|
|
|
|
for (int a = 0; a < WIDGET_CURVE_RESOLU; a++) {
|
|
|
|
set_roundbox_vertex(&vflag_step, c, a, j, true, false, INNER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!antialiased) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*batch = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO);
|
|
|
|
}
|
|
|
|
|
|
|
|
gpu_batch_presets_register(*batch);
|
|
|
|
}
|
|
|
|
return *batch;
|
2018-03-29 03:21:03 +02:00
|
|
|
}
|
|
|
|
|
2018-04-06 10:09:23 +02:00
|
|
|
Gwn_Batch *ui_batch_roundbox_shadow_get(void)
|
|
|
|
{
|
|
|
|
if (g_ui_batch_cache.roundbox_shadow == NULL) {
|
|
|
|
uint32_t last_data;
|
|
|
|
Gwn_VertBufRaw vflag_step;
|
|
|
|
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(vflag_format());
|
|
|
|
int vcount = (WIDGET_SIZE_MAX + 1) * 2 + 2 + WIDGET_SIZE_MAX;
|
|
|
|
GWN_vertbuf_data_alloc(vbo, vcount);
|
|
|
|
GWN_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step);
|
|
|
|
|
|
|
|
for (int c = 0; c < 4; c++) {
|
|
|
|
for (int a = 0; a < WIDGET_CURVE_RESOLU; a++) {
|
|
|
|
set_roundbox_vertex(&vflag_step, c, a, NO_AA, true, false, INNER);
|
|
|
|
set_roundbox_vertex(&vflag_step, c, a, NO_AA, false, false, INNER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* close loop */
|
|
|
|
last_data = set_roundbox_vertex(&vflag_step, 0, 0, NO_AA, true, false, INNER);
|
|
|
|
last_data = set_roundbox_vertex(&vflag_step, 0, 0, NO_AA, false, false, INNER);
|
|
|
|
/* restart */
|
|
|
|
set_roundbox_vertex_data(&vflag_step, last_data);
|
|
|
|
set_roundbox_vertex(&vflag_step, 0, 0, NO_AA, true, false, INNER);
|
|
|
|
/* filled */
|
|
|
|
for (int c1 = 0, c2 = 3; c1 < 2; c1++, c2--) {
|
|
|
|
for (int a1 = 0, a2 = WIDGET_CURVE_RESOLU -1; a2 >= 0; a1++, a2--) {
|
|
|
|
set_roundbox_vertex(&vflag_step, c1, a1, NO_AA, true, false, INNER);
|
|
|
|
set_roundbox_vertex(&vflag_step, c2, a2, NO_AA, true, false, INNER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_ui_batch_cache.roundbox_shadow = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO);
|
|
|
|
gpu_batch_presets_register(g_ui_batch_cache.roundbox_shadow);
|
|
|
|
}
|
|
|
|
return g_ui_batch_cache.roundbox_shadow;
|
|
|
|
}
|
|
|
|
|
2018-03-29 16:35:45 +02:00
|
|
|
#undef INNER
|
|
|
|
#undef OUTLINE
|
|
|
|
#undef EMBOSS
|
|
|
|
#undef NO_AA
|
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
/* ************************************************* */
|
|
|
|
|
2018-04-22 19:02:17 +02:00
|
|
|
void UI_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3,
|
2017-02-14 13:00:22 +01:00
|
|
|
const float color[4])
|
2009-04-02 15:01:11 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
float tri_arr[3][2] = {{x1, y1}, {x2, y2}, {x3, y3}};
|
2017-02-14 13:00:22 +01:00
|
|
|
float draw_color[4];
|
|
|
|
|
|
|
|
copy_v4_v4(draw_color, color);
|
2018-04-22 17:01:57 +02:00
|
|
|
/* Note: This won't give back the original color. */
|
|
|
|
draw_color[3] *= 1.0f / WIDGET_AA_JITTER;
|
2017-02-14 13:00:22 +01:00
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
glEnable(GL_BLEND);
|
2011-09-09 14:44:36 +00:00
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
2017-02-14 13:00:22 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
|
|
|
immUniformColor4fv(draw_color);
|
2017-06-19 20:18:04 +10:00
|
|
|
immBegin(GWN_PRIM_TRIS, 3 * WIDGET_AA_JITTER);
|
2011-09-09 14:44:36 +00:00
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
/* for each AA step */
|
2017-02-14 13:00:22 +01:00
|
|
|
for (int j = 0; j < WIDGET_AA_JITTER; j++) {
|
2017-02-14 14:35:18 +01:00
|
|
|
immVertex2f(pos, tri_arr[0][0] + jit[j][0], tri_arr[0][1] + jit[j][1]);
|
|
|
|
immVertex2f(pos, tri_arr[1][0] + jit[j][0], tri_arr[1][1] + jit[j][1]);
|
|
|
|
immVertex2f(pos, tri_arr[2][0] + jit[j][0], tri_arr[2][1] + jit[j][1]);
|
2009-04-02 15:01:11 +00:00
|
|
|
}
|
2017-02-14 14:35:18 +01:00
|
|
|
|
2017-02-14 13:00:22 +01:00
|
|
|
immEnd();
|
|
|
|
|
|
|
|
immUnbindProgram();
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
glDisable(GL_BLEND);
|
2011-12-16 22:00:53 +00:00
|
|
|
}
|
|
|
|
|
2018-04-22 18:56:06 +02:00
|
|
|
void UI_draw_anti_fan(float tri_array[][2], unsigned int length, const float color[4])
|
|
|
|
{
|
|
|
|
float draw_color[4];
|
|
|
|
|
|
|
|
copy_v4_v4(draw_color, color);
|
|
|
|
draw_color[3] *= 2.0f / WIDGET_AA_JITTER;
|
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
|
|
|
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
|
|
|
immUniformColor4fv(draw_color);
|
|
|
|
|
|
|
|
/* for each AA step */
|
|
|
|
for (int j = 0; j < WIDGET_AA_JITTER; j++) {
|
|
|
|
immBegin(GWN_PRIM_TRI_FAN, length);
|
|
|
|
immVertex2f(pos, tri_array[0][0], tri_array[0][1]);
|
|
|
|
immVertex2f(pos, tri_array[1][0], tri_array[1][1]);
|
|
|
|
|
|
|
|
/* We jitter only the middle of the fan, the extremes are pinned. */
|
|
|
|
for (int i = 2; i < length - 1; i++) {
|
|
|
|
immVertex2f(pos, tri_array[i][0] + jit[j][0], tri_array[i][1] + jit[j][1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
immVertex2f(pos, tri_array[length - 1][0], tri_array[length - 1][1]);
|
|
|
|
immEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
immUnbindProgram();
|
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
|
|
|
|
2009-04-02 18:16:15 +00:00
|
|
|
static void widget_init(uiWidgetBase *wtb)
|
2009-03-25 16:58:42 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
wtb->totvert = wtb->halfwayvert = 0;
|
|
|
|
wtb->tria1.tot = 0;
|
|
|
|
wtb->tria2.tot = 0;
|
2018-04-01 11:49:15 +02:00
|
|
|
wtb->tria1.type = ROUNDBOX_TRIA_NONE;
|
|
|
|
wtb->tria1.size = 0;
|
|
|
|
wtb->tria2.size = 0;
|
2012-03-30 01:51:25 +00:00
|
|
|
|
2015-05-29 21:30:04 +02:00
|
|
|
wtb->draw_inner = true;
|
|
|
|
wtb->draw_outline = true;
|
|
|
|
wtb->draw_emboss = true;
|
2018-03-29 03:21:03 +02:00
|
|
|
|
|
|
|
wtb->uniform_params.shade_dir = 1.0f;
|
2018-04-28 02:51:27 +02:00
|
|
|
wtb->uniform_params.alpha_discard = 1.0f;
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* helper call, makes shadow rect, with 'sun' above menu, so only shadow to left/right/bottom */
|
|
|
|
/* return tot */
|
2012-12-13 02:40:49 +00:00
|
|
|
static int round_box_shadow_edges(float (*vert)[2], const rcti *rect, float rad, int roundboxalign, float step)
|
2009-04-03 16:26:03 +00:00
|
|
|
{
|
2011-09-09 13:10:18 +00:00
|
|
|
float vec[WIDGET_CURVE_RESOLU][2];
|
2009-04-03 16:26:03 +00:00
|
|
|
float minx, miny, maxx, maxy;
|
2012-03-30 01:51:25 +00:00
|
|
|
int a, tot = 0;
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
rad += step;
|
2009-04-15 14:43:54 +00:00
|
|
|
|
2012-09-15 11:48:20 +00:00
|
|
|
if (2.0f * rad > BLI_rcti_size_y(rect))
|
|
|
|
rad = 0.5f * BLI_rcti_size_y(rect);
|
2012-12-20 16:50:39 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
minx = rect->xmin - step;
|
|
|
|
miny = rect->ymin - step;
|
|
|
|
maxx = rect->xmax + step;
|
|
|
|
maxy = rect->ymax + step;
|
2009-04-03 16:26:03 +00:00
|
|
|
|
|
|
|
/* mult */
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < WIDGET_CURVE_RESOLU; a++) {
|
|
|
|
vec[a][0] = rad * cornervec[a][0];
|
|
|
|
vec[a][1] = rad * cornervec[a][1];
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* start with left-top, anti clockwise */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (roundboxalign & UI_CNR_TOP_LEFT) {
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
|
|
|
vert[tot][0] = minx + rad - vec[a][0];
|
|
|
|
vert[tot][1] = maxy - vec[a][1];
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
|
|
|
vert[tot][0] = minx;
|
|
|
|
vert[tot][1] = maxy;
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (roundboxalign & UI_CNR_BOTTOM_LEFT) {
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
|
|
|
vert[tot][0] = minx + vec[a][1];
|
|
|
|
vert[tot][1] = miny + rad - vec[a][0];
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
|
|
|
vert[tot][0] = minx;
|
|
|
|
vert[tot][1] = miny;
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (roundboxalign & UI_CNR_BOTTOM_RIGHT) {
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
|
|
|
vert[tot][0] = maxx - rad + vec[a][0];
|
|
|
|
vert[tot][1] = miny + vec[a][1];
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
|
|
|
vert[tot][0] = maxx;
|
|
|
|
vert[tot][1] = miny;
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (roundboxalign & UI_CNR_TOP_RIGHT) {
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
|
|
|
vert[tot][0] = maxx - vec[a][1];
|
|
|
|
vert[tot][1] = maxy - rad + vec[a][0];
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
|
|
|
vert[tot][0] = maxx;
|
|
|
|
vert[tot][1] = maxy;
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return tot;
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
2009-06-08 12:39:39 +00:00
|
|
|
/* this call has 1 extra arg to allow mask outline */
|
2012-12-13 02:40:49 +00:00
|
|
|
static void round_box__edges(uiWidgetBase *wt, int roundboxalign, const rcti *rect, float rad, float radi)
|
2009-03-25 16:58:42 +00:00
|
|
|
{
|
2011-09-09 13:10:18 +00:00
|
|
|
float vec[WIDGET_CURVE_RESOLU][2], veci[WIDGET_CURVE_RESOLU][2];
|
2012-03-30 01:51:25 +00:00
|
|
|
float minx = rect->xmin, miny = rect->ymin, maxx = rect->xmax, maxy = rect->ymax;
|
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
|
|
|
float minxi = minx + U.pixelsize; /* boundbox inner */
|
|
|
|
float maxxi = maxx - U.pixelsize;
|
|
|
|
float minyi = miny + U.pixelsize;
|
|
|
|
float maxyi = maxy - U.pixelsize;
|
2012-03-30 01:51:25 +00:00
|
|
|
float facxi = (maxxi != minxi) ? 1.0f / (maxxi - minxi) : 0.0f; /* for uv, can divide by zero */
|
|
|
|
float facyi = (maxyi != minyi) ? 1.0f / (maxyi - minyi) : 0.0f;
|
|
|
|
int a, tot = 0, minsize;
|
|
|
|
const int hnum = ((roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT)) == (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT) ||
|
|
|
|
(roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT)) == (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT)) ? 1 : 2;
|
|
|
|
const int vnum = ((roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)) == (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT) ||
|
|
|
|
(roundboxalign & (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) == (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) ? 1 : 2;
|
|
|
|
|
2012-10-23 13:28:22 +00:00
|
|
|
minsize = min_ii(BLI_rcti_size_x(rect) * hnum,
|
2013-01-21 18:45:31 +00:00
|
|
|
BLI_rcti_size_y(rect) * vnum);
|
2012-03-30 01:51:25 +00:00
|
|
|
|
|
|
|
if (2.0f * rad > minsize)
|
|
|
|
rad = 0.5f * minsize;
|
|
|
|
|
|
|
|
if (2.0f * (radi + 1.0f) > minsize)
|
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
|
|
|
radi = 0.5f * minsize - U.pixelsize;
|
2018-03-29 03:21:03 +02:00
|
|
|
|
|
|
|
wt->uniform_params.rad = rad;
|
|
|
|
wt->uniform_params.radi = radi;
|
|
|
|
wt->uniform_params.facxi = facxi;
|
|
|
|
wt->uniform_params.facyi = facyi;
|
|
|
|
wt->uniform_params.round_corners[0] = (roundboxalign & UI_CNR_BOTTOM_LEFT) ? 1.0f : 0.0f;
|
|
|
|
wt->uniform_params.round_corners[1] = (roundboxalign & UI_CNR_BOTTOM_RIGHT) ? 1.0f : 0.0f;
|
|
|
|
wt->uniform_params.round_corners[2] = (roundboxalign & UI_CNR_TOP_RIGHT) ? 1.0f : 0.0f;
|
|
|
|
wt->uniform_params.round_corners[3] = (roundboxalign & UI_CNR_TOP_LEFT) ? 1.0f : 0.0f;
|
|
|
|
BLI_rctf_rcti_copy(&wt->uniform_params.rect, rect);
|
|
|
|
BLI_rctf_init(&wt->uniform_params.recti, minxi, maxxi, minyi, maxyi);
|
|
|
|
|
2009-03-25 16:58:42 +00:00
|
|
|
/* mult */
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < WIDGET_CURVE_RESOLU; a++) {
|
|
|
|
veci[a][0] = radi * cornervec[a][0];
|
|
|
|
veci[a][1] = radi * cornervec[a][1];
|
|
|
|
vec[a][0] = rad * cornervec[a][0];
|
|
|
|
vec[a][1] = rad * cornervec[a][1];
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* corner left-bottom */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (roundboxalign & UI_CNR_BOTTOM_LEFT) {
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
|
|
|
wt->inner_v[tot][0] = minxi + veci[a][1];
|
|
|
|
wt->inner_v[tot][1] = minyi + radi - veci[a][0];
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->outer_v[tot][0] = minx + vec[a][1];
|
|
|
|
wt->outer_v[tot][1] = miny + rad - vec[a][0];
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->inner_uv[tot][0] = facxi * (wt->inner_v[tot][0] - minxi);
|
|
|
|
wt->inner_uv[tot][1] = facyi * (wt->inner_v[tot][1] - minyi);
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->inner_v[tot][0] = minxi;
|
|
|
|
wt->inner_v[tot][1] = minyi;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->outer_v[tot][0] = minx;
|
|
|
|
wt->outer_v[tot][1] = miny;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->inner_uv[tot][0] = 0.0f;
|
|
|
|
wt->inner_uv[tot][1] = 0.0f;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
tot++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* corner right-bottom */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (roundboxalign & UI_CNR_BOTTOM_RIGHT) {
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
|
|
|
wt->inner_v[tot][0] = maxxi - radi + veci[a][0];
|
|
|
|
wt->inner_v[tot][1] = minyi + veci[a][1];
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->outer_v[tot][0] = maxx - rad + vec[a][0];
|
|
|
|
wt->outer_v[tot][1] = miny + vec[a][1];
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->inner_uv[tot][0] = facxi * (wt->inner_v[tot][0] - minxi);
|
|
|
|
wt->inner_uv[tot][1] = facyi * (wt->inner_v[tot][1] - minyi);
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->inner_v[tot][0] = maxxi;
|
|
|
|
wt->inner_v[tot][1] = minyi;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->outer_v[tot][0] = maxx;
|
|
|
|
wt->outer_v[tot][1] = miny;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->inner_uv[tot][0] = 1.0f;
|
|
|
|
wt->inner_uv[tot][1] = 0.0f;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
tot++;
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->halfwayvert = tot;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
/* corner right-top */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (roundboxalign & UI_CNR_TOP_RIGHT) {
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
|
|
|
wt->inner_v[tot][0] = maxxi - veci[a][1];
|
|
|
|
wt->inner_v[tot][1] = maxyi - radi + veci[a][0];
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->outer_v[tot][0] = maxx - vec[a][1];
|
|
|
|
wt->outer_v[tot][1] = maxy - rad + vec[a][0];
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->inner_uv[tot][0] = facxi * (wt->inner_v[tot][0] - minxi);
|
|
|
|
wt->inner_uv[tot][1] = facyi * (wt->inner_v[tot][1] - minyi);
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->inner_v[tot][0] = maxxi;
|
|
|
|
wt->inner_v[tot][1] = maxyi;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->outer_v[tot][0] = maxx;
|
|
|
|
wt->outer_v[tot][1] = maxy;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->inner_uv[tot][0] = 1.0f;
|
|
|
|
wt->inner_uv[tot][1] = 1.0f;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
tot++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* corner left-top */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (roundboxalign & UI_CNR_TOP_LEFT) {
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
|
|
|
|
wt->inner_v[tot][0] = minxi + radi - veci[a][0];
|
|
|
|
wt->inner_v[tot][1] = maxyi - veci[a][1];
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->outer_v[tot][0] = minx + rad - vec[a][0];
|
|
|
|
wt->outer_v[tot][1] = maxy - vec[a][1];
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->inner_uv[tot][0] = facxi * (wt->inner_v[tot][0] - minxi);
|
|
|
|
wt->inner_uv[tot][1] = facyi * (wt->inner_v[tot][1] - minyi);
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->inner_v[tot][0] = minxi;
|
|
|
|
wt->inner_v[tot][1] = maxyi;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->outer_v[tot][0] = minx;
|
|
|
|
wt->outer_v[tot][1] = maxy;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->inner_uv[tot][0] = 0.0f;
|
|
|
|
wt->inner_uv[tot][1] = 1.0f;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
tot++;
|
|
|
|
}
|
2011-09-09 13:10:18 +00:00
|
|
|
|
|
|
|
BLI_assert(tot <= WIDGET_SIZE_MAX);
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->totvert = tot;
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
2012-12-13 02:40:49 +00:00
|
|
|
static void round_box_edges(uiWidgetBase *wt, int roundboxalign, const rcti *rect, float rad)
|
2009-06-08 12:39:39 +00: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
|
|
|
round_box__edges(wt, roundboxalign, rect, rad, rad - U.pixelsize);
|
2009-06-08 12:39:39 +00:00
|
|
|
}
|
|
|
|
|
2017-11-02 05:48:14 +11:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Shape Preset Mini API
|
|
|
|
* \{ */
|
2009-06-08 12:39:39 +00:00
|
|
|
|
2009-03-25 16:58:42 +00:00
|
|
|
/* based on button rect, return scaled array of triangles */
|
2017-11-02 05:48:14 +11:00
|
|
|
static void shape_preset_init_trias_ex(
|
2014-06-22 15:01:54 +10:00
|
|
|
uiWidgetTrias *tria, const rcti *rect, float triasize, char where,
|
|
|
|
/* input data */
|
|
|
|
const float verts[][2], const int verts_tot,
|
|
|
|
const unsigned int tris[][3], const int tris_tot)
|
2009-03-25 16:58:42 +00:00
|
|
|
{
|
2009-07-03 13:21:09 +00:00
|
|
|
float centx, centy, sizex, sizey, minsize;
|
2012-03-30 01:51:25 +00:00
|
|
|
int a, i1 = 0, i2 = 1;
|
2014-06-22 15:01:54 +10:00
|
|
|
|
2018-04-22 13:57:50 +02:00
|
|
|
if (where == 'r' || where == 'l') {
|
|
|
|
minsize = BLI_rcti_size_y(rect);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
minsize = BLI_rcti_size_x(rect);
|
|
|
|
}
|
2014-06-22 15:01:54 +10:00
|
|
|
|
2009-03-25 16:58:42 +00:00
|
|
|
/* center position and size */
|
2014-10-12 01:01:59 +02:00
|
|
|
centx = (float)rect->xmin + 0.4f * minsize;
|
2012-03-30 01:51:25 +00:00
|
|
|
centy = (float)rect->ymin + 0.5f * minsize;
|
2018-04-01 11:49:15 +02:00
|
|
|
tria->size = sizex = sizey = -0.5f * triasize * minsize;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (where == 'r') {
|
2014-10-12 01:01:59 +02:00
|
|
|
centx = (float)rect->xmax - 0.4f * minsize;
|
2012-03-30 01:51:25 +00:00
|
|
|
sizex = -sizex;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2012-03-30 01:51:25 +00:00
|
|
|
else if (where == 't') {
|
2018-04-01 11:50:30 +02:00
|
|
|
centx = (float)rect->xmin + 0.5f * minsize;
|
2012-03-30 01:51:25 +00:00
|
|
|
centy = (float)rect->ymax - 0.5f * minsize;
|
|
|
|
sizey = -sizey;
|
|
|
|
i2 = 0; i1 = 1;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2012-03-30 01:51:25 +00:00
|
|
|
else if (where == 'b') {
|
2018-04-01 11:50:30 +02:00
|
|
|
centx = (float)rect->xmin + 0.5f * minsize;
|
2012-03-30 01:51:25 +00:00
|
|
|
sizex = -sizex;
|
|
|
|
i2 = 0; i1 = 1;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2014-06-22 15:01:54 +10:00
|
|
|
|
|
|
|
for (a = 0; a < verts_tot; a++) {
|
|
|
|
tria->vec[a][0] = sizex * verts[a][i1] + centx;
|
|
|
|
tria->vec[a][1] = sizey * verts[a][i2] + centy;
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
2014-06-22 15:01:54 +10:00
|
|
|
|
2018-04-01 11:49:15 +02:00
|
|
|
tria->center[0] = centx;
|
|
|
|
tria->center[1] = centy;
|
|
|
|
|
2014-06-22 15:01:54 +10:00
|
|
|
tria->tot = tris_tot;
|
|
|
|
tria->index = tris;
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
2017-11-02 05:48:14 +11:00
|
|
|
static void shape_preset_init_number_arrows(uiWidgetTrias *tria, const rcti *rect, float triasize, char where)
|
2009-09-14 12:28:59 +00:00
|
|
|
{
|
2018-04-01 11:49:15 +02:00
|
|
|
tria->type = ROUNDBOX_TRIA_ARROWS;
|
2017-11-02 05:48:14 +11:00
|
|
|
shape_preset_init_trias_ex(
|
2014-06-22 15:01:54 +10:00
|
|
|
tria, rect, triasize, where,
|
2017-11-02 05:48:14 +11:00
|
|
|
g_shape_preset_number_arrow_vert, ARRAY_SIZE(g_shape_preset_number_arrow_vert),
|
|
|
|
g_shape_preset_number_arrow_face, ARRAY_SIZE(g_shape_preset_number_arrow_face));
|
2014-06-22 15:01:54 +10:00
|
|
|
}
|
2009-09-14 12:28:59 +00:00
|
|
|
|
2017-11-02 05:48:14 +11:00
|
|
|
static void shape_preset_init_hold_action(uiWidgetTrias *tria, const rcti *rect, float triasize, char where)
|
2009-09-14 12:28:59 +00:00
|
|
|
{
|
2018-04-15 21:14:10 +02:00
|
|
|
tria->type = ROUNDBOX_TRIA_HOLD_ACTION_ARROW;
|
|
|
|
/* With the current changes to use batches for widget drawing, the code
|
|
|
|
* below is doing almost nothing effectively. 'where' doesn't work either,
|
|
|
|
* shader is currently hardcoded to work for the button triangle pointing
|
|
|
|
* at the lower right. The same limitation applies to other trias as well.
|
|
|
|
* XXX Should be addressed. */
|
2017-11-02 05:48:14 +11:00
|
|
|
shape_preset_init_trias_ex(
|
2014-06-22 15:01:54 +10:00
|
|
|
tria, rect, triasize, where,
|
2017-11-02 05:48:14 +11:00
|
|
|
g_shape_preset_hold_action_vert, ARRAY_SIZE(g_shape_preset_hold_action_vert),
|
|
|
|
g_shape_preset_hold_action_face, ARRAY_SIZE(g_shape_preset_hold_action_face));
|
2014-06-22 15:01:54 +10:00
|
|
|
}
|
2009-09-14 12:28:59 +00:00
|
|
|
|
2017-11-02 05:48:14 +11:00
|
|
|
static void shape_preset_init_scroll_circle(uiWidgetTrias *tria, const rcti *rect, float triasize, char where)
|
2014-06-22 15:01:54 +10:00
|
|
|
{
|
2018-04-01 11:49:15 +02:00
|
|
|
tria->type = ROUNDBOX_TRIA_SCROLL;
|
2017-11-02 05:48:14 +11:00
|
|
|
shape_preset_init_trias_ex(
|
2014-06-22 15:01:54 +10:00
|
|
|
tria, rect, triasize, where,
|
2017-11-02 05:48:14 +11:00
|
|
|
g_shape_preset_scroll_circle_vert, ARRAY_SIZE(g_shape_preset_scroll_circle_vert),
|
|
|
|
g_shape_preset_scroll_circle_face, ARRAY_SIZE(g_shape_preset_scroll_circle_face));
|
2009-09-14 12:28:59 +00:00
|
|
|
}
|
|
|
|
|
2017-02-20 21:21:04 +01:00
|
|
|
static void widget_draw_vertex_buffer(unsigned int pos, unsigned int col, int mode,
|
|
|
|
const float quads_pos[WIDGET_SIZE_MAX][2],
|
|
|
|
const unsigned char quads_col[WIDGET_SIZE_MAX][4],
|
|
|
|
unsigned int totvert)
|
|
|
|
{
|
|
|
|
immBegin(mode, totvert);
|
|
|
|
for (int i = 0; i < totvert; ++i) {
|
|
|
|
if (quads_col)
|
|
|
|
immAttrib4ubv(col, quads_col[i]);
|
|
|
|
immVertex2fv(pos, quads_pos[i]);
|
|
|
|
}
|
|
|
|
immEnd();
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
2017-11-02 05:48:14 +11:00
|
|
|
static void shape_preset_trias_from_rect_menu(uiWidgetTrias *tria, const rcti *rect)
|
2009-03-25 16:58:42 +00:00
|
|
|
{
|
2012-12-18 20:00:52 +00:00
|
|
|
float centx, centy, size;
|
2009-03-25 16:58:42 +00:00
|
|
|
int a;
|
2018-04-01 11:49:15 +02:00
|
|
|
tria->type = ROUNDBOX_TRIA_MENU;
|
2015-04-13 16:56:43 -04:00
|
|
|
|
2009-03-25 16:58:42 +00:00
|
|
|
/* center position and size */
|
2018-04-01 11:49:15 +02:00
|
|
|
tria->center[0] = centx = rect->xmax - 0.32f * BLI_rcti_size_y(rect);
|
|
|
|
tria->center[1] = centy = rect->ymin + 0.50f * BLI_rcti_size_y(rect);
|
|
|
|
tria->size = size = 0.4f * BLI_rcti_size_y(rect);
|
2015-04-13 16:56:43 -04:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < 6; a++) {
|
2017-11-02 05:48:14 +11:00
|
|
|
tria->vec[a][0] = size * g_shape_preset_menu_arrow_vert[a][0] + centx;
|
|
|
|
tria->vec[a][1] = size * g_shape_preset_menu_arrow_vert[a][1] + centy;
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
tria->tot = 2;
|
2017-11-02 05:48:14 +11:00
|
|
|
tria->index = g_shape_preset_menu_arrow_face;
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
2017-11-02 05:48:14 +11:00
|
|
|
static void shape_preset_trias_from_rect_checkmark(uiWidgetTrias *tria, const rcti *rect)
|
2009-03-25 16:58:42 +00:00
|
|
|
{
|
|
|
|
float centx, centy, size;
|
|
|
|
int a;
|
2018-04-01 11:49:15 +02:00
|
|
|
tria->type = ROUNDBOX_TRIA_CHECK;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
/* center position and size */
|
2018-04-01 11:49:15 +02:00
|
|
|
tria->center[0] = centx = rect->xmin + 0.5f * BLI_rcti_size_y(rect);
|
|
|
|
tria->center[1] = centy = rect->ymin + 0.5f * BLI_rcti_size_y(rect);
|
|
|
|
tria->size = size = 0.5f * BLI_rcti_size_y(rect);
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < 6; a++) {
|
2017-11-02 05:48:14 +11:00
|
|
|
tria->vec[a][0] = size * g_shape_preset_checkmark_vert[a][0] + centx;
|
|
|
|
tria->vec[a][1] = size * g_shape_preset_checkmark_vert[a][1] + centy;
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
tria->tot = 4;
|
2017-11-02 05:48:14 +11:00
|
|
|
tria->index = g_shape_preset_checkmark_face;
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
2017-11-02 05:48:14 +11:00
|
|
|
/** \} */
|
|
|
|
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
/* prepares shade colors */
|
2013-12-07 15:47:57 +11:00
|
|
|
static void shadecolors4(char coltop[4], char coldown[4], const char *color, short shadetop, short shadedown)
|
2009-03-25 16:58:42 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
coltop[0] = CLAMPIS(color[0] + shadetop, 0, 255);
|
|
|
|
coltop[1] = CLAMPIS(color[1] + shadetop, 0, 255);
|
|
|
|
coltop[2] = CLAMPIS(color[2] + shadetop, 0, 255);
|
|
|
|
coltop[3] = color[3];
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
coldown[0] = CLAMPIS(color[0] + shadedown, 0, 255);
|
|
|
|
coldown[1] = CLAMPIS(color[1] + shadedown, 0, 255);
|
|
|
|
coldown[2] = CLAMPIS(color[2] + shadedown, 0, 255);
|
|
|
|
coldown[3] = color[3];
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
2014-03-16 03:24:05 +11:00
|
|
|
static void round_box_shade_col4_r(unsigned char r_col[4], const char col1[4], const char col2[4], const float fac)
|
2011-09-09 14:44:36 +00:00
|
|
|
{
|
2018-05-07 17:31:28 +02:00
|
|
|
const int faci = unit_float_to_uchar_clamp(fac);
|
2012-03-30 01:51:25 +00:00
|
|
|
const int facm = 255 - faci;
|
2011-09-09 14:44:36 +00:00
|
|
|
|
2015-04-08 12:23:38 +10:00
|
|
|
r_col[0] = (faci * col1[0] + facm * col2[0]) / 256;
|
|
|
|
r_col[1] = (faci * col1[1] + facm * col2[1]) / 256;
|
|
|
|
r_col[2] = (faci * col1[2] + facm * col2[2]) / 256;
|
|
|
|
r_col[3] = (faci * col1[3] + facm * col2[3]) / 256;
|
2011-09-09 14:44:36 +00:00
|
|
|
}
|
|
|
|
|
2015-01-27 20:18:39 +01:00
|
|
|
static void widget_verts_to_triangle_strip(uiWidgetBase *wtb, const int totvert, float triangle_strip[WIDGET_SIZE_MAX * 2 + 2][2])
|
2009-06-08 12:39:39 +00:00
|
|
|
{
|
|
|
|
int a;
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < totvert; a++) {
|
2015-01-27 20:18:39 +01:00
|
|
|
copy_v2_v2(triangle_strip[a * 2], wtb->outer_v[a]);
|
|
|
|
copy_v2_v2(triangle_strip[a * 2 + 1], wtb->inner_v[a]);
|
2009-06-08 12:39:39 +00:00
|
|
|
}
|
2015-01-27 20:18:39 +01:00
|
|
|
copy_v2_v2(triangle_strip[a * 2], wtb->outer_v[0]);
|
|
|
|
copy_v2_v2(triangle_strip[a * 2 + 1], wtb->inner_v[0]);
|
2011-09-09 14:44:36 +00:00
|
|
|
}
|
|
|
|
|
2017-02-20 21:21:04 +01:00
|
|
|
static void widgetbase_outline(uiWidgetBase *wtb, unsigned int pos)
|
2011-09-09 14:44:36 +00:00
|
|
|
{
|
2015-01-27 20:18:39 +01:00
|
|
|
float triangle_strip[WIDGET_SIZE_MAX * 2 + 2][2]; /* + 2 because the last pair is wrapped */
|
|
|
|
widget_verts_to_triangle_strip(wtb, wtb->totvert, triangle_strip);
|
2011-09-09 14:44:36 +00:00
|
|
|
|
2017-02-20 21:21:04 +01:00
|
|
|
widget_draw_vertex_buffer(pos, 0, GL_TRIANGLE_STRIP, triangle_strip, NULL, wtb->totvert * 2 + 2);
|
2009-06-08 12:39:39 +00:00
|
|
|
}
|
|
|
|
|
2018-04-28 02:51:27 +02:00
|
|
|
static void widgetbase_set_uniform_alpha_discard(
|
|
|
|
uiWidgetBase *wtb,
|
|
|
|
const bool alpha_check,
|
|
|
|
const float discard_factor)
|
|
|
|
{
|
|
|
|
if (alpha_check) {
|
|
|
|
wtb->uniform_params.alpha_discard = -discard_factor;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
wtb->uniform_params.alpha_discard = discard_factor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void widgetbase_set_uniform_alpha_check(
|
|
|
|
uiWidgetBase *wtb,
|
|
|
|
const bool alpha_check)
|
|
|
|
{
|
|
|
|
const float discard_factor = fabs(wtb->uniform_params.alpha_discard);
|
|
|
|
widgetbase_set_uniform_alpha_discard(wtb, alpha_check, discard_factor);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void widgetbase_set_uniform_discard_factor(
|
|
|
|
uiWidgetBase *wtb,
|
|
|
|
const float discard_factor)
|
|
|
|
{
|
|
|
|
bool alpha_check = wtb->uniform_params.alpha_discard < 0.0f;
|
|
|
|
widgetbase_set_uniform_alpha_discard(wtb, alpha_check, discard_factor);
|
|
|
|
}
|
|
|
|
|
2018-03-29 16:35:45 +02:00
|
|
|
static void widgetbase_set_uniform_colors_ubv(
|
|
|
|
uiWidgetBase *wtb,
|
|
|
|
const unsigned char *col1, const unsigned char *col2,
|
|
|
|
const unsigned char *outline,
|
2018-04-01 11:49:15 +02:00
|
|
|
const unsigned char *emboss,
|
2018-04-06 23:54:24 +02:00
|
|
|
const unsigned char *tria,
|
|
|
|
const bool alpha_check)
|
2018-03-29 03:21:03 +02:00
|
|
|
{
|
2018-04-28 02:51:27 +02:00
|
|
|
widgetbase_set_uniform_alpha_check(wtb, alpha_check);
|
2018-03-29 16:35:45 +02:00
|
|
|
rgba_float_args_set_ch(wtb->uniform_params.color_inner1, col1[0], col1[1], col1[2], col1[3]);
|
|
|
|
rgba_float_args_set_ch(wtb->uniform_params.color_inner2, col2[0], col2[1], col2[2], col2[3]);
|
|
|
|
rgba_float_args_set_ch(wtb->uniform_params.color_outline, outline[0], outline[1], outline[2], outline[3]);
|
|
|
|
rgba_float_args_set_ch(wtb->uniform_params.color_emboss, emboss[0], emboss[1], emboss[2], emboss[3]);
|
2018-04-01 11:49:15 +02:00
|
|
|
rgba_float_args_set_ch(wtb->uniform_params.color_tria, tria[0], tria[1], tria[2], tria[3]);
|
2018-03-29 03:21:03 +02:00
|
|
|
}
|
|
|
|
|
2018-04-06 14:25:55 +02:00
|
|
|
/* keep in sync with shader */
|
|
|
|
#define MAX_WIDGET_BASE_BATCH 6
|
2018-04-28 01:29:51 +02:00
|
|
|
#define MAX_WIDGET_PARAMETERS 11
|
2018-04-06 14:25:55 +02:00
|
|
|
|
|
|
|
struct {
|
|
|
|
Gwn_Batch *batch; /* Batch type */
|
|
|
|
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH];
|
|
|
|
int count;
|
|
|
|
bool enabled;
|
|
|
|
} g_widget_base_batch = {0};
|
|
|
|
|
|
|
|
void UI_widgetbase_draw_cache_flush(void)
|
|
|
|
{
|
2018-04-06 23:54:24 +02:00
|
|
|
float checker_params[3] = {UI_ALPHA_CHECKER_DARK / 255.0f, UI_ALPHA_CHECKER_LIGHT / 255.0f, 8.0f};
|
|
|
|
|
2018-04-06 14:25:55 +02:00
|
|
|
if (g_widget_base_batch.count == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Gwn_Batch *batch = g_widget_base_batch.batch;
|
|
|
|
if (g_widget_base_batch.count == 1) {
|
|
|
|
/* draw single */
|
|
|
|
GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
|
2018-04-28 01:29:51 +02:00
|
|
|
GWN_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS, (float *)g_widget_base_batch.params);
|
2018-04-06 23:54:24 +02:00
|
|
|
GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params);
|
2018-04-06 14:25:55 +02:00
|
|
|
GWN_batch_draw(batch);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE_INST);
|
2018-04-28 01:29:51 +02:00
|
|
|
GWN_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS * MAX_WIDGET_BASE_BATCH,
|
|
|
|
(float *)g_widget_base_batch.params);
|
2018-04-06 23:54:24 +02:00
|
|
|
GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params);
|
2018-04-06 14:25:55 +02:00
|
|
|
gpuBindMatrices(batch->interface);
|
|
|
|
GWN_batch_draw_range_ex(batch, 0, g_widget_base_batch.count, true);
|
|
|
|
GWN_batch_program_use_end(batch);
|
|
|
|
}
|
|
|
|
g_widget_base_batch.count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UI_widgetbase_draw_cache_begin(void)
|
|
|
|
{
|
|
|
|
BLI_assert(g_widget_base_batch.enabled == false);
|
|
|
|
g_widget_base_batch.enabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UI_widgetbase_draw_cache_end(void)
|
|
|
|
{
|
|
|
|
BLI_assert(g_widget_base_batch.enabled == true);
|
|
|
|
g_widget_base_batch.enabled = false;
|
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
|
|
|
UI_widgetbase_draw_cache_flush();
|
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
|
|
|
|
2018-03-29 03:21:03 +02:00
|
|
|
static void draw_widgetbase_batch(Gwn_Batch *batch, uiWidgetBase *wtb)
|
|
|
|
{
|
2018-04-01 11:49:15 +02:00
|
|
|
wtb->uniform_params.tria1_size = wtb->tria1.size;
|
|
|
|
wtb->uniform_params.tria2_size = wtb->tria2.size;
|
|
|
|
copy_v2_v2(wtb->uniform_params.tria1_center, wtb->tria1.center);
|
|
|
|
copy_v2_v2(wtb->uniform_params.tria2_center, wtb->tria2.center);
|
|
|
|
|
2018-04-06 14:25:55 +02:00
|
|
|
if (g_widget_base_batch.enabled) {
|
|
|
|
if (g_widget_base_batch.batch == NULL) {
|
|
|
|
g_widget_base_batch.batch = ui_batch_roundbox_widget_get(ROUNDBOX_TRIA_ARROWS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draw multi */
|
|
|
|
if (batch != g_ui_batch_cache.roundbox_widget[ROUNDBOX_TRIA_NONE] &&
|
|
|
|
batch != g_widget_base_batch.batch)
|
|
|
|
{
|
|
|
|
/* issue previous calls before changing batch type. */
|
|
|
|
UI_widgetbase_draw_cache_flush();
|
|
|
|
g_widget_base_batch.batch = batch;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No need to change batch if tria is not visible. Just scale it to 0. */
|
|
|
|
if (batch == g_ui_batch_cache.roundbox_widget[ROUNDBOX_TRIA_NONE]) {
|
|
|
|
wtb->uniform_params.tria1_size = wtb->uniform_params.tria2_size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_widget_base_batch.params[g_widget_base_batch.count] = wtb->uniform_params;
|
|
|
|
g_widget_base_batch.count++;
|
|
|
|
|
|
|
|
if (g_widget_base_batch.count == MAX_WIDGET_BASE_BATCH) {
|
|
|
|
UI_widgetbase_draw_cache_flush();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2018-04-06 23:54:24 +02:00
|
|
|
float checker_params[3] = {UI_ALPHA_CHECKER_DARK / 255.0f, UI_ALPHA_CHECKER_LIGHT / 255.0f, 8.0f};
|
2018-04-06 14:25:55 +02:00
|
|
|
/* draw single */
|
|
|
|
GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
|
|
|
|
GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&wtb->uniform_params);
|
2018-04-06 23:54:24 +02:00
|
|
|
GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params);
|
2018-04-06 14:25:55 +02:00
|
|
|
GWN_batch_draw(batch);
|
|
|
|
}
|
2018-03-29 03:21:03 +02:00
|
|
|
}
|
|
|
|
|
2018-04-28 22:54:11 +02:00
|
|
|
static void widgetbase_draw(uiWidgetBase *wtb, const uiWidgetColors *wcol)
|
2009-03-25 16:58:42 +00:00
|
|
|
{
|
2018-03-29 16:35:45 +02:00
|
|
|
unsigned char inner_col1[4] = {0};
|
|
|
|
unsigned char inner_col2[4] = {0};
|
|
|
|
unsigned char emboss_col[4] = {0};
|
|
|
|
unsigned char outline_col[4] = {0};
|
2018-04-01 11:49:15 +02:00
|
|
|
unsigned char tria_col[4] = {0};
|
2018-04-06 23:54:24 +02:00
|
|
|
/* For color widget. */
|
|
|
|
bool alpha_check = (wcol->alpha_check && (wcol->shaded == 0));
|
|
|
|
|
2009-03-25 16:58:42 +00:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
|
|
|
/* backdrop non AA */
|
2015-05-29 21:30:04 +02:00
|
|
|
if (wtb->draw_inner) {
|
2012-03-30 01:51:25 +00:00
|
|
|
if (wcol->shaded == 0) {
|
2018-04-06 23:54:24 +02:00
|
|
|
/* simple fill */
|
|
|
|
inner_col1[0] = inner_col2[0] = (unsigned char)wcol->inner[0];
|
|
|
|
inner_col1[1] = inner_col2[1] = (unsigned char)wcol->inner[1];
|
|
|
|
inner_col1[2] = inner_col2[2] = (unsigned char)wcol->inner[2];
|
|
|
|
inner_col1[3] = inner_col2[3] = (unsigned char)wcol->inner[3];
|
2009-04-02 18:16:15 +00:00
|
|
|
}
|
|
|
|
else {
|
2018-03-29 16:35:45 +02:00
|
|
|
/* gradient fill */
|
|
|
|
shadecolors4((char *)inner_col1, (char *)inner_col2, wcol->inner, wcol->shadetop, wcol->shadedown);
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
}
|
2017-02-20 21:21:04 +01:00
|
|
|
|
2015-05-29 21:30:04 +02:00
|
|
|
if (wtb->draw_outline) {
|
2018-03-29 16:35:45 +02:00
|
|
|
outline_col[0] = wcol->outline[0];
|
|
|
|
outline_col[1] = wcol->outline[1];
|
|
|
|
outline_col[2] = wcol->outline[2];
|
|
|
|
outline_col[3] = wcol->outline[3] / WIDGET_AA_JITTER;
|
2018-03-27 16:58:11 +02:00
|
|
|
|
|
|
|
/* emboss bottom shadow */
|
|
|
|
if (wtb->draw_emboss) {
|
2018-03-29 16:35:45 +02:00
|
|
|
UI_GetThemeColor4ubv(TH_WIDGET_EMBOSS, emboss_col);
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
}
|
2017-02-20 21:21:04 +01:00
|
|
|
|
2018-04-19 07:47:03 +02:00
|
|
|
if (wtb->tria1.type != ROUNDBOX_TRIA_NONE) {
|
2018-04-01 11:49:15 +02:00
|
|
|
tria_col[0] = wcol->item[0];
|
|
|
|
tria_col[1] = wcol->item[1];
|
|
|
|
tria_col[2] = wcol->item[2];
|
|
|
|
tria_col[3] = (unsigned char)((float)wcol->item[3] / WIDGET_AA_JITTER);
|
|
|
|
}
|
|
|
|
|
2018-03-29 16:35:45 +02:00
|
|
|
/* Draw everything in one drawcall */
|
2018-04-06 23:54:24 +02:00
|
|
|
if (inner_col1[3] || inner_col2[3] || outline_col[3] || emboss_col[3] || tria_col[3] || alpha_check) {
|
|
|
|
widgetbase_set_uniform_colors_ubv(wtb, inner_col1, inner_col2, outline_col, emboss_col, tria_col, alpha_check);
|
2018-03-29 16:35:45 +02:00
|
|
|
|
2018-04-05 18:51:08 +02:00
|
|
|
Gwn_Batch *roundbox_batch = ui_batch_roundbox_widget_get(wtb->tria1.type);
|
2018-03-29 16:35:45 +02:00
|
|
|
draw_widgetbase_batch(roundbox_batch, wtb);
|
|
|
|
}
|
|
|
|
|
2009-03-25 16:58:42 +00:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* *********************** text/icon ************************************** */
|
|
|
|
|
2014-01-04 14:47:20 +01:00
|
|
|
#define UI_TEXT_CLIP_MARGIN (0.25f * U.widget_unit / but->block->aspect)
|
2013-12-18 17:11:38 +11:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
#define PREVIEW_PAD 4
|
2010-01-03 08:37:18 +00:00
|
|
|
|
2015-05-25 22:06:25 +02:00
|
|
|
static void widget_draw_preview(BIFIconID icon, float alpha, const rcti *rect)
|
2010-01-03 08:37:18 +00:00
|
|
|
{
|
2011-01-07 04:10:37 +00:00
|
|
|
int w, h, size;
|
2010-07-26 04:00:09 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (icon == ICON_NONE)
|
2010-07-26 18:37:47 +00:00
|
|
|
return;
|
|
|
|
|
2012-09-15 11:48:20 +00:00
|
|
|
w = BLI_rcti_size_x(rect);
|
|
|
|
h = BLI_rcti_size_y(rect);
|
2010-01-03 08:37:18 +00:00
|
|
|
size = MIN2(w, h);
|
2012-03-30 01:51:25 +00:00
|
|
|
size -= PREVIEW_PAD * 2; /* padding */
|
2011-01-07 04:10:37 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (size > 0) {
|
2012-03-30 01:51:25 +00:00
|
|
|
int x = rect->xmin + w / 2 - size / 2;
|
|
|
|
int y = rect->ymin + h / 2 - size / 2;
|
2011-01-07 04:10:37 +00:00
|
|
|
|
2015-05-25 22:06:25 +02:00
|
|
|
UI_icon_draw_preview_aspect_size(x, y, icon, 1.0f, alpha, size);
|
2011-01-07 04:10:37 +00:00
|
|
|
}
|
2010-01-03 08:37:18 +00:00
|
|
|
}
|
|
|
|
|
2009-04-07 17:08:26 +00:00
|
|
|
|
2013-12-18 17:11:38 +11:00
|
|
|
static int ui_but_draw_menu_icon(const uiBut *but)
|
2011-11-14 14:42:47 +00:00
|
|
|
{
|
2014-11-09 21:20:40 +01:00
|
|
|
return (but->flag & UI_BUT_ICON_SUBMENU) && (but->dt == UI_EMBOSS_PULLDOWN);
|
2011-11-14 14:42:47 +00:00
|
|
|
}
|
|
|
|
|
2009-04-07 17:08:26 +00:00
|
|
|
/* icons have been standardized... and this call draws in untransformed coordinates */
|
|
|
|
|
2018-04-25 17:24:45 +02:00
|
|
|
static void widget_draw_icon_ex(
|
|
|
|
const uiBut *but, BIFIconID icon, float alpha, const rcti *rect, const bool show_menu_icon,
|
|
|
|
const int icon_size)
|
2009-04-07 17:08:26 +00: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
|
|
|
float xs = 0.0f, ys = 0.0f;
|
2009-06-04 15:19:48 +00:00
|
|
|
float aspect, height;
|
2009-04-07 17:08:26 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
if (but->flag & UI_BUT_ICON_PREVIEW) {
|
2014-04-27 23:38:21 +03:00
|
|
|
glEnable(GL_BLEND);
|
2011-01-20 16:29:43 +00:00
|
|
|
widget_draw_preview(icon, alpha, rect);
|
2014-04-27 23:38:21 +03:00
|
|
|
glDisable(GL_BLEND);
|
2010-01-03 08:37:18 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-07 17:08:26 +00:00
|
|
|
/* this icon doesn't need draw... */
|
2014-11-09 21:20:40 +01:00
|
|
|
if (icon == ICON_BLANK1 && (but->flag & UI_BUT_ICON_SUBMENU) == 0) return;
|
2009-04-07 17:08:26 +00:00
|
|
|
|
2012-12-18 19:35:54 +00:00
|
|
|
aspect = but->block->aspect / UI_DPI_FAC;
|
2018-04-25 17:24:45 +02:00
|
|
|
height = icon_size / aspect;
|
2012-12-19 11:55:41 +00:00
|
|
|
|
2009-04-30 17:27:30 +00:00
|
|
|
/* calculate blend color */
|
2014-11-09 21:20:40 +01:00
|
|
|
if (ELEM(but->type, UI_BTYPE_TOGGLE, UI_BTYPE_ROW, UI_BTYPE_TOGGLE_N, UI_BTYPE_LISTROW)) {
|
2012-10-07 09:48:59 +00:00
|
|
|
if (but->flag & UI_SELECT) {}
|
|
|
|
else if (but->flag & UI_ACTIVE) {}
|
2012-03-30 01:51:25 +00:00
|
|
|
else alpha = 0.5f;
|
2009-04-30 17:27:30 +00:00
|
|
|
}
|
2016-05-17 00:15:21 +10:00
|
|
|
else if ((but->type == UI_BTYPE_LABEL)) {
|
|
|
|
/* extra feature allows more alpha blending */
|
|
|
|
if (but->a1 == 1.0f) {
|
|
|
|
alpha *= but->a2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ELEM(but->type, UI_BTYPE_BUT)) {
|
|
|
|
if (but->flag & UI_BUT_DISABLED) {
|
|
|
|
alpha *= 0.5f;
|
|
|
|
}
|
|
|
|
}
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
|
2009-04-30 17:27:30 +00:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (icon && icon != ICON_BLANK1) {
|
2012-12-18 19:35:54 +00:00
|
|
|
float ofs = 1.0f / aspect;
|
|
|
|
|
2017-03-17 16:47:19 +03:00
|
|
|
if (but->drawflag & UI_BUT_ICON_LEFT) {
|
2017-03-28 13:44:02 +03:00
|
|
|
/* special case - icon_only pie buttons */
|
2018-05-05 14:47:50 +02:00
|
|
|
if (ui_block_is_pie_menu(but->block) && !ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_POPOVER) && but->str && but->str[0] == '\0')
|
2017-03-28 13:44:02 +03:00
|
|
|
xs = rect->xmin + 2.0f * ofs;
|
|
|
|
else if (but->dt == UI_EMBOSS_NONE || but->type == UI_BTYPE_LABEL)
|
|
|
|
xs = rect->xmin + 2.0f * ofs;
|
|
|
|
else
|
|
|
|
xs = rect->xmin + 4.0f * ofs;
|
2009-04-07 17:08:26 +00:00
|
|
|
}
|
|
|
|
else {
|
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
|
|
|
xs = (rect->xmin + rect->xmax - height) / 2.0f;
|
2009-04-07 17:08:26 +00:00
|
|
|
}
|
2017-03-28 13:44:02 +03:00
|
|
|
ys = (rect->ymin + rect->ymax - height) / 2.0f;
|
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
|
|
|
|
2012-12-19 11:55:41 +00:00
|
|
|
/* force positions to integers, for zoom levels near 1. draws icons crisp. */
|
|
|
|
if (aspect > 0.95f && aspect < 1.05f) {
|
|
|
|
xs = (int)(xs + 0.1f);
|
|
|
|
ys = (int)(ys + 0.1f);
|
|
|
|
}
|
2018-04-26 15:42:08 +02:00
|
|
|
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
/* to indicate draggable */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (but->dragpoin && (but->flag & UI_ACTIVE)) {
|
2012-03-30 01:51:25 +00:00
|
|
|
float rgb[3] = {1.25f, 1.25f, 1.25f};
|
2012-12-18 19:35:54 +00:00
|
|
|
UI_icon_draw_aspect_color(xs, ys, icon, aspect, rgb);
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
}
|
2018-04-26 15:42:08 +02:00
|
|
|
else if ((but->flag & (UI_ACTIVE | UI_SELECT | UI_SELECT_DRAW)) || !UI_but_is_tool(but)) {
|
2012-12-18 19:35:54 +00:00
|
|
|
UI_icon_draw_aspect(xs, ys, icon, aspect, alpha);
|
2018-04-26 15:42:08 +02:00
|
|
|
}
|
|
|
|
else {
|
2018-04-28 13:34:52 +02:00
|
|
|
const bTheme *btheme = UI_GetTheme();
|
|
|
|
UI_icon_draw_desaturate(xs, ys, icon, aspect, alpha, 1.0 - btheme->tui.icon_saturation);
|
2018-04-26 15:42:08 +02:00
|
|
|
}
|
2009-04-07 17:08:26 +00:00
|
|
|
}
|
2011-11-14 14:42:47 +00:00
|
|
|
|
2014-01-10 02:23:55 +11:00
|
|
|
if (show_menu_icon) {
|
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
|
|
|
xs = rect->xmax - UI_DPI_ICON_SIZE - aspect;
|
|
|
|
ys = (rect->ymin + rect->ymax - height) / 2.0f;
|
2009-04-30 17:27:30 +00:00
|
|
|
|
2012-12-18 19:35:54 +00:00
|
|
|
UI_icon_draw_aspect(xs, ys, ICON_RIGHTARROW_THIN, aspect, alpha);
|
2009-04-07 17:08:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
|
|
|
|
2018-04-25 17:24:45 +02:00
|
|
|
static void widget_draw_icon(
|
|
|
|
const uiBut *but, BIFIconID icon, float alpha, const rcti *rect, const bool show_menu_icon)
|
|
|
|
{
|
|
|
|
widget_draw_icon_ex(but, icon, alpha, rect, show_menu_icon, ICON_DEFAULT_HEIGHT);
|
|
|
|
}
|
|
|
|
|
2014-05-03 09:18:00 +10:00
|
|
|
static void ui_text_clip_give_prev_off(uiBut *but, const char *str)
|
2012-03-22 09:20:22 +00:00
|
|
|
{
|
2014-05-03 09:18:00 +10:00
|
|
|
const char *prev_utf8 = BLI_str_find_prev_char_utf8(str, str + but->ofs);
|
|
|
|
int bytes = str + but->ofs - prev_utf8;
|
2012-03-22 09:20:22 +00:00
|
|
|
|
|
|
|
but->ofs -= bytes;
|
|
|
|
}
|
|
|
|
|
2014-05-03 09:18:00 +10:00
|
|
|
static void ui_text_clip_give_next_off(uiBut *but, const char *str)
|
2012-03-22 09:20:22 +00:00
|
|
|
{
|
2014-05-03 09:18:00 +10:00
|
|
|
const char *next_utf8 = BLI_str_find_next_char_utf8(str + but->ofs, NULL);
|
|
|
|
int bytes = next_utf8 - (str + but->ofs);
|
2012-03-22 09:20:22 +00:00
|
|
|
|
|
|
|
but->ofs += bytes;
|
|
|
|
}
|
|
|
|
|
2015-05-31 14:20:03 +10:00
|
|
|
/**
|
|
|
|
* Helper.
|
2014-01-06 15:02:35 +01:00
|
|
|
* This func assumes things like kerning handling have already been handled!
|
|
|
|
* Return the length of modified (right-clipped + ellipsis) string.
|
|
|
|
*/
|
2015-05-05 03:13:47 +10:00
|
|
|
static void ui_text_clip_right_ex(
|
|
|
|
uiFontStyle *fstyle, char *str, const size_t max_len, const float okwidth,
|
|
|
|
const char *sep, const int sep_len, const float sep_strwidth, size_t *r_final_len)
|
2014-01-06 15:02:35 +01:00
|
|
|
{
|
|
|
|
float tmp;
|
|
|
|
int l_end;
|
|
|
|
|
2014-03-18 11:07:10 +11:00
|
|
|
BLI_assert(str[0]);
|
|
|
|
|
2014-01-06 15:02:35 +01:00
|
|
|
/* If the trailing ellipsis takes more than 20% of all available width, just cut the string
|
|
|
|
* (as using the ellipsis would remove even more useful chars, and we cannot show much already!).
|
|
|
|
*/
|
|
|
|
if (sep_strwidth / okwidth > 0.2f) {
|
2014-02-26 21:53:56 +01:00
|
|
|
l_end = BLF_width_to_strlen(fstyle->uifont_id, str, max_len, okwidth, &tmp);
|
|
|
|
str[l_end] = '\0';
|
2014-08-16 22:21:10 +02:00
|
|
|
if (r_final_len) {
|
|
|
|
*r_final_len = (size_t)l_end;
|
|
|
|
}
|
2014-01-06 15:02:35 +01:00
|
|
|
}
|
|
|
|
else {
|
2014-02-26 21:53:56 +01:00
|
|
|
l_end = BLF_width_to_strlen(fstyle->uifont_id, str, max_len, okwidth - sep_strwidth, &tmp);
|
|
|
|
memcpy(str + l_end, sep, sep_len + 1); /* +1 for trailing '\0'. */
|
2014-08-16 22:21:10 +02:00
|
|
|
if (r_final_len) {
|
|
|
|
*r_final_len = (size_t)(l_end + sep_len);
|
|
|
|
}
|
2014-01-06 15:02:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
/**
|
2014-02-26 21:53:56 +01:00
|
|
|
* Cut off the middle of the text to fit into the given width.
|
2014-01-06 15:02:35 +01:00
|
|
|
* Note in case this middle clipping would just remove a few chars, it rather clips right, which is more readable.
|
2014-08-16 22:21:10 +02:00
|
|
|
* If rpart_sep is not Null, the part of str starting to first occurrence of rpart_sep is preserved at all cost (useful
|
|
|
|
* for strings with shortcuts, like 'AVeryLongFooBarLabelForMenuEntry|Ctrl O' -> 'AVeryLong...MenuEntry|Ctrl O').
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
*/
|
2015-05-04 21:12:28 +02:00
|
|
|
float UI_text_clip_middle_ex(
|
|
|
|
uiFontStyle *fstyle, char *str, float okwidth, const float minwidth,
|
2015-06-03 15:01:02 +10:00
|
|
|
const size_t max_len, const char rpart_sep)
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
{
|
|
|
|
float strwidth;
|
|
|
|
|
2015-05-27 17:15:48 +02:00
|
|
|
/* Add some epsilon to OK width, avoids 'ellipsing' text that nearly fits!
|
2015-11-16 21:06:40 +11:00
|
|
|
* Better to have a small piece of the last char cut out, than two remaining chars replaced by an ellipsis... */
|
2015-05-27 17:15:48 +02:00
|
|
|
okwidth += 1.0f + UI_DPI_FAC;
|
|
|
|
|
2014-03-18 11:07:10 +11:00
|
|
|
BLI_assert(str[0]);
|
|
|
|
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
/* need to set this first */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_fontstyle_set(fstyle);
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
|
2014-02-26 21:53:56 +01:00
|
|
|
if (fstyle->kerning == 1) { /* for BLF_width */
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
2014-02-26 21:53:56 +01:00
|
|
|
}
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
|
2014-02-26 21:53:56 +01:00
|
|
|
strwidth = BLF_width(fstyle->uifont_id, str, max_len);
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
|
2014-02-27 18:29:10 +11:00
|
|
|
if ((okwidth > 0.0f) && (strwidth > okwidth)) {
|
2014-02-23 14:36:31 +11:00
|
|
|
/* utf8 ellipsis '...', some compilers complain */
|
|
|
|
const char sep[] = {0xe2, 0x80, 0xa6, 0x0};
|
2014-01-03 19:31:52 +11:00
|
|
|
const int sep_len = sizeof(sep) - 1;
|
2014-08-16 22:21:10 +02:00
|
|
|
const float sep_strwidth = BLF_width(fstyle->uifont_id, sep, sep_len + 1);
|
|
|
|
float parts_strwidth;
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
size_t l_end;
|
|
|
|
|
2014-08-16 22:21:10 +02:00
|
|
|
char *rpart = NULL, rpart_buf[UI_MAX_DRAW_STR];
|
|
|
|
float rpart_width = 0.0f;
|
|
|
|
size_t rpart_len = 0;
|
|
|
|
size_t final_lpart_len;
|
|
|
|
|
|
|
|
if (rpart_sep) {
|
2015-06-03 15:01:02 +10:00
|
|
|
rpart = strrchr(str, rpart_sep);
|
2014-08-16 22:21:10 +02:00
|
|
|
|
|
|
|
if (rpart) {
|
|
|
|
rpart_len = strlen(rpart);
|
|
|
|
rpart_width = BLF_width(fstyle->uifont_id, rpart, rpart_len);
|
|
|
|
okwidth -= rpart_width;
|
|
|
|
strwidth -= rpart_width;
|
|
|
|
|
|
|
|
if (okwidth < 0.0f) {
|
|
|
|
/* Not enough place for actual label, just display protected right part.
|
|
|
|
* Here just for safety, should never happen in real life! */
|
|
|
|
memmove(str, rpart, rpart_len + 1);
|
|
|
|
rpart = NULL;
|
|
|
|
okwidth += rpart_width;
|
|
|
|
strwidth = rpart_width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
parts_strwidth = (okwidth - sep_strwidth) / 2.0f;
|
|
|
|
|
|
|
|
if (rpart) {
|
|
|
|
strcpy(rpart_buf, rpart);
|
|
|
|
*rpart = '\0';
|
|
|
|
rpart = rpart_buf;
|
|
|
|
}
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
|
2014-08-16 22:21:10 +02:00
|
|
|
l_end = BLF_width_to_strlen(fstyle->uifont_id, str, max_len, parts_strwidth, &rpart_width);
|
|
|
|
if (l_end < 10 || min_ff(parts_strwidth, strwidth - okwidth) < minwidth) {
|
2014-01-04 16:50:42 +01:00
|
|
|
/* If we really have no place, or we would clip a very small piece of string in the middle,
|
|
|
|
* only show start of string.
|
|
|
|
*/
|
2014-08-16 22:21:10 +02:00
|
|
|
ui_text_clip_right_ex(fstyle, str, max_len, okwidth, sep, sep_len, sep_strwidth, &final_lpart_len);
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
size_t r_offset, r_len;
|
|
|
|
|
2014-08-16 22:21:10 +02:00
|
|
|
r_offset = BLF_width_to_rstrlen(fstyle->uifont_id, str, max_len, parts_strwidth, &rpart_width);
|
|
|
|
r_len = strlen(str + r_offset) + 1; /* +1 for the trailing '\0'. */
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
|
2014-08-16 22:21:10 +02:00
|
|
|
if (l_end + sep_len + r_len + rpart_len > max_len) {
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
/* Corner case, the str already takes all available mem, and the ellipsis chars would actually
|
|
|
|
* add more chars...
|
|
|
|
* Better to just trim one or two letters to the right in this case...
|
2014-01-06 15:02:35 +01:00
|
|
|
* Note: with a single-char ellipsis, this should never happen! But better be safe here...
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
*/
|
2014-08-16 22:21:10 +02:00
|
|
|
ui_text_clip_right_ex(fstyle, str, max_len, okwidth, sep, sep_len, sep_strwidth, &final_lpart_len);
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
}
|
|
|
|
else {
|
2014-02-26 21:53:56 +01:00
|
|
|
memmove(str + l_end + sep_len, str + r_offset, r_len);
|
|
|
|
memcpy(str + l_end, sep, sep_len);
|
2014-08-16 22:21:10 +02:00
|
|
|
final_lpart_len = (size_t)(l_end + sep_len + r_len - 1); /* -1 to remove trailing '\0'! */
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
}
|
|
|
|
}
|
2014-08-16 22:21:10 +02:00
|
|
|
|
|
|
|
if (rpart) {
|
|
|
|
/* Add back preserved right part to our shorten str. */
|
|
|
|
memcpy(str + final_lpart_len, rpart, rpart_len + 1); /* +1 for trailing '\0'. */
|
|
|
|
}
|
|
|
|
|
2014-02-26 21:53:56 +01:00
|
|
|
strwidth = BLF_width(fstyle->uifont_id, str, max_len);
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fstyle->kerning == 1) {
|
|
|
|
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
|
|
|
}
|
2014-02-26 21:53:56 +01:00
|
|
|
|
|
|
|
return strwidth;
|
|
|
|
}
|
|
|
|
|
2014-08-16 22:21:10 +02:00
|
|
|
/**
|
2015-05-04 21:12:28 +02:00
|
|
|
* Wrapper around UI_text_clip_middle_ex.
|
2014-08-16 22:21:10 +02:00
|
|
|
*/
|
2014-02-26 21:53:56 +01:00
|
|
|
static void ui_text_clip_middle(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
|
|
|
|
{
|
|
|
|
/* No margin for labels! */
|
2018-05-05 14:47:50 +02:00
|
|
|
const int border = ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_MENU, UI_BTYPE_POPOVER) ? 0 : (int)(UI_TEXT_CLIP_MARGIN + 0.5f);
|
2014-02-26 21:53:56 +01:00
|
|
|
const float okwidth = (float)max_ii(BLI_rcti_size_x(rect) - border, 0);
|
|
|
|
const size_t max_len = sizeof(but->drawstr);
|
|
|
|
const float minwidth = (float)(UI_DPI_ICON_SIZE) / but->block->aspect * 2.0f;
|
|
|
|
|
|
|
|
but->ofs = 0;
|
2015-06-03 15:01:02 +10:00
|
|
|
but->strwidth = UI_text_clip_middle_ex(fstyle, but->drawstr, okwidth, minwidth, max_len, '\0');
|
2014-08-16 22:21:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Like ui_text_clip_middle(), but protect/preserve at all cost the right part of the string after sep.
|
|
|
|
* Useful for strings with shortcuts (like 'AVeryLongFooBarLabelForMenuEntry|Ctrl O' -> 'AVeryLong...MenuEntry|Ctrl O').
|
|
|
|
*/
|
2015-06-03 15:01:02 +10:00
|
|
|
static void ui_text_clip_middle_protect_right(uiFontStyle *fstyle, uiBut *but, const rcti *rect, const char rsep)
|
2014-08-16 22:21:10 +02:00
|
|
|
{
|
|
|
|
/* No margin for labels! */
|
2018-05-05 14:47:50 +02:00
|
|
|
const int border = ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_MENU, UI_BTYPE_POPOVER) ? 0 : (int)(UI_TEXT_CLIP_MARGIN + 0.5f);
|
2014-08-16 22:21:10 +02:00
|
|
|
const float okwidth = (float)max_ii(BLI_rcti_size_x(rect) - border, 0);
|
|
|
|
const size_t max_len = sizeof(but->drawstr);
|
|
|
|
const float minwidth = (float)(UI_DPI_ICON_SIZE) / but->block->aspect * 2.0f;
|
|
|
|
|
|
|
|
but->ofs = 0;
|
2015-05-04 21:12:28 +02:00
|
|
|
but->strwidth = UI_text_clip_middle_ex(fstyle, but->drawstr, okwidth, minwidth, max_len, rsep);
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
}
|
|
|
|
|
2012-09-17 00:57:33 +00:00
|
|
|
/**
|
|
|
|
* Cut off the text, taking into account the cursor location (text display while editing).
|
|
|
|
*/
|
2012-12-13 02:40:49 +00:00
|
|
|
static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
|
2012-09-17 00:57:33 +00:00
|
|
|
{
|
2014-01-04 14:47:20 +01:00
|
|
|
const int border = (int)(UI_TEXT_CLIP_MARGIN + 0.5f);
|
2013-12-18 17:11:38 +11:00
|
|
|
const int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0);
|
2012-09-17 00:57:33 +00:00
|
|
|
|
|
|
|
BLI_assert(but->editstr && but->pos >= 0);
|
|
|
|
|
|
|
|
/* need to set this first */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_fontstyle_set(fstyle);
|
2012-09-17 00:57:33 +00:00
|
|
|
|
|
|
|
if (fstyle->kerning == 1) /* for BLF_width */
|
|
|
|
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
|
|
|
|
2012-09-28 11:28:23 +00:00
|
|
|
/* define ofs dynamically */
|
|
|
|
if (but->ofs > but->pos)
|
|
|
|
but->ofs = but->pos;
|
|
|
|
|
2014-05-03 09:18:00 +10:00
|
|
|
if (BLF_width(fstyle->uifont_id, but->editstr, INT_MAX) <= okwidth)
|
2012-09-17 00:33:07 +00:00
|
|
|
but->ofs = 0;
|
2011-01-20 18:34:48 +00:00
|
|
|
|
2014-05-03 09:18:00 +10:00
|
|
|
but->strwidth = BLF_width(fstyle->uifont_id, but->editstr + but->ofs, INT_MAX);
|
2012-09-17 00:57:33 +00:00
|
|
|
|
2014-05-03 09:18:00 +10:00
|
|
|
if (but->strwidth > okwidth) {
|
|
|
|
int len = strlen(but->editstr);
|
2012-09-28 11:28:23 +00:00
|
|
|
|
2014-05-03 09:18:00 +10:00
|
|
|
while (but->strwidth > okwidth) {
|
|
|
|
float width;
|
2012-09-28 11:28:23 +00:00
|
|
|
|
2014-05-03 09:18:00 +10:00
|
|
|
/* string position of cursor */
|
|
|
|
width = BLF_width(fstyle->uifont_id, but->editstr + but->ofs, (but->pos - but->ofs));
|
|
|
|
|
|
|
|
/* if cursor is at 20 pixels of right side button we clip left */
|
|
|
|
if (width > okwidth - 20) {
|
|
|
|
ui_text_clip_give_next_off(but, but->editstr);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int bytes;
|
|
|
|
/* shift string to the left */
|
|
|
|
if (width < 20 && but->ofs > 0)
|
|
|
|
ui_text_clip_give_prev_off(but, but->editstr);
|
|
|
|
bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->editstr, but->editstr + len));
|
|
|
|
if (bytes == -1)
|
|
|
|
bytes = 1;
|
|
|
|
len -= bytes;
|
|
|
|
}
|
2012-09-28 11:28:23 +00:00
|
|
|
|
2014-05-03 09:18:00 +10:00
|
|
|
but->strwidth = BLF_width(fstyle->uifont_id, but->editstr + but->ofs, len - but->ofs);
|
2012-09-28 11:28:23 +00:00
|
|
|
|
2014-05-03 09:18:00 +10:00
|
|
|
if (but->strwidth < 10) break;
|
|
|
|
}
|
2009-04-10 14:06:24 +00:00
|
|
|
}
|
2012-09-17 00:33:07 +00:00
|
|
|
|
|
|
|
if (fstyle->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(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
2012-09-17 00:33:07 +00:00
|
|
|
}
|
2009-04-10 14:06:24 +00:00
|
|
|
}
|
2009-04-07 17:08:26 +00:00
|
|
|
|
2012-09-17 00:33:07 +00:00
|
|
|
/**
|
|
|
|
* Cut off the end of text to fit into the width of \a rect.
|
|
|
|
*
|
|
|
|
* \note deals with ': ' especially for number buttons
|
|
|
|
*/
|
2012-12-13 02:40:49 +00:00
|
|
|
static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
|
2009-11-11 10:27:25 +00:00
|
|
|
{
|
2013-12-18 17:11:38 +11:00
|
|
|
const int border = UI_TEXT_CLIP_MARGIN + 1;
|
2013-12-18 07:15:25 +11:00
|
|
|
const int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0);
|
2012-03-30 01:51:25 +00:00
|
|
|
char *cpoin = NULL;
|
2012-09-17 00:33:07 +00:00
|
|
|
int drawstr_len = strlen(but->drawstr);
|
2014-04-27 00:22:49 +10:00
|
|
|
const char *cpend = but->drawstr + drawstr_len;
|
2009-11-11 10:27:25 +00:00
|
|
|
|
|
|
|
/* need to set this first */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_fontstyle_set(fstyle);
|
2009-11-11 10:27:25 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (fstyle->kerning == 1) /* for BLF_width */
|
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(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
2010-04-02 11:15:37 +00:00
|
|
|
|
2013-12-02 20:33:45 +11:00
|
|
|
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr, sizeof(but->drawstr));
|
2012-03-30 01:51:25 +00:00
|
|
|
but->ofs = 0;
|
2009-11-11 10:27:25 +00:00
|
|
|
|
2012-09-17 00:33:07 +00:00
|
|
|
|
2014-03-15 20:08:29 +11:00
|
|
|
/* First shorten num-buttons eg,
|
2012-09-17 00:33:07 +00:00
|
|
|
* Translucency: 0.000
|
|
|
|
* becomes
|
|
|
|
* Trans: 0.000
|
|
|
|
*/
|
|
|
|
|
2009-11-11 10:27:25 +00:00
|
|
|
/* find the space after ':' separator */
|
2012-03-30 01:51:25 +00:00
|
|
|
cpoin = strrchr(but->drawstr, ':');
|
2009-11-11 10:27:25 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (cpoin && (cpoin < cpend - 2)) {
|
2009-11-12 00:48:44 +00:00
|
|
|
char *cp2 = cpoin;
|
|
|
|
|
|
|
|
/* chop off the leading text, starting from the right */
|
|
|
|
while (but->strwidth > okwidth && cp2 > but->drawstr) {
|
2014-04-27 00:22:49 +10:00
|
|
|
const char *prev_utf8 = BLI_str_find_prev_char_utf8(but->drawstr, cp2);
|
2012-04-28 09:21:16 +00:00
|
|
|
int bytes = cp2 - prev_utf8;
|
2012-03-22 09:20:22 +00:00
|
|
|
|
2009-11-12 00:48:44 +00:00
|
|
|
/* shift the text after and including cp2 back by 1 char, +1 to include null terminator */
|
2012-09-17 00:33:07 +00:00
|
|
|
memmove(cp2 - bytes, cp2, drawstr_len + 1);
|
2012-03-30 01:51:25 +00:00
|
|
|
cp2 -= bytes;
|
2012-09-17 00:33:07 +00:00
|
|
|
|
|
|
|
drawstr_len -= bytes;
|
|
|
|
// BLI_assert(strlen(but->drawstr) == drawstr_len);
|
2009-11-12 00:48:44 +00:00
|
|
|
|
2013-12-02 20:33:45 +11:00
|
|
|
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (but->strwidth < 10) break;
|
2009-11-12 00:48:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* after the leading text is gone, chop off the : and following space, with ofs */
|
2012-04-28 06:31:57 +00:00
|
|
|
while ((but->strwidth > okwidth) && (but->ofs < 2)) {
|
2014-05-03 09:18:00 +10:00
|
|
|
ui_text_clip_give_next_off(but, but->drawstr);
|
2013-12-02 20:33:45 +11:00
|
|
|
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (but->strwidth < 10) break;
|
2009-11-11 10:27:25 +00:00
|
|
|
}
|
|
|
|
}
|
2009-11-12 00:48:44 +00:00
|
|
|
|
2012-09-17 00:33:07 +00:00
|
|
|
|
|
|
|
/* Now just remove trailing chars */
|
2009-11-11 10:27:25 +00:00
|
|
|
/* once the label's gone, chop off the least significant digits */
|
2013-12-16 21:59:47 +11:00
|
|
|
if (but->strwidth > okwidth) {
|
|
|
|
float strwidth;
|
|
|
|
drawstr_len = BLF_width_to_strlen(fstyle->uifont_id, but->drawstr + but->ofs,
|
|
|
|
drawstr_len - but->ofs, okwidth, &strwidth) + but->ofs;
|
|
|
|
but->strwidth = strwidth;
|
2012-09-17 00:33:07 +00:00
|
|
|
but->drawstr[drawstr_len] = 0;
|
2009-11-11 10:27:25 +00:00
|
|
|
}
|
2009-11-12 00:48:44 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (fstyle->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(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
2009-11-11 10:27:25 +00:00
|
|
|
}
|
|
|
|
|
2014-12-07 00:58:17 +01:00
|
|
|
#ifdef WITH_INPUT_IME
|
|
|
|
static void widget_draw_text_ime_underline(
|
|
|
|
uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, const rcti *rect,
|
|
|
|
const wmIMEData *ime_data, const char *drawstr)
|
|
|
|
{
|
|
|
|
int ofs_x, width;
|
|
|
|
int rect_x = BLI_rcti_size_x(rect);
|
|
|
|
int sel_start = ime_data->sel_start, sel_end = ime_data->sel_end;
|
2017-02-06 16:54:26 +01:00
|
|
|
float fcol[4];
|
2014-12-07 00:58:17 +01:00
|
|
|
|
|
|
|
if (drawstr[0] != 0) {
|
|
|
|
if (but->pos >= but->ofs) {
|
|
|
|
ofs_x = BLF_width(fstyle->uifont_id, drawstr + but->ofs, but->pos - but->ofs);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ofs_x = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
width = BLF_width(fstyle->uifont_id, drawstr + but->ofs,
|
|
|
|
ime_data->composite_len + but->pos - but->ofs);
|
|
|
|
|
2017-02-06 16:54:26 +01:00
|
|
|
rgba_uchar_to_float(fcol, wcol->text);
|
|
|
|
UI_draw_text_underline(rect->xmin + ofs_x, rect->ymin + 6 * U.pixelsize, min_ii(width, rect_x - 2) - ofs_x, 1, fcol);
|
2014-12-07 00:58:17 +01:00
|
|
|
|
|
|
|
/* draw the thick line */
|
|
|
|
if (sel_start != -1 && sel_end != -1) {
|
|
|
|
sel_end -= sel_start;
|
|
|
|
sel_start += but->pos;
|
|
|
|
|
|
|
|
if (sel_start >= but->ofs) {
|
|
|
|
ofs_x = BLF_width(fstyle->uifont_id, drawstr + but->ofs, sel_start - but->ofs);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ofs_x = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
width = BLF_width(fstyle->uifont_id, drawstr + but->ofs,
|
|
|
|
sel_end + sel_start - but->ofs);
|
|
|
|
|
2017-02-06 16:54:26 +01:00
|
|
|
UI_draw_text_underline(rect->xmin + ofs_x, rect->ymin + 6 * U.pixelsize, min_ii(width, rect_x - 2) - ofs_x, 2, fcol);
|
2014-12-07 00:58:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* WITH_INPUT_IME */
|
|
|
|
|
2009-05-21 17:09:06 +00:00
|
|
|
static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect)
|
2009-03-25 16:58:42 +00:00
|
|
|
{
|
2013-12-11 20:33:17 +11:00
|
|
|
int drawstr_left_len = UI_MAX_DRAW_STR;
|
2014-02-08 09:34:01 +11:00
|
|
|
const char *drawstr = but->drawstr;
|
|
|
|
const char *drawstr_right = NULL;
|
2013-12-11 21:27:13 +11:00
|
|
|
bool use_right_only = false;
|
2010-12-14 02:38:29 +00:00
|
|
|
|
2014-12-07 00:58:17 +01:00
|
|
|
#ifdef WITH_INPUT_IME
|
|
|
|
const wmIMEData *ime_data;
|
|
|
|
#endif
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_fontstyle_set(fstyle);
|
2009-05-21 17:09:06 +00:00
|
|
|
|
2013-11-21 14:43:08 +01:00
|
|
|
if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT))
|
2012-03-30 01:51:25 +00:00
|
|
|
fstyle->align = UI_STYLE_TEXT_LEFT;
|
2013-11-21 14:43:08 +01:00
|
|
|
else if (but->drawflag & UI_BUT_TEXT_RIGHT)
|
2013-03-21 12:58:31 +00:00
|
|
|
fstyle->align = UI_STYLE_TEXT_RIGHT;
|
2009-05-21 17:09:06 +00:00
|
|
|
else
|
2012-03-30 01:51:25 +00:00
|
|
|
fstyle->align = UI_STYLE_TEXT_CENTER;
|
2010-04-02 11:15:37 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (fstyle->kerning == 1) /* for BLF_width */
|
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(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
2010-04-02 11:15:37 +00:00
|
|
|
|
2014-02-08 09:34:01 +11:00
|
|
|
|
|
|
|
/* Special case: when we're entering text for multiple buttons,
|
|
|
|
* don't draw the text for any of the multi-editing buttons */
|
|
|
|
if (UNLIKELY(but->flag & UI_BUT_DRAG_MULTI)) {
|
2014-11-09 21:20:40 +01:00
|
|
|
uiBut *but_edit = ui_but_drag_multi_edit_get(but);
|
2014-02-25 10:28:41 +11:00
|
|
|
if (but_edit) {
|
|
|
|
drawstr = but_edit->editstr;
|
|
|
|
fstyle->align = UI_STYLE_TEXT_LEFT;
|
2014-02-08 09:34:01 +11:00
|
|
|
}
|
|
|
|
}
|
2014-05-03 05:03:55 +10:00
|
|
|
else {
|
|
|
|
if (but->editstr) {
|
|
|
|
/* max length isn't used in this case,
|
|
|
|
* we rely on string being NULL terminated. */
|
|
|
|
drawstr_left_len = INT_MAX;
|
2014-12-07 00:58:17 +01:00
|
|
|
|
|
|
|
#ifdef WITH_INPUT_IME
|
|
|
|
/* FIXME, IME is modifying 'const char *drawstr! */
|
2015-03-26 21:24:01 +01:00
|
|
|
ime_data = ui_but_ime_data_get(but);
|
2014-12-07 00:58:17 +01:00
|
|
|
|
|
|
|
if (ime_data && ime_data->composite_len) {
|
|
|
|
/* insert composite string into cursor pos */
|
|
|
|
BLI_snprintf((char *)drawstr, UI_MAX_DRAW_STR, "%s%s%s",
|
|
|
|
but->editstr, ime_data->str_composite,
|
|
|
|
but->editstr + but->pos);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
drawstr = but->editstr;
|
|
|
|
}
|
2014-05-03 05:03:55 +10:00
|
|
|
}
|
|
|
|
}
|
2014-02-08 09:34:01 +11:00
|
|
|
|
|
|
|
|
2014-12-07 00:58:17 +01:00
|
|
|
/* text button selection, cursor, composite underline */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (but->editstr && but->pos != -1) {
|
2014-12-07 00:58:17 +01:00
|
|
|
int but_pos_ofs;
|
|
|
|
int tx, ty;
|
2010-01-12 05:54:15 +00:00
|
|
|
|
2014-05-30 10:20:58 +10:00
|
|
|
/* text button selection */
|
2009-05-21 17:09:06 +00:00
|
|
|
if ((but->selend - but->selsta) > 0) {
|
2014-05-30 10:20:58 +10:00
|
|
|
int selsta_draw, selwidth_draw;
|
2009-05-21 17:09:06 +00:00
|
|
|
|
2014-02-08 09:34:01 +11:00
|
|
|
if (drawstr[0] != 0) {
|
2018-04-08 18:54:34 +02:00
|
|
|
/* We are drawing on top of widget bases. Flush cache. */
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
UI_widgetbase_draw_cache_flush();
|
|
|
|
glDisable(GL_BLEND);
|
2010-01-12 05:54:15 +00:00
|
|
|
|
|
|
|
if (but->selsta >= but->ofs) {
|
2014-05-30 10:20:58 +10:00
|
|
|
selsta_draw = BLF_width(fstyle->uifont_id, drawstr + but->ofs, but->selsta - but->ofs);
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2010-01-12 05:54:15 +00:00
|
|
|
selsta_draw = 0;
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
2013-12-02 20:33:45 +11:00
|
|
|
|
2014-05-30 10:20:58 +10:00
|
|
|
selwidth_draw = BLF_width(fstyle->uifont_id, drawstr + but->ofs, but->selend - but->ofs);
|
2009-07-28 17:59:59 +00:00
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
2017-02-20 21:21:04 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
|
|
|
immUniformColor4ubv((unsigned char *)wcol->item);
|
|
|
|
immRecti(pos, rect->xmin + selsta_draw,
|
|
|
|
rect->ymin + 2,
|
|
|
|
min_ii(rect->xmin + selwidth_draw, rect->xmax - 2),
|
|
|
|
rect->ymax - 2);
|
|
|
|
|
|
|
|
immUnbindProgram();
|
2009-05-21 17:09:06 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
2009-07-28 17:59:59 +00:00
|
|
|
|
2014-05-30 10:20:58 +10:00
|
|
|
/* text cursor */
|
2014-12-07 00:58:17 +01:00
|
|
|
but_pos_ofs = but->pos;
|
|
|
|
|
|
|
|
#ifdef WITH_INPUT_IME
|
|
|
|
/* if is ime compositing, move the cursor */
|
|
|
|
if (ime_data && ime_data->composite_len && ime_data->cursor_pos != -1) {
|
|
|
|
but_pos_ofs += ime_data->cursor_pos;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-05-30 10:20:58 +10:00
|
|
|
if (but->pos >= but->ofs) {
|
|
|
|
int t;
|
|
|
|
if (drawstr[0] != 0) {
|
2014-12-07 00:58:17 +01:00
|
|
|
t = BLF_width(fstyle->uifont_id, drawstr + but->ofs, but_pos_ofs - but->ofs);
|
2009-05-21 17:09:06 +00:00
|
|
|
}
|
2014-05-31 17:30:04 +10:00
|
|
|
else {
|
|
|
|
t = 0;
|
|
|
|
}
|
2018-04-08 18:54:34 +02:00
|
|
|
/* We are drawing on top of widget bases. Flush cache. */
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
UI_widgetbase_draw_cache_flush();
|
|
|
|
glDisable(GL_BLEND);
|
2014-05-30 10:20:58 +10:00
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
2017-02-20 21:21:04 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
|
|
|
immUniformColor3f(0.2f, 0.6f, 0.9f);
|
2014-12-07 00:58:17 +01:00
|
|
|
|
|
|
|
tx = rect->xmin + t + 2;
|
|
|
|
ty = rect->ymin + 2;
|
|
|
|
|
|
|
|
/* draw cursor */
|
2017-02-20 21:21:04 +01:00
|
|
|
immRecti(pos, rect->xmin + t, ty, tx, rect->ymax - 2);
|
|
|
|
|
|
|
|
immUnbindProgram();
|
2009-05-21 17:09:06 +00:00
|
|
|
}
|
2014-12-07 00:58:17 +01:00
|
|
|
|
|
|
|
#ifdef WITH_INPUT_IME
|
|
|
|
if (ime_data && ime_data->composite_len) {
|
|
|
|
/* ime cursor following */
|
|
|
|
if (but->pos >= but->ofs) {
|
|
|
|
ui_but_ime_reposition(but, tx + 5, ty + 3, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* composite underline */
|
|
|
|
widget_draw_text_ime_underline(fstyle, wcol, but, rect, ime_data, drawstr);
|
|
|
|
}
|
|
|
|
#endif
|
2009-05-21 17:09:06 +00:00
|
|
|
}
|
2010-04-02 11:15:37 +00:00
|
|
|
|
|
|
|
if (fstyle->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(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
2012-05-22 16:24:09 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
ui_rasterpos_safe(x, y, but->aspect);
|
2013-06-09 18:05:50 +00:00
|
|
|
transopts = ui_translate_buttons();
|
2012-05-22 16:24:09 +00:00
|
|
|
#endif
|
|
|
|
|
2009-05-03 02:27:36 +00:00
|
|
|
/* cut string in 2 parts - only for menu entries */
|
2018-05-13 10:25:18 +02:00
|
|
|
if ((but->block->flag & (UI_BLOCK_LOOP | UI_BLOCK_SHOW_SHORTCUT_ALWAYS)) &&
|
2014-05-03 05:03:55 +10:00
|
|
|
(but->editstr == NULL))
|
|
|
|
{
|
2014-05-01 12:40:49 +10:00
|
|
|
if (but->flag & UI_BUT_HAS_SEP_CHAR) {
|
|
|
|
drawstr_right = strrchr(drawstr, UI_SEP_CHAR);
|
2013-12-11 20:33:17 +11:00
|
|
|
if (drawstr_right) {
|
2014-02-08 09:34:01 +11:00
|
|
|
drawstr_left_len = (drawstr_right - drawstr);
|
2013-12-11 20:33:17 +11:00
|
|
|
drawstr_right++;
|
|
|
|
}
|
2009-08-19 12:35:40 +00:00
|
|
|
}
|
2009-05-03 02:27:36 +00:00
|
|
|
}
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2013-12-11 21:27:13 +11:00
|
|
|
#ifdef USE_NUMBUTS_LR_ALIGN
|
2014-11-09 21:20:40 +01:00
|
|
|
if (!drawstr_right && ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER) &&
|
2014-02-08 09:34:01 +11:00
|
|
|
/* if we're editing or multi-drag (fake editing), then use left alignment */
|
|
|
|
(but->editstr == NULL) && (drawstr == but->drawstr))
|
|
|
|
{
|
|
|
|
drawstr_right = strchr(drawstr + but->ofs, ':');
|
2013-12-11 21:27:13 +11:00
|
|
|
if (drawstr_right) {
|
|
|
|
drawstr_right++;
|
2014-02-08 09:34:01 +11:00
|
|
|
drawstr_left_len = (drawstr_right - drawstr);
|
2013-12-11 21:27:13 +11:00
|
|
|
|
|
|
|
while (*drawstr_right == ' ') {
|
|
|
|
drawstr_right++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* no prefix, even so use only cpoin */
|
2014-02-08 09:34:01 +11:00
|
|
|
drawstr_right = drawstr + but->ofs;
|
2013-12-11 21:27:13 +11:00
|
|
|
use_right_only = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!use_right_only) {
|
2013-12-17 13:11:31 +11:00
|
|
|
/* for underline drawing */
|
|
|
|
float font_xofs, font_yofs;
|
|
|
|
|
2016-10-18 17:34:29 -04:00
|
|
|
int drawlen = (drawstr_left_len == INT_MAX) ? strlen(drawstr + but->ofs) : (drawstr_left_len - but->ofs);
|
2010-12-14 02:38:29 +00:00
|
|
|
|
2016-10-18 17:34:29 -04:00
|
|
|
if (drawlen > 0) {
|
2017-02-10 00:00:21 +01:00
|
|
|
UI_fontstyle_draw_ex(fstyle, rect, drawstr + but->ofs, (unsigned char *)wcol->text,
|
|
|
|
drawlen, &font_xofs, &font_yofs);
|
2010-12-14 02:38:29 +00:00
|
|
|
|
2016-10-18 17:34:29 -04:00
|
|
|
if (but->menu_key != '\0') {
|
|
|
|
char fixedbuf[128];
|
|
|
|
const char *str;
|
2010-12-14 02:38:29 +00:00
|
|
|
|
2016-10-18 17:34:29 -04:00
|
|
|
BLI_strncpy(fixedbuf, drawstr + but->ofs, min_ii(sizeof(fixedbuf), drawlen));
|
2010-12-14 02:38:29 +00:00
|
|
|
|
2016-10-18 17:34:29 -04:00
|
|
|
str = strchr(fixedbuf, but->menu_key - 32); /* upper case */
|
|
|
|
if (str == NULL)
|
|
|
|
str = strchr(fixedbuf, but->menu_key);
|
2010-12-14 02:38:29 +00:00
|
|
|
|
2016-10-18 17:34:29 -04:00
|
|
|
if (str) {
|
|
|
|
int ul_index = -1;
|
|
|
|
float ul_advance;
|
2010-12-14 02:38:29 +00:00
|
|
|
|
2016-10-18 17:34:29 -04:00
|
|
|
ul_index = (int)(str - fixedbuf);
|
|
|
|
|
|
|
|
if (fstyle->kerning == 1) {
|
|
|
|
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
|
|
|
}
|
2010-12-14 02:38:29 +00:00
|
|
|
|
2016-10-18 17:34:29 -04:00
|
|
|
fixedbuf[ul_index] = '\0';
|
|
|
|
ul_advance = BLF_width(fstyle->uifont_id, fixedbuf, ul_index);
|
2010-12-14 02:38:29 +00:00
|
|
|
|
2016-10-18 17:34:29 -04:00
|
|
|
BLF_position(fstyle->uifont_id, rect->xmin + font_xofs + ul_advance, rect->ymin + font_yofs, 0.0f);
|
2017-02-10 00:00:21 +01:00
|
|
|
BLF_color4ubv(fstyle->uifont_id, (unsigned char *)wcol->text);
|
2016-10-18 17:34:29 -04:00
|
|
|
BLF_draw(fstyle->uifont_id, "_", 2);
|
2010-12-14 02:38:29 +00:00
|
|
|
|
2016-10-18 17:34:29 -04:00
|
|
|
if (fstyle->kerning == 1) {
|
|
|
|
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
|
|
|
}
|
2013-12-17 13:11:31 +11:00
|
|
|
}
|
2010-12-14 02:38:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-04-09 18:11:18 +00:00
|
|
|
|
2009-04-10 14:06:24 +00:00
|
|
|
/* part text right aligned */
|
2013-12-11 20:33:17 +11:00
|
|
|
if (drawstr_right) {
|
2012-03-30 01:51:25 +00:00
|
|
|
fstyle->align = UI_STYLE_TEXT_RIGHT;
|
2013-12-18 17:11:38 +11:00
|
|
|
rect->xmax -= UI_TEXT_CLIP_MARGIN;
|
2017-02-10 00:00:21 +01:00
|
|
|
UI_fontstyle_draw(fstyle, rect, drawstr_right, (unsigned char *)wcol->text);
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draws text and icons for buttons */
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect)
|
2009-03-25 16:58:42 +00:00
|
|
|
{
|
2016-11-28 18:59:31 +01:00
|
|
|
const uiButExtraIconType extra_icon_type = ui_but_icon_extra_get(but);
|
2014-02-20 13:30:52 +11:00
|
|
|
const bool show_menu_icon = ui_but_draw_menu_icon(but);
|
2013-03-18 18:37:59 +00:00
|
|
|
float alpha = (float)wcol->text[3] / 255.0f;
|
* New string property subtype: PASSWORD
When this new subtypes is used, then string of property is hidden using
asterisks, e.g.: mysecretpassword -> ****************
This code was reviewed and modified by Brecht. Thanks very much:
- https://codereview.appspot.com/6713044/
This new subtype of string property is intended mostly for Add-on developers
writing Add-on which communicates with some server (http, sql, ftp, verse,
etc.). When this server requires user authentication and user has to type
username and password, then current API didn't allow to type 'hidden' password,
e.g. when you want to demonstrate this script, then everybody can see this
security password. Some examples of Add-on which could use this new subtype:
- On-line database of textures
- Integration of render farm
- Integration of Verse
Security Notes:
- You can copy paste hiddent string of property from text input using (Ctrl-C, Ctrl-V),
but you can do this in other GUI toolkits too (this behavior it is widely used).
- Text of string property is stored in plain text, but it is widely used in other
GUI toolkits (Qt, Gtk, etc.).
Simple examples:
- https://dl.dropbox.com/u/369894/draw_op_passwd.py
- https://dl.dropbox.com/u/369894/blender-password.png
2012-10-26 12:58:54 +00:00
|
|
|
char password_str[UI_MAX_DRAW_STR];
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
ui_but_text_password_hide(password_str, but, false);
|
2009-11-11 10:27:25 +00:00
|
|
|
|
2009-03-25 16:58:42 +00:00
|
|
|
/* check for button text label */
|
2018-05-05 14:47:50 +02:00
|
|
|
if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_POPOVER) && (but->flag & UI_BUT_NODE_LINK)) {
|
2013-12-18 07:15:25 +11:00
|
|
|
rcti temp = *rect;
|
|
|
|
temp.xmin = rect->xmax - BLI_rcti_size_y(rect) - 1;
|
2014-01-10 02:23:55 +11:00
|
|
|
widget_draw_icon(but, ICON_LAYER_USED, alpha, &temp, false);
|
2018-02-24 17:15:16 +01:00
|
|
|
rect->xmax = temp.xmin;
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
2012-09-17 00:57:33 +00:00
|
|
|
|
2013-06-09 18:05:50 +00:00
|
|
|
/* If there's an icon too (made with uiDefIconTextBut) then draw the icon
|
|
|
|
* and offset the text label to accommodate it */
|
2012-09-17 00:57:33 +00:00
|
|
|
|
2015-05-22 21:31:26 +01:00
|
|
|
/* Big previews with optional text label below */
|
|
|
|
if (but->flag & UI_BUT_ICON_PREVIEW && ui_block_is_menu(but->block)) {
|
|
|
|
const BIFIconID icon = (but->flag & UI_HAS_ICON) ? but->icon + but->iconadd : ICON_NONE;
|
2015-05-31 19:15:10 +02:00
|
|
|
int icon_size = BLI_rcti_size_y(rect);
|
|
|
|
int text_size = 0;
|
2015-05-22 21:31:26 +01:00
|
|
|
|
2015-05-24 15:49:04 +02:00
|
|
|
/* This is a bit britle, but avoids adding an 'UI_BUT_HAS_LABEL' flag to but... */
|
2015-05-31 19:15:10 +02:00
|
|
|
if (icon_size > BLI_rcti_size_x(rect)) {
|
|
|
|
/* button is not square, it has extra height for label */
|
|
|
|
text_size = UI_UNIT_Y;
|
|
|
|
icon_size -= text_size;
|
2015-05-24 15:49:04 +02:00
|
|
|
}
|
2015-05-22 21:31:26 +01:00
|
|
|
|
|
|
|
/* draw icon in rect above the space reserved for the label */
|
|
|
|
rect->ymin += text_size;
|
2015-05-25 15:38:12 +01:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
widget_draw_preview(icon, alpha, rect);
|
|
|
|
glDisable(GL_BLEND);
|
2015-05-22 21:31:26 +01:00
|
|
|
|
2015-05-31 19:15:10 +02:00
|
|
|
/* offset rect to draw label in */
|
2015-05-22 21:31:26 +01:00
|
|
|
rect->ymin -= text_size;
|
|
|
|
rect->ymax -= icon_size;
|
2015-05-31 19:15:10 +02:00
|
|
|
|
|
|
|
/* vertically centering text */
|
|
|
|
rect->ymin += UI_UNIT_Y / 2;
|
2015-05-22 21:31:26 +01:00
|
|
|
}
|
|
|
|
/* Icons on the left with optional text label on the right */
|
|
|
|
else if (but->flag & UI_HAS_ICON || show_menu_icon) {
|
2018-04-25 21:01:36 +02:00
|
|
|
const bool is_tool = UI_but_is_tool(but);
|
|
|
|
|
2014-02-20 13:30:52 +11:00
|
|
|
const BIFIconID icon = (but->flag & UI_HAS_ICON) ? but->icon + but->iconadd : ICON_NONE;
|
2018-04-25 21:01:36 +02:00
|
|
|
int icon_size_init = is_tool ? ICON_DEFAULT_HEIGHT_TOOLBAR : ICON_DEFAULT_HEIGHT;
|
|
|
|
const float icon_size = icon_size_init / (but->block->aspect / UI_DPI_FAC);
|
|
|
|
|
|
|
|
#ifdef USE_TOOLBAR_HACK
|
|
|
|
if (is_tool) {
|
|
|
|
/* pass (even if its a menu toolbar) */
|
|
|
|
but->drawflag |= UI_BUT_TEXT_LEFT;
|
|
|
|
but->drawflag |= UI_BUT_ICON_LEFT;
|
|
|
|
}
|
|
|
|
#endif
|
2014-01-10 02:23:55 +11:00
|
|
|
|
2014-01-17 00:23:00 +01:00
|
|
|
/* menu item - add some more padding so menus don't feel cramped. it must
|
|
|
|
* be part of the button so that this area is still clickable */
|
2018-04-25 21:01:36 +02:00
|
|
|
if (is_tool) {
|
|
|
|
/* pass (even if its a menu toolbar) */
|
|
|
|
}
|
|
|
|
else if (ui_block_is_pie_menu(but->block)) {
|
2017-03-11 22:34:09 +03:00
|
|
|
if (but->dt == UI_EMBOSS_RADIAL)
|
|
|
|
rect->xmin += 0.3f * U.widget_unit;
|
|
|
|
}
|
|
|
|
else if (ui_block_is_menu(but->block))
|
2014-01-17 00:23:00 +01:00
|
|
|
rect->xmin += 0.3f * U.widget_unit;
|
|
|
|
|
2014-02-20 13:30:52 +11:00
|
|
|
widget_draw_icon(but, icon, alpha, rect, show_menu_icon);
|
2014-01-10 02:23:55 +11:00
|
|
|
|
|
|
|
rect->xmin += icon_size;
|
|
|
|
/* without this menu keybindings will overlap the arrow icon [#38083] */
|
|
|
|
if (show_menu_icon) {
|
|
|
|
rect->xmax -= icon_size / 2.0f;
|
|
|
|
}
|
2013-06-09 18:05:50 +00:00
|
|
|
}
|
2013-12-18 07:15:25 +11:00
|
|
|
|
2017-02-15 17:50:49 +01:00
|
|
|
if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) {
|
2013-12-18 07:15:25 +11:00
|
|
|
rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
|
2013-06-09 18:05:50 +00:00
|
|
|
}
|
2013-11-21 14:43:08 +01:00
|
|
|
else if ((but->drawflag & UI_BUT_TEXT_RIGHT)) {
|
2013-06-09 18:05:50 +00:00
|
|
|
rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
|
|
|
|
}
|
2013-12-18 17:11:38 +11:00
|
|
|
|
2016-11-28 18:59:31 +01:00
|
|
|
/* extra icons, e.g. 'x' icon to clear text or icon for eyedropper */
|
|
|
|
if (extra_icon_type != UI_BUT_ICONEXTRA_NONE) {
|
2013-06-09 18:05:50 +00:00
|
|
|
rcti temp = *rect;
|
2009-06-02 18:10:06 +00:00
|
|
|
|
2013-06-09 18:05:50 +00:00
|
|
|
temp.xmin = temp.xmax - (BLI_rcti_size_y(rect) * 1.08f);
|
2015-04-21 14:24:13 +10:00
|
|
|
|
2016-11-28 18:59:31 +01:00
|
|
|
if (extra_icon_type == UI_BUT_ICONEXTRA_CLEAR) {
|
2017-02-09 19:08:58 +13:00
|
|
|
widget_draw_icon(but, ICON_PANEL_CLOSE, alpha, &temp, false);
|
2015-04-21 14:24:13 +10:00
|
|
|
}
|
|
|
|
else if (extra_icon_type == UI_BUT_ICONEXTRA_EYEDROPPER) {
|
|
|
|
widget_draw_icon(but, ICON_EYEDROPPER, alpha, &temp, false);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_assert(0);
|
|
|
|
}
|
|
|
|
|
2013-12-18 17:11:38 +11:00
|
|
|
rect->xmax -= ICON_SIZE_FROM_BUTRECT(rect);
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
* New string property subtype: PASSWORD
When this new subtypes is used, then string of property is hidden using
asterisks, e.g.: mysecretpassword -> ****************
This code was reviewed and modified by Brecht. Thanks very much:
- https://codereview.appspot.com/6713044/
This new subtype of string property is intended mostly for Add-on developers
writing Add-on which communicates with some server (http, sql, ftp, verse,
etc.). When this server requires user authentication and user has to type
username and password, then current API didn't allow to type 'hidden' password,
e.g. when you want to demonstrate this script, then everybody can see this
security password. Some examples of Add-on which could use this new subtype:
- On-line database of textures
- Integration of render farm
- Integration of Verse
Security Notes:
- You can copy paste hiddent string of property from text input using (Ctrl-C, Ctrl-V),
but you can do this in other GUI toolkits too (this behavior it is widely used).
- Text of string property is stored in plain text, but it is widely used in other
GUI toolkits (Qt, Gtk, etc.).
Simple examples:
- https://dl.dropbox.com/u/369894/draw_op_passwd.py
- https://dl.dropbox.com/u/369894/blender-password.png
2012-10-26 12:58:54 +00:00
|
|
|
|
2013-12-18 07:15:25 +11:00
|
|
|
/* clip but->drawstr to fit in available space */
|
|
|
|
if (but->editstr && but->pos >= 0) {
|
|
|
|
ui_text_clip_cursor(fstyle, but, rect);
|
|
|
|
}
|
2014-03-18 11:07:10 +11:00
|
|
|
else if (but->drawstr[0] == '\0') {
|
|
|
|
/* bypass text clipping on icon buttons */
|
|
|
|
but->ofs = 0;
|
|
|
|
but->strwidth = 0;
|
|
|
|
}
|
2014-11-09 21:20:40 +01:00
|
|
|
else if (ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER)) {
|
2013-12-18 07:15:25 +11:00
|
|
|
ui_text_clip_right_label(fstyle, but, rect);
|
|
|
|
}
|
2015-06-03 14:34:04 +10:00
|
|
|
else if (but->flag & UI_BUT_HAS_SEP_CHAR) {
|
2014-08-16 22:21:10 +02:00
|
|
|
/* Clip middle, but protect in all case right part containing the shortcut, if any. */
|
2015-06-03 15:01:02 +10:00
|
|
|
ui_text_clip_middle_protect_right(fstyle, but, rect, UI_SEP_CHAR);
|
2013-12-18 07:15:25 +11:00
|
|
|
}
|
|
|
|
else {
|
Add a new "shortening process" for UI string drawing, which keeps both right and left parts
of the drawstr and replaces the middle by '...'
Rationnal:
It's usually easier to figure out what a troncated string means if you have both its start and end parts.
Details:
It currently affects all UI items (text fields, buttons, labels...).
Only exceptions are buttons inside menus, text fields & co being edited, and numbuttons/sliders.
Note that some static texts (like panels' titles or items in outliner) do not use usual UI items,
and just draw the whole text, using OpenGL to clip it. Will make another patch to fix this.
Reviewers: campbellbarton, brecht, carter2422, #user_interface
Reviewed by: brecht, carter2422
CC: billrey
Differential Revision: https://developer.blender.org/D114
2014-01-01 11:18:27 +01:00
|
|
|
ui_text_clip_middle(fstyle, but, rect);
|
2013-12-18 07:15:25 +11:00
|
|
|
}
|
|
|
|
|
2013-06-09 18:05:50 +00:00
|
|
|
/* always draw text for textbutton cursor */
|
|
|
|
widget_draw_text(fstyle, wcol, but, rect);
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
ui_but_text_password_hide(password_str, but, true);
|
2017-03-17 17:08:20 +01:00
|
|
|
|
|
|
|
/* if a widget uses font shadow it has to be deactivated now */
|
|
|
|
BLF_disable(fstyle->uifont_id, BLF_SHADOW);
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
2013-12-18 17:11:38 +11:00
|
|
|
#undef UI_TEXT_CLIP_MARGIN
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* *********************** widget types ************************************* */
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetStateColors wcol_state_colors = {
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{115, 190, 76, 255},
|
|
|
|
{90, 166, 51, 255},
|
|
|
|
{240, 235, 100, 255},
|
2009-07-12 02:06:15 +00:00
|
|
|
{215, 211, 75, 255},
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{180, 0, 255, 255},
|
2009-07-12 02:06:15 +00:00
|
|
|
{153, 0, 230, 255},
|
2017-11-29 15:47:37 +01:00
|
|
|
{74, 137, 137, 255},
|
|
|
|
{49, 112, 112, 255},
|
2009-07-12 02:06:15 +00:00
|
|
|
0.5f, 0.0f
|
2009-04-13 15:55:27 +00:00
|
|
|
};
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetColors wcol_num = {
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{25, 25, 25, 255},
|
|
|
|
{180, 180, 180, 255},
|
|
|
|
{153, 153, 153, 255},
|
|
|
|
{90, 90, 90, 255},
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{0, 0, 0, 255},
|
|
|
|
{255, 255, 255, 255},
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
1,
|
2018-04-22 13:57:42 +02:00
|
|
|
-20, 0,
|
|
|
|
0,
|
|
|
|
0.5f,
|
2009-03-25 16:58:42 +00:00
|
|
|
};
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetColors wcol_numslider = {
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{25, 25, 25, 255},
|
|
|
|
{180, 180, 180, 255},
|
|
|
|
{153, 153, 153, 255},
|
|
|
|
{128, 128, 128, 255},
|
2009-04-02 18:16:15 +00:00
|
|
|
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{0, 0, 0, 255},
|
|
|
|
{255, 255, 255, 255},
|
2009-04-02 18:16:15 +00:00
|
|
|
|
|
|
|
1,
|
2018-04-22 13:57:42 +02:00
|
|
|
-20, 0,
|
|
|
|
0,
|
|
|
|
0.5f,
|
2009-04-02 18:16:15 +00:00
|
|
|
};
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetColors wcol_text = {
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{25, 25, 25, 255},
|
|
|
|
{153, 153, 153, 255},
|
|
|
|
{153, 153, 153, 255},
|
|
|
|
{90, 90, 90, 255},
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{0, 0, 0, 255},
|
|
|
|
{255, 255, 255, 255},
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
1,
|
2018-04-22 13:57:42 +02:00
|
|
|
0, 25,
|
|
|
|
0,
|
|
|
|
0.2f,
|
2009-03-25 16:58:42 +00:00
|
|
|
};
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetColors wcol_option = {
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{0, 0, 0, 255},
|
2009-04-29 04:43:17 +00:00
|
|
|
{70, 70, 70, 255},
|
|
|
|
{70, 70, 70, 255},
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{255, 255, 255, 255},
|
2009-04-02 15:01:11 +00:00
|
|
|
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{0, 0, 0, 255},
|
|
|
|
{255, 255, 255, 255},
|
2009-04-02 15:01:11 +00:00
|
|
|
|
|
|
|
1,
|
2018-04-22 13:57:42 +02:00
|
|
|
15, -15,
|
|
|
|
0,
|
2018-04-25 11:53:21 +02:00
|
|
|
0.3333333f,
|
2009-04-02 15:01:11 +00:00
|
|
|
};
|
|
|
|
|
2009-04-03 16:26:03 +00:00
|
|
|
/* button that shows popup */
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetColors wcol_menu = {
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{0, 0, 0, 255},
|
2009-04-29 04:43:17 +00:00
|
|
|
{70, 70, 70, 255},
|
|
|
|
{70, 70, 70, 255},
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{255, 255, 255, 255},
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{255, 255, 255, 255},
|
|
|
|
{204, 204, 204, 255},
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
1,
|
2018-04-22 13:57:42 +02:00
|
|
|
15, -15,
|
|
|
|
0,
|
|
|
|
0.2f,
|
2009-03-25 16:58:42 +00:00
|
|
|
};
|
|
|
|
|
2009-04-03 16:26:03 +00:00
|
|
|
/* button that starts pulldown */
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetColors wcol_pulldown = {
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{0, 0, 0, 255},
|
|
|
|
{63, 63, 63, 255},
|
2009-04-29 04:43:17 +00:00
|
|
|
{86, 128, 194, 255},
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{255, 255, 255, 255},
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2009-04-29 04:43:17 +00:00
|
|
|
{0, 0, 0, 255},
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{0, 0, 0, 255},
|
2009-04-03 16:26:03 +00:00
|
|
|
|
|
|
|
0,
|
2018-04-22 13:57:42 +02:00
|
|
|
25, -20,
|
|
|
|
0,
|
|
|
|
0.2f,
|
2009-04-03 16:26:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* button inside menu */
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetColors wcol_menu_item = {
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{0, 0, 0, 255},
|
2009-04-29 04:43:17 +00:00
|
|
|
{0, 0, 0, 0},
|
|
|
|
{86, 128, 194, 255},
|
2012-03-15 21:11:14 +00:00
|
|
|
{172, 172, 172, 128},
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{255, 255, 255, 255},
|
|
|
|
{0, 0, 0, 255},
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2011-05-03 15:30:16 +00:00
|
|
|
1,
|
2018-04-22 13:57:42 +02:00
|
|
|
38, 0,
|
|
|
|
0,
|
|
|
|
0.2f,
|
2009-04-03 16:26:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* backdrop menu + title text color */
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetColors wcol_menu_back = {
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{0, 0, 0, 255},
|
2009-04-29 04:43:17 +00:00
|
|
|
{25, 25, 25, 230},
|
2009-06-10 11:43:21 +00:00
|
|
|
{45, 45, 45, 230},
|
2009-06-27 16:35:42 +00:00
|
|
|
{100, 100, 100, 255},
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2009-07-24 13:25:39 +00:00
|
|
|
{160, 160, 160, 255},
|
2009-06-10 11:43:21 +00:00
|
|
|
{255, 255, 255, 255},
|
2009-04-03 16:26:03 +00:00
|
|
|
|
|
|
|
0,
|
2018-04-22 13:57:42 +02:00
|
|
|
25, -20,
|
|
|
|
0,
|
|
|
|
0.25f,
|
2009-04-03 16:26:03 +00:00
|
|
|
};
|
|
|
|
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
/* pie menus */
|
|
|
|
static struct uiWidgetColors wcol_pie_menu = {
|
|
|
|
{10, 10, 10, 200},
|
|
|
|
{25, 25, 25, 230},
|
|
|
|
{140, 140, 140, 255},
|
|
|
|
{45, 45, 45, 230},
|
|
|
|
|
|
|
|
{160, 160, 160, 255},
|
|
|
|
{255, 255, 255, 255},
|
|
|
|
|
|
|
|
1,
|
2018-04-22 13:57:42 +02:00
|
|
|
10, -10,
|
|
|
|
0,
|
|
|
|
0.5f,
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-07-04 12:19:50 +00:00
|
|
|
/* tooltip color */
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetColors wcol_tooltip = {
|
2012-03-19 22:29:16 +00:00
|
|
|
{0, 0, 0, 255},
|
|
|
|
{25, 25, 25, 230},
|
|
|
|
{45, 45, 45, 230},
|
|
|
|
{100, 100, 100, 255},
|
|
|
|
|
2015-06-04 17:04:48 +02:00
|
|
|
{255, 255, 255, 255},
|
2012-03-19 22:29:16 +00:00
|
|
|
{255, 255, 255, 255},
|
|
|
|
|
|
|
|
0,
|
2018-04-22 13:57:42 +02:00
|
|
|
25, -20,
|
|
|
|
0,
|
|
|
|
0.25f,
|
2012-03-19 22:29:16 +00:00
|
|
|
};
|
2009-04-02 15:01:11 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetColors wcol_radio = {
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{0, 0, 0, 255},
|
2009-04-29 04:43:17 +00:00
|
|
|
{70, 70, 70, 255},
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{86, 128, 194, 255},
|
|
|
|
{255, 255, 255, 255},
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{255, 255, 255, 255},
|
|
|
|
{0, 0, 0, 255},
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
1,
|
2018-04-22 13:57:42 +02:00
|
|
|
15, -15,
|
|
|
|
0,
|
|
|
|
0.2f,
|
2009-03-25 16:58:42 +00:00
|
|
|
};
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetColors wcol_regular = {
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{25, 25, 25, 255},
|
2009-11-18 18:01:54 +00:00
|
|
|
{153, 153, 153, 255},
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{100, 100, 100, 255},
|
|
|
|
{25, 25, 25, 255},
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{0, 0, 0, 255},
|
|
|
|
{255, 255, 255, 255},
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
0,
|
2018-04-22 13:57:42 +02:00
|
|
|
0, 0,
|
|
|
|
0,
|
|
|
|
0.25f,
|
2009-03-25 16:58:42 +00:00
|
|
|
};
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetColors wcol_tool = {
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{25, 25, 25, 255},
|
|
|
|
{153, 153, 153, 255},
|
|
|
|
{100, 100, 100, 255},
|
|
|
|
{25, 25, 25, 255},
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{0, 0, 0, 255},
|
|
|
|
{255, 255, 255, 255},
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
1,
|
2018-04-22 13:57:42 +02:00
|
|
|
15, -15,
|
|
|
|
0,
|
|
|
|
0.2f,
|
2009-03-25 16:58:42 +00:00
|
|
|
};
|
|
|
|
|
2018-04-26 21:17:33 +02:00
|
|
|
static struct uiWidgetColors wcol_toolbar_item = {
|
|
|
|
.outline = {0x19, 0x19, 0x19, 0xff},
|
|
|
|
.inner = {0x46, 0x46, 0x46, 0xff},
|
2018-05-11 22:15:05 +02:00
|
|
|
.inner_sel = {0xcc, 0xcc, 0xcc, 0xff},
|
|
|
|
.item = {0x0, 0x0, 0x0, 0xff},
|
2018-04-26 21:17:33 +02:00
|
|
|
|
|
|
|
.text = {0xff, 0xff, 0xff, 0xff},
|
|
|
|
.text_sel = {0x33, 0x33, 0x33, 0xff},
|
|
|
|
|
|
|
|
.shaded = 0,
|
|
|
|
.shadetop = 0,
|
|
|
|
.shadedown = 0,
|
|
|
|
.alpha_check = 0,
|
|
|
|
.roundness = 0.3f,
|
|
|
|
};
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetColors wcol_box = {
|
2009-06-01 11:31:06 +00:00
|
|
|
{25, 25, 25, 255},
|
|
|
|
{128, 128, 128, 255},
|
|
|
|
{100, 100, 100, 255},
|
|
|
|
{25, 25, 25, 255},
|
|
|
|
|
|
|
|
{0, 0, 0, 255},
|
|
|
|
{255, 255, 255, 255},
|
|
|
|
|
|
|
|
0,
|
2018-04-22 13:57:42 +02:00
|
|
|
0, 0,
|
|
|
|
0,
|
|
|
|
0.2f,
|
2009-06-01 11:31:06 +00:00
|
|
|
};
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetColors wcol_toggle = {
|
2009-06-24 14:16:56 +00:00
|
|
|
{25, 25, 25, 255},
|
|
|
|
{153, 153, 153, 255},
|
|
|
|
{100, 100, 100, 255},
|
|
|
|
{25, 25, 25, 255},
|
|
|
|
|
|
|
|
{0, 0, 0, 255},
|
|
|
|
{255, 255, 255, 255},
|
|
|
|
|
|
|
|
0,
|
2018-04-22 13:57:42 +02:00
|
|
|
0, 0,
|
|
|
|
0,
|
|
|
|
0.25f,
|
2009-06-24 14:16:56 +00:00
|
|
|
};
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetColors wcol_scroll = {
|
2009-07-02 18:12:46 +00:00
|
|
|
{50, 50, 50, 180},
|
|
|
|
{80, 80, 80, 180},
|
|
|
|
{100, 100, 100, 180},
|
2009-07-23 20:50:24 +00:00
|
|
|
{128, 128, 128, 255},
|
2009-06-24 14:16:56 +00:00
|
|
|
|
|
|
|
{0, 0, 0, 255},
|
|
|
|
{255, 255, 255, 255},
|
|
|
|
|
|
|
|
1,
|
2018-04-22 13:57:42 +02:00
|
|
|
5, -5,
|
|
|
|
0,
|
|
|
|
0.5f,
|
2009-06-24 14:16:56 +00:00
|
|
|
};
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetColors wcol_progress = {
|
2010-05-27 08:22:16 +00:00
|
|
|
{0, 0, 0, 255},
|
|
|
|
{190, 190, 190, 255},
|
|
|
|
{100, 100, 100, 180},
|
2016-01-18 01:39:09 +01:00
|
|
|
{128, 128, 128, 255},
|
2010-05-27 08:22:16 +00:00
|
|
|
|
|
|
|
{0, 0, 0, 255},
|
|
|
|
{255, 255, 255, 255},
|
|
|
|
|
|
|
|
0,
|
2018-04-22 13:57:42 +02:00
|
|
|
0, 0,
|
|
|
|
0,
|
|
|
|
0.25f,
|
2010-05-27 08:22:16 +00:00
|
|
|
};
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetColors wcol_list_item = {
|
2009-07-21 01:26:17 +00:00
|
|
|
{0, 0, 0, 255},
|
|
|
|
{0, 0, 0, 0},
|
|
|
|
{86, 128, 194, 255},
|
2016-02-05 02:57:53 +11:00
|
|
|
{90, 90, 90, 255},
|
2009-07-21 01:26:17 +00:00
|
|
|
|
|
|
|
{0, 0, 0, 255},
|
2016-02-05 02:57:53 +11:00
|
|
|
{255, 255, 255, 255},
|
2009-07-21 01:26:17 +00:00
|
|
|
|
|
|
|
0,
|
2018-04-22 13:57:42 +02:00
|
|
|
0, 0,
|
|
|
|
0,
|
|
|
|
0.2f,
|
2009-07-21 01:26:17 +00:00
|
|
|
};
|
|
|
|
|
2017-03-17 17:08:20 +01:00
|
|
|
struct uiWidgetColors wcol_tab = {
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
{60, 60, 60, 255},
|
2017-03-17 17:08:20 +01:00
|
|
|
{83, 83, 83, 255},
|
|
|
|
{114, 114, 114, 255},
|
|
|
|
{90, 90, 90, 255},
|
|
|
|
|
|
|
|
{0, 0, 0, 255},
|
|
|
|
{0, 0, 0, 255},
|
|
|
|
|
|
|
|
0,
|
2018-04-22 13:57:42 +02:00
|
|
|
0, 0,
|
|
|
|
0,
|
|
|
|
0.25f,
|
2017-03-17 17:08:20 +01:00
|
|
|
};
|
|
|
|
|
2009-06-12 14:22:27 +00:00
|
|
|
/* free wcol struct to play with */
|
2012-03-30 01:51:25 +00:00
|
|
|
static struct uiWidgetColors wcol_tmp = {
|
2009-06-12 14:22:27 +00:00
|
|
|
{0, 0, 0, 255},
|
|
|
|
{128, 128, 128, 255},
|
|
|
|
{100, 100, 100, 255},
|
|
|
|
{25, 25, 25, 255},
|
|
|
|
|
|
|
|
{0, 0, 0, 255},
|
|
|
|
{255, 255, 255, 255},
|
|
|
|
|
|
|
|
0,
|
2018-04-22 13:57:42 +02:00
|
|
|
0, 0,
|
|
|
|
0,
|
|
|
|
0.25f,
|
2009-06-12 14:22:27 +00:00
|
|
|
};
|
|
|
|
|
2009-06-01 11:31:06 +00:00
|
|
|
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
/* called for theme init (new theme) and versions */
|
|
|
|
void ui_widget_color_init(ThemeUI *tui)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
tui->wcol_regular = wcol_regular;
|
|
|
|
tui->wcol_tool = wcol_tool;
|
2018-04-26 21:17:33 +02:00
|
|
|
tui->wcol_toolbar_item = wcol_toolbar_item;
|
2012-03-30 01:51:25 +00:00
|
|
|
tui->wcol_text = wcol_text;
|
|
|
|
tui->wcol_radio = wcol_radio;
|
2017-03-17 17:08:20 +01:00
|
|
|
tui->wcol_tab = wcol_tab;
|
2012-03-30 01:51:25 +00:00
|
|
|
tui->wcol_option = wcol_option;
|
|
|
|
tui->wcol_toggle = wcol_toggle;
|
|
|
|
tui->wcol_num = wcol_num;
|
|
|
|
tui->wcol_numslider = wcol_numslider;
|
|
|
|
tui->wcol_menu = wcol_menu;
|
|
|
|
tui->wcol_pulldown = wcol_pulldown;
|
|
|
|
tui->wcol_menu_back = wcol_menu_back;
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
tui->wcol_pie_menu = wcol_pie_menu;
|
2012-03-19 22:29:16 +00:00
|
|
|
tui->wcol_tooltip = wcol_tooltip;
|
2012-03-30 01:51:25 +00:00
|
|
|
tui->wcol_menu_item = wcol_menu_item;
|
|
|
|
tui->wcol_box = wcol_box;
|
|
|
|
tui->wcol_scroll = wcol_scroll;
|
|
|
|
tui->wcol_list_item = wcol_list_item;
|
|
|
|
tui->wcol_progress = wcol_progress;
|
2009-07-12 02:06:15 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
tui->wcol_state = wcol_state_colors;
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
}
|
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
/* ************ button callbacks, state ***************** */
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2011-09-26 17:30:56 +00:00
|
|
|
static void widget_state_blend(char cp[3], const char cpstate[3], const float fac)
|
2009-07-12 02:06:15 +00:00
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (fac != 0.0f) {
|
2012-03-30 01:51:25 +00:00
|
|
|
cp[0] = (int)((1.0f - fac) * cp[0] + fac * cpstate[0]);
|
|
|
|
cp[1] = (int)((1.0f - fac) * cp[1] + fac * cpstate[1]);
|
|
|
|
cp[2] = (int)((1.0f - fac) * cp[2] + fac * cpstate[2]);
|
2009-07-12 02:06:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-11 16:46:41 +01:00
|
|
|
/* put all widget colors on half alpha, use local storage */
|
|
|
|
static void ui_widget_color_disabled(uiWidgetType *wt)
|
|
|
|
{
|
|
|
|
static uiWidgetColors wcol_theme_s;
|
|
|
|
|
|
|
|
wcol_theme_s = *wt->wcol_theme;
|
|
|
|
|
|
|
|
wcol_theme_s.outline[3] *= 0.5;
|
|
|
|
wcol_theme_s.inner[3] *= 0.5;
|
|
|
|
wcol_theme_s.inner_sel[3] *= 0.5;
|
|
|
|
wcol_theme_s.item[3] *= 0.5;
|
|
|
|
wcol_theme_s.text[3] *= 0.5;
|
|
|
|
wcol_theme_s.text_sel[3] *= 0.5;
|
|
|
|
|
|
|
|
wt->wcol_theme = &wcol_theme_s;
|
|
|
|
}
|
|
|
|
|
2018-04-22 13:57:50 +02:00
|
|
|
static void widget_active_color(char cp[3])
|
|
|
|
{
|
|
|
|
cp[0] = cp[0] >= 240 ? 255 : cp[0] + 15;
|
|
|
|
cp[1] = cp[1] >= 240 ? 255 : cp[1] + 15;
|
|
|
|
cp[2] = cp[2] >= 240 ? 255 : cp[2] + 15;
|
|
|
|
}
|
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
/* copy colors from theme, and set changes in it based on state */
|
|
|
|
static void widget_state(uiWidgetType *wt, int state)
|
2009-03-25 16:58:42 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiWidgetStateColors *wcol_state = wt->wcol_state;
|
2009-07-12 02:06:15 +00:00
|
|
|
|
2017-11-03 00:22:59 +11:00
|
|
|
if ((state & UI_BUT_LIST_ITEM) && !(state & UI_STATE_TEXT_INPUT)) {
|
2013-11-23 18:43:23 +01:00
|
|
|
/* Override default widget's colors. */
|
|
|
|
bTheme *btheme = UI_GetTheme();
|
|
|
|
wt->wcol_theme = &btheme->tui.wcol_list_item;
|
2015-02-11 16:46:41 +01:00
|
|
|
|
|
|
|
if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) {
|
|
|
|
ui_widget_color_disabled(wt);
|
|
|
|
}
|
2013-11-23 18:43:23 +01:00
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->wcol = *(wt->wcol_theme);
|
2013-11-23 18:43:23 +01:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_SELECT) {
|
2011-11-07 01:38:32 +00:00
|
|
|
copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel);
|
2009-07-12 02:06:15 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_BUT_ANIMATED_KEY)
|
2009-07-12 02:06:15 +00:00
|
|
|
widget_state_blend(wt->wcol.inner, wcol_state->inner_key_sel, wcol_state->blend);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (state & UI_BUT_ANIMATED)
|
2009-07-12 02:06:15 +00:00
|
|
|
widget_state_blend(wt->wcol.inner, wcol_state->inner_anim_sel, wcol_state->blend);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (state & UI_BUT_DRIVEN)
|
2009-07-12 02:06:15 +00:00
|
|
|
widget_state_blend(wt->wcol.inner, wcol_state->inner_driven_sel, wcol_state->blend);
|
2017-11-29 15:47:37 +01:00
|
|
|
else if (state & UI_BUT_OVERRIDEN)
|
|
|
|
widget_state_blend(wt->wcol.inner, wcol_state->inner_overridden_sel, wcol_state->blend);
|
2009-04-03 23:30:32 +00:00
|
|
|
|
2011-11-07 01:38:32 +00:00
|
|
|
copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel);
|
2010-09-11 00:08:07 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_SELECT)
|
2010-09-11 00:08:07 +00:00
|
|
|
SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown);
|
2009-04-02 15:01:11 +00:00
|
|
|
}
|
2009-04-03 23:30:32 +00:00
|
|
|
else {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_BUT_ANIMATED_KEY)
|
2009-07-12 02:06:15 +00:00
|
|
|
widget_state_blend(wt->wcol.inner, wcol_state->inner_key, wcol_state->blend);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (state & UI_BUT_ANIMATED)
|
2009-07-12 02:06:15 +00:00
|
|
|
widget_state_blend(wt->wcol.inner, wcol_state->inner_anim, wcol_state->blend);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (state & UI_BUT_DRIVEN)
|
2009-07-12 02:06:15 +00:00
|
|
|
widget_state_blend(wt->wcol.inner, wcol_state->inner_driven, wcol_state->blend);
|
2017-11-29 15:47:37 +01:00
|
|
|
else if (state & UI_BUT_OVERRIDEN)
|
|
|
|
widget_state_blend(wt->wcol.inner, wcol_state->inner_overridden, wcol_state->blend);
|
2009-04-03 23:30:32 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_ACTIVE) { /* mouse over? */
|
2018-04-22 13:57:50 +02:00
|
|
|
widget_active_color(wt->wcol.inner);
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
}
|
2009-04-03 23:30:32 +00:00
|
|
|
}
|
2010-09-17 05:58:06 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_BUT_REDALERT) {
|
2012-03-30 01:51:25 +00:00
|
|
|
char red[4] = {255, 0, 0};
|
2010-09-17 05:58:06 +00:00
|
|
|
widget_state_blend(wt->wcol.inner, red, 0.4f);
|
|
|
|
}
|
2014-02-08 09:34:01 +11:00
|
|
|
|
|
|
|
if (state & UI_BUT_DRAG_MULTI) {
|
|
|
|
/* the button isn't SELECT but we're editing this so draw with sel color */
|
2014-06-09 18:47:56 +10:00
|
|
|
copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel);
|
|
|
|
SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown);
|
|
|
|
widget_state_blend(wt->wcol.text, wt->wcol.text_sel, 0.85f);
|
2014-02-08 09:34:01 +11:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_BUT_NODE_ACTIVE) {
|
2012-03-30 01:51:25 +00:00
|
|
|
char blue[4] = {86, 128, 194};
|
2011-11-07 22:28:49 +00:00
|
|
|
widget_state_blend(wt->wcol.inner, blue, 0.3f);
|
|
|
|
}
|
2009-04-02 15:01:11 +00:00
|
|
|
}
|
|
|
|
|
2009-10-15 11:52:23 +00:00
|
|
|
/* sliders use special hack which sets 'item' as inner when drawing filling */
|
|
|
|
static void widget_state_numslider(uiWidgetType *wt, int state)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiWidgetStateColors *wcol_state = wt->wcol_state;
|
2012-08-19 10:41:27 +00:00
|
|
|
float blend = wcol_state->blend - 0.2f; /* XXX special tweak to make sure that bar will still be visible */
|
2009-10-15 11:52:23 +00:00
|
|
|
|
|
|
|
/* call this for option button */
|
|
|
|
widget_state(wt, state);
|
|
|
|
|
|
|
|
/* now, set the inner-part so that it reflects state settings too */
|
2012-08-19 10:41:27 +00:00
|
|
|
/* TODO: maybe we should have separate settings for the blending colors used for this case? */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_SELECT) {
|
2010-09-07 11:14:20 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_BUT_ANIMATED_KEY)
|
2009-10-15 11:52:23 +00:00
|
|
|
widget_state_blend(wt->wcol.item, wcol_state->inner_key_sel, blend);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (state & UI_BUT_ANIMATED)
|
2009-10-15 11:52:23 +00:00
|
|
|
widget_state_blend(wt->wcol.item, wcol_state->inner_anim_sel, blend);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (state & UI_BUT_DRIVEN)
|
2009-10-15 11:52:23 +00:00
|
|
|
widget_state_blend(wt->wcol.item, wcol_state->inner_driven_sel, blend);
|
2017-11-29 15:47:37 +01:00
|
|
|
else if (state & UI_BUT_OVERRIDEN)
|
|
|
|
widget_state_blend(wt->wcol.item, wcol_state->inner_overridden_sel, blend);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_SELECT)
|
2010-09-11 00:08:07 +00:00
|
|
|
SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown);
|
2009-10-15 11:52:23 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_BUT_ANIMATED_KEY)
|
2009-10-15 11:52:23 +00:00
|
|
|
widget_state_blend(wt->wcol.item, wcol_state->inner_key, blend);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (state & UI_BUT_ANIMATED)
|
2009-10-15 11:52:23 +00:00
|
|
|
widget_state_blend(wt->wcol.item, wcol_state->inner_anim, blend);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (state & UI_BUT_DRIVEN)
|
2009-10-15 11:52:23 +00:00
|
|
|
widget_state_blend(wt->wcol.item, wcol_state->inner_driven, blend);
|
2017-11-29 15:47:37 +01:00
|
|
|
else if (state & UI_BUT_OVERRIDEN)
|
|
|
|
widget_state_blend(wt->wcol.item, wcol_state->inner_overridden, blend);
|
2009-10-15 11:52:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-04 15:01:22 +00:00
|
|
|
/* labels use theme colors for text */
|
|
|
|
static void widget_state_option_menu(uiWidgetType *wt, int state)
|
|
|
|
{
|
2013-06-26 20:28:12 +00:00
|
|
|
bTheme *btheme = UI_GetTheme(); /* XXX */
|
2011-04-04 15:01:22 +00:00
|
|
|
|
|
|
|
/* call this for option button */
|
|
|
|
widget_state(wt, state);
|
|
|
|
|
|
|
|
/* if not selected we get theme from menu back */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_SELECT)
|
2013-06-26 20:28:12 +00:00
|
|
|
copy_v3_v3_char(wt->wcol.text, btheme->tui.wcol_menu_back.text_sel);
|
|
|
|
else
|
2011-11-07 01:38:32 +00:00
|
|
|
copy_v3_v3_char(wt->wcol.text, btheme->tui.wcol_menu_back.text);
|
2011-04-04 15:01:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void widget_state_nothing(uiWidgetType *wt, int UNUSED(state))
|
2009-07-02 18:12:46 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->wcol = *(wt->wcol_theme);
|
2009-07-02 18:12:46 +00:00
|
|
|
}
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
|
2009-04-03 16:26:03 +00:00
|
|
|
/* special case, button that calls pulldown */
|
|
|
|
static void widget_state_pulldown(uiWidgetType *wt, int state)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->wcol = *(wt->wcol_theme);
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2011-11-07 01:38:32 +00:00
|
|
|
copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel);
|
|
|
|
copy_v3_v3_char(wt->wcol.outline, wt->wcol.inner);
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_ACTIVE)
|
2011-11-07 01:38:32 +00:00
|
|
|
copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel);
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
|
|
|
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
/* special case, pie menu items */
|
|
|
|
static void widget_state_pie_menu_item(uiWidgetType *wt, int state)
|
|
|
|
{
|
|
|
|
wt->wcol = *(wt->wcol_theme);
|
|
|
|
|
|
|
|
/* active and disabled (not so common) */
|
|
|
|
if ((state & UI_BUT_DISABLED) && (state & UI_ACTIVE)) {
|
|
|
|
widget_state_blend(wt->wcol.text, wt->wcol.text_sel, 0.5f);
|
|
|
|
/* draw the backdrop at low alpha, helps navigating with keys
|
|
|
|
* when disabled items are active */
|
|
|
|
copy_v4_v4_char(wt->wcol.inner, wt->wcol.item);
|
|
|
|
wt->wcol.inner[3] = 64;
|
|
|
|
}
|
|
|
|
/* regular disabled */
|
|
|
|
else if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) {
|
|
|
|
widget_state_blend(wt->wcol.text, wt->wcol.inner, 0.5f);
|
|
|
|
}
|
|
|
|
/* regular active */
|
|
|
|
else if (state & UI_SELECT) {
|
|
|
|
copy_v4_v4_char(wt->wcol.outline, wt->wcol.inner_sel);
|
|
|
|
copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel);
|
|
|
|
}
|
|
|
|
else if (state & UI_ACTIVE) {
|
|
|
|
copy_v4_v4_char(wt->wcol.inner, wt->wcol.item);
|
|
|
|
copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-03 16:26:03 +00:00
|
|
|
/* special case, menu items */
|
|
|
|
static void widget_state_menu_item(uiWidgetType *wt, int state)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->wcol = *(wt->wcol_theme);
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2013-01-17 01:48:42 +00:00
|
|
|
/* active and disabled (not so common) */
|
|
|
|
if ((state & UI_BUT_DISABLED) && (state & UI_ACTIVE)) {
|
|
|
|
widget_state_blend(wt->wcol.text, wt->wcol.text_sel, 0.5f);
|
|
|
|
/* draw the backdrop at low alpha, helps navigating with keys
|
2013-01-17 02:06:54 +00:00
|
|
|
* when disabled items are active */
|
2013-01-17 01:48:42 +00:00
|
|
|
copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel);
|
|
|
|
wt->wcol.inner[3] = 64;
|
|
|
|
}
|
|
|
|
/* regular disabled */
|
|
|
|
else if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) {
|
2013-02-18 21:19:43 +00:00
|
|
|
widget_state_blend(wt->wcol.text, wt->wcol.inner, 0.5f);
|
2009-04-12 13:40:29 +00:00
|
|
|
}
|
2013-01-17 01:48:42 +00:00
|
|
|
/* regular active */
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (state & UI_ACTIVE) {
|
2011-11-07 01:38:32 +00:00
|
|
|
copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel);
|
|
|
|
copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel);
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ************ menu backdrop ************************* */
|
|
|
|
|
|
|
|
/* outside of rect, rad to left/bottom/right */
|
2012-12-20 16:50:39 +00:00
|
|
|
static void widget_softshadow(const rcti *rect, int roundboxalign, const float radin)
|
2009-04-03 16:26:03 +00:00
|
|
|
{
|
2012-12-20 16:50:39 +00:00
|
|
|
bTheme *btheme = UI_GetTheme();
|
2009-04-03 16:26:03 +00:00
|
|
|
uiWidgetBase wtb;
|
2012-03-30 01:51:25 +00:00
|
|
|
rcti rect1 = *rect;
|
2012-12-20 16:50:39 +00:00
|
|
|
float alphastep;
|
2011-09-09 14:44:36 +00:00
|
|
|
int step, totvert;
|
2015-01-27 20:18:39 +01:00
|
|
|
float triangle_strip[WIDGET_SIZE_MAX * 2 + 2][2];
|
2012-12-20 16:50:39 +00:00
|
|
|
const float radout = UI_ThemeMenuShadowWidth();
|
|
|
|
|
|
|
|
/* disabled shadow */
|
|
|
|
if (radout == 0.0f)
|
|
|
|
return;
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2009-04-15 14:43:54 +00:00
|
|
|
/* prevent tooltips to not show round shadow */
|
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
|
|
|
if (radout > 0.2f * BLI_rcti_size_y(&rect1))
|
2012-09-15 11:48:20 +00:00
|
|
|
rect1.ymax -= 0.2f * BLI_rcti_size_y(&rect1);
|
2009-04-15 14:43:54 +00:00
|
|
|
else
|
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
|
|
|
rect1.ymax -= radout;
|
2009-04-03 16:26:03 +00:00
|
|
|
|
|
|
|
/* inner part */
|
2012-03-30 01:51:25 +00:00
|
|
|
totvert = round_box_shadow_edges(wtb.inner_v, &rect1, radin, roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT), 0.0f);
|
2011-09-09 14:44:36 +00:00
|
|
|
|
2012-12-20 16:50:39 +00:00
|
|
|
/* we draw a number of increasing size alpha quad strips */
|
|
|
|
alphastep = 3.0f * btheme->tui.menu_shadow_fac / radout;
|
2017-02-20 21:21:04 +01:00
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
2017-02-20 21:21:04 +01:00
|
|
|
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
2011-09-09 14:44:36 +00:00
|
|
|
|
2012-12-20 16:50:39 +00:00
|
|
|
for (step = 1; step <= (int)radout; step++) {
|
2014-03-28 14:53:37 +11:00
|
|
|
float expfac = sqrtf(step / radout);
|
2012-12-20 16:50:39 +00:00
|
|
|
|
2011-09-11 06:41:09 +00:00
|
|
|
round_box_shadow_edges(wtb.outer_v, &rect1, radin, UI_CNR_ALL, (float)step);
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2017-02-20 21:21:04 +01:00
|
|
|
immUniformColor4f(0.0f, 0.0f, 0.0f, alphastep * (1.0f - expfac));
|
2011-09-09 14:44:36 +00:00
|
|
|
|
2015-01-27 20:18:39 +01:00
|
|
|
widget_verts_to_triangle_strip(&wtb, totvert, triangle_strip);
|
2011-09-09 14:44:36 +00:00
|
|
|
|
2017-02-20 21:21:04 +01:00
|
|
|
widget_draw_vertex_buffer(pos, 0, GL_TRIANGLE_STRIP, triangle_strip, NULL, totvert * 2);
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
2011-09-09 14:44:36 +00:00
|
|
|
|
2017-02-20 21:21:04 +01:00
|
|
|
immUnbindProgram();
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int direction)
|
|
|
|
{
|
|
|
|
uiWidgetBase wtb;
|
2012-03-30 01:51:25 +00:00
|
|
|
int roundboxalign = UI_CNR_ALL;
|
2009-04-03 16:26:03 +00:00
|
|
|
|
|
|
|
widget_init(&wtb);
|
|
|
|
|
|
|
|
/* menu is 2nd level or deeper */
|
|
|
|
if (flag & UI_BLOCK_POPUP) {
|
2009-06-04 18:38:10 +00:00
|
|
|
//rect->ymin -= 4.0;
|
|
|
|
//rect->ymax += 4.0;
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
2014-11-09 21:20:40 +01:00
|
|
|
else if (direction == UI_DIR_DOWN) {
|
2012-03-30 01:51:25 +00:00
|
|
|
roundboxalign = (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT);
|
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
|
|
|
rect->ymin -= 0.1f * U.widget_unit;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2014-11-09 21:20:40 +01:00
|
|
|
else if (direction == UI_DIR_UP) {
|
2012-03-30 01:51:25 +00:00
|
|
|
roundboxalign = UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT;
|
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
|
|
|
rect->ymax += 0.1f * U.widget_unit;
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
2018-04-22 13:57:42 +02:00
|
|
|
widget_softshadow(rect, roundboxalign, wcol->roundness * U.widget_unit);
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2018-04-22 13:57:42 +02:00
|
|
|
round_box_edges(&wtb, roundboxalign, rect, wcol->roundness * U.widget_unit);
|
2015-05-29 21:30:04 +02:00
|
|
|
wtb.draw_emboss = false;
|
2009-04-03 16:26:03 +00:00
|
|
|
widgetbase_draw(&wtb, wcol);
|
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
|
|
|
|
2009-06-12 14:22:27 +00:00
|
|
|
static void ui_hsv_cursor(float x, float y)
|
|
|
|
{
|
2017-06-19 20:18:04 +10:00
|
|
|
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
2017-02-20 21:21:04 +01:00
|
|
|
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
|
|
|
immUniformColor3f(1.0f, 1.0f, 1.0f);
|
2017-09-14 00:39:28 +10:00
|
|
|
imm_draw_circle_fill_2d(pos, x, y, 3.0f * U.pixelsize, 8);
|
2009-06-12 14:22:27 +00:00
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
2012-03-30 01:51:25 +00:00
|
|
|
glEnable(GL_LINE_SMOOTH);
|
2017-02-20 21:21:04 +01:00
|
|
|
immUniformColor3f(0.0f, 0.0f, 0.0f);
|
2017-09-14 00:39:28 +10:00
|
|
|
imm_draw_circle_wire_2d(pos, x, y, 3.0f * U.pixelsize, 12);
|
2009-06-12 14:22:27 +00:00
|
|
|
glDisable(GL_BLEND);
|
2012-03-30 01:51:25 +00:00
|
|
|
glDisable(GL_LINE_SMOOTH);
|
2017-02-20 21:21:04 +01:00
|
|
|
|
|
|
|
immUnbindProgram();
|
2009-06-12 14:22:27 +00:00
|
|
|
}
|
|
|
|
|
2012-10-04 09:33:14 +00:00
|
|
|
void ui_hsvcircle_vals_from_pos(float *val_rad, float *val_dist, const rcti *rect,
|
|
|
|
const float mx, const float my)
|
2009-06-10 11:43:21 +00:00
|
|
|
{
|
|
|
|
/* duplication of code... well, simple is better now */
|
2012-10-04 09:33:14 +00:00
|
|
|
const float centx = BLI_rcti_cent_x_fl(rect);
|
|
|
|
const float centy = BLI_rcti_cent_y_fl(rect);
|
2012-10-23 13:28:22 +00:00
|
|
|
const float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f;
|
2012-10-04 09:33:14 +00:00
|
|
|
const float m_delta[2] = {mx - centx, my - centy};
|
2014-02-03 02:46:45 +11:00
|
|
|
const float dist_sq = len_squared_v2(m_delta);
|
2012-10-04 09:33:14 +00:00
|
|
|
|
2014-02-03 02:46:45 +11:00
|
|
|
*val_dist = (dist_sq < (radius * radius)) ? sqrtf(dist_sq) / radius : 1.0f;
|
2012-10-04 09:33:14 +00:00
|
|
|
*val_rad = atan2f(m_delta[0], m_delta[1]) / (2.0f * (float)M_PI) + 0.5f;
|
2009-06-10 11:43:21 +00:00
|
|
|
}
|
|
|
|
|
2013-04-27 12:54:45 +00:00
|
|
|
/* cursor in hsv circle, in float units -1 to 1, to map on radius */
|
|
|
|
void ui_hsvcircle_pos_from_vals(uiBut *but, const rcti *rect, float *hsv, float *xpos, float *ypos)
|
|
|
|
{
|
|
|
|
/* duplication of code... well, simple is better now */
|
|
|
|
const float centx = BLI_rcti_cent_x_fl(rect);
|
|
|
|
const float centy = BLI_rcti_cent_y_fl(rect);
|
|
|
|
float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f;
|
|
|
|
float ang, radius_t;
|
|
|
|
|
2015-01-31 17:23:30 +11:00
|
|
|
ang = 2.0f * (float)M_PI * hsv[0] + (float)M_PI_2;
|
2013-04-27 12:54:45 +00:00
|
|
|
|
2014-03-18 01:08:24 +02:00
|
|
|
if ((but->flag & UI_BUT_COLOR_CUBIC) && (U.color_picker_type == USER_CP_CIRCLE_HSV))
|
2014-11-11 18:16:20 +01:00
|
|
|
radius_t = (1.0f - pow3f(1.0f - hsv[1]));
|
2013-04-27 12:54:45 +00:00
|
|
|
else
|
|
|
|
radius_t = hsv[1];
|
|
|
|
|
|
|
|
radius = CLAMPIS(radius_t, 0.0f, 1.0f) * radius;
|
|
|
|
*xpos = centx + cosf(-ang) * radius;
|
|
|
|
*ypos = centy + sinf(-ang) * radius;
|
|
|
|
}
|
|
|
|
|
2012-10-04 09:43:27 +00:00
|
|
|
static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
|
2009-06-10 11:43:21 +00:00
|
|
|
{
|
2016-08-20 15:40:08 -04:00
|
|
|
/* TODO(merwin): reimplement as shader for pixel-perfect colors */
|
|
|
|
|
2013-02-10 18:03:01 +00:00
|
|
|
const int tot = 64;
|
2012-10-04 09:43:27 +00:00
|
|
|
const float radstep = 2.0f * (float)M_PI / (float)tot;
|
|
|
|
const float centx = BLI_rcti_cent_x_fl(rect);
|
|
|
|
const float centy = BLI_rcti_cent_y_fl(rect);
|
2012-10-23 13:28:22 +00:00
|
|
|
float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f;
|
2012-10-04 09:43:27 +00:00
|
|
|
|
2014-11-06 20:19:21 +01:00
|
|
|
ColorPicker *cpicker = but->custom_data;
|
|
|
|
const float *hsv_ptr = cpicker->color_data;
|
2010-10-13 13:53:49 +00:00
|
|
|
float rgb[3], hsvo[3], hsv[3], col[3], colcent[3];
|
2014-11-09 21:20:40 +01:00
|
|
|
bool color_profile = ui_but_is_colorpicker_display_space(but);
|
2014-03-14 02:30:27 +02:00
|
|
|
|
2009-06-10 11:43:21 +00:00
|
|
|
/* color */
|
2014-11-09 21:20:40 +01:00
|
|
|
ui_but_v3_get(but, rgb);
|
2012-10-04 09:55:10 +00:00
|
|
|
|
|
|
|
/* since we use compat functions on both 'hsv' and 'hsvo', they need to be initialized */
|
|
|
|
hsvo[0] = hsv[0] = hsv_ptr[0];
|
|
|
|
hsvo[1] = hsv[1] = hsv_ptr[1];
|
|
|
|
hsvo[2] = hsv[2] = hsv_ptr[2];
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
|
|
|
|
if (color_profile)
|
2014-11-09 21:20:40 +01:00
|
|
|
ui_block_cm_to_display_space_v3(but->block, rgb);
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
|
2014-03-12 18:58:50 +02:00
|
|
|
ui_rgb_to_color_picker_compat_v(rgb, hsv);
|
2014-03-18 01:08:24 +02:00
|
|
|
copy_v3_v3(hsvo, hsv);
|
|
|
|
|
|
|
|
CLAMP(hsv[2], 0.0f, 1.0f); /* for display only */
|
|
|
|
|
2010-07-05 07:08:10 +00:00
|
|
|
/* exception: if 'lock' is set
|
2010-01-27 00:22:29 +00:00
|
|
|
* lock the value of the color wheel to 1.
|
2011-10-23 15:43:12 +00:00
|
|
|
* Useful for color correction tools where you're only interested in hue. */
|
2014-03-18 01:33:28 +02:00
|
|
|
if (but->flag & UI_BUT_COLOR_LOCK) {
|
2014-03-24 12:59:36 +11:00
|
|
|
if (U.color_picker_type == USER_CP_CIRCLE_HSV)
|
2015-04-13 16:56:43 -04:00
|
|
|
hsv[2] = 1.0f;
|
2014-03-18 01:33:28 +02:00
|
|
|
else
|
|
|
|
hsv[2] = 0.5f;
|
|
|
|
}
|
2010-01-27 00:22:29 +00:00
|
|
|
|
2015-04-13 16:56:43 -04:00
|
|
|
ui_color_picker_to_rgb(0.0f, 0.0f, hsv[2], colcent, colcent + 1, colcent + 2);
|
2014-03-12 18:58:50 +02:00
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
Gwn_VertFormat *format = immVertexFormat();
|
|
|
|
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
|
|
|
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
2016-08-20 15:40:08 -04:00
|
|
|
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
immBegin(GWN_PRIM_TRI_FAN, tot + 2);
|
2016-08-20 15:40:08 -04:00
|
|
|
immAttrib3fv(color, colcent);
|
|
|
|
immVertex2f(pos, centx, centy);
|
2009-06-10 11:43:21 +00:00
|
|
|
|
2016-08-20 15:40:08 -04:00
|
|
|
float ang = 0.0f;
|
|
|
|
for (int a = 0; a <= tot; a++, ang += radstep) {
|
2014-09-17 14:11:37 +10:00
|
|
|
float si = sinf(ang);
|
|
|
|
float co = cosf(ang);
|
2009-06-10 11:43:21 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
ui_hsvcircle_vals_from_pos(hsv, hsv + 1, rect, centx + co * radius, centy + si * radius);
|
2010-07-05 15:52:25 +00:00
|
|
|
|
2014-03-12 18:58:50 +02:00
|
|
|
ui_color_picker_to_rgb_v(hsv, col);
|
|
|
|
|
2016-08-20 15:40:08 -04:00
|
|
|
immAttrib3fv(color, col);
|
|
|
|
immVertex2f(pos, centx + co * radius, centy + si * radius);
|
2009-06-10 11:43:21 +00:00
|
|
|
}
|
2016-08-20 15:40:08 -04:00
|
|
|
immEnd();
|
|
|
|
immUnbindProgram();
|
|
|
|
|
2009-06-12 14:22:27 +00:00
|
|
|
/* fully rounded outline */
|
2016-08-20 15:40:08 -04:00
|
|
|
format = immVertexFormat();
|
2017-06-19 20:18:04 +10:00
|
|
|
pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
2016-08-20 15:40:08 -04:00
|
|
|
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
2009-06-12 14:22:27 +00:00
|
|
|
glEnable(GL_BLEND);
|
2012-03-30 01:51:25 +00:00
|
|
|
glEnable(GL_LINE_SMOOTH);
|
2016-08-20 15:40:08 -04:00
|
|
|
|
2016-09-20 14:23:15 +02:00
|
|
|
immUniformColor3ubv((unsigned char *)wcol->outline);
|
2017-09-14 00:39:28 +10:00
|
|
|
imm_draw_circle_wire_2d(pos, centx, centy, radius, tot);
|
2016-08-20 15:40:08 -04:00
|
|
|
|
2017-02-20 21:21:04 +01:00
|
|
|
immUnbindProgram();
|
|
|
|
|
2009-06-12 14:22:27 +00:00
|
|
|
glDisable(GL_BLEND);
|
2012-03-30 01:51:25 +00:00
|
|
|
glDisable(GL_LINE_SMOOTH);
|
2016-08-20 15:40:08 -04:00
|
|
|
|
2009-06-12 14:22:27 +00:00
|
|
|
/* cursor */
|
2016-08-20 15:40:08 -04:00
|
|
|
float xpos, ypos;
|
2013-04-27 12:54:45 +00:00
|
|
|
ui_hsvcircle_pos_from_vals(but, rect, hsvo, &xpos, &ypos);
|
|
|
|
ui_hsv_cursor(xpos, ypos);
|
2009-06-10 11:43:21 +00:00
|
|
|
}
|
|
|
|
|
2009-06-12 14:22:27 +00:00
|
|
|
/* ************ custom buttons, old stuff ************** */
|
|
|
|
|
2013-10-25 23:50:55 +00:00
|
|
|
/* draws in resolution of 48x4 colors */
|
2012-12-13 02:40:49 +00:00
|
|
|
void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, const float alpha)
|
2009-04-03 16:26:03 +00:00
|
|
|
{
|
2013-10-25 23:50:55 +00:00
|
|
|
/* allows for 4 steps (red->yellow) */
|
2017-02-20 21:21:04 +01:00
|
|
|
const int steps = 48;
|
|
|
|
const float color_step = 1.0f / steps;
|
2009-04-03 16:26:03 +00:00
|
|
|
int a;
|
2012-03-30 01:51:25 +00:00
|
|
|
float h = hsv[0], s = hsv[1], v = hsv[2];
|
2010-01-21 00:00:45 +00:00
|
|
|
float dx, dy, sx1, sx2, sy;
|
2012-07-06 23:56:59 +00:00
|
|
|
float col0[4][3]; /* left half, rect bottom to top */
|
|
|
|
float col1[4][3]; /* right half, rect bottom to top */
|
2010-10-13 14:10:42 +00:00
|
|
|
|
2009-04-03 16:26:03 +00:00
|
|
|
/* draw series of gouraud rects */
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
switch (type) {
|
2010-01-21 00:00:45 +00:00
|
|
|
case UI_GRAD_SV:
|
|
|
|
hsv_to_rgb(h, 0.0, 0.0, &col1[0][0], &col1[0][1], &col1[0][2]);
|
2015-03-24 00:18:57 +11:00
|
|
|
hsv_to_rgb(h, 0.0, 0.333, &col1[1][0], &col1[1][1], &col1[1][2]);
|
|
|
|
hsv_to_rgb(h, 0.0, 0.666, &col1[2][0], &col1[2][1], &col1[2][2]);
|
|
|
|
hsv_to_rgb(h, 0.0, 1.0, &col1[3][0], &col1[3][1], &col1[3][2]);
|
2010-01-21 00:00:45 +00:00
|
|
|
break;
|
|
|
|
case UI_GRAD_HV:
|
|
|
|
hsv_to_rgb(0.0, s, 0.0, &col1[0][0], &col1[0][1], &col1[0][2]);
|
|
|
|
hsv_to_rgb(0.0, s, 0.333, &col1[1][0], &col1[1][1], &col1[1][2]);
|
|
|
|
hsv_to_rgb(0.0, s, 0.666, &col1[2][0], &col1[2][1], &col1[2][2]);
|
|
|
|
hsv_to_rgb(0.0, s, 1.0, &col1[3][0], &col1[3][1], &col1[3][2]);
|
|
|
|
break;
|
|
|
|
case UI_GRAD_HS:
|
|
|
|
hsv_to_rgb(0.0, 0.0, v, &col1[0][0], &col1[0][1], &col1[0][2]);
|
|
|
|
hsv_to_rgb(0.0, 0.333, v, &col1[1][0], &col1[1][1], &col1[1][2]);
|
|
|
|
hsv_to_rgb(0.0, 0.666, v, &col1[2][0], &col1[2][1], &col1[2][2]);
|
|
|
|
hsv_to_rgb(0.0, 1.0, v, &col1[3][0], &col1[3][1], &col1[3][2]);
|
|
|
|
break;
|
|
|
|
case UI_GRAD_H:
|
2015-04-13 16:56:43 -04:00
|
|
|
hsv_to_rgb(0.0, 1.0, 1.0, &col1[0][0], &col1[0][1], &col1[0][2]);
|
2011-11-06 16:34:44 +00:00
|
|
|
copy_v3_v3(col1[1], col1[0]);
|
|
|
|
copy_v3_v3(col1[2], col1[0]);
|
|
|
|
copy_v3_v3(col1[3], col1[0]);
|
2010-01-21 00:00:45 +00:00
|
|
|
break;
|
|
|
|
case UI_GRAD_S:
|
2015-04-13 16:56:43 -04:00
|
|
|
hsv_to_rgb(1.0, 0.0, 1.0, &col1[1][0], &col1[1][1], &col1[1][2]);
|
2011-11-06 16:34:44 +00:00
|
|
|
copy_v3_v3(col1[0], col1[1]);
|
|
|
|
copy_v3_v3(col1[2], col1[1]);
|
|
|
|
copy_v3_v3(col1[3], col1[1]);
|
2010-01-21 00:00:45 +00:00
|
|
|
break;
|
|
|
|
case UI_GRAD_V:
|
2015-04-13 16:56:43 -04:00
|
|
|
hsv_to_rgb(1.0, 1.0, 0.0, &col1[2][0], &col1[2][1], &col1[2][2]);
|
2011-11-06 16:34:44 +00:00
|
|
|
copy_v3_v3(col1[0], col1[2]);
|
|
|
|
copy_v3_v3(col1[1], col1[2]);
|
|
|
|
copy_v3_v3(col1[3], col1[2]);
|
2010-01-21 00:00:45 +00:00
|
|
|
break;
|
2010-10-17 08:59:23 +00:00
|
|
|
default:
|
|
|
|
assert(!"invalid 'type' argument");
|
2015-04-13 16:56:43 -04:00
|
|
|
hsv_to_rgb(1.0, 1.0, 1.0, &col1[2][0], &col1[2][1], &col1[2][2]);
|
2011-11-06 16:34:44 +00:00
|
|
|
copy_v3_v3(col1[0], col1[2]);
|
|
|
|
copy_v3_v3(col1[1], col1[2]);
|
|
|
|
copy_v3_v3(col1[3], col1[2]);
|
2013-07-21 08:16:37 +00:00
|
|
|
break;
|
2010-01-09 06:44:54 +00:00
|
|
|
}
|
2017-02-20 21:21:04 +01:00
|
|
|
|
2010-01-09 06:44:54 +00:00
|
|
|
/* old below */
|
2017-06-19 20:18:04 +10:00
|
|
|
Gwn_VertFormat *format = immVertexFormat();
|
|
|
|
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
|
|
|
unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
|
2017-02-20 21:21:04 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
immBegin(GWN_PRIM_TRIS, steps * 3 * 6);
|
2012-11-09 10:33:42 +00:00
|
|
|
for (dx = 0.0f; dx < 0.999f; dx += color_step) { /* 0.999 = prevent float inaccuracy for steps */
|
2013-10-25 23:50:55 +00:00
|
|
|
const float dx_next = dx + color_step;
|
|
|
|
|
2012-08-19 10:41:27 +00:00
|
|
|
/* previous color */
|
2011-11-06 16:34:44 +00:00
|
|
|
copy_v3_v3(col0[0], col1[0]);
|
|
|
|
copy_v3_v3(col0[1], col1[1]);
|
|
|
|
copy_v3_v3(col0[2], col1[2]);
|
|
|
|
copy_v3_v3(col0[3], col1[3]);
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2012-08-19 10:41:27 +00:00
|
|
|
/* new color */
|
2012-03-30 01:51:25 +00:00
|
|
|
switch (type) {
|
2010-01-21 00:00:45 +00:00
|
|
|
case UI_GRAD_SV:
|
2015-03-24 00:18:57 +11:00
|
|
|
hsv_to_rgb(h, dx, 0.0, &col1[0][0], &col1[0][1], &col1[0][2]);
|
|
|
|
hsv_to_rgb(h, dx, 0.333, &col1[1][0], &col1[1][1], &col1[1][2]);
|
|
|
|
hsv_to_rgb(h, dx, 0.666, &col1[2][0], &col1[2][1], &col1[2][2]);
|
|
|
|
hsv_to_rgb(h, dx, 1.0, &col1[3][0], &col1[3][1], &col1[3][2]);
|
2010-01-21 00:00:45 +00:00
|
|
|
break;
|
|
|
|
case UI_GRAD_HV:
|
2013-10-25 23:50:55 +00:00
|
|
|
hsv_to_rgb(dx_next, s, 0.0, &col1[0][0], &col1[0][1], &col1[0][2]);
|
|
|
|
hsv_to_rgb(dx_next, s, 0.333, &col1[1][0], &col1[1][1], &col1[1][2]);
|
|
|
|
hsv_to_rgb(dx_next, s, 0.666, &col1[2][0], &col1[2][1], &col1[2][2]);
|
|
|
|
hsv_to_rgb(dx_next, s, 1.0, &col1[3][0], &col1[3][1], &col1[3][2]);
|
2010-01-21 00:00:45 +00:00
|
|
|
break;
|
|
|
|
case UI_GRAD_HS:
|
2013-10-25 23:50:55 +00:00
|
|
|
hsv_to_rgb(dx_next, 0.0, v, &col1[0][0], &col1[0][1], &col1[0][2]);
|
|
|
|
hsv_to_rgb(dx_next, 0.333, v, &col1[1][0], &col1[1][1], &col1[1][2]);
|
|
|
|
hsv_to_rgb(dx_next, 0.666, v, &col1[2][0], &col1[2][1], &col1[2][2]);
|
|
|
|
hsv_to_rgb(dx_next, 1.0, v, &col1[3][0], &col1[3][1], &col1[3][2]);
|
2010-01-21 00:00:45 +00:00
|
|
|
break;
|
|
|
|
case UI_GRAD_H:
|
2012-06-21 19:45:36 +00:00
|
|
|
/* annoying but without this the color shifts - could be solved some other way
|
|
|
|
* - campbell */
|
2015-04-13 16:56:43 -04:00
|
|
|
hsv_to_rgb(dx_next, 1.0, 1.0, &col1[0][0], &col1[0][1], &col1[0][2]);
|
2011-11-06 16:34:44 +00:00
|
|
|
copy_v3_v3(col1[1], col1[0]);
|
|
|
|
copy_v3_v3(col1[2], col1[0]);
|
|
|
|
copy_v3_v3(col1[3], col1[0]);
|
2010-01-21 00:00:45 +00:00
|
|
|
break;
|
|
|
|
case UI_GRAD_S:
|
2015-04-13 16:56:43 -04:00
|
|
|
hsv_to_rgb(h, dx, 1.0, &col1[1][0], &col1[1][1], &col1[1][2]);
|
2011-11-06 16:34:44 +00:00
|
|
|
copy_v3_v3(col1[0], col1[1]);
|
|
|
|
copy_v3_v3(col1[2], col1[1]);
|
|
|
|
copy_v3_v3(col1[3], col1[1]);
|
2010-01-21 00:00:45 +00:00
|
|
|
break;
|
|
|
|
case UI_GRAD_V:
|
2015-04-13 16:56:43 -04:00
|
|
|
hsv_to_rgb(h, 1.0, dx, &col1[2][0], &col1[2][1], &col1[2][2]);
|
2011-11-06 16:34:44 +00:00
|
|
|
copy_v3_v3(col1[0], col1[2]);
|
|
|
|
copy_v3_v3(col1[1], col1[2]);
|
|
|
|
copy_v3_v3(col1[3], col1[2]);
|
2010-01-21 00:00:45 +00:00
|
|
|
break;
|
2010-01-09 06:44:54 +00:00
|
|
|
}
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2012-08-19 10:41:27 +00:00
|
|
|
/* rect */
|
2013-10-25 23:50:55 +00:00
|
|
|
sx1 = rect->xmin + dx * BLI_rcti_size_x(rect);
|
|
|
|
sx2 = rect->xmin + dx_next * BLI_rcti_size_x(rect);
|
2012-03-30 01:51:25 +00:00
|
|
|
sy = rect->ymin;
|
2012-11-09 11:03:53 +00:00
|
|
|
dy = (float)BLI_rcti_size_y(rect) / 3.0f;
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < 3; a++, sy += dy) {
|
2017-02-20 21:21:04 +01:00
|
|
|
immAttrib4f(col, col0[a][0], col0[a][1], col0[a][2], alpha);
|
|
|
|
immVertex2f(pos, sx1, sy);
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2017-02-20 21:21:04 +01:00
|
|
|
immAttrib4f(col, col1[a][0], col1[a][1], col1[a][2], alpha);
|
|
|
|
immVertex2f(pos, sx2, sy);
|
|
|
|
|
|
|
|
immAttrib4f(col, col1[a + 1][0], col1[a + 1][1], col1[a + 1][2], alpha);
|
|
|
|
immVertex2f(pos, sx2, sy + dy);
|
2010-01-21 00:00:45 +00:00
|
|
|
|
2017-02-20 21:21:04 +01:00
|
|
|
immAttrib4f(col, col0[a][0], col0[a][1], col0[a][2], alpha);
|
|
|
|
immVertex2f(pos, sx1, sy);
|
|
|
|
|
|
|
|
immAttrib4f(col, col1[a + 1][0], col1[a + 1][1], col1[a + 1][2], alpha);
|
|
|
|
immVertex2f(pos, sx2, sy + dy);
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2017-02-20 21:21:04 +01:00
|
|
|
immAttrib4f(col, col0[a + 1][0], col0[a + 1][1], col0[a + 1][2], alpha);
|
|
|
|
immVertex2f(pos, sx1, sy + dy);
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
|
|
|
}
|
2017-02-20 21:21:04 +01:00
|
|
|
immEnd();
|
|
|
|
|
|
|
|
immUnbindProgram();
|
2010-01-21 00:00:45 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
bool ui_but_is_colorpicker_display_space(uiBut *but)
|
2013-11-20 11:34:18 +01:00
|
|
|
{
|
|
|
|
bool color_profile = but->block->color_profile;
|
|
|
|
|
|
|
|
if (but->rnaprop) {
|
|
|
|
if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
|
2014-01-04 17:16:19 +11:00
|
|
|
color_profile = false;
|
2013-11-20 11:34:18 +01:00
|
|
|
}
|
|
|
|
|
2014-03-14 01:37:32 +02:00
|
|
|
return color_profile;
|
2013-11-20 11:34:18 +01:00
|
|
|
}
|
|
|
|
|
2013-04-27 12:54:45 +00:00
|
|
|
void ui_hsvcube_pos_from_vals(uiBut *but, const rcti *rect, float *hsv, float *xp, float *yp)
|
|
|
|
{
|
2014-01-06 15:05:21 +01:00
|
|
|
float x = 0.0f, y = 0.0f;
|
|
|
|
|
2013-04-27 12:54:45 +00:00
|
|
|
switch ((int)but->a1) {
|
|
|
|
case UI_GRAD_SV:
|
2015-03-24 00:18:57 +11:00
|
|
|
x = hsv[1]; y = hsv[2]; break;
|
2013-04-27 12:54:45 +00:00
|
|
|
case UI_GRAD_HV:
|
|
|
|
x = hsv[0]; y = hsv[2]; break;
|
|
|
|
case UI_GRAD_HS:
|
|
|
|
x = hsv[0]; y = hsv[1]; break;
|
|
|
|
case UI_GRAD_H:
|
|
|
|
x = hsv[0]; y = 0.5; break;
|
|
|
|
case UI_GRAD_S:
|
|
|
|
x = hsv[1]; y = 0.5; break;
|
|
|
|
case UI_GRAD_V:
|
|
|
|
x = hsv[2]; y = 0.5; break;
|
2014-03-12 18:58:50 +02:00
|
|
|
case UI_GRAD_L_ALT:
|
2014-03-18 01:08:24 +02:00
|
|
|
x = 0.5f;
|
|
|
|
/* exception only for value strip - use the range set in but->min/max */
|
|
|
|
y = hsv[2];
|
|
|
|
break;
|
|
|
|
case UI_GRAD_V_ALT:
|
2013-04-27 12:54:45 +00:00
|
|
|
x = 0.5f;
|
|
|
|
/* exception only for value strip - use the range set in but->min/max */
|
2014-04-20 22:05:05 +10:00
|
|
|
y = (hsv[2] - but->softmin) / (but->softmax - but->softmin);
|
2013-04-27 12:54:45 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-04-13 16:56:43 -04:00
|
|
|
|
2013-04-27 12:54:45 +00:00
|
|
|
/* cursor */
|
|
|
|
*xp = rect->xmin + x * BLI_rcti_size_x(rect);
|
|
|
|
*yp = rect->ymin + y * BLI_rcti_size_y(rect);
|
|
|
|
}
|
2010-01-21 00:00:45 +00:00
|
|
|
|
2012-12-13 02:40:49 +00:00
|
|
|
static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect)
|
2010-01-21 00:00:45 +00:00
|
|
|
{
|
2012-05-26 11:01:01 +00:00
|
|
|
float rgb[3];
|
2012-03-30 01:51:25 +00:00
|
|
|
float x = 0.0f, y = 0.0f;
|
2014-11-06 20:19:21 +01:00
|
|
|
ColorPicker *cpicker = but->custom_data;
|
|
|
|
float *hsv = cpicker->color_data;
|
2012-05-26 11:01:01 +00:00
|
|
|
float hsv_n[3];
|
2014-11-09 21:20:40 +01:00
|
|
|
bool use_display_colorspace = ui_but_is_colorpicker_display_space(but);
|
2010-10-13 13:53:49 +00:00
|
|
|
|
2012-05-26 11:01:01 +00:00
|
|
|
copy_v3_v3(hsv_n, hsv);
|
2010-01-21 00:00:45 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
ui_but_v3_get(but, rgb);
|
2012-12-15 18:12:38 +00:00
|
|
|
|
2013-11-20 11:34:18 +01:00
|
|
|
if (use_display_colorspace)
|
2014-11-09 21:20:40 +01:00
|
|
|
ui_block_cm_to_display_space_v3(but->block, rgb);
|
2012-12-15 18:12:38 +00:00
|
|
|
|
2012-05-26 11:01:01 +00:00
|
|
|
rgb_to_hsv_compat_v(rgb, hsv_n);
|
2010-01-21 00:00:45 +00:00
|
|
|
|
2012-05-26 11:01:01 +00:00
|
|
|
ui_draw_gradient(rect, hsv_n, but->a1, 1.0f);
|
2013-04-27 12:54:45 +00:00
|
|
|
|
|
|
|
ui_hsvcube_pos_from_vals(but, rect, hsv_n, &x, &y);
|
2012-03-30 01:51:25 +00:00
|
|
|
CLAMP(x, rect->xmin + 3.0f, rect->xmax - 3.0f);
|
|
|
|
CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f);
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2009-06-12 14:22:27 +00:00
|
|
|
ui_hsv_cursor(x, y);
|
2009-04-03 16:26:03 +00:00
|
|
|
|
|
|
|
/* outline */
|
2017-06-19 20:18:04 +10:00
|
|
|
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
2017-02-20 21:21:04 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
immUniformColor3ub(0, 0, 0);
|
2017-09-26 15:21:01 +10:00
|
|
|
imm_draw_box_wire_2d(pos, (rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax));
|
2017-02-20 21:21:04 +01:00
|
|
|
immUnbindProgram();
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
|
|
|
|
2009-06-12 14:22:27 +00:00
|
|
|
/* vertical 'value' slider, using new widget code */
|
2012-12-13 02:40:49 +00:00
|
|
|
static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect)
|
2009-06-12 14:22:27 +00:00
|
|
|
{
|
2018-04-22 13:57:42 +02:00
|
|
|
bTheme *btheme = UI_GetTheme();
|
|
|
|
uiWidgetColors *wcol = &btheme->tui.wcol_numslider;
|
2009-06-12 14:22:27 +00:00
|
|
|
uiWidgetBase wtb;
|
2018-04-25 11:53:21 +02:00
|
|
|
const float rad = wcol->roundness * BLI_rcti_size_x(rect);
|
2009-06-12 14:22:27 +00:00
|
|
|
float x, y;
|
2014-03-18 01:08:24 +02:00
|
|
|
float rgb[3], hsv[3], v;
|
2014-01-04 17:16:19 +11:00
|
|
|
bool color_profile = but->block->color_profile;
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
|
2010-08-25 07:49:12 +00:00
|
|
|
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
|
2014-01-04 17:16:19 +11:00
|
|
|
color_profile = false;
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
ui_but_v3_get(but, rgb);
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
|
|
|
|
if (color_profile)
|
2014-11-09 21:20:40 +01:00
|
|
|
ui_block_cm_to_display_space_v3(but->block, rgb);
|
2014-03-12 19:12:39 +02:00
|
|
|
|
|
|
|
if (but->a1 == UI_GRAD_L_ALT)
|
2014-03-12 18:58:50 +02:00
|
|
|
rgb_to_hsl_v(rgb, hsv);
|
|
|
|
else
|
|
|
|
rgb_to_hsv_v(rgb, hsv);
|
2010-01-07 09:55:11 +00:00
|
|
|
v = hsv[2];
|
|
|
|
|
2010-01-27 00:22:29 +00:00
|
|
|
/* map v from property range to [0,1] */
|
2014-03-18 01:08:24 +02:00
|
|
|
if (but->a1 == UI_GRAD_V_ALT) {
|
2015-09-15 21:22:33 +10:00
|
|
|
float min = but->softmin, max = but->softmax;
|
|
|
|
if (color_profile) {
|
|
|
|
ui_block_cm_to_display_space_range(but->block, &min, &max);
|
|
|
|
}
|
|
|
|
v = (v - min) / (max - min);
|
2014-03-18 01:08:24 +02:00
|
|
|
}
|
|
|
|
|
2009-06-12 14:22:27 +00:00
|
|
|
widget_init(&wtb);
|
|
|
|
|
|
|
|
/* fully rounded */
|
2011-09-11 06:41:09 +00:00
|
|
|
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
|
2009-06-12 14:22:27 +00:00
|
|
|
|
|
|
|
/* setup temp colors */
|
2012-03-30 01:51:25 +00:00
|
|
|
wcol_tmp.outline[0] = wcol_tmp.outline[1] = wcol_tmp.outline[2] = 0;
|
|
|
|
wcol_tmp.inner[0] = wcol_tmp.inner[1] = wcol_tmp.inner[2] = 128;
|
|
|
|
wcol_tmp.shadetop = 127;
|
|
|
|
wcol_tmp.shadedown = -128;
|
|
|
|
wcol_tmp.shaded = 1;
|
2009-06-12 14:22:27 +00:00
|
|
|
|
|
|
|
widgetbase_draw(&wtb, &wcol_tmp);
|
|
|
|
|
2018-04-10 17:42:33 +02:00
|
|
|
/* We are drawing on top of widget bases. Flush cache. */
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
UI_widgetbase_draw_cache_flush();
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
2009-06-12 14:22:27 +00:00
|
|
|
/* cursor */
|
2012-09-15 11:48:20 +00:00
|
|
|
x = rect->xmin + 0.5f * BLI_rcti_size_x(rect);
|
|
|
|
y = rect->ymin + v * BLI_rcti_size_y(rect);
|
2012-03-30 01:51:25 +00:00
|
|
|
CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f);
|
2015-04-13 16:56:43 -04:00
|
|
|
|
2009-06-12 14:22:27 +00:00
|
|
|
ui_hsv_cursor(x, y);
|
|
|
|
}
|
2009-04-02 15:01:11 +00:00
|
|
|
|
2010-01-19 01:32:06 +00:00
|
|
|
|
2010-01-11 01:26:16 +00:00
|
|
|
/* ************ separator, for menus etc ***************** */
|
2012-12-13 02:40:49 +00:00
|
|
|
static void ui_draw_separator(const rcti *rect, uiWidgetColors *wcol)
|
2010-01-11 01:26:16 +00:00
|
|
|
{
|
2012-09-15 11:48:20 +00:00
|
|
|
int y = rect->ymin + BLI_rcti_size_y(rect) / 2 - 1;
|
2016-01-05 01:35:19 -05:00
|
|
|
unsigned char col[4] = {
|
|
|
|
wcol->text[0],
|
|
|
|
wcol->text[1],
|
|
|
|
wcol->text[2],
|
|
|
|
30
|
|
|
|
};
|
2017-02-20 21:21:04 +01:00
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
2017-02-20 21:21:04 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
2010-01-11 01:26:16 +00:00
|
|
|
glEnable(GL_BLEND);
|
2017-02-20 21:21:04 +01:00
|
|
|
immUniformColor4ubv(col);
|
2016-10-06 22:44:15 +02:00
|
|
|
glLineWidth(1.0f);
|
2017-02-23 02:52:36 -03:00
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
immBegin(GWN_PRIM_LINES, 2);
|
2017-02-23 02:52:36 -03:00
|
|
|
immVertex2f(pos, rect->xmin, y);
|
|
|
|
immVertex2f(pos, rect->xmax, y);
|
|
|
|
immEnd();
|
|
|
|
|
2010-01-11 01:26:16 +00:00
|
|
|
glDisable(GL_BLEND);
|
2017-02-20 21:21:04 +01:00
|
|
|
|
|
|
|
immUnbindProgram();
|
2010-01-11 01:26:16 +00:00
|
|
|
}
|
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
/* ************ button callbacks, draw ***************** */
|
2013-06-18 09:02:13 +00:00
|
|
|
static void widget_numbut_draw(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign, bool emboss)
|
2009-04-02 15:01:11 +00:00
|
|
|
{
|
|
|
|
uiWidgetBase wtb;
|
2018-04-25 11:53:21 +02:00
|
|
|
const float rad = wcol->roundness * BLI_rcti_size_y(rect);
|
2018-04-22 13:57:50 +02:00
|
|
|
const int handle_width = min_ii(BLI_rcti_size_x(rect) / 3, BLI_rcti_size_y(rect) * 0.7f);
|
2009-11-11 10:27:25 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_SELECT)
|
2010-09-11 00:08:07 +00:00
|
|
|
SWAP(short, wcol->shadetop, wcol->shadedown);
|
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
widget_init(&wtb);
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2013-06-18 09:02:13 +00:00
|
|
|
if (!emboss) {
|
|
|
|
round_box_edges(&wtb, roundboxalign, rect, rad);
|
|
|
|
}
|
2018-01-11 13:20:08 +11:00
|
|
|
else {
|
|
|
|
wtb.draw_inner = false;
|
|
|
|
wtb.draw_outline = false;
|
|
|
|
}
|
2013-06-18 09:02:13 +00:00
|
|
|
|
2009-03-25 16:58:42 +00:00
|
|
|
/* decoration */
|
2018-04-22 13:57:50 +02:00
|
|
|
if ((state & UI_ACTIVE) && !(state & UI_STATE_TEXT_INPUT)) {
|
|
|
|
uiWidgetColors wcol_zone;
|
|
|
|
uiWidgetBase wtb_zone;
|
|
|
|
rcti rect_zone;
|
|
|
|
int roundboxalign_zone;
|
|
|
|
|
|
|
|
/* left arrow zone */
|
|
|
|
widget_init(&wtb_zone);
|
|
|
|
wtb_zone.draw_outline = false;
|
|
|
|
wtb_zone.draw_emboss = false;
|
|
|
|
|
|
|
|
wcol_zone = *wcol;
|
|
|
|
copy_v3_v3_char(wcol_zone.item, wcol->text);
|
|
|
|
if (state & UI_STATE_ACTIVE_LEFT) {
|
|
|
|
widget_active_color(wcol_zone.inner);
|
|
|
|
}
|
2009-11-12 00:48:44 +00:00
|
|
|
|
2018-04-22 13:57:50 +02:00
|
|
|
rect_zone = *rect;
|
|
|
|
rect_zone.xmax = rect->xmin + handle_width + U.pixelsize;
|
|
|
|
roundboxalign_zone = roundboxalign & ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT);
|
|
|
|
round_box_edges(&wtb_zone, roundboxalign_zone, &rect_zone, rad);
|
|
|
|
|
|
|
|
shape_preset_init_number_arrows(&wtb_zone.tria1, &rect_zone, 0.6f, 'l');
|
|
|
|
widgetbase_draw(&wtb_zone, &wcol_zone);
|
|
|
|
|
|
|
|
/* right arrow zone */
|
|
|
|
widget_init(&wtb_zone);
|
|
|
|
wtb_zone.draw_outline = false;
|
|
|
|
wtb_zone.draw_emboss = false;
|
|
|
|
wtb_zone.tria1.type = ROUNDBOX_TRIA_ARROWS;
|
|
|
|
|
|
|
|
wcol_zone = *wcol;
|
|
|
|
copy_v3_v3_char(wcol_zone.item, wcol->text);
|
|
|
|
if (state & UI_STATE_ACTIVE_RIGHT) {
|
|
|
|
widget_active_color(wcol_zone.inner);
|
|
|
|
}
|
|
|
|
|
|
|
|
rect_zone = *rect;
|
|
|
|
rect_zone.xmin = rect->xmax - handle_width - U.pixelsize;
|
|
|
|
roundboxalign_zone = roundboxalign & ~(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT);
|
|
|
|
round_box_edges(&wtb_zone, roundboxalign_zone, &rect_zone, rad);
|
|
|
|
|
|
|
|
shape_preset_init_number_arrows(&wtb_zone.tria2, &rect_zone, 0.6f, 'r');
|
|
|
|
widgetbase_draw(&wtb_zone, &wcol_zone);
|
|
|
|
|
|
|
|
/* middle highlight zone */
|
|
|
|
widget_init(&wtb_zone);
|
|
|
|
wtb_zone.draw_outline = false;
|
|
|
|
wtb_zone.draw_emboss = false;
|
|
|
|
|
|
|
|
wcol_zone = *wcol;
|
|
|
|
copy_v3_v3_char(wcol_zone.item, wcol->text);
|
2018-04-28 09:01:34 +02:00
|
|
|
if (!(state & (UI_STATE_ACTIVE_LEFT | UI_STATE_ACTIVE_RIGHT))) {
|
2018-04-22 13:57:50 +02:00
|
|
|
widget_active_color(wcol_zone.inner);
|
|
|
|
}
|
|
|
|
|
|
|
|
rect_zone = *rect;
|
|
|
|
rect_zone.xmin = rect->xmin + handle_width - U.pixelsize;
|
|
|
|
rect_zone.xmax = rect->xmax - handle_width + U.pixelsize;
|
|
|
|
round_box_edges(&wtb_zone, 0, &rect_zone, 0);
|
|
|
|
widgetbase_draw(&wtb_zone, &wcol_zone);
|
|
|
|
|
|
|
|
/* outline */
|
|
|
|
wtb.draw_inner = false;
|
|
|
|
widgetbase_draw(&wtb, wcol);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* inner and outline */
|
|
|
|
widgetbase_draw(&wtb, wcol);
|
|
|
|
}
|
2009-04-09 18:11:18 +00:00
|
|
|
|
2017-11-03 00:22:59 +11:00
|
|
|
if (!(state & UI_STATE_TEXT_INPUT)) {
|
2018-04-22 13:57:42 +02:00
|
|
|
const float textofs = 0.425f * BLI_rcti_size_y(rect);
|
|
|
|
|
2014-02-25 10:28:41 +11:00
|
|
|
/* text space */
|
|
|
|
rect->xmin += textofs;
|
|
|
|
rect->xmax -= textofs;
|
|
|
|
}
|
2009-04-02 18:16:15 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 09:02:13 +00:00
|
|
|
static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
|
|
|
{
|
|
|
|
widget_numbut_draw(wcol, rect, state, roundboxalign, false);
|
|
|
|
}
|
|
|
|
|
2013-11-24 15:23:38 +11:00
|
|
|
/**
|
2013-06-18 09:02:13 +00:00
|
|
|
* Draw number buttons still with triangles when field is not embossed
|
2013-11-24 15:23:38 +11:00
|
|
|
*/
|
2013-06-18 10:09:45 +00:00
|
|
|
static void widget_numbut_embossn(uiBut *UNUSED(but), uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
2013-06-18 09:02:13 +00:00
|
|
|
{
|
|
|
|
widget_numbut_draw(wcol, rect, state, roundboxalign, true);
|
|
|
|
}
|
|
|
|
|
2009-07-02 18:12:46 +00:00
|
|
|
/* function in use for buttons and for view2d sliders */
|
2014-11-09 21:20:40 +01:00
|
|
|
void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *slider, int state)
|
2009-06-24 14:16:56 +00:00
|
|
|
{
|
|
|
|
uiWidgetBase wtb;
|
|
|
|
int horizontal;
|
2012-12-13 02:40:49 +00:00
|
|
|
float rad;
|
2013-07-19 10:39:44 +00:00
|
|
|
bool outline = false;
|
2009-06-24 14:16:56 +00:00
|
|
|
|
2009-07-02 18:12:46 +00:00
|
|
|
widget_init(&wtb);
|
|
|
|
|
2009-06-24 14:16:56 +00:00
|
|
|
/* determine horizontal/vertical */
|
2012-09-15 11:48:20 +00:00
|
|
|
horizontal = (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect));
|
2012-12-13 02:40:49 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (horizontal)
|
2018-04-22 13:57:42 +02:00
|
|
|
rad = wcol->roundness * BLI_rcti_size_y(rect);
|
2009-06-24 14:16:56 +00:00
|
|
|
else
|
2018-04-22 13:57:42 +02:00
|
|
|
rad = wcol->roundness * BLI_rcti_size_x(rect);
|
2009-07-02 18:12:46 +00:00
|
|
|
|
2018-03-29 03:21:03 +02:00
|
|
|
wtb.uniform_params.shade_dir = (horizontal) ? 1.0f : 0.0;
|
2009-07-02 18:12:46 +00:00
|
|
|
|
2009-06-24 14:16:56 +00:00
|
|
|
/* draw back part, colors swapped and shading inverted */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (horizontal)
|
2009-06-24 14:16:56 +00:00
|
|
|
SWAP(short, wcol->shadetop, wcol->shadedown);
|
|
|
|
|
2011-09-11 06:41:09 +00:00
|
|
|
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
|
2009-06-24 14:16:56 +00:00
|
|
|
widgetbase_draw(&wtb, wcol);
|
|
|
|
|
2009-07-02 18:12:46 +00:00
|
|
|
/* slider */
|
2012-09-15 11:48:20 +00:00
|
|
|
if ((BLI_rcti_size_x(slider) < 2) || (BLI_rcti_size_y(slider) < 2)) {
|
2012-08-20 23:06:17 +00:00
|
|
|
/* pass */
|
|
|
|
}
|
2009-07-02 18:12:46 +00:00
|
|
|
else {
|
|
|
|
SWAP(short, wcol->shadetop, wcol->shadedown);
|
|
|
|
|
2011-11-07 01:38:32 +00:00
|
|
|
copy_v4_v4_char(wcol->inner, wcol->item);
|
2009-07-02 18:12:46 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (wcol->shadetop > wcol->shadedown)
|
|
|
|
wcol->shadetop += 20; /* XXX violates themes... */
|
|
|
|
else wcol->shadedown += 20;
|
2009-07-02 18:12:46 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_SCROLL_PRESSED) {
|
2012-03-30 01:51:25 +00:00
|
|
|
wcol->inner[0] = wcol->inner[0] >= 250 ? 255 : wcol->inner[0] + 5;
|
|
|
|
wcol->inner[1] = wcol->inner[1] >= 250 ? 255 : wcol->inner[1] + 5;
|
|
|
|
wcol->inner[2] = wcol->inner[2] >= 250 ? 255 : wcol->inner[2] + 5;
|
2009-07-23 20:50:24 +00:00
|
|
|
}
|
2009-07-02 18:12:46 +00:00
|
|
|
|
|
|
|
/* draw */
|
2015-05-29 21:30:04 +02:00
|
|
|
wtb.draw_emboss = false; /* only emboss once */
|
2009-07-02 18:12:46 +00:00
|
|
|
|
2010-05-27 08:22:16 +00:00
|
|
|
/* exception for progress bar */
|
2013-07-19 10:39:44 +00:00
|
|
|
if (state & UI_SCROLL_NO_OUTLINE) {
|
2015-05-29 21:30:04 +02:00
|
|
|
SWAP(bool, outline, wtb.draw_outline);
|
2013-07-19 10:39:44 +00:00
|
|
|
}
|
2010-05-27 08:22:16 +00:00
|
|
|
|
2011-09-11 06:41:09 +00:00
|
|
|
round_box_edges(&wtb, UI_CNR_ALL, slider, rad);
|
2009-07-02 18:12:46 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_SCROLL_ARROWS) {
|
2012-03-30 01:51:25 +00:00
|
|
|
if (wcol->item[0] > 48) wcol->item[0] -= 48;
|
|
|
|
if (wcol->item[1] > 48) wcol->item[1] -= 48;
|
|
|
|
if (wcol->item[2] > 48) wcol->item[2] -= 48;
|
|
|
|
wcol->item[3] = 255;
|
2009-07-03 13:21:09 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (horizontal) {
|
2017-11-02 05:48:14 +11:00
|
|
|
shape_preset_init_scroll_circle(&wtb.tria1, slider, 0.6f, 'l');
|
|
|
|
shape_preset_init_scroll_circle(&wtb.tria2, slider, 0.6f, 'r');
|
2009-07-03 13:21:09 +00:00
|
|
|
}
|
|
|
|
else {
|
2017-11-02 05:48:14 +11:00
|
|
|
shape_preset_init_scroll_circle(&wtb.tria1, slider, 0.6f, 'b');
|
|
|
|
shape_preset_init_scroll_circle(&wtb.tria2, slider, 0.6f, 't');
|
2009-07-03 13:21:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
widgetbase_draw(&wtb, wcol);
|
2010-05-27 08:22:16 +00:00
|
|
|
|
2013-07-19 10:39:44 +00:00
|
|
|
if (state & UI_SCROLL_NO_OUTLINE) {
|
2015-05-29 21:30:04 +02:00
|
|
|
SWAP(bool, outline, wtb.draw_outline);
|
2013-07-19 10:39:44 +00:00
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-07-02 18:12:46 +00:00
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int UNUSED(roundboxalign))
|
2009-07-02 18:12:46 +00:00
|
|
|
{
|
|
|
|
rcti rect1;
|
|
|
|
double value;
|
2009-07-21 01:26:17 +00:00
|
|
|
float fac, size, min;
|
2009-07-02 18:12:46 +00:00
|
|
|
int horizontal;
|
|
|
|
|
|
|
|
/* calculate slider part */
|
2014-11-09 21:20:40 +01:00
|
|
|
value = ui_but_value_get(but);
|
2009-06-24 14:16:56 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
size = (but->softmax + but->a1 - but->softmin);
|
2012-10-27 11:18:54 +00:00
|
|
|
size = max_ff(size, 2.0f);
|
2009-06-24 14:16:56 +00:00
|
|
|
|
|
|
|
/* position */
|
2012-03-30 01:51:25 +00:00
|
|
|
rect1 = *rect;
|
2009-06-24 14:16:56 +00:00
|
|
|
|
2009-07-02 18:12:46 +00:00
|
|
|
/* determine horizontal/vertical */
|
2012-09-15 11:48:20 +00:00
|
|
|
horizontal = (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect));
|
2009-07-02 18:12:46 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (horizontal) {
|
2012-09-15 11:48:20 +00:00
|
|
|
fac = BLI_rcti_size_x(rect) / size;
|
2012-03-30 01:51:25 +00:00
|
|
|
rect1.xmin = rect1.xmin + ceilf(fac * ((float)value - but->softmin));
|
|
|
|
rect1.xmax = rect1.xmin + ceilf(fac * (but->a1 - but->softmin));
|
2009-07-21 01:26:17 +00:00
|
|
|
|
|
|
|
/* ensure minimium size */
|
2012-09-15 11:48:20 +00:00
|
|
|
min = BLI_rcti_size_y(rect);
|
2009-07-21 01:26:17 +00:00
|
|
|
|
2012-09-15 11:48:20 +00:00
|
|
|
if (BLI_rcti_size_x(&rect1) < min) {
|
2012-03-24 02:51:46 +00:00
|
|
|
rect1.xmax = rect1.xmin + min;
|
2009-07-21 01:26:17 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (rect1.xmax > rect->xmax) {
|
2012-03-24 02:51:46 +00:00
|
|
|
rect1.xmax = rect->xmax;
|
2012-10-23 13:28:22 +00:00
|
|
|
rect1.xmin = max_ii(rect1.xmax - min, rect->xmin);
|
2009-07-21 01:26:17 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-24 14:16:56 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-09-15 11:48:20 +00:00
|
|
|
fac = BLI_rcti_size_y(rect) / size;
|
2012-03-30 01:51:25 +00:00
|
|
|
rect1.ymax = rect1.ymax - ceilf(fac * ((float)value - but->softmin));
|
|
|
|
rect1.ymin = rect1.ymax - ceilf(fac * (but->a1 - but->softmin));
|
2009-07-21 01:26:17 +00:00
|
|
|
|
|
|
|
/* ensure minimium size */
|
2012-09-15 11:48:20 +00:00
|
|
|
min = BLI_rcti_size_x(rect);
|
2009-07-21 01:26:17 +00:00
|
|
|
|
2012-09-15 11:48:20 +00:00
|
|
|
if (BLI_rcti_size_y(&rect1) < min) {
|
2012-03-24 02:51:46 +00:00
|
|
|
rect1.ymax = rect1.ymin + min;
|
2009-07-21 01:26:17 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (rect1.ymax > rect->ymax) {
|
2012-03-24 02:51:46 +00:00
|
|
|
rect1.ymax = rect->ymax;
|
2012-10-27 11:18:54 +00:00
|
|
|
rect1.ymin = max_ii(rect1.ymax - min, rect->ymin);
|
2009-07-21 01:26:17 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-24 14:16:56 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_SELECT)
|
2012-03-30 01:51:25 +00:00
|
|
|
state = UI_SCROLL_PRESSED;
|
2009-07-03 13:21:09 +00:00
|
|
|
else
|
2012-03-30 01:51:25 +00:00
|
|
|
state = 0;
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_widget_scroll(wcol, rect, &rect1, state);
|
2009-06-24 14:16:56 +00:00
|
|
|
}
|
2009-06-17 11:01:05 +00:00
|
|
|
|
2016-01-18 01:39:09 +01:00
|
|
|
static void widget_progressbar(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
|
2009-06-17 11:01:05 +00:00
|
|
|
{
|
2016-01-18 01:39:09 +01:00
|
|
|
uiWidgetBase wtb, wtb_bar;
|
2010-05-27 08:22:16 +00:00
|
|
|
rcti rect_prog = *rect, rect_bar = *rect;
|
2016-01-18 01:39:09 +01:00
|
|
|
|
|
|
|
widget_init(&wtb);
|
|
|
|
widget_init(&wtb_bar);
|
|
|
|
|
|
|
|
/* round corners */
|
2010-05-27 08:22:16 +00:00
|
|
|
float value = but->a1;
|
2018-04-25 11:53:21 +02:00
|
|
|
float offs = wcol->roundness * BLI_rcti_size_y(&rect_prog);
|
2016-01-18 01:39:09 +01:00
|
|
|
float w = value * BLI_rcti_size_x(&rect_prog);
|
|
|
|
|
2010-05-27 08:22:16 +00:00
|
|
|
/* ensure minimium size */
|
2016-01-18 01:39:09 +01:00
|
|
|
w = MAX2(w, offs);
|
|
|
|
|
2010-05-27 08:22:16 +00:00
|
|
|
rect_bar.xmax = rect_bar.xmin + w;
|
2016-01-18 01:39:09 +01:00
|
|
|
|
|
|
|
round_box_edges(&wtb, roundboxalign, &rect_prog, offs);
|
|
|
|
round_box_edges(&wtb_bar, roundboxalign, &rect_bar, offs);
|
|
|
|
|
|
|
|
wtb.draw_outline = true;
|
|
|
|
widgetbase_draw(&wtb, wcol);
|
|
|
|
|
|
|
|
/* "slider" bar color */
|
|
|
|
copy_v3_v3_char(wcol->inner, wcol->item);
|
|
|
|
widgetbase_draw(&wtb_bar, wcol);
|
|
|
|
|
2010-05-27 08:22:16 +00:00
|
|
|
/* raise text a bit */
|
2016-01-18 01:39:09 +01:00
|
|
|
rect->xmin += (BLI_rcti_size_x(&rect_prog) / 2);
|
|
|
|
rect->xmax += (BLI_rcti_size_x(&rect_prog) / 2);
|
2010-05-27 08:22:16 +00:00
|
|
|
}
|
2009-06-17 11:01:05 +00:00
|
|
|
|
2009-04-02 18:16:15 +00:00
|
|
|
static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
|
|
|
{
|
|
|
|
uiWidgetBase wtb, wtb1;
|
|
|
|
rcti rect1;
|
2018-04-28 02:51:27 +02:00
|
|
|
float offs, toffs;
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
char outline[3];
|
2011-04-25 11:52:42 +00:00
|
|
|
|
2009-04-02 18:16:15 +00:00
|
|
|
widget_init(&wtb);
|
|
|
|
widget_init(&wtb1);
|
2018-04-28 02:51:27 +02:00
|
|
|
|
|
|
|
/* Backdrop first. */
|
2018-04-25 11:53:21 +02:00
|
|
|
offs = wcol->roundness * BLI_rcti_size_y(rect);
|
2012-03-30 01:51:25 +00:00
|
|
|
toffs = offs * 0.75f;
|
2009-04-02 18:16:15 +00:00
|
|
|
round_box_edges(&wtb, roundboxalign, rect, offs);
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2015-05-29 21:30:04 +02:00
|
|
|
wtb.draw_outline = false;
|
2009-04-02 18:16:15 +00:00
|
|
|
widgetbase_draw(&wtb, wcol);
|
2018-04-28 02:51:27 +02:00
|
|
|
|
|
|
|
/* Draw slider part only when not in text editing. */
|
2017-11-03 00:22:59 +11:00
|
|
|
if (!(state & UI_STATE_TEXT_INPUT)) {
|
2018-04-28 02:51:27 +02:00
|
|
|
int roundboxalign_slider = roundboxalign;
|
|
|
|
|
2011-11-07 01:38:32 +00:00
|
|
|
copy_v3_v3_char(outline, wcol->outline);
|
|
|
|
copy_v3_v3_char(wcol->outline, wcol->item);
|
|
|
|
copy_v3_v3_char(wcol->inner, wcol->item);
|
2010-09-07 11:14:20 +00:00
|
|
|
|
2018-04-28 02:51:27 +02:00
|
|
|
if (!(state & UI_SELECT)) {
|
2011-06-11 12:10:01 +00:00
|
|
|
SWAP(short, wcol->shadetop, wcol->shadedown);
|
2018-04-28 02:51:27 +02:00
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
rect1 = *rect;
|
2018-04-28 02:51:27 +02:00
|
|
|
float factor, factor_ui;
|
|
|
|
float factor_discard = 1.0f; /* No discard. */
|
|
|
|
float value = (float)ui_but_value_get(but);
|
|
|
|
|
2018-04-28 11:49:14 +02:00
|
|
|
if (but->rnaprop && (RNA_property_subtype(but->rnaprop) == PROP_PERCENTAGE)) {
|
|
|
|
factor = value / but->softmax;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
factor = (value - but->softmin) / (but->softmax - but->softmin);
|
|
|
|
}
|
|
|
|
|
2018-05-01 18:35:11 +02:00
|
|
|
float width = (float)BLI_rcti_size_x(rect);
|
|
|
|
factor_ui = factor * width;
|
2018-04-28 02:51:27 +02:00
|
|
|
|
|
|
|
if (factor_ui <= offs) {
|
|
|
|
/* Left part only. */
|
|
|
|
roundboxalign_slider &= ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT);
|
|
|
|
rect1.xmax = rect1.xmin + offs;
|
|
|
|
factor_discard = factor_ui / offs;
|
2015-01-05 21:05:17 +01:00
|
|
|
}
|
2018-05-01 18:35:11 +02:00
|
|
|
else if (factor_ui <= width - offs) {
|
2018-04-28 02:51:27 +02:00
|
|
|
/* Left part + middle part. */
|
|
|
|
roundboxalign_slider &= ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT);
|
|
|
|
rect1.xmax = rect1.xmin + factor_ui;
|
2014-01-29 04:10:39 +11:00
|
|
|
}
|
|
|
|
else {
|
2018-04-28 02:51:27 +02:00
|
|
|
/* Left part + middle part + right part. */
|
|
|
|
factor_discard = factor;
|
2014-01-29 04:10:39 +11:00
|
|
|
}
|
2018-04-28 02:51:27 +02:00
|
|
|
|
2014-01-29 04:10:39 +11:00
|
|
|
round_box_edges(&wtb1, roundboxalign_slider, &rect1, offs);
|
2018-04-28 02:51:27 +02:00
|
|
|
wtb1.draw_outline = false;
|
|
|
|
widgetbase_set_uniform_discard_factor(&wtb1, factor_discard);
|
2011-06-11 12:10:01 +00:00
|
|
|
widgetbase_draw(&wtb1, wcol);
|
2018-04-28 02:51:27 +02:00
|
|
|
|
2011-11-07 01:38:32 +00:00
|
|
|
copy_v3_v3_char(wcol->outline, outline);
|
2018-04-28 02:51:27 +02:00
|
|
|
|
|
|
|
if (!(state & UI_SELECT)) {
|
2011-06-11 12:10:01 +00:00
|
|
|
SWAP(short, wcol->shadetop, wcol->shadedown);
|
2018-04-28 02:51:27 +02:00
|
|
|
}
|
2011-06-11 12:10:01 +00:00
|
|
|
}
|
2018-04-28 02:51:27 +02:00
|
|
|
|
|
|
|
/* Outline. */
|
2015-05-29 21:30:04 +02:00
|
|
|
wtb.draw_outline = true;
|
|
|
|
wtb.draw_inner = false;
|
2009-04-02 18:16:15 +00:00
|
|
|
widgetbase_draw(&wtb, wcol);
|
2014-02-12 02:34:48 +11:00
|
|
|
|
2018-04-28 02:51:27 +02:00
|
|
|
/* Add space at either side of the button so text aligns with numbuttons (which have arrow icons). */
|
2017-11-03 00:22:59 +11:00
|
|
|
if (!(state & UI_STATE_TEXT_INPUT)) {
|
2014-02-25 10:28:41 +11:00
|
|
|
rect->xmax -= toffs;
|
|
|
|
rect->xmin += toffs;
|
|
|
|
}
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
2010-09-30 12:10:18 +00:00
|
|
|
/* I think 3 is sufficient border to indicate keyed status */
|
|
|
|
#define SWATCH_KEYED_BORDER 3
|
|
|
|
|
2009-04-03 16:26:03 +00:00
|
|
|
static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
|
|
|
{
|
|
|
|
uiWidgetBase wtb;
|
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
|
|
|
float rad, col[4];
|
2014-01-04 17:16:19 +11:00
|
|
|
bool color_profile = but->block->color_profile;
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
col[3] = 1.0f;
|
2010-06-26 17:12:55 +00:00
|
|
|
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
if (but->rnaprop) {
|
2012-12-18 17:00:49 +00:00
|
|
|
BLI_assert(but->rnaindex == -1);
|
|
|
|
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
|
2014-01-04 17:16:19 +11:00
|
|
|
color_profile = false;
|
2010-06-26 17:12:55 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (RNA_property_array_length(&but->rnapoin, but->rnaprop) == 4) {
|
|
|
|
col[3] = RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3);
|
2010-06-26 17:12:55 +00:00
|
|
|
}
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
}
|
2009-04-03 16:26:03 +00:00
|
|
|
|
|
|
|
widget_init(&wtb);
|
|
|
|
|
2018-04-22 13:57:42 +02:00
|
|
|
rad = wcol->roundness * U.widget_unit;
|
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
|
|
|
round_box_edges(&wtb, roundboxalign, rect, rad);
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
ui_but_v3_get(but, col);
|
2012-07-06 23:56:59 +00:00
|
|
|
|
2017-11-29 15:47:37 +01:00
|
|
|
if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_OVERRIDEN | UI_BUT_REDALERT)) {
|
2012-07-06 23:56:59 +00:00
|
|
|
/* draw based on state - color for keyed etc */
|
2010-09-30 12:10:18 +00:00
|
|
|
widgetbase_draw(&wtb, wcol);
|
2012-07-06 23:56:59 +00:00
|
|
|
|
|
|
|
/* inset to draw swatch color */
|
2012-03-30 01:51:25 +00:00
|
|
|
rect->xmin += SWATCH_KEYED_BORDER;
|
|
|
|
rect->xmax -= SWATCH_KEYED_BORDER;
|
|
|
|
rect->ymin += SWATCH_KEYED_BORDER;
|
|
|
|
rect->ymax -= SWATCH_KEYED_BORDER;
|
2010-09-30 12:10:18 +00: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
|
|
|
round_box_edges(&wtb, roundboxalign, rect, rad);
|
2010-09-30 12:10:18 +00:00
|
|
|
}
|
|
|
|
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
if (color_profile)
|
2014-11-09 21:20:40 +01:00
|
|
|
ui_block_cm_to_display_space_v3(but->block, col);
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
|
2012-01-19 10:04:51 +00:00
|
|
|
rgba_float_to_uchar((unsigned char *)wcol->inner, col);
|
2012-01-14 11:21:00 +00:00
|
|
|
|
2010-01-21 05:14:05 +00:00
|
|
|
wcol->shaded = 0;
|
2010-06-26 17:12:55 +00:00
|
|
|
wcol->alpha_check = (wcol->inner[3] < 255);
|
2016-04-19 00:42:59 +12:00
|
|
|
|
|
|
|
if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) {
|
|
|
|
/* Now we reduce alpha of the inner color (i.e. the color shown)
|
2016-07-08 00:48:03 +10:00
|
|
|
* so that this setting can look grayed out, while retaining
|
2016-04-19 00:42:59 +12:00
|
|
|
* the checkboard (for transparent values). This is needed
|
|
|
|
* here as the effects of ui_widget_color_disabled() are overwritten.
|
|
|
|
*/
|
|
|
|
wcol->inner[3] /= 2;
|
|
|
|
}
|
2010-06-26 17:12:55 +00:00
|
|
|
|
2009-04-03 16:26:03 +00:00
|
|
|
widgetbase_draw(&wtb, wcol);
|
2014-09-18 12:45:49 +02:00
|
|
|
if (but->a1 == UI_PALETTE_COLOR && ((Palette *)but->rnapoin.id.data)->active_color == (int)but->a2) {
|
2014-07-21 12:02:05 +02:00
|
|
|
float width = rect->xmax - rect->xmin;
|
|
|
|
float height = rect->ymax - rect->ymin;
|
2014-09-18 12:20:34 +02:00
|
|
|
/* find color luminance and change it slightly */
|
2015-03-19 14:09:01 +11:00
|
|
|
float bw = rgb_to_grayscale(col);
|
2015-01-31 17:23:30 +11:00
|
|
|
|
|
|
|
bw += (bw < 0.5f) ? 0.5f : -0.5f;
|
2017-02-20 21:21:04 +01:00
|
|
|
|
2018-04-10 17:42:33 +02:00
|
|
|
/* We are drawing on top of widget bases. Flush cache. */
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
UI_widgetbase_draw_cache_flush();
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
2017-02-20 21:21:04 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
2017-04-16 13:44:34 -04:00
|
|
|
immUniformColor3f(bw, bw, bw);
|
2017-06-19 20:18:04 +10:00
|
|
|
immBegin(GWN_PRIM_TRIS, 3);
|
2017-02-20 21:21:04 +01:00
|
|
|
immVertex2f(pos, rect->xmin + 0.1f * width, rect->ymin + 0.9f * height);
|
|
|
|
immVertex2f(pos, rect->xmin + 0.1f * width, rect->ymin + 0.5f * height);
|
|
|
|
immVertex2f(pos, rect->xmin + 0.5f * width, rect->ymin + 0.9f * height);
|
|
|
|
immEnd();
|
|
|
|
|
|
|
|
immUnbindProgram();
|
2014-07-21 12:02:05 +02:00
|
|
|
}
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
static void widget_unitvec(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign))
|
2012-11-17 16:11:02 +00:00
|
|
|
{
|
2014-11-09 21:20:40 +01:00
|
|
|
ui_draw_but_UNITVEC(but, wcol, rect);
|
2012-11-17 16:11:02 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 09:02:13 +00:00
|
|
|
static void widget_icon_has_anim(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
2010-12-09 18:08:58 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT)) {
|
2010-12-09 18:08:58 +00:00
|
|
|
uiWidgetBase wtb;
|
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
|
|
|
float rad;
|
|
|
|
|
2010-12-09 18:08:58 +00:00
|
|
|
widget_init(&wtb);
|
2015-05-29 21:30:04 +02:00
|
|
|
wtb.draw_outline = false;
|
2010-12-09 18:08:58 +00:00
|
|
|
|
2018-04-25 11:53:21 +02:00
|
|
|
rad = wcol->roundness * BLI_rcti_size_y(rect);
|
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
|
|
|
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
|
2010-12-09 18:08:58 +00:00
|
|
|
widgetbase_draw(&wtb, wcol);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2014-11-09 21:20:40 +01:00
|
|
|
else if (but->type == UI_BTYPE_NUM) {
|
2013-06-18 09:02:13 +00:00
|
|
|
/* Draw number buttons still with left/right
|
|
|
|
* triangles when field is not embossed */
|
|
|
|
widget_numbut_embossn(but, wcol, rect, state, roundboxalign);
|
|
|
|
}
|
2010-12-09 18:08:58 +00:00
|
|
|
}
|
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
|
|
|
|
static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
2009-03-25 16:58:42 +00:00
|
|
|
{
|
2009-04-02 15:01:11 +00:00
|
|
|
uiWidgetBase wtb;
|
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
|
|
|
float rad;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_SELECT)
|
2010-09-11 00:08:07 +00:00
|
|
|
SWAP(short, wcol->shadetop, wcol->shadedown);
|
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
widget_init(&wtb);
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2018-04-22 13:57:42 +02:00
|
|
|
rad = wcol->roundness * U.widget_unit;
|
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
|
|
|
round_box_edges(&wtb, roundboxalign, rect, rad);
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2009-04-02 18:16:15 +00:00
|
|
|
widgetbase_draw(&wtb, wcol);
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
|
2009-03-25 16:58:42 +00:00
|
|
|
{
|
2009-04-02 15:01:11 +00:00
|
|
|
uiWidgetBase wtb;
|
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
|
|
|
float rad;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
widget_init(&wtb);
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2018-04-22 13:57:42 +02:00
|
|
|
rad = wcol->roundness * U.widget_unit;
|
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
|
|
|
round_box_edges(&wtb, roundboxalign, rect, rad);
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
/* decoration */
|
2017-11-02 05:48:14 +11:00
|
|
|
shape_preset_trias_from_rect_menu(&wtb.tria1, rect);
|
2018-04-01 11:49:15 +02:00
|
|
|
/* copy size and center to 2nd tria */
|
|
|
|
wtb.tria2 = wtb.tria1;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2009-04-02 18:16:15 +00:00
|
|
|
widgetbase_draw(&wtb, wcol);
|
2009-04-09 18:11:18 +00:00
|
|
|
|
2012-10-25 10:51:03 +00:00
|
|
|
/* text space, arrows are about 0.6 height of button */
|
2012-11-01 09:54:00 +00:00
|
|
|
rect->xmax -= (6 * BLI_rcti_size_y(rect)) / 10;
|
2009-09-28 15:59:09 +00:00
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
|
2009-09-28 15:59:09 +00:00
|
|
|
{
|
|
|
|
uiWidgetBase wtb;
|
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
|
|
|
float rad;
|
2009-09-28 15:59:09 +00:00
|
|
|
|
|
|
|
widget_init(&wtb);
|
|
|
|
|
2018-04-22 13:57:42 +02:00
|
|
|
rad = wcol->roundness * U.widget_unit;
|
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
|
|
|
round_box_edges(&wtb, roundboxalign, rect, rad);
|
2009-04-09 18:11:18 +00:00
|
|
|
|
2009-09-28 15:59:09 +00:00
|
|
|
/* decoration */
|
|
|
|
widgetbase_draw(&wtb, wcol);
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
2011-11-07 22:28:49 +00:00
|
|
|
static void widget_menunodebut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
|
|
|
|
{
|
|
|
|
/* silly node link button hacks */
|
|
|
|
uiWidgetBase wtb;
|
2012-03-30 01:51:25 +00:00
|
|
|
uiWidgetColors wcol_backup = *wcol;
|
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
|
|
|
float rad;
|
2011-11-07 22:28:49 +00:00
|
|
|
|
|
|
|
widget_init(&wtb);
|
|
|
|
|
2018-04-22 13:57:42 +02:00
|
|
|
rad = wcol->roundness * U.widget_unit;
|
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
|
|
|
round_box_edges(&wtb, roundboxalign, rect, rad);
|
2011-11-07 22:28:49 +00:00
|
|
|
|
2014-01-08 20:40:37 +01:00
|
|
|
wcol->inner[0] = min_ii(wcol->inner[0] + 15, 255);
|
|
|
|
wcol->inner[1] = min_ii(wcol->inner[1] + 15, 255);
|
|
|
|
wcol->inner[2] = min_ii(wcol->inner[2] + 15, 255);
|
|
|
|
wcol->outline[0] = min_ii(wcol->outline[0] + 15, 255);
|
|
|
|
wcol->outline[1] = min_ii(wcol->outline[1] + 15, 255);
|
|
|
|
wcol->outline[2] = min_ii(wcol->outline[2] + 15, 255);
|
2011-11-07 22:28:49 +00:00
|
|
|
|
|
|
|
/* decoration */
|
|
|
|
widgetbase_draw(&wtb, wcol);
|
2012-03-30 01:51:25 +00:00
|
|
|
*wcol = wcol_backup;
|
2011-11-07 22:28:49 +00:00
|
|
|
}
|
|
|
|
|
2012-10-04 20:12:05 +00:00
|
|
|
static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
2009-04-03 16:26:03 +00:00
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_ACTIVE) {
|
2009-04-03 16:26:03 +00:00
|
|
|
uiWidgetBase wtb;
|
2018-04-22 13:57:42 +02:00
|
|
|
const float rad = wcol->roundness * U.widget_unit;
|
2012-10-04 20:12:05 +00:00
|
|
|
|
2009-04-03 16:26:03 +00:00
|
|
|
widget_init(&wtb);
|
2012-10-04 20:12:05 +00:00
|
|
|
|
2009-08-23 21:56:32 +00:00
|
|
|
/* half rounded */
|
2012-10-04 20:12:05 +00:00
|
|
|
round_box_edges(&wtb, roundboxalign, rect, rad);
|
2009-04-03 16:26:03 +00:00
|
|
|
|
|
|
|
widgetbase_draw(&wtb, wcol);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void widget_menu_itembut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign))
|
2009-04-03 16:26:03 +00:00
|
|
|
{
|
|
|
|
uiWidgetBase wtb;
|
|
|
|
|
|
|
|
widget_init(&wtb);
|
|
|
|
|
|
|
|
/* not rounded, no outline */
|
2015-05-29 21:30:04 +02:00
|
|
|
wtb.draw_outline = false;
|
2009-04-03 16:26:03 +00:00
|
|
|
round_box_edges(&wtb, 0, rect, 0.0f);
|
|
|
|
|
|
|
|
widgetbase_draw(&wtb, wcol);
|
|
|
|
}
|
|
|
|
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
static void widget_menu_radial_itembut(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign))
|
|
|
|
{
|
|
|
|
uiWidgetBase wtb;
|
|
|
|
float rad;
|
|
|
|
float fac = but->block->pie_data.alphafac;
|
|
|
|
|
|
|
|
widget_init(&wtb);
|
|
|
|
|
2015-05-29 21:30:04 +02:00
|
|
|
wtb.draw_emboss = false;
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
|
2018-04-22 13:57:42 +02:00
|
|
|
rad = wcol->roundness * BLI_rcti_size_y(rect);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
|
|
|
|
|
|
|
|
wcol->inner[3] *= fac;
|
|
|
|
wcol->inner_sel[3] *= fac;
|
|
|
|
wcol->item[3] *= fac;
|
|
|
|
wcol->text[3] *= fac;
|
|
|
|
wcol->text_sel[3] *= fac;
|
|
|
|
wcol->outline[3] *= fac;
|
|
|
|
|
|
|
|
widgetbase_draw(&wtb, wcol);
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void widget_list_itembut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign))
|
2009-07-21 01:26:17 +00:00
|
|
|
{
|
|
|
|
uiWidgetBase wtb;
|
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
|
|
|
float rad;
|
2009-07-21 01:26:17 +00:00
|
|
|
|
|
|
|
widget_init(&wtb);
|
|
|
|
|
2018-04-22 13:57:42 +02:00
|
|
|
/* no outline */
|
2015-05-29 21:30:04 +02:00
|
|
|
wtb.draw_outline = false;
|
2018-04-22 13:57:42 +02:00
|
|
|
rad = wcol->roundness * U.widget_unit;
|
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
|
|
|
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
|
2009-07-21 01:26:17 +00:00
|
|
|
|
|
|
|
widgetbase_draw(&wtb, wcol);
|
|
|
|
}
|
2009-04-03 16:26:03 +00:00
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UNUSED(roundboxalign))
|
2009-03-25 16:58:42 +00:00
|
|
|
{
|
2009-04-02 15:01:11 +00:00
|
|
|
uiWidgetBase wtb;
|
2012-03-30 01:51:25 +00:00
|
|
|
rcti recttemp = *rect;
|
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
|
|
|
float rad;
|
2009-03-25 16:58:42 +00:00
|
|
|
int delta;
|
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
widget_init(&wtb);
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
/* square */
|
2012-09-15 11:48:20 +00:00
|
|
|
recttemp.xmax = recttemp.xmin + BLI_rcti_size_y(&recttemp);
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
/* smaller */
|
2012-09-15 11:48:20 +00:00
|
|
|
delta = 1 + BLI_rcti_size_y(&recttemp) / 8;
|
2012-03-30 01:51:25 +00:00
|
|
|
recttemp.xmin += delta;
|
|
|
|
recttemp.ymin += delta;
|
|
|
|
recttemp.xmax -= delta;
|
|
|
|
recttemp.ymax -= delta;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2018-04-25 11:53:21 +02:00
|
|
|
rad = wcol->roundness * BLI_rcti_size_y(&recttemp);
|
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
|
|
|
round_box_edges(&wtb, UI_CNR_ALL, &recttemp, rad);
|
2009-03-25 16:58:42 +00:00
|
|
|
|
|
|
|
/* decoration */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state & UI_SELECT) {
|
2017-11-02 05:48:14 +11:00
|
|
|
shape_preset_trias_from_rect_checkmark(&wtb.tria1, &recttemp);
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
2009-04-02 18:16:15 +00:00
|
|
|
widgetbase_draw(&wtb, wcol);
|
2009-04-09 18:11:18 +00:00
|
|
|
|
|
|
|
/* text space */
|
2012-09-15 11:48:20 +00:00
|
|
|
rect->xmin += BLI_rcti_size_y(rect) * 0.7 + delta;
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
2013-08-26 09:59:51 +00:00
|
|
|
/* labels use Editor theme colors for text */
|
|
|
|
static void widget_state_label(uiWidgetType *wt, int state)
|
|
|
|
{
|
2013-11-21 16:51:29 +01:00
|
|
|
if (state & UI_BUT_LIST_ITEM) {
|
|
|
|
/* Override default label theme's colors. */
|
|
|
|
bTheme *btheme = UI_GetTheme();
|
|
|
|
wt->wcol_theme = &btheme->tui.wcol_list_item;
|
|
|
|
/* call this for option button */
|
|
|
|
widget_state(wt, state);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* call this for option button */
|
|
|
|
widget_state(wt, state);
|
|
|
|
if (state & UI_SELECT)
|
|
|
|
UI_GetThemeColor3ubv(TH_TEXT_HI, (unsigned char *)wt->wcol.text);
|
|
|
|
else
|
|
|
|
UI_GetThemeColor3ubv(TH_TEXT, (unsigned char *)wt->wcol.text);
|
|
|
|
}
|
2013-08-26 09:59:51 +00:00
|
|
|
}
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void widget_radiobut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
|
2009-03-25 16:58:42 +00:00
|
|
|
{
|
2009-04-02 15:01:11 +00:00
|
|
|
uiWidgetBase wtb;
|
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
|
|
|
float rad;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
widget_init(&wtb);
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2018-04-22 13:57:42 +02:00
|
|
|
rad = wcol->roundness * U.widget_unit;
|
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
|
|
|
round_box_edges(&wtb, roundboxalign, rect, rad);
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2009-04-02 18:16:15 +00:00
|
|
|
widgetbase_draw(&wtb, wcol);
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void widget_box(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
|
2010-04-06 07:02:16 +00:00
|
|
|
{
|
|
|
|
uiWidgetBase wtb;
|
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
|
|
|
float rad;
|
2010-06-03 07:27:55 +00:00
|
|
|
char old_col[3];
|
2010-04-06 07:02:16 +00:00
|
|
|
|
|
|
|
widget_init(&wtb);
|
|
|
|
|
2011-11-07 01:38:32 +00:00
|
|
|
copy_v3_v3_char(old_col, wcol->inner);
|
2010-06-03 07:27:55 +00:00
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
/* abuse but->hsv - if it's non-zero, use this color as the box's background */
|
2010-10-13 13:53:49 +00:00
|
|
|
if (but->col[3]) {
|
|
|
|
wcol->inner[0] = but->col[0];
|
|
|
|
wcol->inner[1] = but->col[1];
|
|
|
|
wcol->inner[2] = but->col[2];
|
2010-06-03 07:27:55 +00:00
|
|
|
}
|
|
|
|
|
2018-04-22 13:57:42 +02:00
|
|
|
rad = wcol->roundness * U.widget_unit;
|
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
|
|
|
round_box_edges(&wtb, roundboxalign, rect, rad);
|
2010-04-06 07:02:16 +00:00
|
|
|
|
|
|
|
widgetbase_draw(&wtb, wcol);
|
2013-03-18 18:29:22 +00:00
|
|
|
|
2011-11-07 01:38:32 +00:00
|
|
|
copy_v3_v3_char(wcol->inner, old_col);
|
2010-04-06 07:02:16 +00:00
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void widget_but(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
|
2009-03-25 16:58:42 +00:00
|
|
|
{
|
2009-04-02 15:01:11 +00:00
|
|
|
uiWidgetBase wtb;
|
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
|
|
|
float rad;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
widget_init(&wtb);
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2018-04-22 13:57:42 +02:00
|
|
|
rad = wcol->roundness * U.widget_unit;
|
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
|
|
|
round_box_edges(&wtb, roundboxalign, rect, rad);
|
|
|
|
|
2009-04-02 18:16:15 +00:00
|
|
|
widgetbase_draw(&wtb, wcol);
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
2017-11-02 04:30:07 +11:00
|
|
|
#if 0
|
2010-10-16 02:40:31 +00:00
|
|
|
static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
|
2009-03-25 16:58:42 +00:00
|
|
|
{
|
2009-04-02 15:01:11 +00:00
|
|
|
uiWidgetBase wtb;
|
2018-04-22 13:57:42 +02:00
|
|
|
const float rad = wcol->roundness * U.widget_unit;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
widget_init(&wtb);
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2009-08-23 21:56:32 +00:00
|
|
|
/* half rounded */
|
2009-08-26 00:38:43 +00:00
|
|
|
round_box_edges(&wtb, roundboxalign, rect, rad);
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2009-04-02 18:16:15 +00:00
|
|
|
widgetbase_draw(&wtb, wcol);
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
2017-11-02 04:30:07 +11:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static void widget_roundbut_exec(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
|
|
|
{
|
|
|
|
uiWidgetBase wtb;
|
2018-04-22 13:57:42 +02:00
|
|
|
const float rad = wcol->roundness * U.widget_unit;
|
2017-11-02 04:30:07 +11:00
|
|
|
|
|
|
|
widget_init(&wtb);
|
|
|
|
|
|
|
|
if (state & UI_STATE_HOLD_ACTION) {
|
|
|
|
/* Show that keeping pressed performs another action (typically a menu). */
|
2017-11-02 05:48:14 +11:00
|
|
|
shape_preset_init_hold_action(&wtb.tria1, rect, 0.75f, 'r');
|
2017-11-02 04:30:07 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
/* half rounded */
|
|
|
|
round_box_edges(&wtb, roundboxalign, rect, rad);
|
|
|
|
|
|
|
|
widgetbase_draw(&wtb, wcol);
|
|
|
|
}
|
2009-03-25 16:58:42 +00:00
|
|
|
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
static void widget_tab(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
2017-03-17 17:08:20 +01:00
|
|
|
{
|
|
|
|
const uiStyle *style = UI_style_get();
|
2018-04-22 13:57:42 +02:00
|
|
|
const float rad = wcol->roundness * U.widget_unit;
|
2017-03-17 17:08:20 +01:00
|
|
|
const int fontid = style->widget.uifont_id;
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
const bool is_active = (state & UI_SELECT);
|
|
|
|
|
|
|
|
/* Draw shaded outline - Disabled for now, seems incorrect and also looks nicer without it imho ;) */
|
|
|
|
//#define USE_TAB_SHADED_HIGHLIGHT
|
2017-03-17 17:08:20 +01:00
|
|
|
|
|
|
|
uiWidgetBase wtb;
|
|
|
|
unsigned char theme_col_tab_highlight[3];
|
|
|
|
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
#ifdef USE_TAB_SHADED_HIGHLIGHT
|
2017-03-17 17:08:20 +01:00
|
|
|
/* create outline highlight colors */
|
|
|
|
if (is_active) {
|
|
|
|
interp_v3_v3v3_uchar(theme_col_tab_highlight, (unsigned char *)wcol->inner_sel,
|
|
|
|
(unsigned char *)wcol->outline, 0.2f);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
interp_v3_v3v3_uchar(theme_col_tab_highlight, (unsigned char *)wcol->inner,
|
|
|
|
(unsigned char *)wcol->outline, 0.12f);
|
|
|
|
}
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
#endif
|
2017-03-17 17:08:20 +01:00
|
|
|
|
|
|
|
widget_init(&wtb);
|
|
|
|
|
|
|
|
/* half rounded */
|
|
|
|
round_box_edges(&wtb, roundboxalign, rect, rad);
|
|
|
|
|
|
|
|
/* draw inner */
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
#ifdef USE_TAB_SHADED_HIGHLIGHT
|
2017-03-17 17:08:20 +01:00
|
|
|
wtb.draw_outline = 0;
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
#endif
|
2017-03-17 17:08:20 +01:00
|
|
|
widgetbase_draw(&wtb, wcol);
|
|
|
|
|
2018-04-10 17:42:33 +02:00
|
|
|
/* We are drawing on top of widget bases. Flush cache. */
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
UI_widgetbase_draw_cache_flush();
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
#ifdef USE_TAB_SHADED_HIGHLIGHT
|
2017-03-17 17:08:20 +01:00
|
|
|
/* draw outline (3d look) */
|
|
|
|
ui_draw_but_TAB_outline(rect, rad, theme_col_tab_highlight, (unsigned char *)wcol->inner);
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
#endif
|
2017-03-17 17:08:20 +01:00
|
|
|
|
|
|
|
/* text shadow */
|
|
|
|
BLF_enable(fontid, BLF_SHADOW);
|
|
|
|
BLF_shadow(fontid, 3, (const float[4]){1.0f, 1.0f, 1.0f, 0.25f});
|
|
|
|
BLF_shadow_offset(fontid, 0, -1);
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
|
|
|
|
#ifndef USE_TAB_SHADED_HIGHLIGHT
|
|
|
|
UNUSED_VARS(is_active, theme_col_tab_highlight);
|
|
|
|
#endif
|
2017-03-17 17:08:20 +01:00
|
|
|
}
|
|
|
|
|
2009-06-08 10:00:14 +00:00
|
|
|
static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *wt, rcti *rect)
|
|
|
|
{
|
2018-04-22 13:57:42 +02:00
|
|
|
bTheme *btheme = UI_GetTheme();
|
|
|
|
uiWidgetColors *wcol = &btheme->tui.wcol_radio;
|
2009-06-08 10:00:14 +00:00
|
|
|
uiWidgetBase wtb;
|
2018-04-22 13:57:42 +02:00
|
|
|
const float rad = wcol->roundness * U.widget_unit;
|
2010-12-20 03:59:22 +00:00
|
|
|
unsigned char col[4];
|
2017-02-20 21:21:04 +01:00
|
|
|
|
2009-06-08 10:00:14 +00:00
|
|
|
/* state copy! */
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->wcol = *(wt->wcol_theme);
|
2009-06-08 10:00:14 +00:00
|
|
|
|
|
|
|
widget_init(&wtb);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (but->block->drawextra) {
|
2009-06-08 16:24:37 +00:00
|
|
|
/* note: drawextra can change rect +1 or -1, to match round errors of existing previews */
|
2009-08-18 19:58:27 +00:00
|
|
|
but->block->drawextra(C, but->poin, but->block->drawextra_arg1, but->block->drawextra_arg2, rect);
|
2009-06-08 10:00:14 +00:00
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
2017-02-20 21:21:04 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
2009-06-08 12:39:39 +00:00
|
|
|
/* make mask to draw over image */
|
|
|
|
UI_GetThemeColor3ubv(TH_BACK, col);
|
2017-02-20 21:21:04 +01:00
|
|
|
immUniformColor3ubv(col);
|
|
|
|
|
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
|
|
|
round_box__edges(&wtb, UI_CNR_ALL, rect, 0.0f, rad);
|
2017-02-20 21:21:04 +01:00
|
|
|
widgetbase_outline(&wtb, pos);
|
|
|
|
|
|
|
|
immUnbindProgram();
|
2009-06-08 10:00:14 +00:00
|
|
|
}
|
2009-06-08 11:27:40 +00:00
|
|
|
|
2009-06-08 10:00:14 +00:00
|
|
|
/* outline */
|
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
|
|
|
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
|
2015-05-29 21:30:04 +02:00
|
|
|
wtb.draw_outline = true;
|
|
|
|
wtb.draw_inner = false;
|
2009-06-08 12:39:39 +00:00
|
|
|
widgetbase_draw(&wtb, &wt->wcol);
|
2009-06-08 10:00:14 +00:00
|
|
|
}
|
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
static uiWidgetType *widget_type(uiWidgetTypeEnum type)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
bTheme *btheme = UI_GetTheme();
|
2009-04-02 15:01:11 +00:00
|
|
|
static uiWidgetType wt;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
/* defaults */
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.wcol_theme = &btheme->tui.wcol_regular;
|
|
|
|
wt.wcol_state = &btheme->tui.wcol_state;
|
|
|
|
wt.state = widget_state;
|
|
|
|
wt.draw = widget_but;
|
|
|
|
wt.custom = NULL;
|
|
|
|
wt.text = widget_draw_text_icon;
|
|
|
|
|
|
|
|
switch (type) {
|
2009-06-24 14:16:56 +00:00
|
|
|
case UI_WTYPE_REGULAR:
|
|
|
|
break;
|
|
|
|
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
case UI_WTYPE_LABEL:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.draw = NULL;
|
2013-08-26 09:59:51 +00:00
|
|
|
wt.state = widget_state_label;
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
break;
|
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
case UI_WTYPE_TOGGLE:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.wcol_theme = &btheme->tui.wcol_toggle;
|
2009-04-02 15:01:11 +00:00
|
|
|
break;
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_WTYPE_CHECKBOX:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.wcol_theme = &btheme->tui.wcol_option;
|
|
|
|
wt.draw = widget_optionbut;
|
2009-04-02 15:01:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case UI_WTYPE_RADIO:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.wcol_theme = &btheme->tui.wcol_radio;
|
|
|
|
wt.draw = widget_radiobut;
|
2009-04-02 15:01:11 +00:00
|
|
|
break;
|
2009-06-24 14:16:56 +00:00
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
case UI_WTYPE_NUMBER:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.wcol_theme = &btheme->tui.wcol_num;
|
|
|
|
wt.draw = widget_numbut;
|
2009-04-02 15:01:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case UI_WTYPE_SLIDER:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.wcol_theme = &btheme->tui.wcol_numslider;
|
|
|
|
wt.custom = widget_numslider;
|
|
|
|
wt.state = widget_state_numslider;
|
2009-04-02 15:01:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case UI_WTYPE_EXEC:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.wcol_theme = &btheme->tui.wcol_tool;
|
2017-11-02 04:30:07 +11:00
|
|
|
wt.draw = widget_roundbut_exec;
|
2009-04-02 15:01:11 +00:00
|
|
|
break;
|
2012-03-19 22:29:16 +00:00
|
|
|
|
2018-04-26 21:17:33 +02:00
|
|
|
case UI_WTYPE_TOOLBAR_ITEM:
|
|
|
|
wt.wcol_theme = &btheme->tui.wcol_toolbar_item;
|
|
|
|
wt.draw = widget_roundbut_exec;
|
|
|
|
break;
|
|
|
|
|
2017-03-17 17:08:20 +01:00
|
|
|
case UI_WTYPE_TAB:
|
|
|
|
wt.wcol_theme = &btheme->tui.wcol_tab;
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
wt.draw = widget_tab;
|
2017-03-17 17:08:20 +01:00
|
|
|
break;
|
|
|
|
|
2012-03-19 22:29:16 +00:00
|
|
|
case UI_WTYPE_TOOLTIP:
|
|
|
|
wt.wcol_theme = &btheme->tui.wcol_tooltip;
|
|
|
|
wt.draw = widget_menu_back;
|
|
|
|
break;
|
2009-04-02 15:01:11 +00:00
|
|
|
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
/* strings */
|
2009-04-02 15:01:11 +00:00
|
|
|
case UI_WTYPE_NAME:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.wcol_theme = &btheme->tui.wcol_text;
|
|
|
|
wt.draw = widget_textbut;
|
2009-04-02 15:01:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case UI_WTYPE_NAME_LINK:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UI_WTYPE_POINTER_LINK:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UI_WTYPE_FILENAME:
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
/* start menus */
|
2009-04-02 15:01:11 +00:00
|
|
|
case UI_WTYPE_MENU_RADIO:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.wcol_theme = &btheme->tui.wcol_menu;
|
|
|
|
wt.draw = widget_menubut;
|
2009-04-02 15:01:11 +00:00
|
|
|
break;
|
2009-09-28 15:59:09 +00:00
|
|
|
|
|
|
|
case UI_WTYPE_MENU_ICON_RADIO:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.wcol_theme = &btheme->tui.wcol_menu;
|
|
|
|
wt.draw = widget_menuiconbut;
|
2009-09-28 15:59:09 +00:00
|
|
|
break;
|
2009-04-02 15:01:11 +00:00
|
|
|
|
|
|
|
case UI_WTYPE_MENU_POINTER_LINK:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.wcol_theme = &btheme->tui.wcol_menu;
|
|
|
|
wt.draw = widget_menubut;
|
2009-04-02 15:01:11 +00:00
|
|
|
break;
|
2011-11-07 22:28:49 +00:00
|
|
|
|
|
|
|
case UI_WTYPE_MENU_NODE_LINK:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.wcol_theme = &btheme->tui.wcol_menu;
|
|
|
|
wt.draw = widget_menunodebut;
|
2011-11-07 22:28:49 +00:00
|
|
|
break;
|
2009-04-02 15:01:11 +00:00
|
|
|
|
|
|
|
case UI_WTYPE_PULLDOWN:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.wcol_theme = &btheme->tui.wcol_pulldown;
|
|
|
|
wt.draw = widget_pulldownbut;
|
|
|
|
wt.state = widget_state_pulldown;
|
2009-04-02 15:01:11 +00:00
|
|
|
break;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
/* in menus */
|
2009-04-02 15:01:11 +00:00
|
|
|
case UI_WTYPE_MENU_ITEM:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.wcol_theme = &btheme->tui.wcol_menu_item;
|
|
|
|
wt.draw = widget_menu_itembut;
|
|
|
|
wt.state = widget_state_menu_item;
|
2009-04-02 15:01:11 +00:00
|
|
|
break;
|
|
|
|
|
2009-04-03 16:26:03 +00:00
|
|
|
case UI_WTYPE_MENU_BACK:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.wcol_theme = &btheme->tui.wcol_menu_back;
|
|
|
|
wt.draw = widget_menu_back;
|
2009-04-03 16:26:03 +00:00
|
|
|
break;
|
2018-04-22 23:03:08 +02:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
/* specials */
|
2009-04-02 15:01:11 +00:00
|
|
|
case UI_WTYPE_ICON:
|
2016-03-23 03:37:23 +11:00
|
|
|
wt.custom = widget_icon_has_anim;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UI_WTYPE_ICON_LABEL:
|
2016-01-11 19:35:39 +11:00
|
|
|
/* behave like regular labels (this is simply a label with an icon) */
|
|
|
|
wt.state = widget_state_label;
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.custom = widget_icon_has_anim;
|
2009-04-02 15:01:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case UI_WTYPE_SWATCH:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.custom = widget_swatch;
|
2009-04-02 15:01:11 +00:00
|
|
|
break;
|
|
|
|
|
2009-06-01 11:31:06 +00:00
|
|
|
case UI_WTYPE_BOX:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.custom = widget_box;
|
|
|
|
wt.wcol_theme = &btheme->tui.wcol_box;
|
2009-06-01 11:31:06 +00:00
|
|
|
break;
|
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
case UI_WTYPE_RGB_PICKER:
|
|
|
|
break;
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_WTYPE_UNITVEC:
|
|
|
|
wt.custom = widget_unitvec;
|
2009-04-02 15:01:11 +00:00
|
|
|
break;
|
2009-06-24 14:16:56 +00:00
|
|
|
|
|
|
|
case UI_WTYPE_SCROLL:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.wcol_theme = &btheme->tui.wcol_scroll;
|
|
|
|
wt.state = widget_state_nothing;
|
|
|
|
wt.custom = widget_scroll;
|
2009-06-24 14:16:56 +00:00
|
|
|
break;
|
2009-07-21 01:26:17 +00:00
|
|
|
|
|
|
|
case UI_WTYPE_LISTITEM:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.wcol_theme = &btheme->tui.wcol_list_item;
|
|
|
|
wt.draw = widget_list_itembut;
|
2009-07-21 01:26:17 +00:00
|
|
|
break;
|
2010-05-27 08:22:16 +00:00
|
|
|
|
|
|
|
case UI_WTYPE_PROGRESSBAR:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt.wcol_theme = &btheme->tui.wcol_progress;
|
|
|
|
wt.custom = widget_progressbar;
|
2010-05-27 08:22:16 +00:00
|
|
|
break;
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
|
|
|
|
case UI_WTYPE_MENU_ITEM_RADIAL:
|
|
|
|
wt.wcol_theme = &btheme->tui.wcol_pie_menu;
|
|
|
|
wt.custom = widget_menu_radial_itembut;
|
|
|
|
wt.state = widget_state_pie_menu_item;
|
|
|
|
break;
|
2009-04-02 15:01:11 +00:00
|
|
|
}
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
return &wt;
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-09 13:37:17 +00:00
|
|
|
static int widget_roundbox_set(uiBut *but, rcti *rect)
|
2009-03-25 16:58:42 +00:00
|
|
|
{
|
2012-10-04 20:12:05 +00:00
|
|
|
int roundbox = UI_CNR_ALL;
|
|
|
|
|
2009-03-25 16:58:42 +00:00
|
|
|
/* alignment */
|
2014-11-09 21:20:40 +01:00
|
|
|
if ((but->drawflag & UI_BUT_ALIGN) && but->type != UI_BTYPE_PULLDOWN) {
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2018-05-06 18:08:27 +02:00
|
|
|
/* ui_popup_block_position has this correction too, keep in sync */
|
2015-11-06 18:39:56 +01:00
|
|
|
if (but->drawflag & (UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_STITCH_TOP))
|
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
|
|
|
rect->ymax += U.pixelsize;
|
2015-11-06 18:39:56 +01:00
|
|
|
if (but->drawflag & (UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_STITCH_LEFT))
|
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
|
|
|
rect->xmin -= U.pixelsize;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2013-11-21 14:43:08 +01:00
|
|
|
switch (but->drawflag & UI_BUT_ALIGN) {
|
2009-03-25 16:58:42 +00:00
|
|
|
case UI_BUT_ALIGN_TOP:
|
2012-10-04 20:12:05 +00:00
|
|
|
roundbox = UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT;
|
|
|
|
break;
|
2009-03-25 16:58:42 +00:00
|
|
|
case UI_BUT_ALIGN_DOWN:
|
2012-10-04 20:12:05 +00:00
|
|
|
roundbox = UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT;
|
|
|
|
break;
|
2009-03-25 16:58:42 +00:00
|
|
|
case UI_BUT_ALIGN_LEFT:
|
2012-10-04 20:12:05 +00:00
|
|
|
roundbox = UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT;
|
|
|
|
break;
|
2009-03-25 16:58:42 +00:00
|
|
|
case UI_BUT_ALIGN_RIGHT:
|
2012-10-04 20:12:05 +00:00
|
|
|
roundbox = UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT;
|
|
|
|
break;
|
2011-09-09 13:10:18 +00:00
|
|
|
case UI_BUT_ALIGN_DOWN | UI_BUT_ALIGN_RIGHT:
|
2012-10-04 20:12:05 +00:00
|
|
|
roundbox = UI_CNR_TOP_LEFT;
|
|
|
|
break;
|
2011-09-09 13:10:18 +00:00
|
|
|
case UI_BUT_ALIGN_DOWN | UI_BUT_ALIGN_LEFT:
|
2012-10-04 20:12:05 +00:00
|
|
|
roundbox = UI_CNR_TOP_RIGHT;
|
|
|
|
break;
|
2011-09-09 13:10:18 +00:00
|
|
|
case UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_RIGHT:
|
2012-10-04 20:12:05 +00:00
|
|
|
roundbox = UI_CNR_BOTTOM_LEFT;
|
|
|
|
break;
|
2011-09-09 13:10:18 +00:00
|
|
|
case UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_LEFT:
|
2012-10-04 20:12:05 +00:00
|
|
|
roundbox = UI_CNR_BOTTOM_RIGHT;
|
|
|
|
break;
|
2009-03-25 16:58:42 +00:00
|
|
|
default:
|
2012-10-04 20:12:05 +00:00
|
|
|
roundbox = 0;
|
|
|
|
break;
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
2011-09-09 13:10:18 +00:00
|
|
|
}
|
|
|
|
|
2012-10-04 20:12:05 +00:00
|
|
|
/* align with open menu */
|
2018-04-23 08:38:15 +02:00
|
|
|
if (but->active && (but->type != UI_BTYPE_POPOVER)) {
|
2014-11-09 21:20:40 +01:00
|
|
|
int direction = ui_but_menu_direction(but);
|
2012-10-04 20:12:05 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
if (direction == UI_DIR_UP) roundbox &= ~(UI_CNR_TOP_RIGHT | UI_CNR_TOP_LEFT);
|
|
|
|
else if (direction == UI_DIR_DOWN) roundbox &= ~(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT);
|
|
|
|
else if (direction == UI_DIR_LEFT) roundbox &= ~(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT);
|
|
|
|
else if (direction == UI_DIR_RIGHT) roundbox &= ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT);
|
2012-10-04 20:12:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return roundbox;
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
2017-11-02 05:48:14 +11:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Public API
|
|
|
|
* \{ */
|
|
|
|
|
2009-04-03 16:26:03 +00:00
|
|
|
/* conversion from old to new buttons, so still messy */
|
2009-06-08 10:00:14 +00:00
|
|
|
void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rcti *rect)
|
2009-03-25 16:58:42 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
bTheme *btheme = UI_GetTheme();
|
|
|
|
ThemeUI *tui = &btheme->tui;
|
|
|
|
uiFontStyle *fstyle = &style->widget;
|
|
|
|
uiWidgetType *wt = NULL;
|
2011-06-14 01:04:11 +00:00
|
|
|
|
2009-11-02 17:25:15 +00:00
|
|
|
/* handle menus separately */
|
2014-11-09 21:20:40 +01:00
|
|
|
if (but->dt == UI_EMBOSS_PULLDOWN) {
|
2009-04-03 16:26:03 +00:00
|
|
|
switch (but->type) {
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_LABEL:
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
widget_draw_text_icon(&style->widgetlabel, &tui->wcol_menu_back, but, rect);
|
2009-04-03 16:26:03 +00:00
|
|
|
break;
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_SEPR_LINE:
|
2010-10-16 02:40:31 +00:00
|
|
|
ui_draw_separator(rect, &tui->wcol_menu_item);
|
2009-04-03 16:26:03 +00:00
|
|
|
break;
|
|
|
|
default:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt = widget_type(UI_WTYPE_MENU_ITEM);
|
2013-07-21 08:16:37 +00:00
|
|
|
break;
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
|
|
|
}
|
2014-11-09 21:20:40 +01:00
|
|
|
else if (but->dt == UI_EMBOSS_NONE) {
|
2009-04-03 16:26:03 +00:00
|
|
|
/* "nothing" */
|
2016-03-23 03:37:23 +11:00
|
|
|
switch (but->type) {
|
|
|
|
case UI_BTYPE_LABEL:
|
|
|
|
wt = widget_type(UI_WTYPE_ICON_LABEL);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
wt = widget_type(UI_WTYPE_ICON);
|
|
|
|
break;
|
|
|
|
}
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
2014-11-09 21:20:40 +01:00
|
|
|
else if (but->dt == UI_EMBOSS_RADIAL) {
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
wt = widget_type(UI_WTYPE_MENU_ITEM_RADIAL);
|
|
|
|
}
|
2009-04-03 16:26:03 +00:00
|
|
|
else {
|
2014-11-11 10:55:07 +01:00
|
|
|
BLI_assert(but->dt == UI_EMBOSS);
|
|
|
|
|
2009-04-03 16:26:03 +00:00
|
|
|
switch (but->type) {
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_LABEL:
|
2017-07-27 10:27:29 +03:00
|
|
|
wt = widget_type(UI_WTYPE_LABEL);
|
|
|
|
fstyle = &style->widgetlabel;
|
|
|
|
if (but->drawflag & UI_BUT_BOX_ITEM) {
|
|
|
|
wt->wcol_theme = &tui->wcol_box;
|
|
|
|
wt->state = widget_state;
|
|
|
|
}
|
|
|
|
else if (but->block->flag & UI_BLOCK_LOOP) {
|
|
|
|
wt->wcol_theme = &tui->wcol_menu_back;
|
|
|
|
wt->state = widget_state;
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
}
|
2009-04-03 16:26:03 +00:00
|
|
|
break;
|
Fix [#35750] list items in properties editor (text colors not following list item theme).
Issue goes back since we stopped using LISTROW button to draw item's name (i.e. since we have custom buttons in list items!).
This commit:
* Adds a new flag to uiBlock, UI_BLOCK_LIST_ITEM, to mark blocks used for each list item.
* Adds a new button type, LISTLABEL, which basically behaves exactly as LABEL, but uses wcol_list_item color set.
* When uiItemL is called, it checks whether current block has UI_BLOCK_LIST_ITEM set, and if so, switch produced button to LISTLABEL type.
* Adds a new helper func, ui_layout_list_set_labels_active, called after the active list item has been "drawn", to set all LISTLABEL buttons as UI_SELECT.
Note custom widget_state_label() was removed, in interface_widgets.c, as it did nothing more than default widget_state().
Thanks to Brecht for the review and advices.
2013-06-26 07:28:55 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_SEPR:
|
|
|
|
case UI_BTYPE_SEPR_LINE:
|
2009-04-03 16:26:03 +00:00
|
|
|
break;
|
2009-06-12 14:22:27 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_BUT:
|
2018-04-26 21:17:33 +02:00
|
|
|
#ifdef USE_TOOLBAR_HACK
|
|
|
|
if (UI_but_is_tool(but)) {
|
|
|
|
wt = widget_type(UI_WTYPE_TOOLBAR_ITEM);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
wt = widget_type(UI_WTYPE_EXEC);
|
|
|
|
}
|
|
|
|
#else
|
2012-03-30 01:51:25 +00:00
|
|
|
wt = widget_type(UI_WTYPE_EXEC);
|
2018-04-26 21:17:33 +02:00
|
|
|
#endif
|
2009-04-03 16:26:03 +00:00
|
|
|
break;
|
2009-06-24 14:16:56 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_NUM:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt = widget_type(UI_WTYPE_NUMBER);
|
2009-04-03 16:26:03 +00:00
|
|
|
break;
|
2009-06-12 14:22:27 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_NUM_SLIDER:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt = widget_type(UI_WTYPE_SLIDER);
|
2009-04-03 16:26:03 +00:00
|
|
|
break;
|
2009-06-12 14:22:27 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_ROW:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt = widget_type(UI_WTYPE_RADIO);
|
2009-04-03 16:26:03 +00:00
|
|
|
break;
|
2009-07-21 01:26:17 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_LISTROW:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt = widget_type(UI_WTYPE_LISTITEM);
|
2009-07-21 01:26:17 +00:00
|
|
|
break;
|
2009-06-12 14:22:27 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_TEXT:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt = widget_type(UI_WTYPE_NAME);
|
2009-06-10 11:43:21 +00:00
|
|
|
break;
|
2015-03-24 15:05:27 +11:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_SEARCH_MENU:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt = widget_type(UI_WTYPE_NAME);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (but->block->flag & UI_BLOCK_LOOP)
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->wcol_theme = &btheme->tui.wcol_menu_back;
|
2009-04-03 16:26:03 +00:00
|
|
|
break;
|
2017-03-17 17:08:20 +01:00
|
|
|
|
|
|
|
case UI_BTYPE_TAB:
|
|
|
|
wt = widget_type(UI_WTYPE_TAB);
|
|
|
|
break;
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_BUT_TOGGLE:
|
|
|
|
case UI_BTYPE_TOGGLE:
|
|
|
|
case UI_BTYPE_TOGGLE_N:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt = widget_type(UI_WTYPE_TOGGLE);
|
2009-05-27 00:03:49 +00:00
|
|
|
break;
|
2009-06-12 14:22:27 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_CHECKBOX:
|
|
|
|
case UI_BTYPE_CHECKBOX_N:
|
2009-04-09 18:11:18 +00:00
|
|
|
if (!(but->flag & UI_HAS_ICON)) {
|
2014-11-09 21:20:40 +01:00
|
|
|
wt = widget_type(UI_WTYPE_CHECKBOX);
|
2013-11-21 14:43:08 +01:00
|
|
|
but->drawflag |= UI_BUT_TEXT_LEFT;
|
2009-04-09 18:11:18 +00:00
|
|
|
}
|
2009-04-03 16:26:03 +00:00
|
|
|
else
|
2012-03-30 01:51:25 +00:00
|
|
|
wt = widget_type(UI_WTYPE_TOGGLE);
|
2011-04-04 15:01:22 +00:00
|
|
|
|
|
|
|
/* option buttons have strings outside, on menus use different colors */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (but->block->flag & UI_BLOCK_LOOP)
|
2012-03-30 01:51:25 +00:00
|
|
|
wt->state = widget_state_option_menu;
|
2011-04-04 15:01:22 +00:00
|
|
|
|
2009-04-03 16:26:03 +00:00
|
|
|
break;
|
2009-06-12 14:22:27 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_MENU:
|
|
|
|
case UI_BTYPE_BLOCK:
|
2018-05-05 14:47:50 +02:00
|
|
|
case UI_BTYPE_POPOVER:
|
2014-03-12 19:24:47 +11:00
|
|
|
if (but->flag & UI_BUT_NODE_LINK) {
|
|
|
|
/* new node-link button, not active yet XXX */
|
2012-03-30 01:51:25 +00:00
|
|
|
wt = widget_type(UI_WTYPE_MENU_NODE_LINK);
|
2012-05-22 15:50:13 +00:00
|
|
|
}
|
2014-03-12 19:24:47 +11:00
|
|
|
else {
|
|
|
|
/* with menu arrows */
|
|
|
|
|
|
|
|
/* we could use a flag for this, but for now just check size,
|
|
|
|
* add updown arrows if there is room. */
|
|
|
|
if ((!but->str[0] && but->icon && (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect) + 2)) ||
|
|
|
|
/* disable for brushes also */
|
2014-11-09 21:20:40 +01:00
|
|
|
(but->flag & UI_BUT_ICON_PREVIEW))
|
2014-03-12 19:24:47 +11:00
|
|
|
{
|
|
|
|
/* no arrows */
|
|
|
|
wt = widget_type(UI_WTYPE_MENU_ICON_RADIO);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
wt = widget_type(UI_WTYPE_MENU_RADIO);
|
|
|
|
}
|
|
|
|
}
|
2009-04-03 16:26:03 +00:00
|
|
|
break;
|
2018-04-22 18:39:29 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_PULLDOWN:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt = widget_type(UI_WTYPE_PULLDOWN);
|
2009-04-03 16:26:03 +00:00
|
|
|
break;
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_BUT_MENU:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt = widget_type(UI_WTYPE_MENU_ITEM);
|
2009-04-03 16:26:03 +00:00
|
|
|
break;
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_COLOR:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt = widget_type(UI_WTYPE_SWATCH);
|
2009-04-03 16:26:03 +00:00
|
|
|
break;
|
2009-06-01 11:31:06 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_ROUNDBOX:
|
|
|
|
case UI_BTYPE_LISTBOX:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt = widget_type(UI_WTYPE_BOX);
|
2009-06-01 11:31:06 +00:00
|
|
|
break;
|
2018-04-16 14:07:42 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_EXTRA:
|
2009-06-08 10:00:14 +00:00
|
|
|
widget_draw_extra_mask(C, but, widget_type(UI_WTYPE_BOX), rect);
|
|
|
|
break;
|
2009-06-01 11:31:06 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_HSVCUBE:
|
2014-03-12 18:58:50 +02:00
|
|
|
if (ELEM(but->a1, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) { /* vertical V slider, uses new widget draw now */
|
2009-06-12 14:22:27 +00:00
|
|
|
ui_draw_but_HSV_v(but, rect);
|
2012-08-19 10:41:27 +00:00
|
|
|
}
|
|
|
|
else { /* other HSV pickers... */
|
2009-06-12 14:22:27 +00:00
|
|
|
ui_draw_but_HSVCUBE(but, rect);
|
2012-08-19 10:41:27 +00:00
|
|
|
}
|
2009-06-12 14:22:27 +00:00
|
|
|
break;
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_HSVCIRCLE:
|
2010-01-07 09:55:11 +00:00
|
|
|
ui_draw_but_HSVCIRCLE(but, &tui->wcol_regular, rect);
|
2009-04-06 15:44:30 +00:00
|
|
|
break;
|
2009-06-12 14:22:27 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_COLORBAND:
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
ui_draw_but_COLORBAND(but, &tui->wcol_regular, rect);
|
2009-04-06 15:44:30 +00:00
|
|
|
break;
|
2009-06-12 14:22:27 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_UNITVEC:
|
|
|
|
wt = widget_type(UI_WTYPE_UNITVEC);
|
2009-04-06 15:44:30 +00:00
|
|
|
break;
|
2009-06-12 14:22:27 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_IMAGE:
|
2009-11-23 13:58:55 +00:00
|
|
|
ui_draw_but_IMAGE(ar, but, &tui->wcol_regular, rect);
|
|
|
|
break;
|
2010-01-19 01:32:06 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_HISTOGRAM:
|
2010-01-28 07:26:21 +00:00
|
|
|
ui_draw_but_HISTOGRAM(ar, but, &tui->wcol_regular, rect);
|
2010-01-19 01:32:06 +00:00
|
|
|
break;
|
2009-11-23 13:58:55 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_WAVEFORM:
|
2010-04-06 02:05:54 +00:00
|
|
|
ui_draw_but_WAVEFORM(ar, but, &tui->wcol_regular, rect);
|
|
|
|
break;
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_VECTORSCOPE:
|
2010-04-06 02:05:54 +00:00
|
|
|
ui_draw_but_VECTORSCOPE(ar, but, &tui->wcol_regular, rect);
|
|
|
|
break;
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_CURVE:
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
ui_draw_but_CURVE(ar, but, &tui->wcol_regular, rect);
|
2009-04-03 16:26:03 +00:00
|
|
|
break;
|
2010-05-27 08:22:16 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_PROGRESS_BAR:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt = widget_type(UI_WTYPE_PROGRESSBAR);
|
|
|
|
fstyle = &style->widgetlabel;
|
2010-05-27 08:22:16 +00:00
|
|
|
break;
|
2009-06-24 14:16:56 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_SCROLL:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt = widget_type(UI_WTYPE_SCROLL);
|
2009-06-24 14:16:56 +00:00
|
|
|
break;
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_GRIP:
|
Add drag-resize to uiTemplatePreview (mat/tex/etc. preview widget).
This is done by adding a new button type, GRIP, similar to other numbuttons
(scroll, slider, ...), which here controls the preview height.
Then, we add a new DNA struct to be able to save that height in Blend files
(note I choose not to use Panel struct for this, because we would then have the
same limitation we used to have with uiLists, only one preview per panel
and no preview outside panel).
This implies a change to template_preview UI RNA/py API (each preview needs an ID),
but this is backward compatible, as by default datablock type will be used if no ID is
given (which means e.g. all material previews with no ID will have same height).
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D342
2014-04-02 12:59:48 +02:00
|
|
|
wt = widget_type(UI_WTYPE_ICON);
|
|
|
|
break;
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_TRACK_PREVIEW:
|
2011-11-07 12:55:18 +00:00
|
|
|
ui_draw_but_TRACKPREVIEW(ar, but, &tui->wcol_regular, rect);
|
|
|
|
break;
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
case UI_BTYPE_NODE_SOCKET:
|
2013-03-18 16:34:57 +00:00
|
|
|
ui_draw_but_NODESOCKET(ar, but, &tui->wcol_regular, rect);
|
|
|
|
break;
|
|
|
|
|
2009-04-03 16:26:03 +00:00
|
|
|
default:
|
2012-03-30 01:51:25 +00:00
|
|
|
wt = widget_type(UI_WTYPE_REGULAR);
|
2013-07-21 08:16:37 +00:00
|
|
|
break;
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
2009-03-25 16:58:42 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (wt) {
|
2013-03-18 18:29:22 +00:00
|
|
|
//rcti disablerect = *rect; /* rect gets clipped smaller for text */
|
2009-04-02 15:01:11 +00:00
|
|
|
int roundboxalign, state;
|
2013-05-29 11:49:39 +00:00
|
|
|
bool disabled = false;
|
2009-04-02 15:01:11 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
roundboxalign = widget_roundbox_set(but, rect);
|
2009-06-24 14:16:56 +00:00
|
|
|
|
2017-11-04 14:10:04 +11:00
|
|
|
/* Mask out flags re-used for local state. */
|
|
|
|
state = but->flag & ~UI_STATE_FLAGS_ALL;
|
2014-02-25 10:28:41 +11:00
|
|
|
|
2017-11-03 00:45:30 +11:00
|
|
|
if (state & UI_SELECT_DRAW) {
|
|
|
|
state |= UI_SELECT;
|
|
|
|
}
|
|
|
|
|
2014-02-25 10:28:41 +11:00
|
|
|
if ((but->editstr) ||
|
2014-11-09 21:20:40 +01:00
|
|
|
(UNLIKELY(but->flag & UI_BUT_DRAG_MULTI) && ui_but_drag_multi_edit_get(but)))
|
2014-02-25 10:28:41 +11:00
|
|
|
{
|
2017-11-03 00:22:59 +11:00
|
|
|
state |= UI_STATE_TEXT_INPUT;
|
2014-02-25 10:28:41 +11:00
|
|
|
}
|
|
|
|
|
2017-11-02 04:30:07 +11:00
|
|
|
if (but->hold_func) {
|
|
|
|
state |= UI_STATE_HOLD_ACTION;
|
|
|
|
}
|
|
|
|
|
2018-04-22 13:57:50 +02:00
|
|
|
if (state & UI_ACTIVE) {
|
|
|
|
if (but->drawflag & UI_BUT_ACTIVE_LEFT) {
|
|
|
|
state |= UI_STATE_ACTIVE_LEFT;
|
|
|
|
}
|
|
|
|
else if (but->drawflag & UI_BUT_ACTIVE_RIGHT) {
|
|
|
|
state |= UI_STATE_ACTIVE_RIGHT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-18 18:29:22 +00:00
|
|
|
if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE))
|
2014-11-09 21:20:40 +01:00
|
|
|
if (but->dt != UI_EMBOSS_PULLDOWN)
|
2013-05-29 11:49:39 +00:00
|
|
|
disabled = true;
|
2013-03-18 18:29:22 +00:00
|
|
|
|
|
|
|
if (disabled)
|
|
|
|
ui_widget_color_disabled(wt);
|
2015-02-11 16:46:41 +01:00
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
wt->state(wt, state);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (wt->custom)
|
2009-04-09 18:11:18 +00:00
|
|
|
wt->custom(but, &wt->wcol, rect, state, roundboxalign);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (wt->draw)
|
2009-04-09 18:11:18 +00:00
|
|
|
wt->draw(&wt->wcol, rect, state, roundboxalign);
|
2015-02-11 16:46:41 +01:00
|
|
|
|
2013-03-18 18:29:22 +00:00
|
|
|
if (disabled)
|
|
|
|
glEnable(GL_BLEND);
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
wt->text(fstyle, &wt->wcol, but, rect);
|
2013-03-18 18:29:22 +00:00
|
|
|
if (disabled)
|
|
|
|
glDisable(GL_BLEND);
|
2009-04-02 15:01:11 +00:00
|
|
|
|
2013-03-18 18:29:22 +00:00
|
|
|
// if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE))
|
2014-11-09 21:20:40 +01:00
|
|
|
// if (but->dt != UI_EMBOSS_PULLDOWN)
|
2013-03-18 18:29:22 +00:00
|
|
|
// widget_disabled(&disablerect);
|
2009-04-02 15:01:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
|
2009-04-03 16:26:03 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK);
|
2009-04-03 16:26:03 +00:00
|
|
|
|
|
|
|
wt->state(wt, 0);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (block)
|
2009-04-15 14:43:54 +00:00
|
|
|
wt->draw(&wt->wcol, rect, block->flag, block->direction);
|
|
|
|
else
|
|
|
|
wt->draw(&wt->wcol, rect, 0, 0);
|
2018-04-22 17:16:39 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (block) {
|
2017-02-14 13:00:22 +01:00
|
|
|
float draw_color[4];
|
|
|
|
unsigned char *color = (unsigned char *)wt->wcol.text;
|
|
|
|
|
|
|
|
draw_color[0] = ((float)color[0]) / 255.0f;
|
|
|
|
draw_color[1] = ((float)color[1]) / 255.0f;
|
|
|
|
draw_color[2] = ((float)color[2]) / 255.0f;
|
|
|
|
draw_color[3] = 1.0f;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (block->flag & UI_BLOCK_CLIPTOP) {
|
Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
- name "Undo History"
- hotkey alt+ctrl+z (alt+apple+z for mac)
- works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
- for small windows or screens, popup menus now allow to display
all items, using internal scrolling
- works with a timer, scrolling 10 items per second when mouse
is over the top or bottom arrow
- if menu is too big to display, it now draws to top or bottom,
based on largest available space.
- also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
- widgets & headers now become bigger and smaller, to match
'dpi' font sizes. Works well to match UI to monitor size.
- note that icons can get fuzzy, we need better mipmaps for it
2011-06-04 17:03:46 +00:00
|
|
|
/* XXX no scaling for UI here yet */
|
2017-02-14 13:00:22 +01:00
|
|
|
UI_draw_icon_tri(BLI_rcti_cent_x(rect), rect->ymax - 8, 't', draw_color);
|
Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
- name "Undo History"
- hotkey alt+ctrl+z (alt+apple+z for mac)
- works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
- for small windows or screens, popup menus now allow to display
all items, using internal scrolling
- works with a timer, scrolling 10 items per second when mouse
is over the top or bottom arrow
- if menu is too big to display, it now draws to top or bottom,
based on largest available space.
- also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
- widgets & headers now become bigger and smaller, to match
'dpi' font sizes. Works well to match UI to monitor size.
- note that icons can get fuzzy, we need better mipmaps for it
2011-06-04 17:03:46 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (block->flag & UI_BLOCK_CLIPBOTTOM) {
|
Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
- name "Undo History"
- hotkey alt+ctrl+z (alt+apple+z for mac)
- works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
- for small windows or screens, popup menus now allow to display
all items, using internal scrolling
- works with a timer, scrolling 10 items per second when mouse
is over the top or bottom arrow
- if menu is too big to display, it now draws to top or bottom,
based on largest available space.
- also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
- widgets & headers now become bigger and smaller, to match
'dpi' font sizes. Works well to match UI to monitor size.
- note that icons can get fuzzy, we need better mipmaps for it
2011-06-04 17:03:46 +00:00
|
|
|
/* XXX no scaling for UI here yet */
|
2017-02-14 13:00:22 +01:00
|
|
|
UI_draw_icon_tri(BLI_rcti_cent_x(rect), rect->ymin + 10, 'v', draw_color);
|
Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
- name "Undo History"
- hotkey alt+ctrl+z (alt+apple+z for mac)
- works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
- for small windows or screens, popup menus now allow to display
all items, using internal scrolling
- works with a timer, scrolling 10 items per second when mouse
is over the top or bottom arrow
- if menu is too big to display, it now draws to top or bottom,
based on largest available space.
- also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
- widgets & headers now become bigger and smaller, to match
'dpi' font sizes. Works well to match UI to monitor size.
- note that icons can get fuzzy, we need better mipmaps for it
2011-06-04 17:03:46 +00:00
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-04-03 16:26:03 +00:00
|
|
|
}
|
2009-04-02 15:01:11 +00:00
|
|
|
|
2018-04-28 22:54:11 +02:00
|
|
|
/**
|
|
|
|
* Similar to 'widget_menu_back', however we can't use the widget preset system
|
|
|
|
* because we need to pass in the original location so we know where to show the arrow.
|
|
|
|
*/
|
|
|
|
static void ui_draw_popover_back_impl(
|
|
|
|
const uiWidgetColors *wcol, rcti *rect, int direction,
|
|
|
|
const float mval_origin[2])
|
2018-04-22 22:08:48 +02:00
|
|
|
{
|
2018-04-28 22:54:11 +02:00
|
|
|
/* tsk, this isn't nice. */
|
|
|
|
const float unit_half = (BLI_rcti_size_x(rect) / UI_POPOVER_WIDTH_UNITS) / 2;
|
|
|
|
const float cent_x = mval_origin ? mval_origin[0] : BLI_rcti_cent_x(rect);
|
|
|
|
rect->ymax -= unit_half;
|
|
|
|
rect->ymin += unit_half;
|
2018-04-22 22:08:48 +02:00
|
|
|
|
2018-04-28 22:54:11 +02:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
|
|
|
/* Extracted from 'widget_menu_back', keep separate to avoid menu changes breaking popovers */
|
|
|
|
{
|
|
|
|
uiWidgetBase wtb;
|
|
|
|
widget_init(&wtb);
|
|
|
|
|
|
|
|
const int roundboxalign = UI_CNR_ALL;
|
|
|
|
widget_softshadow(rect, roundboxalign, wcol->roundness * U.widget_unit);
|
|
|
|
|
|
|
|
round_box_edges(&wtb, roundboxalign, rect, wcol->roundness * U.widget_unit);
|
|
|
|
wtb.draw_emboss = false;
|
|
|
|
widgetbase_draw(&wtb, wcol);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw popover arrow (top/bottom) */
|
|
|
|
if (ELEM(direction, UI_DIR_UP, UI_DIR_DOWN)) {
|
|
|
|
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
immUniformColor4ubv((unsigned char *)wcol->inner);
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
immBegin(GWN_PRIM_TRIS, 3);
|
|
|
|
if (direction == UI_DIR_DOWN) {
|
|
|
|
const float y = rect->ymax;
|
|
|
|
immVertex2f(pos, cent_x - unit_half, y);
|
|
|
|
immVertex2f(pos, cent_x + unit_half, y);
|
|
|
|
immVertex2f(pos, cent_x, y + unit_half);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const float y = rect->ymin;
|
|
|
|
immVertex2f(pos, cent_x - unit_half, y);
|
2018-04-29 12:22:55 +02:00
|
|
|
immVertex2f(pos, cent_x + unit_half, y);
|
2018-04-28 22:54:11 +02:00
|
|
|
immVertex2f(pos, cent_x, y - unit_half);
|
|
|
|
}
|
|
|
|
immEnd();
|
|
|
|
immUnbindProgram();
|
|
|
|
}
|
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ui_draw_popover_back(ARegion *ar, uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
|
|
|
|
{
|
2018-04-22 22:08:48 +02:00
|
|
|
if (block) {
|
2018-04-28 22:54:11 +02:00
|
|
|
float mval_origin[2] = {block->mx, block->my};
|
|
|
|
ui_window_to_block_fl(ar, block, &mval_origin[0], &mval_origin[1]);
|
|
|
|
ui_draw_popover_back_impl(&wcol_menu_back, rect, block->direction, mval_origin);
|
2018-04-22 22:08:48 +02:00
|
|
|
}
|
|
|
|
else {
|
2018-04-28 22:54:11 +02:00
|
|
|
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK);
|
|
|
|
|
|
|
|
wt->state(wt, 0);
|
2018-04-22 22:08:48 +02:00
|
|
|
wt->draw(&wt->wcol, rect, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
static void draw_disk_shaded(
|
|
|
|
float start, float angle,
|
|
|
|
float radius_int, float radius_ext, int subd,
|
|
|
|
const char col1[4], const char col2[4],
|
|
|
|
bool shaded)
|
|
|
|
{
|
|
|
|
const float radius_ext_scale = (0.5f / radius_ext); /* 1 / (2 * radius_ext) */
|
|
|
|
int i;
|
|
|
|
|
|
|
|
float s, c;
|
|
|
|
float y1, y2;
|
|
|
|
float fac;
|
|
|
|
unsigned char r_col[4];
|
2017-02-20 21:21:04 +01:00
|
|
|
unsigned int pos, col;
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
Gwn_VertFormat *format = immVertexFormat();
|
|
|
|
pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
if (shaded) {
|
2017-06-19 20:18:04 +10:00
|
|
|
col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
2017-02-20 21:21:04 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
}
|
2017-02-20 21:21:04 +01:00
|
|
|
else {
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
immUniformColor4ubv((unsigned char *)col1);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
}
|
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
immBegin(GWN_PRIM_TRI_STRIP, subd * 2);
|
2017-02-20 21:21:04 +01:00
|
|
|
for (i = 0; i < subd; i++) {
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
float a;
|
|
|
|
|
|
|
|
a = start + ((i) / (float)(subd - 1)) * angle;
|
|
|
|
s = sinf(a);
|
|
|
|
c = cosf(a);
|
|
|
|
y1 = s * radius_int;
|
|
|
|
y2 = s * radius_ext;
|
|
|
|
|
|
|
|
if (shaded) {
|
|
|
|
fac = (y1 + radius_ext) * radius_ext_scale;
|
|
|
|
round_box_shade_col4_r(r_col, col1, col2, fac);
|
2017-02-20 21:21:04 +01:00
|
|
|
immAttrib4ubv(col, r_col);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
}
|
2017-02-20 21:21:04 +01:00
|
|
|
immVertex2f(pos, c * radius_int, s * radius_int);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
|
|
|
|
if (shaded) {
|
|
|
|
fac = (y2 + radius_ext) * radius_ext_scale;
|
|
|
|
round_box_shade_col4_r(r_col, col1, col2, fac);
|
2017-02-20 21:21:04 +01:00
|
|
|
immAttrib4ubv(col, r_col);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
}
|
2017-02-20 21:21:04 +01:00
|
|
|
immVertex2f(pos, c * radius_ext, s * radius_ext);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
}
|
2017-02-20 21:21:04 +01:00
|
|
|
immEnd();
|
|
|
|
|
|
|
|
immUnbindProgram();
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ui_draw_pie_center(uiBlock *block)
|
|
|
|
{
|
|
|
|
bTheme *btheme = UI_GetTheme();
|
|
|
|
float cx = block->pie_data.pie_center_spawned[0];
|
|
|
|
float cy = block->pie_data.pie_center_spawned[1];
|
|
|
|
|
|
|
|
float *pie_dir = block->pie_data.pie_dir;
|
|
|
|
|
|
|
|
float pie_radius_internal = U.pixelsize * U.pie_menu_threshold;
|
|
|
|
float pie_radius_external = U.pixelsize * (U.pie_menu_threshold + 7.0f);
|
|
|
|
|
|
|
|
int subd = 40;
|
|
|
|
|
2014-09-17 14:11:37 +10:00
|
|
|
float angle = atan2f(pie_dir[1], pie_dir[0]);
|
2015-01-31 17:23:30 +11:00
|
|
|
float range = (block->pie_data.flags & UI_PIE_DEGREES_RANGE_LARGE) ? M_PI_2 : M_PI_4;
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
|
2017-02-20 21:21:04 +01:00
|
|
|
gpuPushMatrix();
|
2017-03-23 01:45:46 -04:00
|
|
|
gpuTranslate2f(cx, cy);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
if (btheme->tui.wcol_pie_menu.shaded) {
|
|
|
|
char col1[4], col2[4];
|
|
|
|
shadecolors4(col1, col2, btheme->tui.wcol_pie_menu.inner, btheme->tui.wcol_pie_menu.shadetop, btheme->tui.wcol_pie_menu.shadedown);
|
|
|
|
draw_disk_shaded(0.0f, (float)(M_PI * 2.0), pie_radius_internal, pie_radius_external, subd, col1, col2, true);
|
|
|
|
}
|
|
|
|
else {
|
2017-02-20 21:21:04 +01:00
|
|
|
draw_disk_shaded(0.0f, (float)(M_PI * 2.0), pie_radius_internal, pie_radius_external, subd, btheme->tui.wcol_pie_menu.inner, NULL, false);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(block->pie_data.flags & UI_PIE_INVALID_DIR)) {
|
|
|
|
if (btheme->tui.wcol_pie_menu.shaded) {
|
|
|
|
char col1[4], col2[4];
|
|
|
|
shadecolors4(col1, col2, btheme->tui.wcol_pie_menu.inner_sel, btheme->tui.wcol_pie_menu.shadetop, btheme->tui.wcol_pie_menu.shadedown);
|
|
|
|
draw_disk_shaded(angle - range / 2.0f, range, pie_radius_internal, pie_radius_external, subd, col1, col2, true);
|
|
|
|
}
|
|
|
|
else {
|
2017-02-26 16:53:04 +01:00
|
|
|
draw_disk_shaded(angle - range / 2.0f, range, pie_radius_internal, pie_radius_external, subd, btheme->tui.wcol_pie_menu.inner_sel, NULL, false);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
Gwn_VertFormat *format = immVertexFormat();
|
|
|
|
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
2017-02-20 21:21:04 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
immUniformColor4ubv((unsigned char *)btheme->tui.wcol_pie_menu.outline);
|
|
|
|
|
2017-09-14 00:39:28 +10:00
|
|
|
imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, pie_radius_internal, subd);
|
|
|
|
imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, pie_radius_external, subd);
|
2017-02-20 21:21:04 +01:00
|
|
|
|
|
|
|
immUnbindProgram();
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
|
2014-10-14 11:57:50 +02:00
|
|
|
if (U.pie_menu_confirm > 0 && !(block->pie_data.flags & (UI_PIE_INVALID_DIR | UI_PIE_CLICK_STYLE))) {
|
|
|
|
float pie_confirm_radius = U.pixelsize * (pie_radius_internal + U.pie_menu_confirm);
|
|
|
|
float pie_confirm_external = U.pixelsize * (pie_radius_internal + U.pie_menu_confirm + 7.0f);
|
|
|
|
|
2017-02-20 21:21:04 +01:00
|
|
|
const char col[4] = {btheme->tui.wcol_pie_menu.text_sel[0],
|
|
|
|
btheme->tui.wcol_pie_menu.text_sel[1],
|
|
|
|
btheme->tui.wcol_pie_menu.text_sel[2],
|
|
|
|
64};
|
|
|
|
|
|
|
|
draw_disk_shaded(angle - range / 2.0f, range, pie_confirm_radius, pie_confirm_external, subd, col, NULL, false);
|
2014-10-10 19:13:40 +02:00
|
|
|
}
|
2014-10-14 11:57:50 +02:00
|
|
|
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
glDisable(GL_BLEND);
|
2017-02-20 21:21:04 +01:00
|
|
|
gpuPopMatrix();
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-24 22:50:49 +00:00
|
|
|
uiWidgetColors *ui_tooltip_get_theme(void)
|
|
|
|
{
|
2012-03-22 20:24:11 +00:00
|
|
|
uiWidgetType *wt = widget_type(UI_WTYPE_TOOLTIP);
|
|
|
|
return wt->wcol_theme;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *UNUSED(block), rcti *rect)
|
2012-03-19 22:29:16 +00:00
|
|
|
{
|
|
|
|
uiWidgetType *wt = widget_type(UI_WTYPE_TOOLTIP);
|
|
|
|
wt->state(wt, 0);
|
|
|
|
/* wt->draw ends up using same function to draw the tooltip as menu_back */
|
|
|
|
wt->draw(&wt->wcol, rect, 0, 0);
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
void ui_draw_search_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
|
2009-06-03 18:31:37 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiWidgetType *wt = widget_type(UI_WTYPE_BOX);
|
2009-06-03 18:31:37 +00:00
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
2012-12-20 16:50:39 +00:00
|
|
|
widget_softshadow(rect, UI_CNR_ALL, 0.25f * U.widget_unit);
|
2009-06-03 18:31:37 +00:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
|
|
|
wt->state(wt, 0);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (block)
|
2011-09-11 06:41:09 +00:00
|
|
|
wt->draw(&wt->wcol, rect, block->flag, UI_CNR_ALL);
|
2009-06-03 18:31:37 +00:00
|
|
|
else
|
2011-09-11 06:41:09 +00:00
|
|
|
wt->draw(&wt->wcol, rect, 0, UI_CNR_ALL);
|
2009-06-03 18:31:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-02 18:10:06 +00:00
|
|
|
/* helper call to draw a menu item without button */
|
|
|
|
/* state: UI_ACTIVE or 0 */
|
2013-09-11 04:56:35 +00:00
|
|
|
void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state, bool use_sep)
|
2009-06-02 18:10:06 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM);
|
|
|
|
rcti _rect = *rect;
|
2014-02-26 21:53:56 +01:00
|
|
|
char *cpoin = NULL;
|
2013-01-17 01:48:42 +00:00
|
|
|
|
2009-06-02 18:10:06 +00:00
|
|
|
wt->state(wt, state);
|
|
|
|
wt->draw(&wt->wcol, rect, 0, 0);
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_fontstyle_set(fstyle);
|
2012-03-30 01:51:25 +00:00
|
|
|
fstyle->align = UI_STYLE_TEXT_LEFT;
|
2009-06-02 18:10:06 +00:00
|
|
|
|
|
|
|
/* text location offset */
|
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
|
|
|
rect->xmin += 0.25f * UI_UNIT_X;
|
2012-03-30 01:51:25 +00:00
|
|
|
if (iconid) rect->xmin += UI_DPI_ICON_SIZE;
|
2009-06-02 18:10:06 +00:00
|
|
|
|
|
|
|
/* cut string in 2 parts? */
|
2013-09-11 04:56:35 +00:00
|
|
|
if (use_sep) {
|
2013-09-11 05:06:27 +00:00
|
|
|
cpoin = strchr(name, UI_SEP_CHAR);
|
2013-09-11 04:56:35 +00:00
|
|
|
if (cpoin) {
|
|
|
|
*cpoin = 0;
|
2014-02-26 21:53:56 +01:00
|
|
|
|
|
|
|
/* need to set this first */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_fontstyle_set(fstyle);
|
2014-02-26 21:53:56 +01:00
|
|
|
|
|
|
|
if (fstyle->kerning == 1) { /* for BLF_width */
|
|
|
|
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
|
|
|
}
|
|
|
|
|
|
|
|
rect->xmax -= BLF_width(fstyle->uifont_id, cpoin + 1, INT_MAX) + UI_DPI_ICON_SIZE;
|
|
|
|
|
|
|
|
if (fstyle->kerning == 1) {
|
|
|
|
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
|
|
|
}
|
2013-09-11 04:56:35 +00:00
|
|
|
}
|
2009-06-03 18:31:37 +00:00
|
|
|
}
|
2014-02-26 21:53:56 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
char drawstr[UI_MAX_DRAW_STR];
|
|
|
|
const float okwidth = (float)BLI_rcti_size_x(rect);
|
|
|
|
const size_t max_len = sizeof(drawstr);
|
|
|
|
const float minwidth = (float)(UI_DPI_ICON_SIZE);
|
|
|
|
|
|
|
|
BLI_strncpy(drawstr, name, sizeof(drawstr));
|
2016-03-02 12:53:55 +11:00
|
|
|
if (drawstr[0]) {
|
|
|
|
UI_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, '\0');
|
|
|
|
}
|
2014-02-26 21:53:56 +01:00
|
|
|
|
2017-02-10 00:00:21 +01:00
|
|
|
UI_fontstyle_draw(fstyle, rect, drawstr, (unsigned char *)wt->wcol.text);
|
2014-02-26 21:53:56 +01:00
|
|
|
}
|
|
|
|
|
2009-06-02 18:10:06 +00:00
|
|
|
/* part text right aligned */
|
2013-09-11 04:56:35 +00:00
|
|
|
if (use_sep) {
|
|
|
|
if (cpoin) {
|
|
|
|
fstyle->align = UI_STYLE_TEXT_RIGHT;
|
|
|
|
rect->xmax = _rect.xmax - 5;
|
2017-02-10 00:00:21 +01:00
|
|
|
UI_fontstyle_draw(fstyle, rect, cpoin + 1, (unsigned char *)wt->wcol.text);
|
2013-09-11 05:06:27 +00:00
|
|
|
*cpoin = UI_SEP_CHAR;
|
2013-09-11 04:56:35 +00:00
|
|
|
}
|
2009-06-02 18:10:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* restore rect, was messed with */
|
2012-03-30 01:51:25 +00:00
|
|
|
*rect = _rect;
|
2009-06-02 18:10:06 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (iconid) {
|
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
|
|
|
float height, aspect;
|
|
|
|
int xs = rect->xmin + 0.2f * UI_UNIT_X;
|
2012-12-23 13:02:38 +00:00
|
|
|
int ys = rect->ymin + 0.1f * BLI_rcti_size_y(rect);
|
2013-12-18 17:11:38 +11:00
|
|
|
|
|
|
|
height = ICON_SIZE_FROM_BUTRECT(rect);
|
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
|
|
|
aspect = ICON_DEFAULT_HEIGHT / height;
|
2012-12-23 13:02:38 +00:00
|
|
|
|
2009-06-24 16:44:54 +00:00
|
|
|
glEnable(GL_BLEND);
|
2012-12-23 13:02:38 +00:00
|
|
|
UI_icon_draw_aspect(xs, ys, iconid, aspect, 1.0f); /* XXX scale weak get from fstyle? */
|
2009-06-24 16:44:54 +00:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
2009-06-02 18:10:06 +00:00
|
|
|
}
|
2009-03-25 16:58:42 +00:00
|
|
|
|
2011-02-07 22:48:23 +00:00
|
|
|
void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state)
|
2010-01-03 08:37:18 +00:00
|
|
|
{
|
2015-05-25 21:55:48 +01:00
|
|
|
rcti trect = *rect;
|
2015-05-31 19:15:10 +02:00
|
|
|
const float text_size = UI_UNIT_Y;
|
2012-01-11 05:45:39 +00:00
|
|
|
float font_dims[2] = {0.0f, 0.0f};
|
2012-03-30 01:51:25 +00:00
|
|
|
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM);
|
2010-01-03 08:37:18 +00:00
|
|
|
|
2015-05-25 21:55:48 +01:00
|
|
|
/* drawing button background */
|
2010-01-03 08:37:18 +00:00
|
|
|
wt->state(wt, state);
|
|
|
|
wt->draw(&wt->wcol, rect, 0, 0);
|
|
|
|
|
2015-05-25 21:55:48 +01:00
|
|
|
/* draw icon in rect above the space reserved for the label */
|
|
|
|
rect->ymin += text_size;
|
2014-04-27 23:38:21 +03:00
|
|
|
glEnable(GL_BLEND);
|
2011-01-20 16:29:43 +00:00
|
|
|
widget_draw_preview(iconid, 1.0f, rect);
|
2015-05-25 21:55:48 +01:00
|
|
|
glDisable(GL_BLEND);
|
2010-01-03 08:37:18 +00:00
|
|
|
|
2013-12-02 20:33:45 +11:00
|
|
|
BLF_width_and_height(fstyle->uifont_id, name, BLF_DRAW_STR_DUMMY_MAX, &font_dims[0], &font_dims[1]);
|
2012-01-11 05:45:39 +00:00
|
|
|
|
2012-02-28 01:55:27 +00:00
|
|
|
/* text rect */
|
2010-01-03 08:37:18 +00:00
|
|
|
trect.xmin += 0;
|
2015-05-31 19:15:10 +02:00
|
|
|
trect.xmax = trect.xmin + font_dims[0] + U.widget_unit / 2;
|
|
|
|
trect.ymin += U.widget_unit / 2;
|
2012-01-11 05:45:39 +00:00
|
|
|
trect.ymax = trect.ymin + font_dims[1];
|
2012-03-24 06:38:07 +00:00
|
|
|
if (trect.xmax > rect->xmax - PREVIEW_PAD)
|
2012-02-28 01:55:27 +00:00
|
|
|
trect.xmax = rect->xmax - PREVIEW_PAD;
|
|
|
|
|
2014-02-26 21:53:56 +01:00
|
|
|
{
|
|
|
|
char drawstr[UI_MAX_DRAW_STR];
|
|
|
|
const float okwidth = (float)BLI_rcti_size_x(&trect);
|
|
|
|
const size_t max_len = sizeof(drawstr);
|
|
|
|
const float minwidth = (float)(UI_DPI_ICON_SIZE);
|
|
|
|
|
|
|
|
BLI_strncpy(drawstr, name, sizeof(drawstr));
|
2015-06-03 15:01:02 +10:00
|
|
|
UI_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, '\0');
|
2014-02-26 21:53:56 +01:00
|
|
|
|
2017-02-10 00:00:21 +01:00
|
|
|
UI_fontstyle_draw(fstyle, &trect, drawstr, (unsigned char *)wt->wcol.text);
|
2014-02-26 21:53:56 +01:00
|
|
|
}
|
2010-01-03 08:37:18 +00:00
|
|
|
}
|
2017-11-02 05:48:14 +11:00
|
|
|
|
|
|
|
/** \} */
|