1
0
mirror of synced 2025-01-30 19:43:43 +01:00

fix: Various pattern drawer issues

This commit is contained in:
WerWolv 2023-06-06 11:29:58 +02:00
parent 1e2cf87532
commit 456895a6a6
5 changed files with 17 additions and 24 deletions

@ -1 +1 @@
Subproject commit f0a68249e71f6a3f38fdba292c4a2c9e9bab3ad2
Subproject commit 456dd11fc74b12630c1c7679862cb665e741c4d0

View File

@ -174,7 +174,11 @@ namespace hex {
void TaskManager::init() {
for (u32 i = 0; i < std::thread::hardware_concurrency(); i++)
const auto threadCount = std::thread::hardware_concurrency();
log::debug("Initializing task manager thread pool with {} workers.", threadCount);
for (u32 i = 0; i < threadCount; i++)
TaskManager::s_workers.emplace_back(TaskManager::runner);
}
@ -207,6 +211,7 @@ namespace hex {
try {
task->m_function(*task);
log::debug("Finished task {}", task->m_unlocalizedName);
} catch (const Task::TaskInterruptor &) {
task->interruption();
} catch (const std::exception &e) {
@ -222,6 +227,7 @@ namespace hex {
}
TaskHolder TaskManager::createTask(std::string name, u64 maxValue, std::function<void(Task &)> function) {
log::debug("Creating task {}", name);
std::unique_lock lock(s_queueMutex);
auto task = std::make_shared<Task>(std::move(name), maxValue, false, std::move(function));
s_tasks.emplace_back(task);
@ -233,6 +239,7 @@ namespace hex {
}
TaskHolder TaskManager::createBackgroundTask(std::string name, std::function<void(Task &)> function) {
log::debug("Creating background task {}", name);
std::unique_lock lock(s_queueMutex);
auto task = std::make_shared<Task>(std::move(name), 0, true, std::move(function));

View File

@ -7,7 +7,6 @@
#include "init/splash_window.hpp"
#include "init/tasks.hpp"
#include "init/tasks.hpp"
#include <hex/api/task.hpp>
#include <hex/api/project_file_manager.hpp>

View File

@ -83,20 +83,6 @@ namespace hex::plugin::builtin::ui {
ImGui::TableNextColumn();
}
void drawNameColumn(const pl::ptrn::Pattern& pattern) {
highlightWhenSelected(pattern, [&]{
auto name = pattern.getDisplayName();
ImGui::TextFormatted("{}", name);
if (ImGui::CalcTextSize(name.c_str()).x > ImGui::GetColumnWidth()) {
ImGui::InfoTooltip(name.c_str());
}
});
ImGui::TableNextColumn();
}
void drawColorColumn(const pl::ptrn::Pattern& pattern) {
if (pattern.getVisibility() == pl::ptrn::Visibility::Visible)
ImGui::ColorButton("color", ImColor(pattern.getColor()), ImGuiColorEditFlags_NoTooltip, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()));
@ -364,12 +350,12 @@ namespace hex::plugin::builtin::ui {
void PatternDrawer::visit(pl::ptrn::PatternBitfieldField& pattern) {
ImGui::TableNextRow();
createTreeNode(pattern, true);
ImGui::TableNextColumn();
createTreeNode(pattern, true);
ImGui::SameLine(0, 0);
makeSelectable(pattern);
drawCommentTooltip(pattern);
ImGui::SameLine();
drawNameColumn(pattern);
ImGui::TableNextColumn();
drawColorColumn(pattern);
drawOffsetColumnForBitfieldMember(pattern);
ImGui::TableNextColumn();
@ -502,12 +488,12 @@ namespace hex::plugin::builtin::ui {
void PatternDrawer::visit(pl::ptrn::PatternEnum& pattern) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
createTreeNode(pattern, true);
ImGui::SameLine(0, 0);
makeSelectable(pattern);
drawCommentTooltip(pattern);
ImGui::TableNextColumn();
makeSelectable(pattern);
ImGui::SameLine();
drawNameColumn(pattern);
drawColorColumn(pattern);
drawOffsetColumn(pattern);
drawSizeColumn(pattern);
@ -834,6 +820,7 @@ namespace hex::plugin::builtin::ui {
if (chunkCount > displayEnd) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TableNextColumn();
ImGui::Selectable(hex::format("... ({})", "hex.builtin.pattern_drawer.double_click"_lang).c_str(), false, ImGuiSelectableFlags_SpanAllColumns);
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))