Continuing with GUI move to events, and fixed build system missing EGL (broken build)

This commit is contained in:
Yousef Khadadeh 2026-03-29 20:23:38 +03:00
parent ef7dfcef05
commit 644bb85d99
11 changed files with 145 additions and 142 deletions

View file

@ -206,6 +206,10 @@ if((NOT EMSCRIPTEN) AND (NOT APPLE))
find_package(TBB REQUIRED)
endif()
if((NOT (GRAPHICS_BACKEND STREQUAL "Vulkan")) AND (NOT EMSCRIPTEN) AND LINUX AND (NOT NO_CONAN_BUILD))
find_package(egl)
endif()
find_package(zstd REQUIRED)
message("Skia root: " ${SKIA_INCLUDE})
@ -380,6 +384,10 @@ if((NOT (GRAPHICS_BACKEND STREQUAL "Vulkan")) AND (NOT EMSCRIPTEN) AND LINUX)
target_link_libraries(main OpenGL::EGL)
endif()
if((NOT (GRAPHICS_BACKEND STREQUAL "Vulkan")) AND (NOT EMSCRIPTEN) AND LINUX AND (NOT NO_CONAN_BUILD))
target_link_libraries(infinipaint egl::egl)
endif()
if(ANDROID)
target_link_libraries(main EGL)
endif()

View file

@ -90,6 +90,8 @@ class CompressorRecipe(ConanFile):
if self.settings.os == "Linux":
self.requires("fontconfig/2.17.1")
self.requires("egl/system")
self.requires("sdl/3.4.0", options = {
"wayland": False,
"x11": True,

View file

@ -36,6 +36,12 @@
#include "Tools/EraserTool.hpp"
#include "../GUIStuff/Elements/LayoutElement.hpp"
#include "../GUIStuff/Elements/RotateWheel.hpp"
#include "../GUIStuff/Elements/PositionAdjustingPopupMenu.hpp"
#include "../GUIStuff/ElementHelpers/ButtonHelpers.hpp"
#include "../GUIStuff/ElementHelpers/TextLabelHelpers.hpp"
DrawingProgram::DrawingProgram(World& initWorld):
world(initWorld),
drawCache(*this),
@ -320,118 +326,128 @@ void DrawingProgram::send_transforms_for(const std::vector<CanvasComponentContai
}
void DrawingProgram::toolbar_gui() {
using namespace GUIStuff;
using namespace ElementHelpers;
Toolbar& t = world.main.toolbar;
t.gui.push_id("Drawing Program Toolbar GUI");
Clay_ElementId localID = CLAY_ID_LOCAL("Drawing program toolbar GUI");
CLAY(localID, {
.layout = {
.sizing = {.width = CLAY_SIZING_FIT(0), .height = CLAY_SIZING_FIT(0)},
.padding = CLAY_PADDING_ALL(static_cast<uint16_t>(t.io->theme->padding1 / 2)),
.childGap = static_cast<uint16_t>(t.io->theme->childGap1 / 2),
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP},
.layoutDirection = CLAY_TOP_TO_BOTTOM
},
.backgroundColor = convert_vec4<Clay_Color>(t.io->theme->backColor1),
.cornerRadius = CLAY_CORNER_RADIUS(t.io->theme->windowCorners1)
}) {
t.gui.obstructing_window(localID);
if(t.gui.svg_icon_button_transparent("Brush Toolbar Button", "data/icons/brush.svg", drawTool->get_type() == DrawingProgramToolType::BRUSH)) { switch_to_tool(DrawingProgramToolType::BRUSH); }
if(t.gui.svg_icon_button_transparent("Eraser Toolbar Button", "data/icons/eraser.svg", drawTool->get_type() == DrawingProgramToolType::ERASER)) { switch_to_tool(DrawingProgramToolType::ERASER); }
if(t.gui.svg_icon_button_transparent("Line Toolbar Button", "data/icons/line.svg", drawTool->get_type() == DrawingProgramToolType::LINE)) { switch_to_tool(DrawingProgramToolType::LINE); }
if(t.gui.svg_icon_button_transparent("Text Toolbar Button", "data/icons/text.svg", drawTool->get_type() == DrawingProgramToolType::TEXTBOX)) { switch_to_tool(DrawingProgramToolType::TEXTBOX); }
if(t.gui.svg_icon_button_transparent("Ellipse Toolbar Button", "data/icons/circle.svg", drawTool->get_type() == DrawingProgramToolType::ELLIPSE)) { switch_to_tool(DrawingProgramToolType::ELLIPSE); }
if(t.gui.svg_icon_button_transparent("Rect Toolbar Button", "data/icons/rectangle.svg", drawTool->get_type() == DrawingProgramToolType::RECTANGLE)) { switch_to_tool(DrawingProgramToolType::RECTANGLE); }
if(t.gui.svg_icon_button_transparent("RectSelect Toolbar Button", "data/icons/rectselect.svg", drawTool->get_type() == DrawingProgramToolType::RECTSELECT)) { switch_to_tool(DrawingProgramToolType::RECTSELECT); }
if(t.gui.svg_icon_button_transparent("LassoSelect Toolbar Button", "data/icons/lassoselect.svg", drawTool->get_type() == DrawingProgramToolType::LASSOSELECT)) { switch_to_tool(DrawingProgramToolType::LASSOSELECT); }
if(t.gui.svg_icon_button_transparent("Edit Toolbar Button", "data/icons/cursor.svg", drawTool->get_type() == DrawingProgramToolType::EDIT)) { switch_to_tool(DrawingProgramToolType::EDIT); }
if(t.gui.svg_icon_button_transparent("Eyedropper Toolbar Button", "data/icons/eyedropper.svg", drawTool->get_type() == DrawingProgramToolType::EYEDROPPER)) { switch_to_tool(DrawingProgramToolType::EYEDROPPER); }
if(t.gui.svg_icon_button_transparent("Zoom Canvas Toolbar Button", "data/icons/zoom.svg", drawTool->get_type() == DrawingProgramToolType::ZOOM)) { switch_to_tool(DrawingProgramToolType::ZOOM); }
if(t.gui.svg_icon_button_transparent("Pan Canvas Toolbar Button", "data/icons/hand.svg", drawTool->get_type() == DrawingProgramToolType::PAN)) { switch_to_tool(DrawingProgramToolType::PAN); }
t.gui.element<LayoutElement>("Drawing Program Toolbar GUI", [&] {
CLAY_AUTO_ID({
.layout = {
.sizing = {.width = CLAY_SIZING_FIT(0), .height = CLAY_SIZING_FIT(0)},
.padding = CLAY_PADDING_ALL(static_cast<uint16_t>(t.io->theme->padding1 / 2)),
.childGap = static_cast<uint16_t>(t.io->theme->childGap1 / 2),
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP},
.layoutDirection = CLAY_TOP_TO_BOTTOM
},
.backgroundColor = convert_vec4<Clay_Color>(t.io->theme->backColor1),
.cornerRadius = CLAY_CORNER_RADIUS(t.io->theme->windowCorners1)
}) {
double newRotationAngle = world.drawData.cam.c.rotation, oldRotationAngle = world.drawData.cam.c.rotation;
t.gui.rotate_wheel("Canvas Rotate Wheel", &newRotationAngle);
if(newRotationAngle != oldRotationAngle)
world.drawData.cam.c.rotate_about(world.drawData.cam.c.from_space(world.main.window.size.cast<float>() * 0.5f), newRotationAngle - oldRotationAngle);
auto tool_button = [&](const char* id, const std::string& svgPath, DrawingProgramToolType toolType) {
svg_icon_button(t.gui, id, svgPath, {
.drawType = SelectableButton::DrawType::TRANSPARENT_ALL,
.isSelected = drawTool->get_type() == toolType,
.onClick = [&, toolType] {
switch_to_tool(toolType);
}
});
};
auto& globalConf = world.main.toolConfig.globalConf;
tool_button("Brush Toolbar Button", "data/icons/brush.svg", DrawingProgramToolType::BRUSH);
tool_button("Eraser Toolbar Button", "data/icons/eraser.svg", DrawingProgramToolType::ERASER);
tool_button("Line Toolbar Button", "data/icons/line.svg", DrawingProgramToolType::LINE);
tool_button("Text Toolbar Button", "data/icons/text.svg", DrawingProgramToolType::TEXTBOX);
tool_button("Ellipse Toolbar Button", "data/icons/circle.svg", DrawingProgramToolType::ELLIPSE);
tool_button("Rect Toolbar Button", "data/icons/rectangle.svg", DrawingProgramToolType::RECTANGLE);
tool_button("RectSelect Toolbar Button", "data/icons/rectselect.svg", DrawingProgramToolType::RECTSELECT);
tool_button("LassoSelect Toolbar Button", "data/icons/lassoselect.svg", DrawingProgramToolType::LASSOSELECT);
tool_button("Edit Toolbar Button", "data/icons/cursor.svg", DrawingProgramToolType::EDIT);
tool_button("Eyedropper Toolbar Button", "data/icons/eyedropper.svg", DrawingProgramToolType::EYEDROPPER);
tool_button("Zoom Canvas Toolbar Button", "data/icons/zoom.svg", DrawingProgramToolType::ZOOM);
tool_button("Pan Canvas Toolbar Button", "data/icons/hand.svg", DrawingProgramToolType::PAN);
if(t.gui.big_color_button("Foreground Color", &globalConf.foregroundColor, &globalConf.foregroundColor == t.colorLeft))
t.color_selector_left(&globalConf.foregroundColor == t.colorLeft ? nullptr : &globalConf.foregroundColor);
if(t.gui.big_color_button("Background Color", &globalConf.backgroundColor, &globalConf.backgroundColor == t.colorLeft))
t.color_selector_left(&globalConf.backgroundColor == t.colorLeft ? nullptr : &globalConf.backgroundColor);
}
t.gui.pop_id();
std::shared_ptr<double> oldRotationAngle = std::make_shared<double>(world.drawData.cam.c.rotation);
t.gui.element<RotateWheel>("Canvas Rotate Wheel", &world.drawData.cam.c.rotation, [&, oldRotationAngle] {
world.drawData.cam.c.rotate_about(world.drawData.cam.c.from_space(world.main.window.size.cast<float>() * 0.5f), world.drawData.cam.c.rotation - *oldRotationAngle);
*oldRotationAngle = world.drawData.cam.c.rotation;
});
}
});
}
void DrawingProgram::popup_menu_action_button(const char* id, const char* text, const std::function<void()>& onClick) {
GUIStuff::ElementHelpers::text_button(world.main.toolbar.gui, id, text, {
.drawType = GUIStuff::SelectableButton::DrawType::TRANSPARENT_ALL,
.wide = true,
.onClick = onClick
});
}
// Should only be used in selection allowing tools
bool DrawingProgram::selection_action_menu(Vector2f popupPos) {
void DrawingProgram::selection_action_menu(Vector2f popupPos) {
using namespace GUIStuff;
using namespace ElementHelpers;
Toolbar& t = world.main.toolbar;
bool shouldClose = false;
t.gui.list_popup_menu("Selection popup menu", popupPos, [&]() {
t.gui.text_label_light("Selection menu");
if(t.gui.text_button_left_transparent("Paste", "Paste")) {
t.gui.element<PositionAdjustingPopupMenu>("Selection popup menu", popupPos, [&, popupPos] {
text_label_light(t.gui, "Selection menu");
popup_menu_action_button("Paste", "Paste", [&] {
selection.deselect_all();
selection.paste_clipboard(popupPos * t.final_gui_scale());
shouldClose = true;
}
if(t.gui.text_button_left_transparent("Paste Image", "Paste Image")) {
});
popup_menu_action_button("Paste Image", "Paste Image", [&] {
selection.deselect_all();
selection.paste_image(popupPos * t.final_gui_scale());
shouldClose = true;
}
});
if(selection.is_something_selected()) {
if(t.gui.text_button_left_transparent("Copy", "Copy")) {
popup_menu_action_button("Copy", "Copy", [&] {
selection.selection_to_clipboard();
shouldClose = true;
}
if(t.gui.text_button_left_transparent("Cut", "Cut")) {
});
popup_menu_action_button("Cut", "Cut", [&] {
selection.selection_to_clipboard();
selection.delete_all();
shouldClose = true;
}
if(t.gui.text_button_left_transparent("Delete", "Delete")) {
});
popup_menu_action_button("Delete", "Delete", [&] {
selection.delete_all();
shouldClose = true;
}
if(t.gui.text_button_left_transparent("Bring to front of layer", "Bring to front of layer")) {
});
popup_menu_action_button("Bring to front of layer", "Bring to front of layer", [&] {
selection.push_selection_to_front();
shouldClose = true;
}
if(t.gui.text_button_left_transparent("Send to back of layer", "Send to back of layer")) {
});
popup_menu_action_button("Send to back of layer", "Send to back of layer", [&] {
selection.push_selection_to_back();
shouldClose = true;
}
});
}
});
return !shouldClose;
}
bool DrawingProgram::right_click_popup_gui(Vector2f popupPos) {
void DrawingProgram::right_click_popup_gui(Vector2f popupPos) {
Toolbar& t = world.main.toolbar;
t.gui.push_id("Drawing Program right click GUI");
bool toRet = drawTool->right_click_popup_gui(popupPos);
drawTool->right_click_popup_gui(popupPos);
t.gui.pop_id();
return toRet;
}
void DrawingProgram::tool_options_gui() {
using namespace GUIStuff;
Toolbar& t = world.main.toolbar;
float minGUIWidth = drawTool->get_type() == DrawingProgramToolType::SCREENSHOT ? 300 : 200;
Clay_ElementId localID = CLAY_ID_LOCAL("Drawing program tool options gui");
CLAY(localID, {
.layout = {
.sizing = {.width = CLAY_SIZING_FIT(minGUIWidth), .height = CLAY_SIZING_FIT(0)},
.padding = CLAY_PADDING_ALL(t.io->theme->padding1),
.childGap = t.io->theme->childGap1,
.childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_TOP},
.layoutDirection = CLAY_TOP_TO_BOTTOM
},
.backgroundColor = convert_vec4<Clay_Color>(t.io->theme->backColor1),
.cornerRadius = CLAY_CORNER_RADIUS(t.io->theme->windowCorners1)
}) {
t.gui.obstructing_window(localID);
drawTool->gui_toolbox();
}
t.gui.element<LayoutElement>("Drawing program tool options gui", [&] {
CLAY_AUTO_ID({
.layout = {
.sizing = {.width = CLAY_SIZING_FIT(minGUIWidth), .height = CLAY_SIZING_FIT(0)},
.padding = CLAY_PADDING_ALL(t.io->theme->padding1),
.childGap = t.io->theme->childGap1,
.childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_TOP},
.layoutDirection = CLAY_TOP_TO_BOTTOM
},
.backgroundColor = convert_vec4<Clay_Color>(t.io->theme->backColor1),
.cornerRadius = CLAY_CORNER_RADIUS(t.io->theme->windowCorners1)
}) {
drawTool->gui_toolbox();
}
});
}
void DrawingProgram::modify_grid(const NetworkingObjects::NetObjWeakPtr<WorldGrid>& gridToModify) {
@ -498,6 +514,7 @@ void DrawingProgram::switch_to_tool_ptr(std::unique_ptr<DrawingProgramToolBase>
drawTool->switch_tool(newTool->get_type());
drawTool = std::move(newTool);
world.main.toolbar.rightClickPopupLocation = std::nullopt;
world.main.toolbar.gui.set_to_layout();
}
void DrawingProgram::switch_to_tool(DrawingProgramToolType newToolType, bool force) {

View file

@ -27,7 +27,7 @@ class DrawingProgram {
void server_init_no_file();
void toolbar_gui();
void tool_options_gui();
bool right_click_popup_gui(Vector2f popupPos);
void right_click_popup_gui(Vector2f popupPos);
void update();
void scale_up(const WorldScalar& scaleUpAmount);
void draw(SkCanvas* canvas, const DrawData& drawData);
@ -77,7 +77,8 @@ class DrawingProgram {
void check_updateable_components();
void update_downloading_dropped_files();
bool selection_action_menu(Vector2f popupPos);
void selection_action_menu(Vector2f popupPos);
void popup_menu_action_button(const char* id, const char* text, const std::function<void()>& onClick);
void rebuild_cache();
std::atomic<bool> addFileInNextFrame = false;

View file

@ -7,6 +7,9 @@
#include "Helpers/Logger.hpp"
#include "Tools/DrawingProgramToolBase.hpp"
#include "../GUIStuff/ElementHelpers/NumberSliderHelpers.hpp"
#include "../GUIStuff/ElementHelpers/ButtonHelpers.hpp"
float& ToolConfiguration::get_stroke_size_relative_width_ref(DrawingProgramToolType toolType) {
if(globalConf.useGlobalRelativeWidth)
return globalConf.relativeWidth;
@ -80,11 +83,14 @@ void ToolConfiguration::print_relative_width_fail_message(RelativeWidthFailCode
void ToolConfiguration::relative_width_gui(DrawingProgram& drawP, const char* label) {
auto& gui = drawP.world.main.toolbar.gui;
auto& lockedCameraScale = drawP.controls.lockedCameraScale;
gui.slider_scalar_field<float>("relstrokewidth", label, &get_stroke_size_relative_width_ref(drawP.drawTool->get_type()), 3.0f, 40.0f);
if(gui.text_button_wide("lock brush size", lockedCameraScale.has_value() ? "Unlock Size" : "Lock Size to Zoom")) {
if(lockedCameraScale.has_value())
lockedCameraScale = std::nullopt;
else
lockedCameraScale = drawP.world.drawData.cam.c.inverseScale;
}
GUIStuff::ElementHelpers::slider_scalar_field(gui, "relstrokewidth", label, &get_stroke_size_relative_width_ref(drawP.drawTool->get_type()), 3.0f, 40.0f);
GUIStuff::ElementHelpers::text_button(gui, "lock brush size", lockedCameraScale.has_value() ? "Unlock Size" : "Lock Size to Zoom", {
.wide = true,
.onClick = [&] {
if(lockedCameraScale.has_value())
lockedCameraScale = std::nullopt;
else
lockedCameraScale = drawP.world.drawData.cam.c.inverseScale;
}
});
}

View file

@ -10,6 +10,9 @@
#include "../../CanvasComponents/CanvasComponentContainer.hpp"
#include <chrono>
#include "../../GUIStuff/ElementHelpers/TextLabelHelpers.hpp"
#include "../../GUIStuff/ElementHelpers/CheckBoxHelpers.hpp"
#define VEL_SMOOTH_MIN 0.6
#define VEL_SMOOTH_MAX 1.0
#define MINIMUM_DISTANCE_TO_NEXT_POINT 0.002f
@ -165,15 +168,18 @@ void BrushTool::commit_stroke() {
}
void BrushTool::gui_toolbox() {
using namespace GUIStuff;
using namespace ElementHelpers;
Toolbar& t = drawP.world.main.toolbar;
t.gui.push_id("brush tool");
t.gui.text_label_centered("Brush");
t.gui.checkbox_field("hasroundcaps", "Round Caps", &drawP.world.main.toolConfig.brush.hasRoundCaps);
text_label_centered(t.gui, "Brush");
checkbox_boolean_field(t.gui, "hasroundcaps", "Round Caps", &drawP.world.main.toolConfig.brush.hasRoundCaps);
drawP.world.main.toolConfig.relative_width_gui(drawP, "Size");
t.gui.pop_id();
}
bool BrushTool::right_click_popup_gui(Vector2f popupPos) {
void BrushTool::right_click_popup_gui(Vector2f popupPos) {
Toolbar& t = drawP.world.main.toolbar;
t.paint_popup(popupPos);
return true;

View file

@ -19,7 +19,7 @@ class BrushTool : public DrawingProgramToolBase {
virtual DrawingProgramToolType get_type() override;
virtual void gui_toolbox() override;
virtual void tool_update() override;
virtual bool right_click_popup_gui(Vector2f popupPos) override;
virtual void right_click_popup_gui(Vector2f popupPos) override;
virtual void erase_component(CanvasComponentContainer::ObjInfo* erasedComp) override;
virtual void switch_tool(DrawingProgramToolType newTool) override;
virtual void draw(SkCanvas* canvas, const DrawData& drawData) override;

View file

@ -31,7 +31,7 @@ class DrawingProgramToolBase {
virtual DrawingProgramToolType get_type() = 0;
virtual void gui_toolbox() = 0;
virtual void erase_component(CanvasComponentContainer::ObjInfo* erasedComp) = 0;
virtual bool right_click_popup_gui(Vector2f popupPos) = 0;
virtual void right_click_popup_gui(Vector2f popupPos) = 0;
virtual void tool_update() = 0;
virtual void draw(SkCanvas* canvas, const DrawData& drawData) = 0;
virtual void switch_tool(DrawingProgramToolType newTool) = 0;

View file

@ -15,6 +15,8 @@
#include "EditTools/EllipseDrawEditTool.hpp"
#include "EditTools/BrushEditTool.hpp"
#include "../../GUIStuff/ElementHelpers/TextLabelHelpers.hpp"
EditTool::EditTool(DrawingProgram& initDrawP):
DrawingProgramToolBase(initDrawP)
{}
@ -24,6 +26,9 @@ DrawingProgramToolType EditTool::get_type() {
}
void EditTool::gui_toolbox() {
using namespace GUIStuff;
using namespace ElementHelpers;
Toolbar& t = drawP.world.main.toolbar;
if(objInfoBeingEdited) {
bool editHappened = compEditTool->edit_gui(objInfoBeingEdited);
@ -32,7 +37,7 @@ void EditTool::gui_toolbox() {
}
else {
t.gui.push_id("edit tool");
t.gui.text_label_centered("Edit");
text_label_centered(t.gui, "Edit");
t.gui.pop_id();
}
}

View file

@ -42,11 +42,11 @@ struct FixedSizeColorButtonOptions {
std::function<void()> onClick;
};
void text_button(GUIManager& gui, const char* id, std::string_view text, const TextButtonOptions& options);
void text_button_sized(GUIManager& gui, const char* id, std::string_view text, Clay_SizingAxis x, Clay_SizingAxis y, const TextButtonOptions& options);
void svg_icon_button(GUIManager& gui, const char* id, const std::string& svgPath, const SVGButtonOptions& options);
void text_button(GUIManager& gui, const char* id, std::string_view text, const TextButtonOptions& options = {});
void text_button_sized(GUIManager& gui, const char* id, std::string_view text, Clay_SizingAxis x, Clay_SizingAxis y, const TextButtonOptions& options = {});
void svg_icon_button(GUIManager& gui, const char* id, const std::string& svgPath, const SVGButtonOptions& options = {});
template <typename T> void color_button(GUIManager& gui, const char* id, T* val, const FixedSizeColorButtonOptions& options) {
template <typename T> void color_button(GUIManager& gui, const char* id, T* val, const FixedSizeColorButtonOptions& options = {}) {
SelectableButton::Data d = selectable_button_options_to_data(options);
d.innerContent = [&] (const SelectableButton::InnerContentCallbackParameters&) {
gui.element<ColorRectangleDisplay>([val, hasAlpha = options.hasAlpha] {

View file

@ -220,7 +220,6 @@ void Toolbar::open_file_selector(const std::string& filePickerName, const std::v
}
else {
filePicker.isOpen = true;
filePicker.refreshEntries = true;
filePicker.extensionFiltersComplete = extensionFilters;
filePicker.extensionFilters.clear();
for(auto& [name, exList] : extensionFilters)
@ -229,6 +228,7 @@ void Toolbar::open_file_selector(const std::string& filePickerName, const std::v
filePicker.filePickerWindowName = filePickerName;
filePicker.postSelectionFunc = postSelectionFunc;
filePicker.fileName = "";
file_picker_gui_refresh_entries();
}
}
@ -2369,58 +2369,21 @@ void Toolbar::input_mouse_button_callback(const InputManager::MouseButtonCallbac
}
void Toolbar::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion) {
if(motion.deviceType != InputManager::MouseDeviceType::TOUCH)
io->mouse.globalPos = motion.pos / final_gui_scale();
}
void Toolbar::input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel) {
io->mouse.scroll = wheel.amount;
}
void Toolbar::input_finger_touch_callback(const InputManager::FingerTouchCallbackArgs& touch) {
io->mouse.globalPos = touch.pos / final_gui_scale();
if(touch.down) {
io->mouse.leftClick = std::max<int>(io->mouse.leftClick, touch.fingerTapCount);
io->mouse.leftHeld = true;
}
else
io->mouse.leftHeld = false;
}
void Toolbar::input_finger_motion_callback(const InputManager::FingerMotionCallbackArgs& motion) {
io->mouse.globalPos = motion.pos / final_gui_scale();
}
void Toolbar::start_gui() {
SDL_Rect windowRect;
if(SDL_GetWindowSafeArea(main.window.sdlWindow, &windowRect)) {
io->windowPos = gui.windowPos = Vector2f{windowRect.x, windowRect.y} / final_gui_scale();
gui.windowSize = Vector2f{windowRect.w, windowRect.h} / final_gui_scale();
}
else {
io->windowPos = gui.windowPos = Vector2f{0.0f, 0.0f};
gui.windowSize = main.window.size.cast<float>() / final_gui_scale();
}
initialize_io();
gui.io = io;
io->isTouch = main.input.isTouchDevice;
gui.begin();
}
float Toolbar::final_gui_scale() {
return finalCalculatedGuiScale;
}
bool Toolbar::check_if_position_isnt_obstructed(const Vector2f& pos) {
bool positionIsntObstructed = true;
Vector2f posGUI = pos / final_gui_scale();
for(auto& aabb : io->hoverObstructingAABBs)
positionIsntObstructed &= !SCollision::collide(posGUI, aabb);
for(auto& circle : io->hoverObstructingCircles)
positionIsntObstructed &= !SCollision::collide(posGUI, circle);
return positionIsntObstructed;
}
void Toolbar::calculate_final_gui_scale() {
Vector2f maxWindowSizeBeforeForcedFit = final_gui_scale_not_fit() * Vector2f{700.0f, 700.0f};
Vector2f fitRatio = {main.window.size.x() / maxWindowSizeBeforeForcedFit.x(), main.window.size.y() / maxWindowSizeBeforeForcedFit.y()};
@ -2431,11 +2394,6 @@ float Toolbar::final_gui_scale_not_fit() {
return guiScale * main.get_scale_and_density_factor_gui();
}
void Toolbar::end_gui() {
gui.end();
end_io();
}
void Toolbar::draw(SkCanvas* canvas, bool skiaAA) {
canvas->save();
canvas->scale(final_gui_scale(), final_gui_scale());