Hold space to temporary switch to pan tool
This commit is contained in:
parent
658799610b
commit
d52fe2ded2
5 changed files with 24 additions and 6 deletions
|
|
@ -265,15 +265,28 @@ void DrawingProgram::update() {
|
|||
unorderedObjectsExistTimePoint = std::chrono::steady_clock::now();
|
||||
}
|
||||
|
||||
if(drawTool->get_type() == DrawingProgramToolType::BRUSH && world.main.input.pen.isEraser && !temporaryEraser) {
|
||||
switch_to_tool(DrawingProgramToolType::ERASER);
|
||||
if(world.main.input.pen.isEraser && !temporaryEraser) {
|
||||
if(drawTool->get_type() == DrawingProgramToolType::BRUSH)
|
||||
switch_to_tool(DrawingProgramToolType::ERASER);
|
||||
temporaryEraser = true;
|
||||
}
|
||||
else if(drawTool->get_type() == DrawingProgramToolType::ERASER && !world.main.input.pen.isEraser && temporaryEraser) {
|
||||
switch_to_tool(DrawingProgramToolType::BRUSH);
|
||||
else if(!world.main.input.pen.isEraser && temporaryEraser) {
|
||||
if(drawTool->get_type() == DrawingProgramToolType::ERASER)
|
||||
switch_to_tool(DrawingProgramToolType::BRUSH);
|
||||
temporaryEraser = false;
|
||||
}
|
||||
|
||||
if(world.main.input.key(InputManager::KEY_HOLD_TO_PAN).held && !temporaryPan) {
|
||||
toolTypeAfterTempPan = drawTool->get_type();
|
||||
switch_to_tool(DrawingProgramToolType::PAN);
|
||||
temporaryPan = true;
|
||||
}
|
||||
|
||||
if(!world.main.input.key(InputManager::KEY_HOLD_TO_PAN).held && temporaryPan) {
|
||||
switch_to_tool(toolTypeAfterTempPan);
|
||||
temporaryPan = false;
|
||||
}
|
||||
|
||||
controls.cursorHoveringOverCanvas = !world.main.toolbar.io->hoverObstructed;
|
||||
controls.leftClick = controls.cursorHoveringOverCanvas && world.main.input.mouse.leftClicks;
|
||||
if(controls.leftClick) {
|
||||
|
|
|
|||
|
|
@ -92,6 +92,8 @@ class DrawingProgram {
|
|||
DrawingProgramSelection selection;
|
||||
|
||||
bool temporaryEraser = false;
|
||||
bool temporaryPan = false;
|
||||
DrawingProgramToolType toolTypeAfterTempPan;
|
||||
|
||||
struct GlobalControls {
|
||||
float relativeWidth = 15.0f;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ InputManager::InputManager() {
|
|||
defaultKeyAssignments[{0, SDLK_F1}] = KEY_OPEN_CHAT;
|
||||
defaultKeyAssignments[{0, SDLK_F3}] = KEY_SHOW_METRICS;
|
||||
defaultKeyAssignments[{0, SDLK_F2}] = KEY_SHOW_PLAYER_LIST;
|
||||
defaultKeyAssignments[{0, SDLK_SPACE}] = KEY_HOLD_TO_PAN;
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
// Without this, SDL eats the CTRL-V event that initiates the paste event
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ struct InputManager {
|
|||
KEY_SHOW_METRICS,
|
||||
KEY_OPEN_CHAT,
|
||||
KEY_SHOW_PLAYER_LIST,
|
||||
KEY_HOLD_TO_PAN,
|
||||
|
||||
KEY_ASSIGNABLE_COUNT, // Not a real key
|
||||
|
||||
|
|
@ -216,5 +217,6 @@ NLOHMANN_JSON_SERIALIZE_ENUM(InputManager::KeyCodeEnum, {
|
|||
{InputManager::KEY_DRAW_TOOL_SCREENSHOT, "Screenshot Tool"},
|
||||
{InputManager::KEY_SHOW_METRICS, "Show Metrics"},
|
||||
{InputManager::KEY_OPEN_CHAT, "Open Chat"},
|
||||
{InputManager::KEY_SHOW_PLAYER_LIST, "Show Player List"}
|
||||
{InputManager::KEY_SHOW_PLAYER_LIST, "Show Player List"},
|
||||
{InputManager::KEY_HOLD_TO_PAN, "Hold to Pan"}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1823,7 +1823,7 @@ float Toolbar::final_gui_scale() {
|
|||
}
|
||||
|
||||
void Toolbar::calculate_final_gui_scale() {
|
||||
Vector2f maxWindowSizeBeforeForcedFit = final_gui_scale_not_fit() * Vector2f{800.0f, 800.0f};
|
||||
Vector2f maxWindowSizeBeforeForcedFit = final_gui_scale_not_fit() * Vector2f{800.0f, 880.0f};
|
||||
Vector2f fitRatio = {main.window.size.x() / maxWindowSizeBeforeForcedFit.x(), main.window.size.y() / maxWindowSizeBeforeForcedFit.y()};
|
||||
finalCalculatedGuiScale = final_gui_scale_not_fit() * std::min(std::min(fitRatio.x(), fitRatio.y()), 1.0f);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue