<NME> ResourceBrowser.h
<BEF> /*******************************
Copyright (c) 2016-2022 Grégoire Angerand

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
**********************************/
#ifndef EDITOR_WIDGETS_RESOURCEBROWSER_H
#define EDITOR_WIDGETS_RESOURCEBROWSER_H

#include "FileSystemView.h"

#include <yave/assets/AssetId.h>

#include <y/core/FixedArray.h>


namespace editor {

class ResourceBrowser : public FileSystemView {

    editor_widget(ResourceBrowser, "View")

    public:
        ResourceBrowser();

    protected:
        ResourceBrowser(std::string_view title);

        void on_gui() override;

        AssetId asset_id(std::string_view name) const;
        AssetType read_file_type(AssetId id) const;

        virtual void asset_selected(AssetId) {}

    protected:
        void update() override;

        void draw_context_menu() override;
        void path_changed() override;

        core::Result<core::String> entry_icon(const core::String& name, EntryType type) const override;
        void entry_hoverred(const Entry* entry) override;
	public:
		ResourceBrowser(ContextPtr ctx);

		void refresh();

	protected:
		virtual void asset_selected(const FileInfo& file) const;
        void draw_import_menu();

        void update_search();

        core::Vector<core::String> _path_pieces;
        core::Vector<core::String> _jump_menu;

		void paint_context_menu();

	private:
		template<typename T>
		void save_assets(const core::String& path, core::ArrayView<Named<T>> assets, const char* asset_name_type) const;

		void save_images(const core::String& path, core::ArrayView<Named<ImageData>> images) const;
		void save_meshes(const core::String& path, core::ArrayView<Named<MeshData>> meshes) const;
		void save_anims(const core::String& path, core::ArrayView<Named<Animation>> anims) const;
		void save_materials(const core::String& path, core::ArrayView<Named<BasicMaterialData>> mats) const;

		const FileSystemModel* filesystem() const;

		void set_current(DirNode* current);

}

#endif // EDITOR_WIDGETS_RESOURCEBROWSER_H


<MSG> Reworked import helpers

<DFF> @@ -59,7 +59,7 @@ class ResourceBrowser final : public Widget, public ContextLinked {
 	public:
 		ResourceBrowser(ContextPtr ctx);
 
-		void refresh();
+		void refresh() override;
 
 	protected:
 		virtual void asset_selected(const FileInfo& file) const;
@@ -73,14 +73,6 @@ class ResourceBrowser final : public Widget, public ContextLinked {
 		void paint_context_menu();
 
 	private:
-		template<typename T>
-		void save_assets(const core::String& path, core::ArrayView<Named<T>> assets, const char* asset_name_type) const;
-
-		void save_images(const core::String& path, core::ArrayView<Named<ImageData>> images) const;
-		void save_meshes(const core::String& path, core::ArrayView<Named<MeshData>> meshes) const;
-		void save_anims(const core::String& path, core::ArrayView<Named<Animation>> anims) const;
-		void save_materials(const core::String& path, core::ArrayView<Named<BasicMaterialData>> mats) const;
-
 		const FileSystemModel* filesystem() const;
 
 		void set_current(DirNode* current);

Reworked import helpers