Implement state save/restore for custom viewers