2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-26 13:11:04 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* 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.
|
2008-12-26 13:11:04 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
2009-04-09 18:11:18 +00:00
|
|
|
* Contributor(s): Blender Foundation, 2003-2009 full recode.
|
2008-12-26 13:11:04 +00:00
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/interface/interface_panel.c
|
|
|
|
* \ingroup edinterface
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-10-13 14:44:22 +00:00
|
|
|
/* a full doc with API notes can be found in bf-blender/trunk/blender/doc/guides/interface_API.txt */
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "PIL_time.h"
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2013-12-17 03:21:55 +11:00
|
|
|
#include "BLI_math_color_blend.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2011-11-09 14:13:17 +00:00
|
|
|
#include "BLF_translation.h"
|
|
|
|
|
2008-12-26 13:11:04 +00:00
|
|
|
#include "DNA_userdef_types.h"
|
|
|
|
|
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_screen.h"
|
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
#include "BIF_glutil.h"
|
|
|
|
|
2013-12-17 03:21:55 +11:00
|
|
|
#include "BLF_api.h"
|
|
|
|
|
2008-12-26 13:11:04 +00:00
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "ED_screen.h"
|
|
|
|
|
2014-02-22 13:07:02 +11:00
|
|
|
#include "UI_view2d.h"
|
2008-12-26 13:11:04 +00:00
|
|
|
#include "UI_interface.h"
|
2013-12-17 03:21:55 +11:00
|
|
|
#include "UI_interface_icons.h"
|
2011-11-19 20:57:53 +00:00
|
|
|
#include "UI_resources.h"
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
#include "interface_intern.h"
|
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
/*********************** defines and structs ************************/
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
#define ANIMATION_TIME 0.30
|
|
|
|
#define ANIMATION_INTERVAL 0.02
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
#define PNL_LAST_ADDED 1
|
|
|
|
#define PNL_ACTIVE 2
|
|
|
|
#define PNL_WAS_ACTIVE 4
|
|
|
|
#define PNL_ANIM_ALIGN 8
|
|
|
|
#define PNL_NEW_ADDED 16
|
|
|
|
#define PNL_FIRST 32
|
2009-04-16 21:39:45 +00:00
|
|
|
|
2013-12-17 03:21:55 +11:00
|
|
|
/* only show pin header button for pinned panels */
|
|
|
|
#define USE_PIN_HIDDEN
|
|
|
|
|
2008-12-26 13:11:04 +00:00
|
|
|
typedef enum uiHandlePanelState {
|
|
|
|
PANEL_STATE_DRAG,
|
|
|
|
PANEL_STATE_DRAG_SCALE,
|
|
|
|
PANEL_STATE_WAIT_UNTAB,
|
|
|
|
PANEL_STATE_ANIMATION,
|
|
|
|
PANEL_STATE_EXIT
|
|
|
|
} uiHandlePanelState;
|
|
|
|
|
|
|
|
typedef struct uiHandlePanelData {
|
|
|
|
uiHandlePanelState state;
|
|
|
|
|
|
|
|
/* animation */
|
|
|
|
wmTimer *animtimer;
|
|
|
|
double starttime;
|
|
|
|
|
|
|
|
/* dragging */
|
|
|
|
int startx, starty;
|
|
|
|
int startofsx, startofsy;
|
|
|
|
int startsizex, startsizey;
|
|
|
|
} uiHandlePanelData;
|
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelState state);
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
/*********************** space specific code ************************/
|
|
|
|
/* temporary code to remove all sbuts stuff from panel code */
|
2009-02-10 15:38:00 +00:00
|
|
|
|
|
|
|
static int panel_aligned(ScrArea *sa, ARegion *ar)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
if (sa->spacetype == SPACE_BUTS && ar->regiontype == RGN_TYPE_WINDOW) {
|
|
|
|
SpaceButs *sbuts = sa->spacedata.first;
|
2009-02-10 15:38:00 +00:00
|
|
|
return sbuts->align;
|
|
|
|
}
|
2012-03-30 01:51:25 +00:00
|
|
|
else if (sa->spacetype == SPACE_USERPREF && ar->regiontype == RGN_TYPE_WINDOW)
|
2009-07-15 19:19:43 +00:00
|
|
|
return BUT_VERTICAL;
|
2012-03-30 01:51:25 +00:00
|
|
|
else if (sa->spacetype == SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS)
|
2009-06-29 20:23:40 +00:00
|
|
|
return BUT_VERTICAL;
|
2012-03-30 01:51:25 +00:00
|
|
|
else if (sa->spacetype == SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW)
|
2012-12-26 13:05:39 +00:00
|
|
|
return BUT_VERTICAL;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ELEM3(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS))
|
2009-02-10 15:38:00 +00:00
|
|
|
return BUT_VERTICAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
static int panels_re_align(ScrArea *sa, ARegion *ar, Panel **r_pa)
|
2009-04-02 01:39:33 +00:00
|
|
|
{
|
2009-04-16 21:39:45 +00:00
|
|
|
Panel *pa;
|
2012-03-30 01:51:25 +00:00
|
|
|
int active = 0;
|
2009-04-16 21:39:45 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
*r_pa = NULL;
|
2009-04-16 21:39:45 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (sa->spacetype == SPACE_BUTS && ar->regiontype == RGN_TYPE_WINDOW) {
|
|
|
|
SpaceButs *sbuts = sa->spacedata.first;
|
2009-04-02 01:39:33 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sbuts->align)
|
2012-03-30 01:51:25 +00:00
|
|
|
if (sbuts->re_align || sbuts->mainbo != sbuts->mainb)
|
2009-04-02 01:39:33 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2012-03-30 01:51:25 +00:00
|
|
|
else if (sa->spacetype == SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW)
|
2010-01-19 01:32:06 +00:00
|
|
|
return 1;
|
2012-03-30 01:51:25 +00:00
|
|
|
else if (sa->spacetype == SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS)
|
2009-06-29 20:23:40 +00:00
|
|
|
return 1;
|
2009-04-16 21:39:45 +00:00
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
/* in case panel is added or disappears */
|
2012-03-30 01:51:25 +00:00
|
|
|
for (pa = ar->panels.first; pa; pa = pa->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((pa->runtime_flag & PNL_WAS_ACTIVE) && !(pa->runtime_flag & PNL_ACTIVE))
|
2009-04-16 21:39:45 +00:00
|
|
|
return 1;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!(pa->runtime_flag & PNL_WAS_ACTIVE) && (pa->runtime_flag & PNL_ACTIVE))
|
2009-04-16 21:39:45 +00:00
|
|
|
return 1;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pa->activedata)
|
2012-03-30 01:51:25 +00:00
|
|
|
active = 1;
|
2009-04-16 21:39:45 +00:00
|
|
|
}
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
/* in case we need to do an animation (size changes) */
|
2012-03-30 01:51:25 +00:00
|
|
|
for (pa = ar->panels.first; pa; pa = pa->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pa->runtime_flag & PNL_ANIM_ALIGN) {
|
|
|
|
if (!active)
|
2012-03-30 01:51:25 +00:00
|
|
|
*r_pa = pa;
|
2009-04-16 21:39:45 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2009-04-02 01:39:33 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
/****************************** panels ******************************/
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-12-18 14:46:00 +00:00
|
|
|
static void panels_collapse_all(ScrArea *sa, ARegion *ar, Panel *from_pa)
|
2012-05-28 00:02:24 +00:00
|
|
|
{
|
2012-06-04 20:11:09 +00:00
|
|
|
Panel *pa;
|
2012-12-18 14:46:00 +00:00
|
|
|
PanelType *pt, *from_pt;
|
2012-06-05 21:54:21 +00:00
|
|
|
int flag = ((panel_aligned(sa, ar) == BUT_HORIZONTAL) ? PNL_CLOSEDX : PNL_CLOSEDY);
|
2012-05-28 00:02:24 +00:00
|
|
|
|
2012-06-05 21:54:21 +00:00
|
|
|
for (pa = ar->panels.first; pa; pa = pa->next) {
|
2012-12-18 14:46:00 +00:00
|
|
|
pt = pa->type;
|
|
|
|
from_pt = from_pa->type;
|
|
|
|
|
|
|
|
/* close panels with headers in the same context */
|
2014-02-05 13:39:39 +01:00
|
|
|
if (pt && from_pt && !(pt->flag & PNL_NO_HEADER)) {
|
|
|
|
if (!pt->context[0] || strcmp(pt->context, from_pt->context) == 0) {
|
|
|
|
pa->flag &= ~PNL_CLOSED;
|
|
|
|
pa->flag |= flag;
|
|
|
|
}
|
|
|
|
}
|
2012-06-04 20:11:09 +00:00
|
|
|
}
|
2012-05-28 00:02:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
static void ui_panel_copy_offset(Panel *pa, Panel *papar)
|
2008-12-26 13:11:04 +00:00
|
|
|
{
|
|
|
|
/* with respect to sizes... papar is parent */
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
pa->ofsx = papar->ofsx;
|
|
|
|
pa->ofsy = papar->ofsy + papar->sizey - pa->sizey;
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
|
2013-12-17 03:21:55 +11:00
|
|
|
Panel *uiPanelFindByType(ARegion *ar, PanelType *pt)
|
2008-12-26 13:11:04 +00:00
|
|
|
{
|
2013-12-17 03:21:55 +11:00
|
|
|
Panel *pa;
|
|
|
|
|
|
|
|
const char *idname = pt->idname;
|
|
|
|
const char *tabname = pt->idname;
|
|
|
|
|
|
|
|
for (pa = ar->panels.first; pa; pa = pa->next) {
|
|
|
|
if (STREQLEN(pa->panelname, idname, UI_MAX_NAME_STR)) {
|
|
|
|
if (STREQLEN(pa->tabname, tabname, UI_MAX_NAME_STR)) {
|
|
|
|
return pa;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \note \a pa should be return value from #uiPanelFindByType and can be NULL.
|
|
|
|
*/
|
|
|
|
Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, Panel *pa, bool *r_open)
|
|
|
|
{
|
|
|
|
Panel *patab, *palast, *panext;
|
2013-03-15 14:32:29 +00:00
|
|
|
const char *drawname = CTX_IFACE_(pt->translation_context, pt->label);
|
2012-03-30 01:51:25 +00:00
|
|
|
char *idname = pt->idname;
|
|
|
|
char *tabname = pt->idname;
|
|
|
|
char *hookname = NULL;
|
2013-12-17 03:21:55 +11:00
|
|
|
const bool newpanel = (pa == NULL);
|
2012-03-30 01:51:25 +00:00
|
|
|
int align = panel_aligned(sa, ar);
|
2009-04-17 11:59:25 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!newpanel) {
|
2012-03-30 01:51:25 +00:00
|
|
|
pa->type = pt;
|
2009-04-16 21:39:45 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* new panel */
|
2012-03-30 01:51:25 +00:00
|
|
|
pa = MEM_callocN(sizeof(Panel), "new panel");
|
|
|
|
pa->type = pt;
|
2009-06-16 01:08:39 +00:00
|
|
|
BLI_strncpy(pa->panelname, idname, UI_MAX_NAME_STR);
|
2009-04-16 21:39:45 +00:00
|
|
|
BLI_strncpy(pa->tabname, tabname, UI_MAX_NAME_STR);
|
2009-06-16 01:08:39 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pt->flag & PNL_DEFAULT_CLOSED) {
|
|
|
|
if (align == BUT_VERTICAL)
|
2009-06-16 01:08:39 +00:00
|
|
|
pa->flag |= PNL_CLOSEDY;
|
|
|
|
else
|
|
|
|
pa->flag |= PNL_CLOSEDX;
|
|
|
|
}
|
2009-04-16 21:39:45 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
pa->ofsx = 0;
|
|
|
|
pa->ofsy = 0;
|
|
|
|
pa->sizex = 0;
|
|
|
|
pa->sizey = 0;
|
2009-06-16 01:08:39 +00:00
|
|
|
pa->runtime_flag |= PNL_NEW_ADDED;
|
2009-04-17 11:59:25 +00:00
|
|
|
|
|
|
|
BLI_addtail(&ar->panels, pa);
|
2009-04-16 21:39:45 +00:00
|
|
|
|
|
|
|
/* make new Panel tabbed? */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (hookname) {
|
2012-03-30 01:51:25 +00:00
|
|
|
for (patab = ar->panels.first; patab; patab = patab->next) {
|
|
|
|
if ((patab->runtime_flag & PNL_ACTIVE) && patab->paneltab == NULL) {
|
|
|
|
if (strncmp(hookname, patab->panelname, UI_MAX_NAME_STR) == 0) {
|
|
|
|
if (strncmp(tabname, patab->tabname, UI_MAX_NAME_STR) == 0) {
|
|
|
|
pa->paneltab = patab;
|
2009-04-16 21:39:45 +00:00
|
|
|
ui_panel_copy_offset(pa, patab);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-04-16 21:39:45 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2013-01-28 08:58:20 +00:00
|
|
|
/* Do not allow closed panels without headers! Else user could get "disappeared" UI! */
|
|
|
|
if ((pt->flag & PNL_NO_HEADER) && (pa->flag & PNL_CLOSED)) {
|
|
|
|
pa->flag &= ~PNL_CLOSED;
|
|
|
|
/* Force update of panels' positions! */
|
|
|
|
pa->sizex = 0;
|
|
|
|
pa->sizey = 0;
|
|
|
|
}
|
|
|
|
|
2013-07-15 05:11:14 +00:00
|
|
|
BLI_strncpy(pa->drawname, drawname, sizeof(pa->drawname));
|
2009-06-16 01:08:39 +00:00
|
|
|
|
2009-04-17 11:59:25 +00:00
|
|
|
/* if a new panel is added, we insert it right after the panel
|
|
|
|
* that was last added. this way new panels are inserted in the
|
|
|
|
* right place between versions */
|
2012-03-30 01:51:25 +00:00
|
|
|
for (palast = ar->panels.first; palast; palast = palast->next)
|
2012-03-24 06:38:07 +00:00
|
|
|
if (palast->runtime_flag & PNL_LAST_ADDED)
|
2009-04-16 21:39:45 +00:00
|
|
|
break;
|
2009-04-17 11:59:25 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (newpanel) {
|
2013-12-18 15:10:40 +01:00
|
|
|
pa->sortorder = (palast) ? palast->sortorder + 1 : 0;
|
2009-04-16 21:39:45 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (panext = ar->panels.first; panext; panext = panext->next)
|
2012-03-24 06:38:07 +00:00
|
|
|
if (panext != pa && panext->sortorder >= pa->sortorder)
|
2009-04-17 13:37:03 +00:00
|
|
|
panext->sortorder++;
|
2009-04-16 21:39:45 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (palast)
|
2009-04-17 11:59:25 +00:00
|
|
|
palast->runtime_flag &= ~PNL_LAST_ADDED;
|
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
/* assign to block */
|
2012-03-30 01:51:25 +00:00
|
|
|
block->panel = pa;
|
|
|
|
pa->runtime_flag |= PNL_ACTIVE | PNL_LAST_ADDED;
|
2009-04-16 21:39:45 +00:00
|
|
|
|
2013-12-17 03:21:55 +11:00
|
|
|
*r_open = false;
|
2009-04-16 21:39:45 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pa->paneltab) return pa;
|
|
|
|
if (pa->flag & PNL_CLOSED) return pa;
|
2009-05-19 17:13:33 +00:00
|
|
|
|
2013-12-17 03:21:55 +11:00
|
|
|
*r_open = true;
|
2009-04-16 21:39:45 +00:00
|
|
|
|
|
|
|
return pa;
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
void uiEndPanel(uiBlock *block, int width, int height)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
Panel *pa = block->panel;
|
2009-04-16 21:39:45 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pa->runtime_flag & PNL_NEW_ADDED) {
|
2009-06-16 01:08:39 +00:00
|
|
|
pa->runtime_flag &= ~PNL_NEW_ADDED;
|
2012-03-30 01:51:25 +00:00
|
|
|
pa->sizex = width;
|
|
|
|
pa->sizey = height;
|
2009-04-16 21:39:45 +00:00
|
|
|
}
|
2009-07-15 22:58:34 +00:00
|
|
|
else {
|
|
|
|
/* check if we need to do an animation */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!ELEM(width, 0, pa->sizex) || !ELEM(height, 0, pa->sizey)) {
|
2009-06-16 01:08:39 +00:00
|
|
|
pa->runtime_flag |= PNL_ANIM_ALIGN;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (height != 0)
|
2012-03-30 01:51:25 +00:00
|
|
|
pa->ofsy += pa->sizey - height;
|
2009-06-16 01:08:39 +00:00
|
|
|
}
|
2009-04-16 21:39:45 +00:00
|
|
|
|
2009-07-15 22:58:34 +00:00
|
|
|
/* update width/height if non-zero */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (width != 0)
|
2012-03-30 01:51:25 +00:00
|
|
|
pa->sizex = width;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (height != 0)
|
2012-03-30 01:51:25 +00:00
|
|
|
pa->sizey = height;
|
2009-06-16 01:08:39 +00:00
|
|
|
}
|
2009-04-16 21:39:45 +00:00
|
|
|
}
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
static void ui_offset_panel_block(uiBlock *block)
|
2008-12-26 13:11:04 +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
|
|
|
uiStyle *style = UI_GetStyleDraw();
|
2008-12-26 13:11:04 +00:00
|
|
|
uiBut *but;
|
2009-05-20 14:46:49 +00:00
|
|
|
int ofsy;
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2009-05-20 14:46:49 +00:00
|
|
|
/* compute bounds and offset */
|
2.5: UI & Menus
* Cleaned up UI_interface.h a bit, and added some comments to
organize things a bit and indicate what should be used when.
* uiMenu* functions can now be used to create menus for headers
too, this is done with a uiDefMenuBut, which takes a pointer
to a uiMenuCreateFunc, that will then call uiMenu* functions.
* Renamed uiMenuBegin/End to uiPupMenuBegin/End, as these are
specific to making popup menus. Will convert the other
conformation popup menu functions to use this too so we can
remove some code.
* Extended uiMenu functions, now there is is also:
BooleanO, FloatO, BooleanR, EnumR, LevelEnumR, Separator.
* Converted image window headers to use uiMenu functions, simplifies
menu code further here. Did not remove the uiDefMenu functions as
they are used in sequencer/view3d in some places now (will fix).
* Also tried to simplify and fix bounds computation a bit better
for popup menus. It tried to find out in advance what the size
of the menu was but this is difficult with keymap strings in
there, now uiPopupBoundsBlock can figure this out afterwards and
ensure the popup is within the window bounds. Will convert some
other functions to use this too.
2009-01-30 12:18:08 +00:00
|
|
|
ui_bounds_block(block);
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
ofsy = block->panel->sizey - style->panelspace;
|
2009-05-20 14:46:49 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (but = block->buttons.first; but; but = but->next) {
|
2012-08-18 16:53:46 +00:00
|
|
|
but->rect.ymin += ofsy;
|
|
|
|
but->rect.ymax += ofsy;
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
|
2012-08-18 16:53:46 +00:00
|
|
|
block->rect.xmax = block->panel->sizex;
|
|
|
|
block->rect.ymax = block->panel->sizey;
|
|
|
|
block->rect.xmin = block->rect.ymin = 0.0;
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
/**************************** drawing *******************************/
|
|
|
|
|
2008-12-26 13:11:04 +00:00
|
|
|
/* extern used by previewrender */
|
2011-02-17 22:34:41 +00:00
|
|
|
#if 0 /*UNUSED 2.5*/
|
2011-02-13 14:16:36 +00:00
|
|
|
static void uiPanelPush(uiBlock *block)
|
2008-12-26 13:11:04 +00:00
|
|
|
{
|
|
|
|
glPushMatrix();
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (block->panel)
|
2008-12-26 13:11:04 +00:00
|
|
|
glTranslatef((float)block->panel->ofsx, (float)block->panel->ofsy, 0.0);
|
|
|
|
}
|
|
|
|
|
2011-02-13 14:16:36 +00:00
|
|
|
static void uiPanelPop(uiBlock *UNUSED(block))
|
2008-12-26 13:11:04 +00:00
|
|
|
{
|
|
|
|
glPopMatrix();
|
|
|
|
}
|
2011-02-17 22:34:41 +00:00
|
|
|
#endif
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
/* triangle 'icon' for panel header */
|
2011-02-13 14:16:36 +00:00
|
|
|
void UI_DrawTriIcon(float x, float y, char dir)
|
2008-12-26 13:11:04 +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 f3 = 0.15 * U.widget_unit;
|
|
|
|
float f5 = 0.25 * U.widget_unit;
|
|
|
|
float f7 = 0.35 * U.widget_unit;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (dir == 'h') {
|
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
|
|
|
ui_draw_anti_tria(x - f3, y - f5, x - f3, y + f5, x + f7, y);
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
2012-03-30 01:51:25 +00:00
|
|
|
else if (dir == 't') {
|
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
|
|
|
ui_draw_anti_tria(x - f5, y - f7, x + f5, y - f7, x, y + f3);
|
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
|
|
|
}
|
|
|
|
else { /* 'v' = vertical, down */
|
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
|
|
|
ui_draw_anti_tria(x - f5, y + f3, x + f5, y + f3, x, y - f7);
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-12 13:40:29 +00:00
|
|
|
/* triangle 'icon' inside rect */
|
2012-09-15 11:48:20 +00:00
|
|
|
static void ui_draw_tria_rect(const rctf *rect, char dir)
|
2009-04-12 13:40:29 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
if (dir == 'h') {
|
2012-09-15 11:48:20 +00:00
|
|
|
float half = 0.5f * BLI_rctf_size_y(rect);
|
2012-03-30 01:51:25 +00:00
|
|
|
ui_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, rect->ymax, rect->xmax, rect->ymin + half);
|
2009-04-12 13:40:29 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-09-15 11:48:20 +00:00
|
|
|
float half = 0.5f * BLI_rctf_size_x(rect);
|
2012-03-30 01:51:25 +00:00
|
|
|
ui_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, rect->ymax, rect->xmin + half, rect->ymin);
|
2009-04-12 13:40:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-13 14:16:36 +00:00
|
|
|
static void ui_draw_anti_x(float x1, float y1, float x2, float y2)
|
2008-12-26 13:11:04 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/* set antialias line */
|
2009-04-16 21:39:45 +00:00
|
|
|
glEnable(GL_LINE_SMOOTH);
|
|
|
|
glEnable(GL_BLEND);
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
glLineWidth(2.0);
|
|
|
|
|
|
|
|
fdrawline(x1, y1, x2, y2);
|
|
|
|
fdrawline(x1, y2, x2, y1);
|
|
|
|
|
|
|
|
glLineWidth(1.0);
|
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
glDisable(GL_LINE_SMOOTH);
|
|
|
|
glDisable(GL_BLEND);
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* x 'icon' for panel header */
|
|
|
|
static void ui_draw_x_icon(float x, float y)
|
|
|
|
{
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
ui_draw_anti_x(x, y, x + 9.375f, y + 9.375f);
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
#define PNL_ICON UI_UNIT_X /* could be UI_UNIT_Y too */
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2013-12-07 15:47:57 +11:00
|
|
|
static void ui_draw_panel_scalewidget(const rcti *rect)
|
2008-12-26 13:11:04 +00:00
|
|
|
{
|
|
|
|
float xmin, xmax, dx;
|
|
|
|
float ymin, ymax, dy;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
xmin = rect->xmax - PNL_HEADER + 2;
|
|
|
|
xmax = rect->xmax - 3;
|
|
|
|
ymin = rect->ymin + 3;
|
|
|
|
ymax = rect->ymin + PNL_HEADER - 2;
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
dx = 0.5f * (xmax - xmin);
|
|
|
|
dy = 0.5f * (ymax - ymin);
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glColor4ub(255, 255, 255, 50);
|
|
|
|
fdrawline(xmin, ymin, xmax, ymax);
|
2012-03-30 01:51:25 +00:00
|
|
|
fdrawline(xmin + dx, ymin, xmax, ymax - dy);
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
glColor4ub(0, 0, 0, 50);
|
2012-03-30 01:51:25 +00:00
|
|
|
fdrawline(xmin, ymin + 1, xmax, ymax + 1);
|
|
|
|
fdrawline(xmin + dx, ymin + 1, xmax, ymax - dy + 1);
|
2008-12-26 13:11:04 +00:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
|
|
|
|
2012-08-18 20:54:43 +00:00
|
|
|
static void ui_draw_panel_dragwidget(const rctf *rect)
|
2009-04-08 16:51:35 +00:00
|
|
|
{
|
|
|
|
float xmin, xmax, dx;
|
|
|
|
float ymin, ymax, dy;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
xmin = rect->xmin;
|
|
|
|
xmax = rect->xmax;
|
|
|
|
ymin = rect->ymin;
|
|
|
|
ymax = rect->ymax;
|
2009-04-08 16:51:35 +00:00
|
|
|
|
2013-02-14 17:35:43 +00:00
|
|
|
dx = (xmax - xmin) / 3.0f;
|
|
|
|
dy = (ymax - ymin) / 3.0f;
|
2009-04-08 16:51:35 +00:00
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glColor4ub(255, 255, 255, 50);
|
|
|
|
fdrawline(xmin, ymax, xmax, ymin);
|
2012-03-30 01:51:25 +00:00
|
|
|
fdrawline(xmin + dx, ymax, xmax, ymin + dy);
|
|
|
|
fdrawline(xmin + 2 * dx, ymax, xmax, ymin + 2 * dy);
|
2009-04-08 16:51:35 +00:00
|
|
|
|
|
|
|
glColor4ub(0, 0, 0, 50);
|
2012-03-30 01:51:25 +00:00
|
|
|
fdrawline(xmin, ymax + 1, xmax, ymin + 1);
|
|
|
|
fdrawline(xmin + dx, ymax + 1, xmax, ymin + dy + 1);
|
|
|
|
fdrawline(xmin + 2 * dx, ymax + 1, xmax, ymin + 2 * dy + 1);
|
2009-04-08 16:51:35 +00:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-07 15:47:57 +11:00
|
|
|
static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, const rcti *rect, char dir)
|
2009-04-08 16:51:35 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
Panel *panel = block->panel;
|
2009-04-09 18:11:18 +00:00
|
|
|
rcti hrect;
|
2012-03-30 01:51:25 +00:00
|
|
|
int pnl_icons;
|
2013-03-15 14:32:29 +00:00
|
|
|
const char *activename = panel->drawname[0] ? panel->drawname : panel->panelname;
|
2011-09-15 13:20:18 +00:00
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
/* + 0.001f to avoid flirting with float inaccuracy */
|
2013-06-24 12:18:28 +00:00
|
|
|
if (panel->control & UI_PNL_CLOSE)
|
|
|
|
pnl_icons = (panel->labelofs + 2 * PNL_ICON + 5) / block->aspect + 0.001f;
|
|
|
|
else
|
|
|
|
pnl_icons = (panel->labelofs + PNL_ICON + 5) / block->aspect + 0.001f;
|
2009-04-08 16:51:35 +00:00
|
|
|
|
2009-10-19 03:54:30 +00:00
|
|
|
/* active tab */
|
|
|
|
/* draw text label */
|
|
|
|
UI_ThemeColor(TH_TITLE);
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
hrect = *rect;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (dir == 'h') {
|
2012-03-30 01:51:25 +00:00
|
|
|
hrect.xmin = rect->xmin + pnl_icons;
|
|
|
|
hrect.ymin += 2.0f / block->aspect;
|
2009-04-10 14:06:24 +00:00
|
|
|
uiStyleFontDraw(&style->paneltitle, &hrect, activename);
|
2009-04-08 16:51:35 +00:00
|
|
|
}
|
2009-10-19 03:54:30 +00:00
|
|
|
else {
|
|
|
|
/* ignore 'pnl_icons', otherwise the text gets offset horizontally
|
|
|
|
* + 0.001f to avoid flirting with float inaccuracy
|
|
|
|
*/
|
2012-03-30 01:51:25 +00:00
|
|
|
hrect.xmin = rect->xmin + (PNL_ICON + 5) / block->aspect + 0.001f;
|
2009-10-19 03:54:30 +00:00
|
|
|
uiStyleFontDrawRotated(&style->paneltitle, &hrect, activename);
|
2009-04-08 16:51:35 +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
|
|
|
/* panel integrated in buttonswindow, tool/property lists etc */
|
2013-12-17 03:21:55 +11:00
|
|
|
void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, const bool show_pin)
|
2009-04-02 15:01:11 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
Panel *panel = block->panel;
|
2009-04-12 13:40:29 +00:00
|
|
|
rcti headrect;
|
|
|
|
rctf itemrect;
|
2009-04-02 15:01:11 +00:00
|
|
|
int ofsx;
|
2013-06-24 12:18:28 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (panel->paneltab) return;
|
|
|
|
if (panel->type && (panel->type->flag & PNL_NO_HEADER)) return;
|
2009-04-16 21:39:45 +00:00
|
|
|
|
2009-04-12 13:40:29 +00:00
|
|
|
/* calculate header rect */
|
2009-05-19 17:13:33 +00:00
|
|
|
/* + 0.001f to prevent flicker due to float inaccuracy */
|
2012-03-30 01:51:25 +00:00
|
|
|
headrect = *rect;
|
2012-03-24 02:51:46 +00:00
|
|
|
headrect.ymin = headrect.ymax;
|
2012-03-30 01:51:25 +00:00
|
|
|
headrect.ymax = headrect.ymin + floor(PNL_HEADER / block->aspect + 0.001f);
|
2013-06-24 12:18:28 +00:00
|
|
|
|
2011-11-19 20:57:53 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
float minx = rect->xmin;
|
|
|
|
float maxx = rect->xmax;
|
|
|
|
float y = headrect.ymax;
|
2011-11-19 20:57:53 +00:00
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
glEnable(GL_BLEND);
|
2013-06-24 12:18:28 +00:00
|
|
|
|
2012-12-15 16:22:18 +00:00
|
|
|
if (UI_GetThemeValue(TH_PANEL_SHOW_HEADER)) {
|
2011-11-19 20:57:53 +00:00
|
|
|
/* draw with background color */
|
2012-12-15 16:22:18 +00:00
|
|
|
UI_ThemeColor4(TH_PANEL_HEADER);
|
2012-03-30 01:51:25 +00:00
|
|
|
glRectf(minx, headrect.ymin + 1, maxx, y);
|
2011-11-19 20:57:53 +00:00
|
|
|
|
|
|
|
fdrawline(minx, y, maxx, y);
|
|
|
|
fdrawline(minx, y, maxx, y);
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (!(panel->runtime_flag & PNL_FIRST)) {
|
2011-11-19 20:57:53 +00:00
|
|
|
/* draw embossed separator */
|
2012-03-30 01:51:25 +00:00
|
|
|
minx += 5.0f / block->aspect;
|
|
|
|
maxx -= 5.0f / block->aspect;
|
2013-06-24 12:18:28 +00:00
|
|
|
|
2011-11-19 20:57:53 +00:00
|
|
|
glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
|
|
|
|
fdrawline(minx, y, maxx, y);
|
2011-11-29 23:00:10 +00:00
|
|
|
glColor4f(1.0f, 1.0f, 1.0f, 0.25f);
|
2012-03-30 01:51:25 +00:00
|
|
|
fdrawline(minx, y - 1, maxx, y - 1);
|
2011-11-19 20:57:53 +00:00
|
|
|
}
|
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
2013-06-24 12:18:28 +00:00
|
|
|
|
2013-12-17 03:21:55 +11:00
|
|
|
/* draw optional pin icon */
|
|
|
|
|
|
|
|
#ifdef USE_PIN_HIDDEN
|
|
|
|
if (show_pin && (block->panel->flag & PNL_PIN))
|
|
|
|
#else
|
|
|
|
if (show_pin)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
UI_icon_draw_aspect(headrect.xmax - ((PNL_ICON * 2.2f) / block->aspect), headrect.ymin + (5.0f / block->aspect),
|
|
|
|
(panel->flag & PNL_PIN) ? ICON_PINNED : ICON_UNPINNED,
|
2014-01-15 04:56:37 +11:00
|
|
|
(block->aspect / UI_DPI_FAC), 1.0f);
|
2013-12-17 03:21:55 +11:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
|
|
|
|
2009-10-19 03:54:30 +00:00
|
|
|
/* horizontal title */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!(panel->flag & PNL_CLOSEDX)) {
|
2010-10-16 02:40:31 +00:00
|
|
|
ui_draw_aligned_panel_header(style, block, &headrect, 'h');
|
2013-06-24 12:18:28 +00:00
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
/* itemrect smaller */
|
2012-03-30 01:51:25 +00:00
|
|
|
itemrect.xmax = headrect.xmax - 5.0f / block->aspect;
|
2012-09-15 11:48:20 +00:00
|
|
|
itemrect.xmin = itemrect.xmax - BLI_rcti_size_y(&headrect);
|
2012-03-24 02:51:46 +00:00
|
|
|
itemrect.ymin = headrect.ymin;
|
|
|
|
itemrect.ymax = headrect.ymax;
|
2011-11-19 20:57:53 +00:00
|
|
|
|
2013-12-03 23:53:21 +11:00
|
|
|
BLI_rctf_scale(&itemrect, 0.7f);
|
2009-04-12 13:40:29 +00:00
|
|
|
ui_draw_panel_dragwidget(&itemrect);
|
2009-04-02 15:01:11 +00:00
|
|
|
}
|
2013-06-24 12:18:28 +00:00
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
/* if the panel is minimized vertically:
|
2012-03-03 16:31:46 +00:00
|
|
|
* (------)
|
|
|
|
*/
|
2012-03-24 06:38:07 +00:00
|
|
|
if (panel->flag & PNL_CLOSEDY) {
|
2009-04-02 15:01:11 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (panel->flag & PNL_CLOSEDX) {
|
2009-10-19 03:54:30 +00:00
|
|
|
/* draw vertical title */
|
2010-10-16 02:40:31 +00:00
|
|
|
ui_draw_aligned_panel_header(style, block, &headrect, 'v');
|
2009-04-02 15:01:11 +00:00
|
|
|
}
|
|
|
|
/* an open panel */
|
|
|
|
else {
|
|
|
|
/* in some occasions, draw a border */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (panel->flag & PNL_SELECT) {
|
|
|
|
if (panel->control & UI_PNL_SOLID) uiSetRoundBox(UI_CNR_ALL);
|
2011-11-19 20:57:53 +00:00
|
|
|
else uiSetRoundBox(UI_CNR_NONE);
|
2013-06-24 12:18:28 +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
|
|
|
UI_ThemeColorShade(TH_BACK, -120);
|
2012-03-30 01:51:25 +00:00
|
|
|
uiRoundRect(0.5f + rect->xmin, 0.5f + rect->ymin, 0.5f + rect->xmax, 0.5f + headrect.ymax + 1, 8);
|
2009-04-02 15:01:11 +00:00
|
|
|
}
|
2013-06-24 12:18:28 +00:00
|
|
|
|
2012-12-15 16:22:18 +00:00
|
|
|
/* panel backdrop */
|
|
|
|
if (UI_GetThemeValue(TH_PANEL_SHOW_BACK)) {
|
|
|
|
/* draw with background color */
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
UI_ThemeColor4(TH_PANEL_BACK);
|
|
|
|
glRecti(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
|
|
|
|
}
|
2013-06-24 12:18:28 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (panel->control & UI_PNL_SCALE)
|
2009-04-09 18:11:18 +00:00
|
|
|
ui_draw_panel_scalewidget(rect);
|
2009-04-02 15:01:11 +00:00
|
|
|
}
|
2013-06-24 12:18:28 +00:00
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
/* draw optional close icon */
|
2013-06-24 12:18:28 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
ofsx = 6;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (panel->control & UI_PNL_CLOSE) {
|
2013-06-24 12:18:28 +00:00
|
|
|
UI_ThemeColor(TH_TITLE);
|
2012-03-30 01:51:25 +00:00
|
|
|
ui_draw_x_icon(rect->xmin + 2 + ofsx, rect->ymax + 2);
|
|
|
|
ofsx = 22;
|
2009-04-02 15:01:11 +00:00
|
|
|
}
|
2013-06-24 12:18:28 +00:00
|
|
|
|
2009-04-02 15:01:11 +00:00
|
|
|
/* draw collapse icon */
|
2013-06-24 12:18:28 +00:00
|
|
|
UI_ThemeColor(TH_TITLE);
|
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
/* itemrect smaller */
|
2012-03-30 01:51:25 +00:00
|
|
|
itemrect.xmin = headrect.xmin + 5.0f / block->aspect;
|
2012-09-15 11:48:20 +00:00
|
|
|
itemrect.xmax = itemrect.xmin + BLI_rcti_size_y(&headrect);
|
2012-03-24 02:51:46 +00:00
|
|
|
itemrect.ymin = headrect.ymin;
|
|
|
|
itemrect.ymax = headrect.ymax;
|
2013-06-24 12:18:28 +00:00
|
|
|
|
2013-12-03 23:53:21 +11:00
|
|
|
BLI_rctf_scale(&itemrect, 0.35f);
|
2013-06-24 12:18:28 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (panel->flag & PNL_CLOSEDY)
|
2009-04-12 13:40:29 +00:00
|
|
|
ui_draw_tria_rect(&itemrect, 'h');
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (panel->flag & PNL_CLOSEDX)
|
2009-04-12 13:40:29 +00:00
|
|
|
ui_draw_tria_rect(&itemrect, 'h');
|
2009-04-02 15:01:11 +00:00
|
|
|
else
|
2009-04-12 13:40:29 +00:00
|
|
|
ui_draw_tria_rect(&itemrect, 'v');
|
2011-07-26 19:47:56 +00:00
|
|
|
|
|
|
|
(void)ofsx;
|
2009-04-02 15:01:11 +00:00
|
|
|
}
|
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
/************************** panel alignment *************************/
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2009-07-08 15:34:41 +00:00
|
|
|
static int get_panel_header(Panel *pa)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pa->type && (pa->type->flag & PNL_NO_HEADER))
|
2009-07-08 15:34:41 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return PNL_HEADER;
|
|
|
|
}
|
|
|
|
|
2011-11-19 20:57:53 +00:00
|
|
|
static int get_panel_size_y(Panel *pa)
|
2009-07-09 19:45:27 +00:00
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pa->type && (pa->type->flag & PNL_NO_HEADER))
|
2009-07-09 19:45:27 +00:00
|
|
|
return pa->sizey;
|
|
|
|
|
2011-11-19 20:57:53 +00:00
|
|
|
return PNL_HEADER + pa->sizey;
|
2009-07-09 19:45:27 +00:00
|
|
|
}
|
|
|
|
|
2012-03-18 07:38:51 +00:00
|
|
|
/* this function is needed because uiBlock and Panel itself don't
|
2012-03-03 16:31:46 +00:00
|
|
|
* change sizey or location when closed */
|
2008-12-26 13:11:04 +00:00
|
|
|
static int get_panel_real_ofsy(Panel *pa)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
if (pa->flag & PNL_CLOSEDY) return pa->ofsy + pa->sizey;
|
|
|
|
else if (pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDY)) return pa->ofsy + pa->sizey;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (pa->paneltab) return pa->paneltab->ofsy;
|
2008-12-26 13:11:04 +00:00
|
|
|
else return pa->ofsy;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int get_panel_real_ofsx(Panel *pa)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
if (pa->flag & PNL_CLOSEDX) return pa->ofsx + get_panel_header(pa);
|
|
|
|
else if (pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDX)) return pa->ofsx + get_panel_header(pa);
|
|
|
|
else return pa->ofsx + pa->sizex;
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct PanelSort {
|
|
|
|
Panel *pa, *orig;
|
|
|
|
} PanelSort;
|
|
|
|
|
|
|
|
/* note about sorting;
|
2012-03-03 16:31:46 +00:00
|
|
|
* the sortorder has a lower value for new panels being added.
|
|
|
|
* however, that only works to insert a single panel, when more new panels get
|
2012-03-04 04:35:12 +00:00
|
|
|
* added the coordinates of existing panels and the previously stored to-be-inserted
|
2012-03-03 16:31:46 +00:00
|
|
|
* panels do not match for sorting */
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
static int find_leftmost_panel(const void *a1, const void *a2)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
const PanelSort *ps1 = a1, *ps2 = a2;
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ps1->pa->ofsx > ps2->pa->ofsx) return 1;
|
|
|
|
else if (ps1->pa->ofsx < ps2->pa->ofsx) return -1;
|
|
|
|
else if (ps1->pa->sortorder > ps2->pa->sortorder) return 1;
|
|
|
|
else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1;
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int find_highest_panel(const void *a1, const void *a2)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
const PanelSort *ps1 = a1, *ps2 = a2;
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2010-06-09 07:55:49 +00:00
|
|
|
/* stick uppermost header-less panels to the top of the region -
|
|
|
|
* prevent them from being sorted */
|
|
|
|
if (ps1->pa->sortorder < ps2->pa->sortorder && ps1->pa->type->flag & PNL_NO_HEADER) return -1;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (ps1->pa->ofsy + ps1->pa->sizey < ps2->pa->ofsy + ps2->pa->sizey) return 1;
|
|
|
|
else if (ps1->pa->ofsy + ps1->pa->sizey > ps2->pa->ofsy + ps2->pa->sizey) return -1;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ps1->pa->sortorder > ps2->pa->sortorder) return 1;
|
|
|
|
else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1;
|
2009-04-16 21:39:45 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int compare_panel(const void *a1, const void *a2)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
const PanelSort *ps1 = a1, *ps2 = a2;
|
2009-04-16 21:39:45 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ps1->pa->sortorder > ps2->pa->sortorder) return 1;
|
|
|
|
else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1;
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this doesnt draw */
|
|
|
|
/* returns 1 when it did something */
|
2014-01-04 17:16:19 +11:00
|
|
|
static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bool drag)
|
2008-12-26 13:11:04 +00:00
|
|
|
{
|
|
|
|
Panel *pa;
|
|
|
|
PanelSort *ps, *panelsort, *psnext;
|
2014-01-04 17:16:19 +11:00
|
|
|
int a, tot = 0;
|
|
|
|
bool done;
|
2012-03-30 01:51:25 +00:00
|
|
|
int align = panel_aligned(sa, ar);
|
2013-12-17 03:21:55 +11:00
|
|
|
bool has_category_tabs = UI_panel_category_is_visible(ar);
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
/* count active, not tabbed panels */
|
2012-03-30 01:51:25 +00:00
|
|
|
for (pa = ar->panels.first; pa; pa = pa->next)
|
|
|
|
if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL)
|
2009-04-16 21:39:45 +00:00
|
|
|
tot++;
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (tot == 0) return 0;
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
/* extra; change close direction? */
|
2012-03-30 01:51:25 +00:00
|
|
|
for (pa = ar->panels.first; pa; pa = pa->next) {
|
|
|
|
if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL) {
|
|
|
|
if ((pa->flag & PNL_CLOSEDX) && (align == BUT_VERTICAL))
|
2008-12-26 13:11:04 +00:00
|
|
|
pa->flag ^= PNL_CLOSED;
|
2012-03-30 01:51:25 +00:00
|
|
|
else if ((pa->flag & PNL_CLOSEDY) && (align == BUT_HORIZONTAL))
|
2008-12-26 13:11:04 +00:00
|
|
|
pa->flag ^= PNL_CLOSED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
/* sort panels */
|
2012-03-30 01:51:25 +00:00
|
|
|
panelsort = MEM_callocN(tot * sizeof(PanelSort), "panelsort");
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
ps = panelsort;
|
|
|
|
for (pa = ar->panels.first; pa; pa = pa->next) {
|
|
|
|
if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL) {
|
|
|
|
ps->pa = MEM_dupallocN(pa);
|
|
|
|
ps->orig = pa;
|
2008-12-26 13:11:04 +00:00
|
|
|
ps++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (drag) {
|
2009-04-17 11:59:25 +00:00
|
|
|
/* while we are dragging, we sort on location and update sortorder */
|
2012-03-30 01:51:25 +00:00
|
|
|
if (align == BUT_VERTICAL)
|
2009-04-17 11:59:25 +00:00
|
|
|
qsort(panelsort, tot, sizeof(PanelSort), find_highest_panel);
|
|
|
|
else
|
|
|
|
qsort(panelsort, tot, sizeof(PanelSort), find_leftmost_panel);
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (ps = panelsort, a = 0; a < tot; a++, ps++)
|
|
|
|
ps->orig->sortorder = a;
|
2009-04-17 11:59:25 +00:00
|
|
|
}
|
2008-12-26 13:11:04 +00:00
|
|
|
else
|
2009-04-17 11:59:25 +00:00
|
|
|
/* otherwise use sortorder */
|
|
|
|
qsort(panelsort, tot, sizeof(PanelSort), compare_panel);
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
/* no smart other default start loc! this keeps switching f5/f6/etc compatible */
|
2012-03-30 01:51:25 +00:00
|
|
|
ps = panelsort;
|
|
|
|
ps->pa->ofsx = 0;
|
|
|
|
ps->pa->ofsy = -get_panel_size_y(ps->pa);
|
2009-04-02 01:39:33 +00:00
|
|
|
|
2013-12-17 03:21:55 +11:00
|
|
|
if (has_category_tabs) {
|
|
|
|
if (align == BUT_VERTICAL) {
|
|
|
|
ps->pa->ofsx += UI_PANEL_CATEGORY_MARGIN_WIDTH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < tot - 1; a++, ps++) {
|
|
|
|
psnext = ps + 1;
|
|
|
|
|
|
|
|
if (align == BUT_VERTICAL) {
|
|
|
|
psnext->pa->ofsx = ps->pa->ofsx;
|
|
|
|
psnext->pa->ofsy = get_panel_real_ofsy(ps->pa) - get_panel_size_y(psnext->pa);
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
psnext->pa->ofsx = get_panel_real_ofsx(ps->pa);
|
|
|
|
psnext->pa->ofsy = ps->pa->ofsy + get_panel_size_y(ps->pa) - get_panel_size_y(psnext->pa);
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we interpolate */
|
2014-01-04 17:16:19 +11:00
|
|
|
done = false;
|
2012-03-30 01:51:25 +00:00
|
|
|
ps = panelsort;
|
|
|
|
for (a = 0; a < tot; a++, ps++) {
|
|
|
|
if ((ps->pa->flag & PNL_SELECT) == 0) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((ps->orig->ofsx != ps->pa->ofsx) || (ps->orig->ofsy != ps->pa->ofsy)) {
|
2014-01-15 13:00:03 +11:00
|
|
|
ps->orig->ofsx = iroundf(fac * (float)ps->pa->ofsx + (1.0f - fac) * (float)ps->orig->ofsx);
|
|
|
|
ps->orig->ofsy = iroundf(fac * (float)ps->pa->ofsy + (1.0f - fac) * (float)ps->orig->ofsy);
|
2014-01-04 17:16:19 +11:00
|
|
|
done = true;
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* copy locations to tabs */
|
2012-03-30 01:51:25 +00:00
|
|
|
for (pa = ar->panels.first; pa; pa = pa->next)
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pa->paneltab && (pa->runtime_flag & PNL_ACTIVE))
|
2009-04-16 21:39:45 +00:00
|
|
|
ui_panel_copy_offset(pa, pa->paneltab);
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
/* free panelsort array */
|
2012-01-21 22:00:40 +00:00
|
|
|
for (ps = panelsort, a = 0; a < tot; a++, ps++) {
|
2008-12-26 13:11:04 +00:00
|
|
|
MEM_freeN(ps->pa);
|
2012-01-21 22:00:40 +00:00
|
|
|
}
|
2008-12-26 13:11:04 +00:00
|
|
|
MEM_freeN(panelsort);
|
|
|
|
|
|
|
|
return done;
|
|
|
|
}
|
|
|
|
|
2011-11-20 14:31:01 +00:00
|
|
|
static void ui_panels_size(ScrArea *sa, ARegion *ar, int *x, int *y)
|
|
|
|
{
|
|
|
|
Panel *pa;
|
2012-03-30 01:51:25 +00:00
|
|
|
int align = panel_aligned(sa, ar);
|
2012-12-26 13:05:39 +00:00
|
|
|
int sizex = 0;
|
|
|
|
int sizey = 0;
|
2011-11-20 14:31:01 +00:00
|
|
|
|
|
|
|
/* compute size taken up by panels, for setting in view2d */
|
2012-03-30 01:51:25 +00:00
|
|
|
for (pa = ar->panels.first; pa; pa = pa->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pa->runtime_flag & PNL_ACTIVE) {
|
2011-11-20 14:31:01 +00:00
|
|
|
int pa_sizex, pa_sizey;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (align == BUT_VERTICAL) {
|
|
|
|
pa_sizex = pa->ofsx + pa->sizex;
|
|
|
|
pa_sizey = get_panel_real_ofsy(pa);
|
2011-11-20 14:31:01 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
pa_sizex = get_panel_real_ofsx(pa) + pa->sizex;
|
|
|
|
pa_sizey = pa->ofsy + get_panel_size_y(pa);
|
2011-11-20 14:31:01 +00:00
|
|
|
}
|
|
|
|
|
2012-10-24 05:06:40 +00:00
|
|
|
sizex = max_ii(sizex, pa_sizex);
|
|
|
|
sizey = min_ii(sizey, pa_sizey);
|
2011-11-20 14:31:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-26 13:05:39 +00:00
|
|
|
if (sizex == 0)
|
|
|
|
sizex = UI_PANEL_WIDTH;
|
|
|
|
if (sizey == 0)
|
|
|
|
sizey = -UI_PANEL_WIDTH;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
*x = sizex;
|
|
|
|
*y = sizey;
|
2011-11-20 14:31:01 +00:00
|
|
|
}
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
static void ui_do_animate(const bContext *C, Panel *panel)
|
2008-12-26 13:11:04 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiHandlePanelData *data = panel->activedata;
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
ARegion *ar = CTX_wm_region(C);
|
2008-12-26 13:11:04 +00:00
|
|
|
float fac;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
fac = (PIL_check_seconds_timer() - data->starttime) / ANIMATION_TIME;
|
2012-10-23 13:28:22 +00:00
|
|
|
fac = min_ff(sqrt(fac), 1.0f);
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
/* for max 1 second, interpolate positions */
|
2014-01-04 17:16:19 +11:00
|
|
|
if (uiAlignPanelStep(sa, ar, fac, false)) {
|
2008-12-26 13:11:04 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
2012-07-29 16:59:51 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
fac = 1.0f;
|
2012-07-29 16:59:51 +00:00
|
|
|
}
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (fac >= 1.0f) {
|
2008-12-26 13:11:04 +00:00
|
|
|
panel_activate_state(C, panel, PANEL_STATE_EXIT);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-14 12:24:08 +00:00
|
|
|
void uiBeginPanels(const bContext *UNUSED(C), ARegion *ar)
|
2009-04-02 01:39:33 +00:00
|
|
|
{
|
|
|
|
Panel *pa;
|
2013-02-04 00:18:09 +00:00
|
|
|
|
2012-03-03 16:31:46 +00:00
|
|
|
/* set all panels as inactive, so that at the end we know
|
2009-04-02 01:39:33 +00:00
|
|
|
* which ones were used */
|
2012-03-30 01:51:25 +00:00
|
|
|
for (pa = ar->panels.first; pa; pa = pa->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pa->runtime_flag & PNL_ACTIVE)
|
2012-03-30 01:51:25 +00:00
|
|
|
pa->runtime_flag = PNL_WAS_ACTIVE;
|
2009-04-16 21:39:45 +00:00
|
|
|
else
|
2012-03-30 01:51:25 +00:00
|
|
|
pa->runtime_flag = 0;
|
2009-04-16 21:39:45 +00:00
|
|
|
}
|
2009-04-02 01:39:33 +00:00
|
|
|
}
|
|
|
|
|
2008-12-26 13:11:04 +00:00
|
|
|
/* only draws blocks with panels */
|
2011-11-20 14:31:01 +00:00
|
|
|
void uiEndPanels(const bContext *C, ARegion *ar, int *x, int *y)
|
2008-12-26 13:11:04 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
2008-12-26 13:11:04 +00:00
|
|
|
uiBlock *block;
|
2009-06-19 23:11:41 +00:00
|
|
|
Panel *panot, *panew, *patest, *pa, *firstpa;
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2009-05-20 14:46:49 +00:00
|
|
|
/* offset contents */
|
2012-03-30 01:51:25 +00:00
|
|
|
for (block = ar->uiblocks.first; block; block = block->next)
|
2012-03-24 06:38:07 +00:00
|
|
|
if (block->active && block->panel)
|
2009-05-19 17:13:33 +00:00
|
|
|
ui_offset_panel_block(block);
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2011-01-06 04:35:57 +00:00
|
|
|
/* consistency; are panels not made, whilst they have tabs */
|
2012-03-30 01:51:25 +00:00
|
|
|
for (panot = ar->panels.first; panot; panot = panot->next) {
|
2012-08-19 10:41:27 +00:00
|
|
|
if ((panot->runtime_flag & PNL_ACTIVE) == 0) { /* not made */
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (panew = ar->panels.first; panew; panew = panew->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((panew->runtime_flag & PNL_ACTIVE)) {
|
2012-08-19 10:41:27 +00:00
|
|
|
if (panew->paneltab == panot) { /* panew is tab in notmade pa */
|
2008-12-26 13:11:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* now panew can become the new parent, check all other tabs */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (panew) {
|
2012-03-30 01:51:25 +00:00
|
|
|
for (patest = ar->panels.first; patest; patest = patest->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (patest->paneltab == panot) {
|
2012-03-30 01:51:25 +00:00
|
|
|
patest->paneltab = panew;
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-30 01:51:25 +00:00
|
|
|
panot->paneltab = panew;
|
|
|
|
panew->paneltab = NULL;
|
2012-08-19 10:41:27 +00:00
|
|
|
ED_region_tag_redraw(ar); /* the buttons panew were not made */
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
/* re-align, possibly with animation */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (panels_re_align(sa, ar, &pa)) {
|
2012-12-20 19:18:46 +00:00
|
|
|
/* XXX code never gets here... PNL_ANIM_ALIGN flag is never set */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pa)
|
2009-04-16 21:39:45 +00:00
|
|
|
panel_activate_state(C, pa, PANEL_STATE_ANIMATION);
|
|
|
|
else
|
2014-01-04 17:16:19 +11:00
|
|
|
uiAlignPanelStep(sa, ar, 1.0, false);
|
2009-04-16 21:39:45 +00:00
|
|
|
}
|
2009-04-02 01:39:33 +00:00
|
|
|
|
2009-06-19 23:11:41 +00:00
|
|
|
/* tag first panel */
|
2012-03-30 01:51:25 +00:00
|
|
|
firstpa = NULL;
|
|
|
|
for (block = ar->uiblocks.first; block; block = block->next)
|
2012-03-24 06:38:07 +00:00
|
|
|
if (block->active && block->panel)
|
|
|
|
if (!firstpa || block->panel->sortorder < firstpa->sortorder)
|
2012-03-30 01:51:25 +00:00
|
|
|
firstpa = block->panel;
|
2009-06-19 23:11:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (firstpa)
|
2009-06-19 23:11:41 +00:00
|
|
|
firstpa->runtime_flag |= PNL_FIRST;
|
2011-11-20 14:31:01 +00:00
|
|
|
|
|
|
|
/* compute size taken up by panel */
|
|
|
|
ui_panels_size(sa, ar, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiDrawPanels(const bContext *C, ARegion *ar)
|
|
|
|
{
|
|
|
|
uiBlock *block;
|
2009-06-19 23:11:41 +00:00
|
|
|
|
2010-04-06 09:05:00 +00:00
|
|
|
UI_ThemeClearColor(TH_BACK);
|
|
|
|
|
2008-12-26 13:11:04 +00:00
|
|
|
/* draw panels, selected on top */
|
2012-03-30 01:51:25 +00:00
|
|
|
for (block = ar->uiblocks.first; block; block = block->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (block->active && block->panel && !(block->panel->flag & PNL_SELECT)) {
|
2008-12-26 13:11:04 +00:00
|
|
|
uiDrawBlock(C, block);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (block = ar->uiblocks.first; block; block = block->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (block->active && block->panel && (block->panel->flag & PNL_SELECT)) {
|
2008-12-26 13:11:04 +00:00
|
|
|
uiDrawBlock(C, block);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-26 13:05:39 +00:00
|
|
|
void uiScalePanels(ARegion *ar, float new_width)
|
|
|
|
{
|
|
|
|
uiBlock *block;
|
|
|
|
uiBut *but;
|
|
|
|
|
|
|
|
for (block = ar->uiblocks.first; block; block = block->next) {
|
|
|
|
if (block->panel) {
|
|
|
|
float fac = new_width / (float)block->panel->sizex;
|
2013-12-18 15:10:40 +01:00
|
|
|
printf("scaled %f\n", fac);
|
2012-12-26 13:05:39 +00:00
|
|
|
block->panel->sizex = new_width;
|
|
|
|
|
|
|
|
for (but = block->buttons.first; but; but = but->next) {
|
|
|
|
but->rect.xmin *= fac;
|
|
|
|
but->rect.xmax *= fac;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-26 13:11:04 +00:00
|
|
|
/* ------------ panel merging ---------------- */
|
|
|
|
|
|
|
|
static void check_panel_overlap(ARegion *ar, Panel *panel)
|
|
|
|
{
|
|
|
|
Panel *pa;
|
|
|
|
|
2012-05-27 19:40:36 +00:00
|
|
|
/* also called with (panel == NULL) for clear */
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (pa = ar->panels.first; pa; pa = pa->next) {
|
2008-12-26 13:11:04 +00:00
|
|
|
pa->flag &= ~PNL_OVERLAP;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (panel && (pa != panel)) {
|
2012-03-30 01:51:25 +00:00
|
|
|
if (pa->paneltab == NULL && (pa->runtime_flag & PNL_ACTIVE)) {
|
|
|
|
float safex = 0.2, safey = 0.2;
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (pa->flag & PNL_CLOSEDX) safex = 0.05;
|
|
|
|
else if (pa->flag & PNL_CLOSEDY) safey = 0.05;
|
|
|
|
else if (panel->flag & PNL_CLOSEDX) safex = 0.05;
|
|
|
|
else if (panel->flag & PNL_CLOSEDY) safey = 0.05;
|
|
|
|
|
|
|
|
if (pa->ofsx > panel->ofsx - safex * panel->sizex)
|
|
|
|
if (pa->ofsx + pa->sizex < panel->ofsx + (1.0f + safex) * panel->sizex)
|
|
|
|
if (pa->ofsy > panel->ofsy - safey * panel->sizey)
|
|
|
|
if (pa->ofsy + pa->sizey < panel->ofsy + (1.0f + safey) * panel->sizey)
|
|
|
|
pa->flag |= PNL_OVERLAP;
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
/************************ panel dragging ****************************/
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2013-02-01 01:01:20 +00:00
|
|
|
static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel)
|
2008-12-26 13:11:04 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiHandlePanelData *data = panel->activedata;
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
ARegion *ar = CTX_wm_region(C);
|
|
|
|
short align = panel_aligned(sa, ar), dx = 0, dy = 0;
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
/* first clip for window, no dragging outside */
|
2012-08-23 18:25:45 +00:00
|
|
|
if (!BLI_rcti_isect_pt_v(&ar->winrct, &event->x))
|
2008-12-26 13:11:04 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
dx = (event->x - data->startx) & ~(PNL_GRID - 1);
|
|
|
|
dy = (event->y - data->starty) & ~(PNL_GRID - 1);
|
2009-07-23 20:50:24 +00:00
|
|
|
|
2012-09-15 11:48:20 +00:00
|
|
|
dx *= (float)BLI_rctf_size_x(&ar->v2d.cur) / (float)BLI_rcti_size_x(&ar->winrct);
|
|
|
|
dy *= (float)BLI_rctf_size_y(&ar->v2d.cur) / (float)BLI_rcti_size_y(&ar->winrct);
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (data->state == PANEL_STATE_DRAG_SCALE) {
|
2012-03-30 01:51:25 +00:00
|
|
|
panel->sizex = MAX2(data->startsizex + dx, UI_PANEL_MINX);
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (data->startsizey - dy < UI_PANEL_MINY)
|
|
|
|
dy = -UI_PANEL_MINY + data->startsizey;
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
panel->sizey = data->startsizey - dy;
|
|
|
|
panel->ofsy = data->startofsy + dy;
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* reset the panel snapping, to allow dragging away from snapped edges */
|
|
|
|
panel->snap = PNL_SNAP_NONE;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
panel->ofsx = data->startofsx + dx;
|
|
|
|
panel->ofsy = data->startofsy + dy;
|
2008-12-26 13:11:04 +00:00
|
|
|
check_panel_overlap(ar, panel);
|
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
if (align) uiAlignPanelStep(sa, ar, 0.2, true);
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
}
|
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
/******************* region level panel interaction *****************/
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* this function is supposed to call general window drawing too */
|
2012-03-18 07:38:51 +00:00
|
|
|
/* also it supposes a block has panel, and isn't a menu */
|
2014-01-06 03:00:54 +11:00
|
|
|
static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, int my, int event, short ctrl, short shift)
|
2008-12-26 13:11:04 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
ARegion *ar = CTX_wm_region(C);
|
2008-12-26 13:11:04 +00:00
|
|
|
Panel *pa;
|
2013-12-17 03:21:55 +11:00
|
|
|
#ifdef USE_PIN_HIDDEN
|
|
|
|
const bool show_pin = UI_panel_category_is_visible(ar) && (block->panel->flag & PNL_PIN);
|
|
|
|
#else
|
|
|
|
const bool show_pin = UI_panel_category_is_visible(ar);
|
|
|
|
#endif
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
int align = panel_aligned(sa, ar), button = 0;
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2013-12-17 03:21:55 +11:00
|
|
|
rctf rect_drag, rect_pin;
|
|
|
|
float rect_leftmost;
|
|
|
|
|
|
|
|
|
|
|
|
/* drag and pin rect's */
|
|
|
|
rect_drag = block->rect;
|
|
|
|
rect_drag.xmin = block->rect.xmax - (PNL_ICON * 1.5f);
|
|
|
|
rect_pin = rect_drag;
|
|
|
|
if (show_pin) {
|
|
|
|
BLI_rctf_translate(&rect_pin, -PNL_ICON, 0.0f);
|
|
|
|
}
|
|
|
|
rect_leftmost = rect_pin.xmin;
|
|
|
|
|
2008-12-26 13:11:04 +00:00
|
|
|
/* mouse coordinates in panel space! */
|
|
|
|
|
2009-04-12 13:40:29 +00:00
|
|
|
/* XXX weak code, currently it assumes layout style for location of widgets */
|
|
|
|
|
2008-12-26 13:11:04 +00:00
|
|
|
/* check open/collapsed button */
|
2012-03-30 01:51:25 +00:00
|
|
|
if (event == RETKEY)
|
|
|
|
button = 1;
|
|
|
|
else if (event == AKEY)
|
|
|
|
button = 1;
|
2014-01-06 03:00:54 +11:00
|
|
|
else if (ELEM3(event, 0, RETKEY, LEFTMOUSE) && shift) {
|
2013-12-17 03:21:55 +11:00
|
|
|
block->panel->flag ^= PNL_PIN;
|
|
|
|
button = 2;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (block->panel->flag & PNL_CLOSEDX) {
|
2012-08-18 16:53:46 +00:00
|
|
|
if (my >= block->rect.ymax) button = 1;
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (block->panel->control & UI_PNL_CLOSE) {
|
2011-01-12 02:15:38 +00:00
|
|
|
/* whole of header can be used to collapse panel (except top-right corner) */
|
2012-08-18 16:53:46 +00:00
|
|
|
if (mx <= block->rect.xmax - 8 - PNL_ICON) button = 2;
|
|
|
|
//else if (mx <= block->rect.xmin + 10 + 2 * PNL_ICON + 2) button = 1;
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
2013-12-17 03:21:55 +11:00
|
|
|
else if (mx < rect_leftmost) {
|
2012-03-30 01:51:25 +00:00
|
|
|
button = 1;
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (button) {
|
2012-08-19 10:41:27 +00:00
|
|
|
if (button == 2) { /* close */
|
2008-12-26 13:11:04 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
}
|
2012-08-19 10:41:27 +00:00
|
|
|
else { /* collapse */
|
2012-12-20 00:29:31 +00:00
|
|
|
if (ctrl)
|
2012-12-18 14:46:00 +00:00
|
|
|
panels_collapse_all(sa, ar, block->panel);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (block->panel->flag & PNL_CLOSED) {
|
2008-12-26 13:11:04 +00:00
|
|
|
block->panel->flag &= ~PNL_CLOSED;
|
|
|
|
/* snap back up so full panel aligns with screen edge */
|
|
|
|
if (block->panel->snap & PNL_SNAP_BOTTOM)
|
2012-03-30 01:51:25 +00:00
|
|
|
block->panel->ofsy = 0;
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
2012-03-30 01:51:25 +00:00
|
|
|
else if (align == BUT_HORIZONTAL) {
|
2008-12-26 13:11:04 +00:00
|
|
|
block->panel->flag |= PNL_CLOSEDX;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* snap down to bottom screen edge*/
|
|
|
|
block->panel->flag |= PNL_CLOSEDY;
|
|
|
|
if (block->panel->snap & PNL_SNAP_BOTTOM)
|
2012-03-30 01:51:25 +00:00
|
|
|
block->panel->ofsy = -block->panel->sizey;
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (pa = ar->panels.first; pa; pa = pa->next) {
|
|
|
|
if (pa->paneltab == block->panel) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (block->panel->flag & PNL_CLOSED) pa->flag |= PNL_CLOSED;
|
2008-12-26 13:11:04 +00:00
|
|
|
else pa->flag &= ~PNL_CLOSED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (align)
|
2008-12-26 13:11:04 +00:00
|
|
|
panel_activate_state(C, block->panel, PANEL_STATE_ANIMATION);
|
|
|
|
else
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
}
|
2013-12-17 03:21:55 +11:00
|
|
|
else if (BLI_rctf_isect_x(&rect_drag, mx)) {
|
2008-12-26 13:11:04 +00:00
|
|
|
panel_activate_state(C, block->panel, PANEL_STATE_DRAG);
|
|
|
|
}
|
2013-12-17 03:21:55 +11:00
|
|
|
else if (show_pin && BLI_rctf_isect_x(&rect_pin, mx)) {
|
|
|
|
block->panel->flag ^= PNL_PIN;
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool UI_panel_category_is_visible(ARegion *ar)
|
|
|
|
{
|
|
|
|
/* more then one */
|
|
|
|
return ar->panels_category.first && ar->panels_category.first != ar->panels_category.last;
|
|
|
|
}
|
|
|
|
|
|
|
|
PanelCategoryDyn *UI_panel_category_find(ARegion *ar, const char *idname)
|
|
|
|
{
|
|
|
|
return BLI_findstring(&ar->panels_category, idname, offsetof(PanelCategoryDyn, idname));
|
|
|
|
}
|
|
|
|
|
|
|
|
PanelCategoryStack *UI_panel_category_active_find(ARegion *ar, const char *idname)
|
|
|
|
{
|
|
|
|
return BLI_findstring(&ar->panels_category_active, idname, offsetof(PanelCategoryStack, idname));
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *UI_panel_category_active_get(ARegion *ar, bool set_fallback)
|
|
|
|
{
|
|
|
|
PanelCategoryStack *pc_act;
|
|
|
|
|
|
|
|
for (pc_act = ar->panels_category_active.first; pc_act; pc_act = pc_act->next) {
|
|
|
|
if (UI_panel_category_find(ar, pc_act->idname)) {
|
|
|
|
return pc_act->idname;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (set_fallback) {
|
|
|
|
PanelCategoryDyn *pc_dyn = ar->panels_category.first;
|
|
|
|
if (pc_dyn) {
|
|
|
|
UI_panel_category_active_set(ar, pc_dyn->idname);
|
|
|
|
return pc_dyn->idname;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UI_panel_category_active_set(ARegion *ar, const char *idname)
|
|
|
|
{
|
|
|
|
ListBase *lb = &ar->panels_category_active;
|
|
|
|
PanelCategoryStack *pc_act = UI_panel_category_active_find(ar, idname);
|
|
|
|
|
|
|
|
if (pc_act) {
|
|
|
|
BLI_remlink(lb, pc_act);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pc_act = MEM_callocN(sizeof(PanelCategoryStack), __func__);
|
|
|
|
BLI_strncpy(pc_act->idname, idname, sizeof(pc_act->idname));
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_addhead(lb, pc_act);
|
|
|
|
|
|
|
|
|
|
|
|
/* validate all active panels, we could do this on load,
|
|
|
|
* they are harmless - but we should remove somewhere.
|
|
|
|
* (addons could define own and gather cruft over time) */
|
|
|
|
{
|
|
|
|
PanelCategoryStack *pc_act_next;
|
|
|
|
/* intentionally skip first */
|
|
|
|
pc_act_next = pc_act->next;
|
|
|
|
while ((pc_act = pc_act_next)) {
|
|
|
|
pc_act_next = pc_act->next;
|
|
|
|
if (!BLI_findstring(&ar->type->paneltypes, pc_act->idname, offsetof(PanelType, category))) {
|
|
|
|
BLI_remlink(lb, pc_act);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PanelCategoryDyn *UI_panel_category_find_mouse_over_ex(ARegion *ar, const int x, const int y)
|
|
|
|
{
|
|
|
|
PanelCategoryDyn *ptd;
|
|
|
|
|
|
|
|
for (ptd = ar->panels_category.first; ptd; ptd = ptd->next) {
|
|
|
|
if (BLI_rcti_isect_pt(&ptd->rect, x, y)) {
|
|
|
|
return ptd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PanelCategoryDyn *UI_panel_category_find_mouse_over(ARegion *ar, const wmEvent *event)
|
|
|
|
{
|
|
|
|
return UI_panel_category_find_mouse_over_ex(ar, event->mval[0], event->mval[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UI_panel_category_add(ARegion *ar, const char *name)
|
|
|
|
{
|
|
|
|
PanelCategoryDyn *pc_dyn = MEM_callocN(sizeof(*pc_dyn), __func__);
|
|
|
|
BLI_addtail(&ar->panels_category, pc_dyn);
|
|
|
|
|
|
|
|
BLI_strncpy(pc_dyn->idname, name, sizeof(pc_dyn->idname));
|
|
|
|
|
|
|
|
/* 'pc_dyn->rect' must be set on draw */
|
|
|
|
}
|
|
|
|
|
|
|
|
void UI_panel_category_clear_all(ARegion *ar)
|
|
|
|
{
|
|
|
|
BLI_freelistN(&ar->panels_category);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* based on uiDrawBox, check on making a version which allows us to skip some sides */
|
|
|
|
static void ui_panel_category_draw_tab(int mode, float minx, float miny, float maxx, float maxy, float rad,
|
|
|
|
int roundboxtype,
|
|
|
|
const bool use_highlight, const bool use_shadow,
|
|
|
|
const unsigned char highlight_fade[3])
|
|
|
|
{
|
|
|
|
float vec[4][2] = {
|
|
|
|
{0.195, 0.02},
|
|
|
|
{0.55, 0.169},
|
|
|
|
{0.831, 0.45},
|
|
|
|
{0.98, 0.805}};
|
|
|
|
int a;
|
|
|
|
|
|
|
|
/* mult */
|
|
|
|
for (a = 0; a < 4; a++) {
|
|
|
|
mul_v2_fl(vec[a], rad);
|
|
|
|
}
|
|
|
|
|
|
|
|
glBegin(mode);
|
|
|
|
|
|
|
|
/* start with corner right-top */
|
|
|
|
if (use_highlight) {
|
|
|
|
if (roundboxtype & UI_CNR_TOP_RIGHT) {
|
|
|
|
glVertex2f(maxx, maxy - rad);
|
|
|
|
for (a = 0; a < 4; a++) {
|
|
|
|
glVertex2f(maxx - vec[a][1], maxy - rad + vec[a][0]);
|
|
|
|
}
|
|
|
|
glVertex2f(maxx - rad, maxy);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
glVertex2f(maxx, maxy);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* corner left-top */
|
|
|
|
if (roundboxtype & UI_CNR_TOP_LEFT) {
|
|
|
|
glVertex2f(minx + rad, maxy);
|
|
|
|
for (a = 0; a < 4; a++) {
|
|
|
|
glVertex2f(minx + rad - vec[a][0], maxy - vec[a][1]);
|
|
|
|
}
|
|
|
|
glVertex2f(minx, maxy - rad);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
glVertex2f(minx, maxy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_highlight && !use_shadow) {
|
|
|
|
if (highlight_fade) {
|
|
|
|
glColor3ubv(highlight_fade);
|
|
|
|
}
|
|
|
|
glVertex2f(minx, miny + rad);
|
|
|
|
glEnd();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* corner left-bottom */
|
|
|
|
if (roundboxtype & UI_CNR_BOTTOM_LEFT) {
|
|
|
|
glVertex2f(minx, miny + rad);
|
|
|
|
for (a = 0; a < 4; a++) {
|
|
|
|
glVertex2f(minx + vec[a][1], miny + rad - vec[a][0]);
|
|
|
|
}
|
|
|
|
glVertex2f(minx + rad, miny);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
glVertex2f(minx, miny);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* corner right-bottom */
|
|
|
|
|
|
|
|
if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
|
|
|
|
glVertex2f(maxx - rad, miny);
|
|
|
|
for (a = 0; a < 4; a++) {
|
|
|
|
glVertex2f(maxx - rad + vec[a][0], miny + vec[a][1]);
|
|
|
|
}
|
|
|
|
glVertex2f(maxx, miny + rad);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
glVertex2f(maxx, miny);
|
|
|
|
}
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw vertical tabs on the left side of the region,
|
|
|
|
* one tab per category.
|
|
|
|
*/
|
|
|
|
void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
|
|
|
|
{
|
|
|
|
/* no tab outlines for */
|
2014-01-04 13:54:39 -06:00
|
|
|
// #define USE_FLAT_INACTIVE
|
2013-12-17 03:21:55 +11:00
|
|
|
View2D *v2d = &ar->v2d;
|
|
|
|
uiStyle *style = UI_GetStyle();
|
2014-01-04 13:55:40 +11:00
|
|
|
const uiFontStyle *fstyle = &style->widget;
|
|
|
|
const int fontid = fstyle->uifont_id;
|
|
|
|
short fstyle_points = fstyle->points;
|
2013-12-17 03:21:55 +11:00
|
|
|
|
|
|
|
PanelCategoryDyn *pc_dyn;
|
2014-01-04 13:55:40 +11:00
|
|
|
const float aspect = ((uiBlock *)ar->uiblocks.first)->aspect;
|
|
|
|
const float zoom = 1.0f / aspect;
|
2014-01-15 13:38:41 +11:00
|
|
|
const int px = max_ii(1, iroundf(U.pixelsize));
|
|
|
|
const int category_tabs_width = iroundf(UI_PANEL_CATEGORY_MARGIN_WIDTH * zoom);
|
2013-12-17 03:21:55 +11:00
|
|
|
const float dpi_fac = UI_DPI_FAC;
|
2014-01-15 13:38:41 +11:00
|
|
|
const int tab_v_pad_text = iroundf((2 + ((px * 3) * dpi_fac)) * zoom); /* pading of tabs around text */
|
|
|
|
const int tab_v_pad = iroundf((4 + (2 * px * dpi_fac)) * zoom); /* padding between tabs */
|
2014-01-04 13:55:40 +11:00
|
|
|
const float tab_curve_radius = ((px * 3) * dpi_fac) * zoom;
|
2013-12-17 03:21:55 +11:00
|
|
|
const int roundboxtype = UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT;
|
2014-02-09 01:38:20 +11:00
|
|
|
bool is_alpha;
|
2013-12-17 03:21:55 +11:00
|
|
|
bool do_scaletabs = false;
|
|
|
|
#ifdef USE_FLAT_INACTIVE
|
|
|
|
bool is_active_prev = false;
|
|
|
|
#endif
|
|
|
|
float scaletabs = 1.0f;
|
|
|
|
/* same for all tabs */
|
2014-01-13 20:35:35 -06:00
|
|
|
const int rct_xmin = v2d->mask.xmin + 3; /* intentionally dont scale by 'px' */
|
2013-12-17 03:21:55 +11:00
|
|
|
const int rct_xmax = v2d->mask.xmin + category_tabs_width;
|
|
|
|
const int text_v_ofs = (rct_xmax - rct_xmin) * 0.3f;
|
|
|
|
|
|
|
|
int y_ofs = tab_v_pad;
|
|
|
|
|
|
|
|
/* Primary theme colors */
|
|
|
|
unsigned char theme_col_back[4];
|
2014-02-10 17:02:53 +11:00
|
|
|
unsigned char theme_col_text[3];
|
|
|
|
unsigned char theme_col_text_hi[3];
|
2013-12-17 03:21:55 +11:00
|
|
|
|
2014-01-23 11:44:35 +11:00
|
|
|
/* Tab colors */
|
2013-12-17 03:21:55 +11:00
|
|
|
unsigned char theme_col_tab_bg[4];
|
2014-02-10 17:02:53 +11:00
|
|
|
unsigned char theme_col_tab_active[3];
|
|
|
|
unsigned char theme_col_tab_inactive[3];
|
2014-01-23 11:44:35 +11:00
|
|
|
|
|
|
|
/* Secondary theme colors */
|
2014-02-10 17:02:53 +11:00
|
|
|
unsigned char theme_col_tab_outline[3];
|
|
|
|
unsigned char theme_col_tab_divider[3]; /* line that divides tabs from the main area */
|
|
|
|
unsigned char theme_col_tab_highlight[3];
|
|
|
|
unsigned char theme_col_tab_highlight_inactive[3];
|
2013-12-17 03:21:55 +11:00
|
|
|
|
|
|
|
|
2014-01-15 13:38:41 +11:00
|
|
|
|
2013-12-17 03:21:55 +11:00
|
|
|
UI_GetThemeColor4ubv(TH_BACK, theme_col_back);
|
2014-02-10 17:02:53 +11:00
|
|
|
UI_GetThemeColor3ubv(TH_TEXT, theme_col_text);
|
|
|
|
UI_GetThemeColor3ubv(TH_TEXT_HI, theme_col_text_hi);
|
2013-12-17 03:21:55 +11:00
|
|
|
|
2014-01-23 11:44:35 +11:00
|
|
|
UI_GetThemeColor4ubv(TH_TAB_BACK, theme_col_tab_bg);
|
2014-02-10 17:02:53 +11:00
|
|
|
UI_GetThemeColor3ubv(TH_TAB_ACTIVE, theme_col_tab_active);
|
|
|
|
UI_GetThemeColor3ubv(TH_TAB_INACTIVE, theme_col_tab_inactive);
|
|
|
|
UI_GetThemeColor3ubv(TH_TAB_OUTLINE, theme_col_tab_outline);
|
2013-12-17 03:21:55 +11:00
|
|
|
|
2014-02-10 17:02:53 +11:00
|
|
|
interp_v3_v3v3_uchar(theme_col_tab_divider, theme_col_back, theme_col_tab_outline, 0.3f);
|
|
|
|
interp_v3_v3v3_uchar(theme_col_tab_highlight, theme_col_back, theme_col_text_hi, 0.2f);
|
|
|
|
interp_v3_v3v3_uchar(theme_col_tab_highlight_inactive, theme_col_tab_inactive, theme_col_text_hi, 0.12f);
|
2013-12-17 03:21:55 +11:00
|
|
|
|
2014-02-09 01:38:20 +11:00
|
|
|
is_alpha = (ar->overlap && (theme_col_back[3] != 255));
|
|
|
|
|
2014-01-04 13:55:40 +11:00
|
|
|
if (fstyle->kerning == 1) {
|
|
|
|
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
|
|
|
}
|
2013-12-17 03:21:55 +11:00
|
|
|
|
|
|
|
BLF_enable(fontid, BLF_ROTATION);
|
|
|
|
BLF_rotation(fontid, M_PI / 2);
|
|
|
|
//uiStyleFontSet(&style->widget);
|
2014-01-15 13:38:41 +11:00
|
|
|
ui_fontscale(&fstyle_points, aspect / (U.pixelsize * 1.1f));
|
|
|
|
BLF_size(fontid, fstyle_points, U.dpi);
|
2013-12-17 03:21:55 +11:00
|
|
|
|
2014-01-15 15:45:55 +11:00
|
|
|
BLF_enable(fontid, BLF_SHADOW);
|
|
|
|
BLF_shadow(fontid, 3, 1.0f, 1.0f, 1.0f, 0.25f);
|
|
|
|
BLF_shadow_offset(fontid, -1, -1);
|
|
|
|
|
2013-12-17 03:21:55 +11:00
|
|
|
BLI_assert(UI_panel_category_is_visible(ar));
|
|
|
|
|
|
|
|
|
|
|
|
/* calculate tab rect's and check if we need to scale down */
|
|
|
|
for (pc_dyn = ar->panels_category.first; pc_dyn; pc_dyn = pc_dyn->next) {
|
|
|
|
rcti *rct = &pc_dyn->rect;
|
|
|
|
const char *category_id = pc_dyn->idname;
|
|
|
|
const char *category_id_draw = IFACE_(category_id);
|
|
|
|
const int category_width = BLF_width(fontid, category_id_draw, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
|
|
|
|
rct->xmin = rct_xmin;
|
|
|
|
rct->xmax = rct_xmax;
|
|
|
|
|
|
|
|
rct->ymin = v2d->mask.ymax - (y_ofs + category_width + (tab_v_pad_text * 2));
|
|
|
|
rct->ymax = v2d->mask.ymax - (y_ofs);
|
|
|
|
|
|
|
|
y_ofs += category_width + tab_v_pad + (tab_v_pad_text * 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (y_ofs > BLI_rcti_size_y(&v2d->mask)) {
|
|
|
|
scaletabs = (float)BLI_rcti_size_y(&v2d->mask) / (float)y_ofs;
|
|
|
|
|
|
|
|
for (pc_dyn = ar->panels_category.first; pc_dyn; pc_dyn = pc_dyn->next) {
|
|
|
|
rcti *rct = &pc_dyn->rect;
|
|
|
|
rct->ymin = ((rct->ymin - v2d->mask.ymax) * scaletabs) + v2d->mask.ymax;
|
|
|
|
rct->ymax = ((rct->ymax - v2d->mask.ymax) * scaletabs) + v2d->mask.ymax;
|
|
|
|
}
|
|
|
|
|
|
|
|
do_scaletabs = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* begin drawing */
|
|
|
|
glEnable(GL_LINE_SMOOTH);
|
|
|
|
|
|
|
|
/* draw the background */
|
2014-02-09 01:38:20 +11:00
|
|
|
if (is_alpha) {
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glColor4ubv(theme_col_tab_bg);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
glColor3ubv(theme_col_tab_bg);
|
|
|
|
}
|
|
|
|
|
2013-12-17 03:21:55 +11:00
|
|
|
glRecti(v2d->mask.xmin, v2d->mask.ymin, v2d->mask.xmin + category_tabs_width, v2d->mask.ymax);
|
|
|
|
|
2014-02-09 01:38:20 +11:00
|
|
|
if (is_alpha) {
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
|
|
|
|
2013-12-17 03:21:55 +11:00
|
|
|
for (pc_dyn = ar->panels_category.first; pc_dyn; pc_dyn = pc_dyn->next) {
|
|
|
|
const rcti *rct = &pc_dyn->rect;
|
|
|
|
const char *category_id = pc_dyn->idname;
|
|
|
|
const char *category_id_draw = IFACE_(category_id);
|
|
|
|
int category_width = BLI_rcti_size_y(rct) - (tab_v_pad_text * 2);
|
|
|
|
size_t category_draw_len = BLF_DRAW_STR_DUMMY_MAX;
|
|
|
|
// int category_width = BLF_width(fontid, category_id_draw, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
|
|
|
|
const bool is_active = STREQ(category_id, category_id_active);
|
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
|
|
|
#ifdef USE_FLAT_INACTIVE
|
|
|
|
if (is_active)
|
|
|
|
#endif
|
|
|
|
{
|
2014-01-23 11:44:35 +11:00
|
|
|
glColor3ubv(is_active ? theme_col_tab_active : theme_col_tab_inactive);
|
2013-12-17 03:21:55 +11:00
|
|
|
ui_panel_category_draw_tab(GL_POLYGON, rct->xmin, rct->ymin, rct->xmax, rct->ymax,
|
|
|
|
tab_curve_radius - px, roundboxtype, true, true, NULL);
|
|
|
|
|
|
|
|
/* tab outline */
|
|
|
|
glColor3ubv(theme_col_tab_outline);
|
|
|
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
|
|
|
ui_panel_category_draw_tab(GL_LINE_STRIP, rct->xmin - px, rct->ymin - px, rct->xmax - px, rct->ymax + px,
|
|
|
|
tab_curve_radius, roundboxtype, true, true, NULL);
|
|
|
|
/* tab highlight (3d look) */
|
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
glColor3ubv(is_active ? theme_col_tab_highlight : theme_col_tab_highlight_inactive);
|
|
|
|
ui_panel_category_draw_tab(GL_LINE_STRIP, rct->xmin, rct->ymin, rct->xmax, rct->ymax,
|
|
|
|
tab_curve_radius, roundboxtype, true, false,
|
|
|
|
is_active ? theme_col_back : theme_col_tab_inactive);
|
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
|
|
|
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tab blackline */
|
|
|
|
if (!is_active) {
|
|
|
|
glColor3ubv(theme_col_tab_divider);
|
|
|
|
glRecti(v2d->mask.xmin + category_tabs_width - px,
|
|
|
|
rct->ymin - tab_v_pad,
|
|
|
|
v2d->mask.xmin + category_tabs_width,
|
|
|
|
rct->ymax + tab_v_pad);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (do_scaletabs) {
|
|
|
|
category_draw_len = BLF_width_to_strlen(fontid, category_id_draw, category_draw_len,
|
|
|
|
category_width, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
BLF_position(fontid, rct->xmax - text_v_ofs, rct->ymin + tab_v_pad_text, 0.0f);
|
|
|
|
|
2014-01-04 13:54:39 -06:00
|
|
|
/* tab titles */
|
|
|
|
|
2014-01-14 13:39:55 +11:00
|
|
|
/* draw white shadow to give text more depth */
|
2014-01-15 15:45:55 +11:00
|
|
|
glColor3ubv(theme_col_text);
|
2013-12-17 03:21:55 +11:00
|
|
|
|
2014-01-14 13:39:55 +11:00
|
|
|
/* main tab title */
|
|
|
|
BLF_draw(fontid, category_id_draw, category_draw_len);
|
2014-01-04 13:54:39 -06:00
|
|
|
|
2013-12-17 03:21:55 +11:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
|
|
|
/* tab blackline remaining (last tab) */
|
|
|
|
if (pc_dyn->prev == NULL) {
|
|
|
|
glColor3ubv(theme_col_tab_divider);
|
|
|
|
glRecti(v2d->mask.xmin + category_tabs_width - px,
|
|
|
|
rct->ymax + px,
|
|
|
|
v2d->mask.xmin + category_tabs_width,
|
|
|
|
v2d->mask.ymax);
|
|
|
|
}
|
|
|
|
if (pc_dyn->next == NULL) {
|
|
|
|
glColor3ubv(theme_col_tab_divider);
|
|
|
|
glRecti(v2d->mask.xmin + category_tabs_width - px,
|
|
|
|
0,
|
|
|
|
v2d->mask.xmin + category_tabs_width,
|
|
|
|
rct->ymin);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef USE_FLAT_INACTIVE
|
|
|
|
/* draw line between inactive tabs */
|
|
|
|
if (is_active == false && is_active_prev == false && pc_dyn->prev) {
|
|
|
|
glColor3ubv(theme_col_tab_divider);
|
|
|
|
glRecti(v2d->mask.xmin + (category_tabs_width / 5),
|
|
|
|
rct->ymax + px,
|
|
|
|
(v2d->mask.xmin + category_tabs_width) - (category_tabs_width / 5),
|
|
|
|
rct->ymax + (px * 3));
|
|
|
|
}
|
|
|
|
|
|
|
|
is_active_prev = is_active;
|
|
|
|
#endif
|
2014-01-14 04:15:54 +11:00
|
|
|
|
|
|
|
/* not essential, but allows events to be handled right up until the region edge [#38171] */
|
|
|
|
pc_dyn->rect.xmin = v2d->mask.xmin;
|
2013-12-17 03:21:55 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
glDisable(GL_LINE_SMOOTH);
|
|
|
|
|
|
|
|
BLF_disable(fontid, BLF_ROTATION);
|
|
|
|
|
2014-01-15 15:45:55 +11:00
|
|
|
BLF_disable(fontid, BLF_SHADOW);
|
|
|
|
|
2014-01-04 13:55:40 +11:00
|
|
|
if (fstyle->kerning == 1) {
|
|
|
|
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
|
|
|
}
|
|
|
|
|
2013-12-17 03:21:55 +11:00
|
|
|
#undef USE_FLAT_INACTIVE
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
|
2010-04-11 11:52:39 +00:00
|
|
|
/* XXX should become modal keymap */
|
2010-04-12 17:45:51 +00:00
|
|
|
/* AKey is opening/closing panels, independent of button state now */
|
|
|
|
|
2013-12-03 23:53:21 +11:00
|
|
|
int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar)
|
2008-12-26 13:11:04 +00:00
|
|
|
{
|
|
|
|
uiBlock *block;
|
2009-07-08 15:34:41 +00:00
|
|
|
Panel *pa;
|
2012-12-13 10:24:46 +00:00
|
|
|
int retval, mx, my;
|
2013-12-17 03:21:55 +11:00
|
|
|
bool has_category_tabs = UI_panel_category_is_visible(ar);
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
retval = WM_UI_HANDLER_CONTINUE;
|
2013-12-17 03:21:55 +11:00
|
|
|
|
|
|
|
if (has_category_tabs) {
|
|
|
|
if (event->val == KM_PRESS) {
|
|
|
|
if (event->type == LEFTMOUSE) {
|
|
|
|
PanelCategoryDyn *pc_dyn = UI_panel_category_find_mouse_over(ar, event);
|
|
|
|
if (pc_dyn) {
|
|
|
|
UI_panel_category_active_set(ar, pc_dyn->idname);
|
|
|
|
ED_region_tag_redraw(ar);
|
2014-02-22 13:07:02 +11:00
|
|
|
|
|
|
|
/* reset scroll to the top [#38348] */
|
|
|
|
UI_view2d_offset(&ar->v2d, -1.0f, 1.0f);
|
|
|
|
|
2013-12-17 03:21:55 +11:00
|
|
|
retval = WM_UI_HANDLER_BREAK;
|
|
|
|
}
|
|
|
|
}
|
2014-02-17 13:46:07 +11:00
|
|
|
else if (ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE)) {
|
|
|
|
/* mouse wheel cycle tabs */
|
|
|
|
|
|
|
|
/* first check if the mouse is in the tab region */
|
2014-02-21 16:12:53 +11:00
|
|
|
if (event->ctrl || (event->mval[0] < ((PanelCategoryDyn *)ar->panels_category.first)->rect.xmax)) {
|
2014-02-17 13:46:07 +11:00
|
|
|
const char *category = UI_panel_category_active_get(ar, false);
|
|
|
|
if (LIKELY(category)) {
|
|
|
|
PanelCategoryDyn *pc_dyn = UI_panel_category_find(ar, category);
|
|
|
|
if (LIKELY(pc_dyn)) {
|
|
|
|
pc_dyn = (event->type == WHEELDOWNMOUSE) ? pc_dyn->next : pc_dyn->prev;
|
|
|
|
if (pc_dyn) {
|
2014-02-22 13:07:02 +11:00
|
|
|
/* intentionally don't reset scroll in this case,
|
|
|
|
* this allows for quick browsing between tabs */
|
2014-02-17 13:46:07 +11:00
|
|
|
UI_panel_category_active_set(ar, pc_dyn->idname);
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
retval = WM_UI_HANDLER_BREAK;
|
|
|
|
}
|
|
|
|
}
|
2013-12-17 03:21:55 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (retval == WM_UI_HANDLER_BREAK) {
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (block = ar->uiblocks.last; block; block = block->prev) {
|
2013-12-05 17:26:03 +11:00
|
|
|
bool inside = false, inside_header = false, inside_scale = false;
|
2012-12-13 10:24:46 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
mx = event->x;
|
|
|
|
my = event->y;
|
2008-12-26 13:11:04 +00:00
|
|
|
ui_window_to_block(ar, block, &mx, &my);
|
|
|
|
|
2012-12-13 10:24:46 +00:00
|
|
|
/* checks for mouse position inside */
|
2012-03-30 01:51:25 +00:00
|
|
|
pa = block->panel;
|
2009-07-08 15:34:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (!pa || pa->paneltab != NULL)
|
2009-07-08 15:34:41 +00:00
|
|
|
continue;
|
2012-08-19 10:41:27 +00:00
|
|
|
if (pa->type && pa->type->flag & PNL_NO_HEADER) /* XXX - accessed freed panels when scripts reload, need to fix. */
|
2009-07-08 15:34:41 +00:00
|
|
|
continue;
|
2010-04-12 17:45:51 +00:00
|
|
|
|
2012-12-13 10:24:46 +00:00
|
|
|
/* clicked at panel header? */
|
|
|
|
if (pa->flag & PNL_CLOSEDX) {
|
|
|
|
if (block->rect.xmin <= mx && block->rect.xmin + PNL_HEADER >= mx)
|
2013-12-05 17:26:03 +11:00
|
|
|
inside_header = true;
|
2012-12-13 10:24:46 +00:00
|
|
|
}
|
2013-01-21 02:30:40 +00:00
|
|
|
else if (block->rect.xmin > mx || block->rect.xmax < mx) {
|
2013-01-11 15:19:47 +00:00
|
|
|
/* outside left/right side */
|
2013-01-21 02:30:40 +00:00
|
|
|
}
|
2012-12-13 10:24:46 +00:00
|
|
|
else if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my)) {
|
2013-12-05 17:26:03 +11:00
|
|
|
inside_header = true;
|
2012-12-13 10:24:46 +00:00
|
|
|
}
|
|
|
|
else if (!(pa->flag & PNL_CLOSEDY)) {
|
|
|
|
/* open panel */
|
|
|
|
if (pa->control & UI_PNL_SCALE) {
|
|
|
|
if (block->rect.xmax - PNL_HEADER <= mx)
|
|
|
|
if (block->rect.ymin + PNL_HEADER >= my)
|
2013-12-05 17:26:03 +11:00
|
|
|
inside_scale = true;
|
2012-12-13 10:24:46 +00:00
|
|
|
}
|
|
|
|
if (block->rect.xmin <= mx && block->rect.xmax >= mx)
|
|
|
|
if (block->rect.ymin <= my && block->rect.ymax + PNL_HEADER >= my)
|
2013-12-05 17:26:03 +11:00
|
|
|
inside = true;
|
2012-12-13 10:24:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX hardcoded key warning */
|
2012-12-20 18:04:06 +00:00
|
|
|
if ((inside || inside_header) && event->val == KM_PRESS) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (event->type == AKEY && !ELEM4(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift, event->alt)) {
|
2010-04-12 17:45:51 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pa->flag & PNL_CLOSEDY) {
|
2012-08-18 16:53:46 +00:00
|
|
|
if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my))
|
2014-01-06 03:00:54 +11:00
|
|
|
ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift);
|
2010-04-12 17:45:51 +00:00
|
|
|
}
|
|
|
|
else
|
2014-01-06 03:00:54 +11:00
|
|
|
ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift);
|
2010-04-12 17:45:51 +00:00
|
|
|
|
2012-12-20 19:18:46 +00:00
|
|
|
retval = WM_UI_HANDLER_BREAK;
|
2010-04-12 17:45:51 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* on active button, do not handle panels */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ui_button_is_active(ar))
|
2010-04-12 17:45:51 +00:00
|
|
|
continue;
|
|
|
|
|
2012-12-13 10:24:46 +00:00
|
|
|
if (inside || inside_header) {
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (event->val == KM_PRESS) {
|
2012-12-13 10:24:46 +00:00
|
|
|
|
2010-04-11 11:52:39 +00:00
|
|
|
/* open close on header */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ELEM(event->type, RETKEY, PADENTER)) {
|
|
|
|
if (inside_header) {
|
2014-01-06 03:00:54 +11:00
|
|
|
ui_handle_panel_header(C, block, mx, my, RETKEY, event->ctrl, event->shift);
|
2012-12-13 10:58:00 +00:00
|
|
|
retval = WM_UI_HANDLER_BREAK;
|
2010-04-11 11:52:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (event->type == LEFTMOUSE) {
|
2012-12-13 10:58:00 +00:00
|
|
|
/* all inside clicks should return in break - overlapping/float panels */
|
|
|
|
retval = WM_UI_HANDLER_BREAK;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (inside_header) {
|
2014-01-06 03:00:54 +11:00
|
|
|
ui_handle_panel_header(C, block, mx, my, 0, event->ctrl, event->shift);
|
2012-12-13 10:58:00 +00:00
|
|
|
retval = WM_UI_HANDLER_BREAK;
|
2009-04-17 13:37:03 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (inside_scale && !(pa->flag & PNL_CLOSED)) {
|
2009-07-08 15:34:41 +00:00
|
|
|
panel_activate_state(C, pa, PANEL_STATE_DRAG_SCALE);
|
2012-12-13 10:58:00 +00:00
|
|
|
retval = WM_UI_HANDLER_BREAK;
|
2009-04-17 13:37:03 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-12-13 10:58:00 +00:00
|
|
|
|
2009-04-02 01:39:33 +00:00
|
|
|
}
|
2013-12-17 03:21:55 +11:00
|
|
|
else if (event->type == RIGHTMOUSE) {
|
|
|
|
if (inside_header) {
|
|
|
|
ui_panel_menu(C, ar, block->panel);
|
|
|
|
retval = WM_UI_HANDLER_BREAK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (event->type == ESCKEY) {
|
2012-03-03 16:31:46 +00:00
|
|
|
/*XXX 2.50*/
|
|
|
|
#if 0
|
2012-03-24 06:38:07 +00:00
|
|
|
if (block->handler) {
|
2009-04-02 01:39:33 +00:00
|
|
|
rem_blockhandler(sa, block->handler);
|
|
|
|
ED_region_tag_redraw(ar);
|
2012-03-30 01:51:25 +00:00
|
|
|
retval = WM_UI_HANDLER_BREAK;
|
2012-03-03 16:31:46 +00:00
|
|
|
}
|
|
|
|
#endif
|
2009-04-02 01:39:33 +00:00
|
|
|
}
|
2012-03-30 01:51:25 +00:00
|
|
|
else if (event->type == PADPLUSKEY || event->type == PADMINUS) {
|
2012-08-19 10:41:27 +00:00
|
|
|
#if 0 /* XXX make float panel exception? */
|
2012-03-30 01:51:25 +00:00
|
|
|
int zoom = 0;
|
2009-04-02 01:39:33 +00:00
|
|
|
|
|
|
|
/* if panel is closed, only zoom if mouse is over the header */
|
2012-03-30 01:51:25 +00:00
|
|
|
if (pa->flag & (PNL_CLOSEDX | PNL_CLOSEDY)) {
|
2009-04-02 01:39:33 +00:00
|
|
|
if (inside_header)
|
2012-03-30 01:51:25 +00:00
|
|
|
zoom = 1;
|
2009-04-02 01:39:33 +00:00
|
|
|
}
|
|
|
|
else
|
2012-03-30 01:51:25 +00:00
|
|
|
zoom = 1;
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (zoom) {
|
2012-03-30 01:51:25 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
SpaceLink *sl = sa->spacedata.first;
|
2009-04-02 01:39:33 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (sa->spacetype != SPACE_BUTS) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!(pa->control & UI_PNL_SCALE)) {
|
2012-03-30 01:51:25 +00:00
|
|
|
if (event->type == PADPLUSKEY) sl->blockscale += 0.1;
|
|
|
|
else sl->blockscale -= 0.1;
|
2009-04-02 01:39:33 +00:00
|
|
|
CLAMP(sl->blockscale, 0.6, 1.0);
|
|
|
|
|
|
|
|
ED_region_tag_redraw(ar);
|
2012-03-30 01:51:25 +00:00
|
|
|
retval = WM_UI_HANDLER_BREAK;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-04-02 01:39:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
/**************** window level modal panel interaction **************/
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2009-06-27 12:41:28 +00:00
|
|
|
/* note, this is modal handler and should not swallow events for animation */
|
2013-02-01 01:01:20 +00:00
|
|
|
static int ui_handler_panel(bContext *C, const wmEvent *event, void *userdata)
|
2008-12-26 13:11:04 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
Panel *panel = userdata;
|
|
|
|
uiHandlePanelData *data = panel->activedata;
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
/* verify if we can stop */
|
2012-03-30 01:51:25 +00:00
|
|
|
if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
ARegion *ar = CTX_wm_region(C);
|
|
|
|
int align = panel_aligned(sa, ar);
|
2009-04-02 01:39:33 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (align)
|
2009-04-02 01:39:33 +00:00
|
|
|
panel_activate_state(C, panel, PANEL_STATE_ANIMATION);
|
|
|
|
else
|
|
|
|
panel_activate_state(C, panel, PANEL_STATE_EXIT);
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (event->type == MOUSEMOVE) {
|
|
|
|
if (data->state == PANEL_STATE_DRAG)
|
2008-12-26 13:11:04 +00:00
|
|
|
ui_do_drag(C, event, panel);
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (event->type == TIMER && event->customdata == data->animtimer) {
|
|
|
|
if (data->state == PANEL_STATE_ANIMATION)
|
2008-12-26 13:11:04 +00:00
|
|
|
ui_do_animate(C, panel);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (data->state == PANEL_STATE_DRAG)
|
2008-12-26 13:11:04 +00:00
|
|
|
ui_do_drag(C, event, panel);
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
data = panel->activedata;
|
2009-04-02 01:39:33 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (data && data->state == PANEL_STATE_ANIMATION)
|
2008-12-26 13:11:04 +00:00
|
|
|
return WM_UI_HANDLER_CONTINUE;
|
|
|
|
else
|
|
|
|
return WM_UI_HANDLER_BREAK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ui_handler_remove_panel(bContext *C, void *userdata)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
Panel *pa = userdata;
|
2008-12-26 13:11:04 +00:00
|
|
|
|
|
|
|
panel_activate_state(C, pa, PANEL_STATE_EXIT);
|
|
|
|
}
|
|
|
|
|
2009-04-16 21:39:45 +00:00
|
|
|
static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelState state)
|
2008-12-26 13:11:04 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiHandlePanelData *data = pa->activedata;
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
ARegion *ar = CTX_wm_region(C);
|
2009-04-08 16:51:35 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (data && data->state == state)
|
2008-12-26 13:11:04 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state == PANEL_STATE_EXIT || state == PANEL_STATE_ANIMATION) {
|
|
|
|
if (data && data->state != PANEL_STATE_ANIMATION) {
|
2009-09-23 11:49:12 +00:00
|
|
|
/* XXX:
|
|
|
|
* - the panel tabbing function call below (test_add_new_tabs()) has been commented out
|
2012-05-17 07:59:25 +00:00
|
|
|
* "It is too easy to do by accident when reordering panels,
|
|
|
|
* is very hard to control and use, and has no real benefit." - BillRey
|
2009-09-23 11:49:12 +00:00
|
|
|
* Aligorith, 2009Sep
|
|
|
|
*/
|
|
|
|
//test_add_new_tabs(ar); // also copies locations of tabs in dragged panel
|
2012-08-19 10:41:27 +00:00
|
|
|
check_panel_overlap(ar, NULL); /* clears */
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pa->flag &= ~PNL_SELECT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pa->flag |= PNL_SELECT;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (data && data->animtimer) {
|
2009-10-20 13:58:53 +00:00
|
|
|
WM_event_remove_timer(CTX_wm_manager(C), win, data->animtimer);
|
2012-03-30 01:51:25 +00:00
|
|
|
data->animtimer = NULL;
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (state == PANEL_STATE_EXIT) {
|
2008-12-26 13:11:04 +00:00
|
|
|
MEM_freeN(data);
|
2012-03-30 01:51:25 +00:00
|
|
|
pa->activedata = NULL;
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
WM_event_remove_ui_handler(&win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa, false);
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!data) {
|
2012-03-30 01:51:25 +00:00
|
|
|
data = MEM_callocN(sizeof(uiHandlePanelData), "uiHandlePanelData");
|
|
|
|
pa->activedata = data;
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2009-09-18 12:43:36 +00:00
|
|
|
WM_event_add_ui_handler(C, &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa);
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ELEM(state, PANEL_STATE_ANIMATION, PANEL_STATE_DRAG))
|
2012-03-30 01:51:25 +00:00
|
|
|
data->animtimer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, ANIMATION_INTERVAL);
|
|
|
|
|
|
|
|
data->state = state;
|
|
|
|
data->startx = win->eventstate->x;
|
|
|
|
data->starty = win->eventstate->y;
|
|
|
|
data->startofsx = pa->ofsx;
|
|
|
|
data->startofsy = pa->ofsy;
|
|
|
|
data->startsizex = pa->sizex;
|
|
|
|
data->startsizey = pa->sizey;
|
|
|
|
data->starttime = PIL_check_seconds_timer();
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
}
|
|
|
|
|