aboutsummaryrefslogtreecommitdiff
path: root/mayaPlug/shaveIcon.h
blob: 0e78e7ff53ebe58bb73360a308bee998b9727b3f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef shaveIcon_h
#define shaveIcon_h
// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962

#include <maya/MIntArray.h>
#include <maya/MString.h>
#include <maya/MStringArray.h>


class shaveIcon
{
public:
	static void	cleanup();

	//
	// Whenever Maya loads a new icon, it caches the image and never looks
	// at the file again.  This can be annoying when you are using icons as
	// swatches which can be updated during the course of a session.
	//
	// Maya does provide a 'reloadImage' MEL command to reload an icon from
	// its file, into a specific UI control.  However, there is no way to
	// determine whether the icon *needs* to be reloaded.  So you're stuck
	// with always doing the reload, which results in doubled load time the
	// first time the icon is used, and an extra load even when it hasn't
	// changed.
	//
	// This method gets around that by allowing you to register an icon
	// whenever you use it.  It compares timestamps and returns true if the
	// icon needs to be reloaded.
	//
	static bool	needsReload(MString iconFile);

protected:
	static MStringArray	mIcons;
	static MIntArray	mTimestamps;
};

#endif