2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-06-30 19:20:45 +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.
|
2009-06-30 19:20:45 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/space_info/info_ops.c
|
|
|
|
|
* \ingroup spinfo
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2009-06-30 19:20:45 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
#include "DNA_packedFile_types.h"
|
|
|
|
|
#include "DNA_space_types.h"
|
|
|
|
|
#include "DNA_windowmanager_types.h"
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2010-06-03 07:27:55 +00:00
|
|
|
#include "BLI_math.h"
|
2009-06-30 19:20:45 +00:00
|
|
|
#include "BLI_bpath.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
#include "BKE_context.h"
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_image.h"
|
|
|
|
|
#include "BKE_main.h"
|
|
|
|
|
#include "BKE_packedFile.h"
|
|
|
|
|
#include "BKE_report.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
2011-02-27 18:03:19 +00:00
|
|
|
#include "UI_resources.h"
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "info_intern.h"
|
|
|
|
|
|
|
|
|
|
/********************* pack all operator *********************/
|
|
|
|
|
|
|
|
|
|
static int pack_all_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
packAll(bmain, op->reports);
|
|
|
|
|
G.fileflags |= G_AUTOPACK;
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int pack_all_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
2009-06-30 19:20:45 +00:00
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2009-06-30 19:20:45 +00:00
|
|
|
Image *ima;
|
|
|
|
|
ImBuf *ibuf;
|
|
|
|
|
|
|
|
|
|
// first check for dirty images
|
2012-03-28 11:53:18 +00:00
|
|
|
for (ima = bmain->image.first; ima; ima = ima->id.next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ima->ibufs.first) { /* XXX FIX */
|
2012-03-28 11:53:18 +00:00
|
|
|
ibuf = BKE_image_get_ibuf(ima, NULL);
|
2009-06-30 19:20:45 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
|
2009-06-30 19:20:45 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ima) {
|
2009-06-30 19:20:45 +00:00
|
|
|
uiPupMenuOkee(C, "FILE_OT_pack_all", "Some images are painted on. These changes will be lost. Continue?");
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pack_all_exec(C, op);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FILE_OT_pack_all(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Pack All";
|
|
|
|
|
ot->idname = "FILE_OT_pack_all";
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = pack_all_exec;
|
|
|
|
|
ot->invoke = pack_all_invoke;
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-28 11:53:18 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-06-30 19:20:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/********************* unpack all operator *********************/
|
|
|
|
|
|
|
|
|
|
static const EnumPropertyItem unpack_all_method_items[] = {
|
|
|
|
|
{PF_USE_LOCAL, "USE_LOCAL", 0, "Use files in current directory (create when necessary)", ""},
|
|
|
|
|
{PF_WRITE_LOCAL, "WRITE_LOCAL", 0, "Write files to current directory (overwrite existing files)", ""},
|
|
|
|
|
{PF_USE_ORIGINAL, "USE_ORIGINAL", 0, "Use files in original location (create when necessary)", ""},
|
|
|
|
|
{PF_WRITE_ORIGINAL, "WRITE_ORIGINAL", 0, "Write files to original location (overwrite existing files)", ""},
|
|
|
|
|
{PF_KEEP, "KEEP", 0, "Disable AutoPack, keep all packed files", ""},
|
2012-01-17 16:22:22 +00:00
|
|
|
/* {PF_ASK, "ASK", 0, "Ask for each file", ""}, */
|
2009-06-30 19:20:45 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}};
|
|
|
|
|
|
|
|
|
|
static int unpack_all_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
|
int method = RNA_enum_get(op->ptr, "method");
|
2009-06-30 19:20:45 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
if (method != PF_KEEP) unpackAll(bmain, op->reports, method); /* XXX PF_ASK can't work here */
|
2009-06-30 19:20:45 +00:00
|
|
|
G.fileflags &= ~G_AUTOPACK;
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int unpack_all_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
2009-06-30 19:20:45 +00:00
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2009-06-30 19:20:45 +00:00
|
|
|
uiPopupMenu *pup;
|
|
|
|
|
uiLayout *layout;
|
2012-01-11 12:33:51 +00:00
|
|
|
char title[64];
|
2009-06-30 19:20:45 +00:00
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
|
|
count = countPackedFiles(bmain);
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!count) {
|
2011-09-19 12:26:20 +00:00
|
|
|
BKE_report(op->reports, RPT_WARNING, "No packed files. Autopack disabled");
|
2009-06-30 19:20:45 +00:00
|
|
|
G.fileflags &= ~G_AUTOPACK;
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (count == 1)
|
2012-01-11 12:33:51 +00:00
|
|
|
strcpy(title, "Unpack 1 file");
|
2009-06-30 19:20:45 +00:00
|
|
|
else
|
2012-01-11 12:33:51 +00:00
|
|
|
BLI_snprintf(title, sizeof(title), "Unpack %d files", count);
|
2009-06-30 19:20:45 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
pup = uiPupMenuBegin(C, title, ICON_NONE);
|
|
|
|
|
layout = uiPupMenuLayout(pup);
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
|
|
|
|
|
uiItemsEnumO(layout, "FILE_OT_unpack_all", "method");
|
|
|
|
|
|
|
|
|
|
uiPupMenuEnd(C, pup);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FILE_OT_unpack_all(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Unpack All";
|
|
|
|
|
ot->idname = "FILE_OT_unpack_all";
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = unpack_all_exec;
|
|
|
|
|
ot->invoke = unpack_all_invoke;
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-28 11:53:18 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
/* properties */
|
2011-09-19 12:26:20 +00:00
|
|
|
RNA_def_enum(ot->srna, "method", unpack_all_method_items, PF_USE_LOCAL, "Method", "How to unpack");
|
2009-06-30 19:20:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/********************* make paths relative operator *********************/
|
|
|
|
|
|
2010-12-06 00:52:30 +00:00
|
|
|
static int make_paths_relative_exec(bContext *C, wmOperator *op)
|
2009-06-30 19:20:45 +00:00
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2010-12-06 00:52:30 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!G.relbase_valid) {
|
2011-09-19 12:26:20 +00:00
|
|
|
BKE_report(op->reports, RPT_WARNING, "Can't set relative paths with an unsaved blend file");
|
2009-06-30 19:20:45 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 00:52:30 +00:00
|
|
|
makeFilesRelative(bmain, bmain->name, op->reports);
|
2009-06-30 19:20:45 +00:00
|
|
|
|
2010-12-05 23:14:48 +00:00
|
|
|
/* redraw everything so any changed paths register */
|
|
|
|
|
WM_main_add_notifier(NC_WINDOW, NULL);
|
|
|
|
|
|
2009-06-30 19:20:45 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FILE_OT_make_paths_relative(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Make All Paths Relative";
|
|
|
|
|
ot->idname = "FILE_OT_make_paths_relative";
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = make_paths_relative_exec;
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-28 11:53:18 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-06-30 19:20:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/********************* make paths absolute operator *********************/
|
|
|
|
|
|
2010-12-06 00:52:30 +00:00
|
|
|
static int make_paths_absolute_exec(bContext *C, wmOperator *op)
|
2009-06-30 19:20:45 +00:00
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2010-12-06 00:52:30 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!G.relbase_valid) {
|
2011-09-19 12:26:20 +00:00
|
|
|
BKE_report(op->reports, RPT_WARNING, "Can't set absolute paths with an unsaved blend file");
|
2009-06-30 19:20:45 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 00:52:30 +00:00
|
|
|
makeFilesAbsolute(bmain, bmain->name, op->reports);
|
2010-12-05 23:14:48 +00:00
|
|
|
|
|
|
|
|
/* redraw everything so any changed paths register */
|
|
|
|
|
WM_main_add_notifier(NC_WINDOW, NULL);
|
|
|
|
|
|
2009-06-30 19:20:45 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FILE_OT_make_paths_absolute(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Make All Paths Absolute";
|
|
|
|
|
ot->idname = "FILE_OT_make_paths_absolute";
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = make_paths_absolute_exec;
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-28 11:53:18 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-06-30 19:20:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/********************* report missing files operator *********************/
|
|
|
|
|
|
2011-10-27 01:25:07 +00:00
|
|
|
static int report_missing_files_exec(bContext *C, wmOperator *op)
|
2009-06-30 19:20:45 +00:00
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2011-10-27 01:25:07 +00:00
|
|
|
|
2009-06-30 19:20:45 +00:00
|
|
|
/* run the missing file check */
|
2011-10-27 01:25:07 +00:00
|
|
|
checkMissingFiles(bmain, op->reports);
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FILE_OT_report_missing_files(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Report Missing Files";
|
|
|
|
|
ot->idname = "FILE_OT_report_missing_files";
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = report_missing_files_exec;
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = 0; /* only reports so no need to undo/register */
|
2009-06-30 19:20:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/********************* find missing files operator *********************/
|
|
|
|
|
|
2011-10-27 01:25:07 +00:00
|
|
|
static int find_missing_files_exec(bContext *C, wmOperator *op)
|
2009-06-30 19:20:45 +00:00
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
|
const char *searchpath = RNA_string_get_alloc(op->ptr, "filepath", NULL, 0);
|
2011-10-27 01:25:07 +00:00
|
|
|
findMissingFiles(bmain, searchpath, op->reports);
|
|
|
|
|
MEM_freeN((void *)searchpath);
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int find_missing_files_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
2009-06-30 19:20:45 +00:00
|
|
|
{
|
|
|
|
|
/* XXX file open button text "Find Missing Files" */
|
|
|
|
|
WM_event_add_fileselect(C, op);
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FILE_OT_find_missing_files(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Find Missing Files";
|
|
|
|
|
ot->idname = "FILE_OT_find_missing_files";
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = find_missing_files_exec;
|
|
|
|
|
ot->invoke = find_missing_files_invoke;
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-28 11:53:18 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
|
/* properties */
|
2012-01-24 18:18:51 +00:00
|
|
|
WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
|
2009-06-30 19:20:45 +00:00
|
|
|
}
|
2010-06-03 07:27:55 +00:00
|
|
|
|
|
|
|
|
/********************* report box operator *********************/
|
|
|
|
|
|
|
|
|
|
/* Hard to decide whether to keep this as an operator,
|
|
|
|
|
* or turn it into a hardcoded ui control feature,
|
|
|
|
|
* handling TIMER events for all regions in interface_handlers.c
|
|
|
|
|
* Not sure how good that is to be accessing UI data from
|
|
|
|
|
* inactive regions, so use this for now. --matt
|
|
|
|
|
*/
|
|
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
#define INFO_TIMEOUT 5.0f
|
|
|
|
|
#define INFO_COLOR_TIMEOUT 3.0f
|
|
|
|
|
#define ERROR_TIMEOUT 10.0f
|
|
|
|
|
#define ERROR_COLOR_TIMEOUT 6.0f
|
|
|
|
|
#define COLLAPSE_TIMEOUT 0.25f
|
2010-10-15 01:36:14 +00:00
|
|
|
static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
|
2010-06-03 07:27:55 +00:00
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
|
ReportList *reports = CTX_wm_reports(C);
|
2010-06-03 07:27:55 +00:00
|
|
|
Report *report;
|
|
|
|
|
ReportTimerInfo *rti;
|
2012-03-28 11:53:18 +00:00
|
|
|
float progress = 0.0, color_progress = 0.0;
|
2010-06-03 07:27:55 +00:00
|
|
|
float neutral_col[3] = {0.35, 0.35, 0.35};
|
2012-03-28 11:53:18 +00:00
|
|
|
float neutral_grey = 0.6;
|
|
|
|
|
float timeout = 0.0, color_timeout = 0.0;
|
|
|
|
|
int send_note = 0;
|
2010-06-03 07:27:55 +00:00
|
|
|
|
|
|
|
|
/* escape if not our timer */
|
2012-03-28 11:53:18 +00:00
|
|
|
if ((reports->reporttimer == NULL) ||
|
|
|
|
|
(reports->reporttimer != event->customdata) ||
|
|
|
|
|
((report = BKE_reports_last_displayable(reports)) == NULL) /* may have been deleted */
|
|
|
|
|
)
|
|
|
|
|
{
|
2010-06-03 07:27:55 +00:00
|
|
|
return OPERATOR_PASS_THROUGH;
|
2010-12-02 21:40:39 +00:00
|
|
|
}
|
2010-11-24 16:34:38 +00:00
|
|
|
|
2010-06-03 07:27:55 +00:00
|
|
|
rti = (ReportTimerInfo *)reports->reporttimer->customdata;
|
|
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
timeout = (report->type & RPT_ERROR_ALL) ? ERROR_TIMEOUT : INFO_TIMEOUT;
|
|
|
|
|
color_timeout = (report->type & RPT_ERROR_ALL) ? ERROR_COLOR_TIMEOUT : INFO_COLOR_TIMEOUT;
|
2010-06-03 07:27:55 +00:00
|
|
|
|
|
|
|
|
/* clear the report display after timeout */
|
2011-03-28 17:08:33 +00:00
|
|
|
if ((float)reports->reporttimer->duration > timeout) {
|
2010-06-03 07:27:55 +00:00
|
|
|
WM_event_remove_timer(wm, NULL, reports->reporttimer);
|
|
|
|
|
reports->reporttimer = NULL;
|
|
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL);
|
2010-06-03 07:27:55 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
|
2010-06-03 07:27:55 +00:00
|
|
|
}
|
|
|
|
|
|
2011-03-27 17:22:04 +00:00
|
|
|
if (rti->widthfac == 0.0f) {
|
2012-03-02 16:05:54 +00:00
|
|
|
/* initialize colors based on report type */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (report->type & RPT_ERROR_ALL) {
|
2010-06-03 07:27:55 +00:00
|
|
|
rti->col[0] = 1.0;
|
|
|
|
|
rti->col[1] = 0.2;
|
|
|
|
|
rti->col[2] = 0.0;
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
|
else if (report->type & RPT_WARNING_ALL) {
|
2010-06-03 07:27:55 +00:00
|
|
|
rti->col[0] = 1.0;
|
|
|
|
|
rti->col[1] = 1.0;
|
|
|
|
|
rti->col[2] = 0.0;
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
|
else if (report->type & RPT_INFO_ALL) {
|
2010-06-03 07:27:55 +00:00
|
|
|
rti->col[0] = 0.3;
|
|
|
|
|
rti->col[1] = 0.45;
|
|
|
|
|
rti->col[2] = 0.7;
|
|
|
|
|
}
|
|
|
|
|
rti->greyscale = 0.75;
|
2012-03-28 11:53:18 +00:00
|
|
|
rti->widthfac = 1.0;
|
2010-06-03 07:27:55 +00:00
|
|
|
}
|
|
|
|
|
|
2011-03-28 17:08:33 +00:00
|
|
|
progress = (float)reports->reporttimer->duration / timeout;
|
|
|
|
|
color_progress = (float)reports->reporttimer->duration / color_timeout;
|
2010-06-03 07:27:55 +00:00
|
|
|
|
2010-11-24 16:34:38 +00:00
|
|
|
/* save us from too many draws */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (color_progress <= 1.0f) {
|
2012-03-28 11:53:18 +00:00
|
|
|
send_note = 1;
|
2010-11-24 16:34:38 +00:00
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
/* fade colors out sharply according to progress through fade-out duration */
|
2010-11-24 16:34:38 +00:00
|
|
|
interp_v3_v3v3(rti->col, rti->col, neutral_col, color_progress);
|
|
|
|
|
rti->greyscale = interpf(neutral_grey, rti->greyscale, color_progress);
|
|
|
|
|
}
|
2010-06-03 07:27:55 +00:00
|
|
|
|
|
|
|
|
/* collapse report at end of timeout */
|
2012-03-28 11:53:18 +00:00
|
|
|
if (progress * timeout > timeout - COLLAPSE_TIMEOUT) {
|
|
|
|
|
rti->widthfac = (progress * timeout - (timeout - COLLAPSE_TIMEOUT)) / COLLAPSE_TIMEOUT;
|
2011-03-27 17:22:04 +00:00
|
|
|
rti->widthfac = 1.0f - rti->widthfac;
|
2012-03-28 11:53:18 +00:00
|
|
|
send_note = 1;
|
2010-06-03 07:27:55 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (send_note) {
|
2012-03-28 11:53:18 +00:00
|
|
|
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL);
|
2010-11-24 16:34:38 +00:00
|
|
|
}
|
2010-06-03 07:27:55 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
|
2010-06-03 07:27:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void INFO_OT_reports_display_update(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Update Reports Display";
|
|
|
|
|
ot->idname = "INFO_OT_reports_display_update";
|
2010-06-03 07:27:55 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = update_reports_display_invoke;
|
2010-06-03 07:27:55 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = 0;
|
2010-06-03 07:27:55 +00:00
|
|
|
|
|
|
|
|
/* properties */
|
2010-06-09 14:04:34 +00:00
|
|
|
}
|
2010-11-11 13:36:57 +00:00
|
|
|
|
|
|
|
|
/* report operators */
|