Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2009-02-18 16:29:54 +0300
committerTon Roosendaal <ton@blender.org>2009-02-18 16:29:54 +0300
commit1090b0c598712a8375e6189447b461ddd3d781b6 (patch)
treecde5a33c17d262cdf5dd7b7a88c6f3021197686f /source/blender/editors/space_info
parent915e989f9d60d4523563f14b71df8c7f6d5e812e (diff)
2.5
Several things in one commit; could not split this up easily, one job invoked another, and so on. :) - Added pulldowns for save/load .blend file in top bar. - To enable "Save" without further popups (save over) I've added a signaling function in window header to indicate a succesful save. - On any undo push it now signals 'file changed'. This goes by notifiers nicely, but now registers only the undopushes, which is quite unreliable. "Changed" state shows in header as "Blender*" and for OSX with the standard close button black dot. - Made screencast show a button in top bar indicating such, and allowing quit. No hotkey for quit yet... but ESC will keep casting now. - Fixed new BLF_init(), which should be in WM_init() and not on any .B.blend read. - Fixed CTRL+F3 "Save Screenshot", which was still using old fileselect code.
Diffstat (limited to 'source/blender/editors/space_info')
-rw-r--r--source/blender/editors/space_info/info_header.c235
-rw-r--r--source/blender/editors/space_info/space_info.c5
2 files changed, 239 insertions, 1 deletions
diff --git a/source/blender/editors/space_info/info_header.c b/source/blender/editors/space_info/info_header.c
index 4b750600583..32c01b53a9e 100644
--- a/source/blender/editors/space_info/info_header.c
+++ b/source/blender/editors/space_info/info_header.c
@@ -29,17 +29,23 @@
#include <string.h>
#include <stdio.h>
+#include "DNA_packedFile_types.h"
#include "DNA_space_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
+#include "DNA_userdef_types.h"
#include "DNA_windowmanager_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
+#include "BLI_bpath.h"
#include "BKE_context.h"
#include "BKE_global.h"
+#include "BKE_image.h"
+#include "BKE_main.h"
+#include "BKE_packedFile.h"
#include "BKE_screen.h"
#include "ED_screen.h"
@@ -56,12 +62,18 @@
#include "UI_resources.h"
#include "UI_view2d.h"
+#include "IMB_imbuf_types.h"
+
#include "info_intern.h"
+static int pupmenu() {return 0;}
+static int okee() {return 0;}
+static int error() {return 0;}
/* ************************ header area region *********************** */
#define B_STOPRENDER 1
+#define B_STOPCAST 2
static void do_viewmenu(bContext *C, void *arg, int event)
{
@@ -93,6 +105,219 @@ static uiBlock *dummy_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
return block;
}
+static int buttons_do_unpack()
+{
+ int how;
+ char menu[2048];
+ char *line = menu;
+ int ret_value = 1, count = 0;
+
+ count = countPackedFiles();
+
+ if(!count) {
+ pupmenu("No packed files. Autopack disabled");
+ return ret_value;
+ }
+ if (count == 1)
+ line += sprintf(line, "Unpack 1 file%%t");
+ else
+ line += sprintf(line, "Unpack %d files%%t", count);
+
+ line += sprintf(line, "|Use files in current directory (create when necessary)%%x%d", PF_USE_LOCAL);
+ line += sprintf(line, "|Write files to current directory (overwrite existing files)%%x%d", PF_WRITE_LOCAL);
+ line += sprintf(line, "|%%l|Use files in original location (create when necessary)%%x%d", PF_USE_ORIGINAL);
+ line += sprintf(line, "|Write files to original location (overwrite existing files)%%x%d", PF_WRITE_ORIGINAL);
+ line += sprintf(line, "|%%l|Disable AutoPack, keep all packed files %%x%d", PF_KEEP);
+ line += sprintf(line, "|Ask for each file %%x%d", PF_ASK);
+
+ how = pupmenu(menu);
+
+ if(how == -1)
+ ret_value = 0;
+ else {
+ if (how != PF_KEEP) unpackAll(how);
+ G.fileflags &= ~G_AUTOPACK;
+ }
+
+ return ret_value;
+}
+
+static void check_packAll()
+{
+ // first check for dirty images
+ Image *ima;
+
+ for(ima = G.main->image.first; ima; ima= ima->id.next) {
+ if (ima->ibufs.first) { /* XXX FIX */
+ ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
+
+ if (ibuf && (ibuf->userflags &= IB_BITMAPDIRTY))
+ break;
+ }
+ }
+
+ if (ima == NULL || okee("Some images are painted on. These changes will be lost. Continue ?")) {
+ packAll();
+ G.fileflags |= G_AUTOPACK;
+ }
+}
+
+static void do_info_externalfiles(bContext *C, void *arg, int event)
+{
+ switch (event) {
+
+ case 1: /* pack data */
+ check_packAll();
+ break;
+ case 3: /* unpack data */
+ if (buttons_do_unpack() != 0) {
+ /* Clear autopack bit only if user selected one of the unpack options */
+ G.fileflags &= ~G_AUTOPACK;
+ }
+ break;
+ case 10: /* make all paths relative */
+ if (G.relbase_valid) {
+ int tot,changed,failed,linked;
+ char str[512];
+ char txtname[24]; /* text block name */
+ txtname[0] = '\0';
+ makeFilesRelative(txtname, &tot, &changed, &failed, &linked);
+ if (failed) sprintf(str, "Make Relative%%t|Total files %i|Changed %i|Failed %i, See Text \"%s\"|Linked %i", tot, changed, failed, txtname, linked);
+ else sprintf(str, "Make Relative%%t|Total files %i|Changed %i|Failed %i|Linked %i", tot, changed, failed, linked);
+ pupmenu(str);
+ } else {
+ pupmenu("Can't set relative paths with an unsaved blend file");
+ }
+ break;
+ case 11: /* make all paths absolute */
+ {
+ int tot,changed,failed,linked;
+ char str[512];
+ char txtname[24]; /* text block name */
+ txtname[0] = '\0';
+ makeFilesAbsolute(txtname, &tot, &changed, &failed, &linked);
+ sprintf(str, "Make Absolute%%t|Total files %i|Changed %i|Failed %i|Linked %i", tot, changed, failed, linked);
+ if (failed) sprintf(str, "Make Absolute%%t|Total files %i|Changed %i|Failed %i, See Text \"%s\"|Linked %i", tot, changed, failed, txtname, linked);
+ else sprintf(str, "Make Absolute%%t|Total files %i|Changed %i|Failed %i|Linked %i", tot, changed, failed, linked);
+
+ pupmenu(str);
+ }
+ break;
+ case 12: /* check images exist */
+ {
+ char txtname[24]; /* text block name */
+ txtname[0] = '\0';
+
+ /* run the missing file check */
+ checkMissingFiles( txtname );
+
+ if (txtname[0] == '\0') {
+ okee("No external files missing");
+ } else {
+ char str[128];
+ sprintf(str, "Missing files listed in Text \"%s\"", txtname );
+ error(str);
+ }
+ }
+ break;
+ case 13: /* search for referenced files that are not available */
+// XXX if(curarea->spacetype==SPACE_INFO) {
+// ScrArea *sa;
+// sa= closest_bigger_area();
+// areawinset(sa->win);
+// }
+// activate_fileselect(FILE_SPECIAL, "Find Missing Files", "", findMissingFiles);
+ break;
+ }
+
+}
+
+
+uiBlock *info_externalfiles(bContext *C, ARegion *ar, void *arg_unused)
+{
+ uiBlock *block;
+ short yco = 20, menuwidth = 120;
+
+ block= uiBeginBlock(C, ar, "info_externalfiles", UI_EMBOSSP, UI_HELV);
+ uiBlockSetButmFunc(block, do_info_externalfiles, NULL);
+
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pack into .blend file", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Unpack into Files...", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
+
+ uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
+
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make all Paths Relative", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 10, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make all Paths Absolute", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 11, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Report Missing Files...", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 12, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Find Missing Files...", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 13, "");
+
+ uiBlockSetDirection(block, UI_RIGHT);
+ uiTextBoundsBlock(block, 60);
+ return block;
+}
+
+
+
+static void info_filemenu(bContext *C, uiMenuItem *head, void *arg_unused)
+{
+
+ uiMenuContext(head, WM_OP_EXEC_AREA);
+ uiMenuItemO(head, 0, "WM_OT_read_homefile");
+ uiMenuContext(head, WM_OP_INVOKE_AREA);
+ uiMenuItemO(head, 0, "WM_OT_open_mainfile");
+// uiDefIconTextBlockBut(block, info_openrecentmenu, NULL, ICON_RIGHTARROW_THIN, "Open Recent",0, yco-=20, 120, 19, "");
+// uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Recover Last Session", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 15, "");
+
+ uiMenuSeparator(head);
+
+ uiMenuContext(head, WM_OP_EXEC_AREA);
+ uiMenuItemO(head, 0, "WM_OT_save_mainfile");
+ uiMenuContext(head, WM_OP_INVOKE_AREA);
+ uiMenuItemO(head, 0, "WM_OT_save_as_mainfile");
+
+#if 0
+ if(U.flag & USER_FILECOMPRESS) {
+ uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Compress File", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 35, "Enable file compression");
+ } else {
+ uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Compress File", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 35, "Enable file compression");
+ }
+
+ uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
+
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Rendered Image...|F3", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Screenshot Subwindow|Ctrl F3", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 24, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Screenshot All|Ctrl Shift F3", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 25, "");
+#if GAMEBLENDER == 1
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Game As Runtime...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 22, "");
+#endif
+ uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
+
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Default Settings|Ctrl U", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 31, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Load Factory Settings", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 32, "");
+
+
+ uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
+
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Append or Link|Shift F1", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Append or Link (Image Browser)|Ctrl F1", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
+// uiDefIconTextBlockBut(block, info_file_importmenu, NULL, ICON_RIGHTARROW_THIN, "Import", 0, yco-=20, menuwidth, 19, "");
+// uiDefIconTextBlockBut(block, info_file_exportmenu, NULL, ICON_RIGHTARROW_THIN, "Export", 0, yco-=20, menuwidth, 19, "");
+
+ uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
+
+ uiDefIconTextBlockBut(block, info_externalfiles, NULL, ICON_RIGHTARROW_THIN, "External Data",0, yco-=20, 120, 19, "");
+
+ uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
+
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Quit Blender|Ctrl Q", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 13, "");
+ uiBlockSetDirection(block, UI_DOWN);
+ uiTextBoundsBlock(block, 80);
+
+ uiEndBlock(C, block);
+ return block;
+#endif
+}
+
static void do_info_buttons(bContext *C, void *arg, int event)
{
@@ -100,6 +325,9 @@ static void do_info_buttons(bContext *C, void *arg, int event)
case B_STOPRENDER:
G.afbreek= 1;
break;
+ case B_STOPCAST:
+ WM_jobs_stop(CTX_wm_manager(C), CTX_wm_screen(C));
+ break;
}
}
@@ -179,7 +407,7 @@ void info_header_buttons(const bContext *C, ARegion *ar)
uiBlockSetEmboss(block, UI_EMBOSSP);
xmax= GetButStringLength("File");
- uiDefPulldownBut(block, dummy_viewmenu, sa, "File", xco, yco, xmax-3, 22, "");
+ uiDefMenuBut(block, info_filemenu, NULL, "File", xco, yco-2, xmax-3, 24, "");
xco+= xmax;
xmax= GetButStringLength("Add");
@@ -218,6 +446,11 @@ void info_header_buttons(const bContext *C, ARegion *ar)
if(WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) {
uiDefIconTextBut(block, BUT, B_STOPRENDER, ICON_REC, "Render", xco+5,yco,75,19, NULL, 0.0f, 0.0f, 0, 0, "Stop rendering");
+ xco+= 80;
+ }
+ if(WM_jobs_test(CTX_wm_manager(C), CTX_wm_screen(C))) {
+ uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_REC, "Capture", xco+5,yco,85,19, NULL, 0.0f, 0.0f, 0, 0, "Stop screencast");
+ xco+= 90;
}
/* always as last */
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index 141127d7eb5..6d7fb5a1cdf 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -218,9 +218,14 @@ static void info_header_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
switch(wmn->category) {
+ case NC_SCREEN:
+ if(wmn->data==ND_SCREENCAST)
+ ED_region_tag_redraw(ar);
+ break;
case NC_SCENE:
if(wmn->data==ND_RENDER_RESULT)
ED_region_tag_redraw(ar);
+ break;
}
}