#include <PaintableImageAssetHelper.h>
Inherited by GradientSignal::ImageCreatorUtils::PaintableImageAssetHelper< GradientSignal::EditorImageGradientComponent, GradientSignal::EditorImageGradientComponentMode >, and GradientSignal::ImageCreatorUtils::PaintableImageAssetHelper< EditorComponentType, EditorComponentModeType >.
|
using | DefaultSaveNameCallback = AZStd::function< AZ::IO::Path()> |
| Callback that provides the default name to use when creating or saving an image.
|
|
using | OnCreateImageCallback = AZStd::function< void(AZ::Data::Asset< AZ::Data::AssetData > createdAsset)> |
|
|
static void | Reflect (AZ::ReflectContext *context) |
|
|
using | ComponentModeDelegate = AzToolsFramework::ComponentModeFramework::ComponentModeDelegate |
| Delegates the handling of component editing mode to a paint controller.
|
|
|
void | CreateNewImage () |
| Create a new image.
|
|
AZ::IO::Path | GetIncrementingAutoSavePath (const AZ::IO::Path ¤tPath) const |
| Create a new filename with an incrementing number for the "auto save with incrementing names" mode.
|
|
bool | GetSaveLocation (AZ::IO::Path &fullPath, AZStd::string &relativePath, PaintableImageAssetAutoSaveMode autoSaveMode) |
| Determine where to save the image based on the autosave mode.
|
|
bool | RefreshImageAssetStatus (AZ::Data::Asset< AZ::Data::AssetData > imageAsset) |
| Refresh the current image asset load status.
|
|
AZStd::string | GetImageAssetStatusLabel () |
|
AZStd::string | GetRelativePathFromAbsolutePath (AZStd::string_view absolutePath) |
|
AZ::Crc32 | GetPaintModeVisibility () const |
| Returns whether or not the edit mode should currently be visible.
|
|
void | RefreshComponentModeStatus () |
|
virtual void | EnableComponentMode ()=0 |
|
bool | InComponentMode () const |
| Return whether or not component mode is currently active.
|
|
void | DisableComponentMode () |
| Disable component mode for this image asset.
|
|
|
static bool | ImageHasPendingJobs (const AZ::Data::AssetId &assetId) |
| Check to see if an image asset has any pending asset jobs.
|
|
|
ComponentModeDelegate | m_componentModeDelegate |
|
AZ::Data::AssetData::AssetStatus | m_currentImageAssetStatus = AZ::Data::AssetData::AssetStatus::NotLoaded |
|
bool | m_currentImageJobsPending = false |
|
bool | m_waitingForImageReload = false |
|
AZStd::string | m_baseAssetLabel |
|
PaintableImageAssetAutoSaveMode | m_autoSaveMode = PaintableImageAssetAutoSaveMode::AutoSave |
| Offer a choice of different autosave modes.
|
|
bool | m_promptedForSaveLocation = false |
|
AZ::EntityComponentIdPair | m_ownerEntityComponentIdPair = {} |
|
DefaultSaveNameCallback | m_defaultSaveNameCallback = {} |
|
OnCreateImageCallback | m_onCreateImageCallback = {} |
|
OutputFormat | m_defaultOutputFormat = OutputFormat::R8G8B8A8 |
|
Helper class to manage all the common logic and UX for paintable image creation, editing, and saving. This is split out from PaintableImageAssetHelper so that we can minimize the amount of duplicated code caused by the templatized parameters required for hooking it up to a specific editor component mode.
◆ OnCreateImageCallback
Callback that gets notified when a new asset has been created. The typical use is for the parent component to replace its asset reference and refresh itself.
◆ Activate()
void GradientSignal::ImageCreatorUtils::PaintableImageAssetHelperBase::Activate |
( |
AZ::EntityComponentIdPair |
ownerEntityComponentIdPair, |
|
|
OutputFormat |
defaultOutputFormat, |
|
|
AZStd::string |
baseAssetLabel, |
|
|
DefaultSaveNameCallback |
defaultSaveNameCallback, |
|
|
OnCreateImageCallback |
onCreateImageCallback |
|
) |
| |
Activate the PaintableImageAssetHelper. This should get called from the parent component's Activate() method.
- Parameters
-
ownerEntityComponentIdPair | The parent component's entity id and component id, used for component mode communications. |
defaultOutputFormat | The image output format that should be used for image creation and saving. |
baseAssetLabel | The base label to use for the image asset (ex: "Color Texture"). |
defaultSaveNameCallback | A callback that provides a default save name when creating or saving an image. |
onCreateImageCallback | A callback that gets called whenever an image gets created or saved. |
◆ Deactivate()
void GradientSignal::ImageCreatorUtils::PaintableImageAssetHelperBase::Deactivate |
( |
| ) |
|
◆ EnableComponentMode()
virtual void GradientSignal::ImageCreatorUtils::PaintableImageAssetHelperBase::EnableComponentMode |
( |
| ) |
|
|
protectedpure virtual |
◆ GetImageAssetStatusLabel()
AZStd::string GradientSignal::ImageCreatorUtils::PaintableImageAssetHelperBase::GetImageAssetStatusLabel |
( |
| ) |
|
|
protected |
Get a display label for the image asset that includes the current asset status.
- Parameters
-
baseName | The base name to use for the label (ex: "Image" will produce labels like "Image (not loaded)") |
- Returns
- The full label, based on the image asset's last refreshed status.
◆ GetRelativePathFromAbsolutePath()
AZStd::string GradientSignal::ImageCreatorUtils::PaintableImageAssetHelperBase::GetRelativePathFromAbsolutePath |
( |
AZStd::string_view |
absolutePath | ) |
|
|
protected |
Get the relative asset path from the absolute path, or empty if a relative asset path doesn't exist. This can happen if the absolute path exists outside of the project folder.
◆ Refresh()
AZStd::string GradientSignal::ImageCreatorUtils::PaintableImageAssetHelperBase::Refresh |
( |
AZ::Data::Asset< AZ::Data::AssetData > |
imageAsset | ) |
|
Refresh the PaintableImageAssetHelper. This should get called from the parent component whenever the image asset changes its status.
- Parameters
-
EditorComponentType | The class type of the parent editor component. |
EditorComponentModeType | The class type for the component mode to use when editing. |
imageAsset | The image asset that can be edited. |
- Returns
- The refreshed asset label containing the asset status (ex: "Color Texture (not loaded)")
◆ RefreshComponentModeStatus()
void GradientSignal::ImageCreatorUtils::PaintableImageAssetHelperBase::RefreshComponentModeStatus |
( |
| ) |
|
|
protected |
Enable/disable the component mode based on the current image asset load status. Only fully-loaded image assets are editable.
◆ SaveImage()
AZStd::optional< AZ::Data::Asset< AZ::Data::AssetData > > GradientSignal::ImageCreatorUtils::PaintableImageAssetHelperBase::SaveImage |
( |
int |
imageResolutionX, |
|
|
int |
imageResolutionY, |
|
|
OutputFormat |
format, |
|
|
AZStd::span< const uint8_t > |
pixelBuffer |
|
) |
| |
Save a source image with the given data, optionally prompting the user for a location depending on the autosave mode.
- Parameters
-
imageResolutionX | The image width in pixels |
imageResolutionY | The image height in pixels |
format | The output format to save the image in |
pixelBuffer | The pixel data to save |
- Returns
- A reference to the saved asset on success, empty on failure
◆ m_promptedForSaveLocation
bool GradientSignal::ImageCreatorUtils::PaintableImageAssetHelperBase::m_promptedForSaveLocation = false |
|
protected |
Track whether or not we've prompted the user for an image save location at least once since this component was created. This is intentionally not serialized so that every user is prompted at least once per editor run for autosaves. This choice prioritizes data safety over lower friction - it's too easy for autosave to overwrite data accidentally, so we want the user to specifically choose a save location at least once before overwriting without prompts. We could serialize the flag so that the user only selects a location once per component, instead of once per component per Editor run, but that serialized flag would be shared with other users, so we would have other users editing the same image that never get prompted and might overwrite data by mistake.
The documentation for this class was generated from the following file:
- Gems/GradientSignal/Code/Include/GradientSignal/Editor/PaintableImageAssetHelper.h