From BlenderWiki

Jump to: navigation, search
Note: This is an archived version of the Blender Developer Wiki. The current and active wiki is available on wiki.blender.org.

Developer Docs

  • reworked SpaceImaSel completely to be much more similar to filebrowser SpaceFile
    • reading and writing should go fine, I even attempted a do_version for the SpaceImaSel, but this part probably needs some more work, maybe even not loading old ImaSel structs at all.
    • Also opening the .blend files saved with the patched version in older .blend files probably has issues with image browser, I need some advice here on how to make it safe if possible.(One idea that could probably work would be to completely rename SpaceImasel to something else)
  • refactoring of the filelist functions out of filesel into BIF_filelist.h, filelist.c
    • these should be eventually used by filebrowser too, so in the future we only have to maintain these once, I'm planning to do this after code review and first public tests show that imagebrowser is reasonably stable
  • creation and storeage of the preview images:
    • Previews are currently stored into the .blend file if set by the UserPref (in the AutoSave buttons)
    • The Previews are stored alongside the icons, for icons the stored size is 32x32, for previews is 96x96 currently, but I have taken care that it shouldn't be too hard to change the sizes.
    • The previews are stored as a struct PreviewImage in the Material, Texture, World, Lamp and image struct
    • Creation of the preview images happens when drawing is requested by BIF_icon_draw_preview and there is no preview image present or the preview has been signalled that is has changed.
    • The images in the filesystem are currently created on the fly and not stored on the users harddisk, which means the old .bpib saving is gone for the moment. If this proves too slow, two alternatives could be investigated, first storing the thumbnails in a dir below the .blender directory, second loading the previews in a separate thread.
    • Images in the filesystem as well as the images loaded from an external file for linking or appending are not stored as a struct PreviewImage with a struct ID, but as a Image in the filelist and thus only live until the filelist is freed.
  • loading previews from external .blend when linking or appending
    • When the .blend file is saved with previews, these previews can be seen in the imagebrowser when linking or appending that file.
    • In this case no new previews are created (I think this might be possible to implement when it is possible to load individual library blocks without actually linking them.
    • The loading of the preview images from extenal library .blend files bypasses do_versions and linking, so currently only works with the patched version.
  • smaller change affecting nodes: moved nodeshadow to ui_dropshadow in interface_draw.c
  • drawing and event handling code
    • should be pretty standard, to make it interactive, the timer is checked and creation of previews and loading of images is stopped at this point. Only the rest of the existing previews are drawn. An event is the added to the queue if work is still to be done to load or create images.

Detail of changes per affected file

blenkernel:

  • icons.c, BKE_icons.h:
    • icons now check if there is a previewimage stored already, in which case no image is loaded and the material is also not rendered, but the preview image is used.
    • added functions to acces the stored preview images
    • license changed to GPL header block instead of old dual license
  • image.c
    • freeing of image also frees preview image.
  • material.c, object.c, texture.c, world.c
    • added preview image to material, lamp, texture and world
  • BLI_storage_types
    • added ImBuf pointer to each directory entry to potentially hold the image preview for display in the image browser-

blendloader

  • BLO_readfile.h, readfile.c:
    • new function BLO_blendhandle_get_previews to read the PreviewImage struct (if existing) from an external library file without actually linking the datablocks
    • added linking of the preview image as newdataadr
    • changed linking of SPACE_IMASEL (completely new SDNA struct)
    • implemented preliminary do_version
    • refactoring of BLO_library_append so scripts, filesel and filelist use basically same code.
  • readblenentry.c:
    • new function BLO_blendhandle_get_previews to read the PreviewImage struct (if existing) from an external library file without actually linking the datablocks
  • writefile.c:
    • added write_previews to store the previews with the relevant SDNA structs (like materials, textures, lamp, image, world)
  • IMB_imbuf.h, anim.c:
    • added function IMB_anim_previewframe(struct anim * anim) to fetch frame for preview from animation.

src

  • BIF_interface_icons.h, interface_icons.c:
    • new function BIF_icon_draw_preview for drawing of the larger preview images. These are stored along with the small icons in the .blend file to avoid time intensive recalculation of all previews.
    • general cleanup of code
    • made functions more general to be able to handle different (at the moment two) categories of 'icons': the smaller interface icons and the larger preview icons.
    • note: naming the categories of 'icons' mipmaps might be a bit misleading, looking for a better name still.
  • buttons_shading.c:
    • activate image browser with CTRL+LMB on load image button
  • drawnode.c:
    • moved nodeshadow to interface_draw.c, so other space types can reuse
  • glutil.c:
    • used fix provided by Matthew Plough (meestaplu) (thanks! - patch tracker #6772 ) to glDrawPixelsTex
    • small float inaccuracy fix which sometimes was drawing one line of pixels too much, leading to artifacts.
  • filesel.c, BSE_filesel.h:
    • removed activate for imasel, now in imasel.c
    • added a freefilelist(TODO: check what this was actually for)
  • headerbuttons.c
    • activate_imasel for databrowse
  • interface_draw.c, interface.h
    • moved nodeshadow.c to here as ui_dropshadow
  • resources.c
    • added themes for image browser
  • space.c
    • added preference for user to save (internal) previews in .blend file
    • new changeimaselspace and initimaselspace
    • set viewmat only after space (v2d) has been initialised
  • toets.c
    • activated imagebrowser on CTRL F1 for appending/linking
    • activated imagebrowser on CTRL+F4 for data select
  • usiblender.c
    • added init and freeing of icons (and previews)
  • quicktime.c
    • using GetMediaSampleCount to find frame count of movie instead of looping.
    • retrieve image depth earlier to avoid double checking



NEW ImageBrowser:

(probably easier to review these files on their own instead of checking diff)

  • BSE_drawimasel.h
  • drawimasel.c
  • BIF_imasel.h
  • imasel.c
  • editimasel.c
  • editscreen.c: added SPACE_IMASEL to areawinset
  • header_imasel.c
  • space.c: new changeimaselspace and initimaselspace
  • blendef.h: moved imasel event defines here
  • datatoc.h, new file prvicons.c:
    • added file prvicons for the default icons representing file types


  • BIF_filelist.h, filelist.c:
    • refactored functions dealing with directories out of filesel, to be able to use the same functionality within the imagebrowser. The functions are not used by filebrowser yet, refactoring in this direction is planned.