Shkyera Engine
Easy to use, game engine for Python
shkyera::FilesystemWidget Class Reference

A user interface widget for interacting with the filesystem. More...

#include <FilesystemWidget.hpp>

Inheritance diagram for shkyera::FilesystemWidget:
[legend]

Public Member Functions

virtual void draw () override
 Implementation of the abstract draw method to render the filesystem widget. More...
 
void setDirectory (std::filesystem::path path)
 Set the current working directory to display its contents. More...
 
 Widget (std::string name)
 Constructor to create a widget with a specified name. More...
 
- Public Member Functions inherited from shkyera::Widget
 Widget (std::string name)
 Constructor to create a widget with a specified name. More...
 

Private Member Functions

void drawDirectoryTree (const std::shared_ptr< Directory > directory)
 Draw the directory tree, starting from the specified directory. More...
 
void drawDirectoryContents (const std::shared_ptr< Directory > directory)
 Draw the contents of the specified directory. More...
 
void drawDirectory (const std::shared_ptr< Directory > directory)
 Draw a directory icon and name. More...
 
void drawFile (const std::shared_ptr< File > file)
 Draw a file icon and name. More...
 
void drawIconName (const std::string name) const
 Draw an icon and name within the UI. More...
 
void handleRightMouseClick ()
 Handle a right mouse click within the UI. More...
 
void drawCreateMenu () const
 Draw a context menu for creating new files or directories. More...
 
ImTextureID getTextureOfFile (const std::shared_ptr< File > file) const
 Get the texture ID associated with a specific file for rendering an icon. More...
 

Static Private Member Functions

static std::string getDisplayableName (std::string name, size_t maxCharactersInLine=12)
 Get a displayable name for rendering within the UI, ensuring it doesn't exceed a maximum line length. More...
 

Private Attributes

std::shared_ptr< Directory_currentDirectory
 The current working directory to display. More...
 
std::vector< std::shared_ptr< Directory > > _directoriesToDisplay
 Directories to display in the UI. More...
 
std::vector< std::shared_ptr< File > > _filesToDisplay
 Files to display in the UI. More...
 
bool _hoveredIcon
 A flag indicating whether an icon is currently hovered. More...
 

Static Private Attributes

static constexpr float CONTENTS_ICON_SIZE = 64
 The size of icons representing directory contents. More...
 
static std::string DEFAULT_FOLDER_NAME = "New Folder"
 The default folder name. More...
 
static std::string DEFAULT_FILE_NAME = "object.py"
 The default file name. More...
 

Additional Inherited Members

- Public Attributes inherited from shkyera::Widget
std::string _name
 The name of the widget. More...
 

Detailed Description

A user interface widget for interacting with the filesystem.

The FilesystemWidget class provides a graphical user interface for navigating and interacting with the filesystem, displaying directories, files, and enabling file-related actions.

Member Function Documentation

◆ draw()

void shkyera::FilesystemWidget::draw ( )
overridevirtual

Implementation of the abstract draw method to render the filesystem widget.

Apologies to the reader for this hack

Implements shkyera::Widget.

◆ drawCreateMenu()

void shkyera::FilesystemWidget::drawCreateMenu ( ) const
private

Draw a context menu for creating new files or directories.

◆ drawDirectory()

void shkyera::FilesystemWidget::drawDirectory ( const std::shared_ptr< Directory directory)
private

Draw a directory icon and name.

Parameters
directoryThe directory to draw.

◆ drawDirectoryContents()

void shkyera::FilesystemWidget::drawDirectoryContents ( const std::shared_ptr< Directory directory)
private

Draw the contents of the specified directory.

Parameters
directoryThe directory whose contents to draw.

◆ drawDirectoryTree()

void shkyera::FilesystemWidget::drawDirectoryTree ( const std::shared_ptr< Directory directory)
private

Draw the directory tree, starting from the specified directory.

Parameters
directoryThe root directory to draw.

◆ drawFile()

void shkyera::FilesystemWidget::drawFile ( const std::shared_ptr< File file)
private

Draw a file icon and name.

Parameters
fileThe file to draw.

◆ drawIconName()

void shkyera::FilesystemWidget::drawIconName ( const std::string  name) const
private

Draw an icon and name within the UI.

Parameters
nameThe name to display.

◆ getDisplayableName()

std::string shkyera::FilesystemWidget::getDisplayableName ( std::string  name,
size_t  maxCharactersInLine = 12 
)
staticprivate

Get a displayable name for rendering within the UI, ensuring it doesn't exceed a maximum line length.

Parameters
nameThe original name.
maxCharactersInLineThe maximum number of characters in a line.
Returns
The displayable name.

◆ getTextureOfFile()

ImTextureID shkyera::FilesystemWidget::getTextureOfFile ( const std::shared_ptr< File file) const
private

Get the texture ID associated with a specific file for rendering an icon.

Parameters
fileThe file for which to retrieve the texture ID.
Returns
The texture ID for rendering the file's icon.

◆ handleRightMouseClick()

void shkyera::FilesystemWidget::handleRightMouseClick ( )
private

Handle a right mouse click within the UI.

◆ setDirectory()

void shkyera::FilesystemWidget::setDirectory ( std::filesystem::path  path)

Set the current working directory to display its contents.

Parameters
pathThe path to the directory to set as the current working directory.

◆ Widget()

shkyera::Widget::Widget

Constructor to create a widget with a specified name.

Parameters
nameThe name of the widget.

Member Data Documentation

◆ _currentDirectory

std::shared_ptr<Directory> shkyera::FilesystemWidget::_currentDirectory
private

The current working directory to display.

◆ _directoriesToDisplay

std::vector<std::shared_ptr<Directory> > shkyera::FilesystemWidget::_directoriesToDisplay
private

Directories to display in the UI.

◆ _filesToDisplay

std::vector<std::shared_ptr<File> > shkyera::FilesystemWidget::_filesToDisplay
private

Files to display in the UI.

◆ _hoveredIcon

bool shkyera::FilesystemWidget::_hoveredIcon
private

A flag indicating whether an icon is currently hovered.

◆ CONTENTS_ICON_SIZE

constexpr float shkyera::FilesystemWidget::CONTENTS_ICON_SIZE = 64
staticconstexprprivate

The size of icons representing directory contents.

◆ DEFAULT_FILE_NAME

std::string shkyera::FilesystemWidget::DEFAULT_FILE_NAME = "object.py"
staticprivate

The default file name.

◆ DEFAULT_FOLDER_NAME

std::string shkyera::FilesystemWidget::DEFAULT_FOLDER_NAME = "New Folder"
staticprivate

The default folder name.


The documentation for this class was generated from the following files: