@@ -44,6 +44,14 @@ set(MSDFGEN_DISABLE_SVG ON)
|
|||||||
set(MSDFGEN_DISABLE_PNG ON)
|
set(MSDFGEN_DISABLE_PNG ON)
|
||||||
FetchContent_MakeAvailable(msdfgen)
|
FetchContent_MakeAvailable(msdfgen)
|
||||||
|
|
||||||
|
FetchContent_Declare(
|
||||||
|
mINI
|
||||||
|
GIT_REPOSITORY https://github.com/metayeti/mINI.git
|
||||||
|
GIT_TAG "0.9.18"
|
||||||
|
GIT_SHALLOW 1
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(mINI)
|
||||||
|
|
||||||
find_program(WAYLAND_SCANNER wayland-scanner REQUIRED)
|
find_program(WAYLAND_SCANNER wayland-scanner REQUIRED)
|
||||||
|
|
||||||
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
|
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
|
||||||
@@ -140,6 +148,7 @@ add_custom_target(generate_protocols ALL
|
|||||||
add_executable(waylight
|
add_executable(waylight
|
||||||
${GEN_C_PRIVATES}
|
${GEN_C_PRIVATES}
|
||||||
|
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src/IconRegistry.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/TextRenderer.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/TextRenderer.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/ImGui.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/ImGui.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/App.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/App.cpp
|
||||||
@@ -163,6 +172,7 @@ target_link_libraries(waylight PRIVATE
|
|||||||
PkgConfig::FONTCONFIG
|
PkgConfig::FONTCONFIG
|
||||||
PkgConfig::HARFBUZZ
|
PkgConfig::HARFBUZZ
|
||||||
|
|
||||||
|
mINI
|
||||||
raylib
|
raylib
|
||||||
msdfgen::msdfgen-core
|
msdfgen::msdfgen-core
|
||||||
msdfgen::msdfgen-ext
|
msdfgen::msdfgen-ext
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#include <mini/ini.h>
|
||||||
|
|
||||||
IconTheme::IconTheme(std::filesystem::path const &themes_directory_path)
|
IconTheme::IconTheme(std::filesystem::path const &themes_directory_path)
|
||||||
{
|
{
|
||||||
for (auto const &dir :
|
for (auto const &dir :
|
||||||
@@ -15,6 +17,56 @@ IconTheme::IconTheme(std::filesystem::path const &themes_directory_path)
|
|||||||
auto const index_path = dir.path() / "index.theme";
|
auto const index_path = dir.path() / "index.theme";
|
||||||
if (std::filesystem::is_regular_file(index_path))
|
if (std::filesystem::is_regular_file(index_path))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
mINI::INIFile ini_file(index_path);
|
||||||
|
mINI::INIStructure ini;
|
||||||
|
ini_file.read(ini);
|
||||||
|
|
||||||
|
auto const &directories { ini["Icon Theme"]["Directories"] };
|
||||||
|
for (auto const &&dir_entry : directories | std::views::split(':')) {
|
||||||
|
auto const dir_entry_str { std::string(
|
||||||
|
dir_entry.begin(), dir_entry.end()) };
|
||||||
|
auto const path { std::filesystem::path(dir_entry_str) };
|
||||||
|
auto const path_actual { dir.path() / path };
|
||||||
|
|
||||||
|
if (!std::filesystem::is_directory(path_actual))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto const &type_raw { ini[dir_entry_str]["Type"] };
|
||||||
|
DirectoryEntry::Type type;
|
||||||
|
if (type_raw == "Fixed") {
|
||||||
|
type = DirectoryEntry::Type::Fixed;
|
||||||
|
} else if (type_raw == "Scalable") {
|
||||||
|
type = DirectoryEntry::Type::Scalable;
|
||||||
|
} else if (type_raw == "Threshold") {
|
||||||
|
type = DirectoryEntry::Type::Threshold;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto const &context_raw { ini[dir_entry_str]["context"] };
|
||||||
|
DirectoryEntry::Context context;
|
||||||
|
if (context_raw == "Actions") {
|
||||||
|
context = DirectoryEntry::Context::Actions;
|
||||||
|
} else if (type_raw == "Devices") {
|
||||||
|
context = DirectoryEntry::Context::Devices;
|
||||||
|
} else if (type_raw == "FileSystems") {
|
||||||
|
context = DirectoryEntry::Context::FileSystems;
|
||||||
|
} else if (type_raw == "MomeTypes") {
|
||||||
|
context = DirectoryEntry::Context::MimeTypes;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int size { std::atoi(ini[dir_entry_str]["Size"].c_str()) };
|
||||||
|
|
||||||
|
m_directories.push_back({
|
||||||
|
.path = path,
|
||||||
|
.size = size,
|
||||||
|
.type = type,
|
||||||
|
.context = context,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +96,7 @@ IconRegistry::IconRegistry()
|
|||||||
theme_directory_paths.push_back(path);
|
theme_directory_paths.push_back(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const &path : std::move(theme_directory_paths)
|
for (auto &&path : std::move(theme_directory_paths)
|
||||||
| std::views::filter([](std::filesystem::path &path) {
|
| std::views::filter([](std::filesystem::path &path) {
|
||||||
return std::filesystem::is_directory(path);
|
return std::filesystem::is_directory(path);
|
||||||
})) {
|
})) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <span>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -10,8 +11,35 @@ struct IconTheme {
|
|||||||
IconTheme(std::filesystem::path const &themes_directory_path);
|
IconTheme(std::filesystem::path const &themes_directory_path);
|
||||||
~IconTheme() = default;
|
~IconTheme() = default;
|
||||||
|
|
||||||
|
auto inherits() const -> std::span<std::string const>
|
||||||
|
{
|
||||||
|
return std::span { m_inherits };
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct DirectoryEntry {
|
||||||
|
enum class Type {
|
||||||
|
Fixed,
|
||||||
|
Scalable,
|
||||||
|
Threshold,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class Context {
|
||||||
|
Actions,
|
||||||
|
Devices,
|
||||||
|
FileSystems,
|
||||||
|
MimeTypes,
|
||||||
|
};
|
||||||
|
|
||||||
|
std::filesystem::path path;
|
||||||
|
int size;
|
||||||
|
Type type;
|
||||||
|
Context context;
|
||||||
|
};
|
||||||
|
|
||||||
std::unordered_map<std::string, Icon> m_cached_icons;
|
std::unordered_map<std::string, Icon> m_cached_icons;
|
||||||
|
std::vector<std::string> m_inherits;
|
||||||
|
std::vector<DirectoryEntry> m_directories;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IconRegistry {
|
struct IconRegistry {
|
||||||
|
|||||||
@@ -118,11 +118,7 @@ private:
|
|||||||
{
|
{
|
||||||
return sel_anchor_idx != -1 && sel_anchor_idx != curr_idx;
|
return sel_anchor_idx != -1 && sel_anchor_idx != curr_idx;
|
||||||
}
|
}
|
||||||
void clear_selection()
|
void clear_selection() { sel_anchor_idx = -1; }
|
||||||
{
|
|
||||||
sel_anchor_idx = -1;
|
|
||||||
selecting_all = false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ListViewState {
|
struct ListViewState {
|
||||||
|
|||||||
Reference in New Issue
Block a user