| 1061 | } |
| 1062 | |
| 1063 | void Editor::updateToolLoopModifiersIndicators() |
| 1064 | { |
| 1065 | int modifiers = int(tools::ToolLoopModifiers::kNone); |
| 1066 | bool autoSelectLayer = Preferences::instance().editor.autoSelectLayer(); |
| 1067 | KeyAction action; |
| 1068 | |
| 1069 | if (m_customizationDelegate) { |
| 1070 | // When the mouse is captured, is when we are scrolling, or |
| 1071 | // drawing, or moving, or selecting, etc. So several |
| 1072 | // parameters/tool-loop-modifiers are static. |
| 1073 | if (hasCapture()) { |
| 1074 | modifiers |= (int(m_toolLoopModifiers) & |
| 1075 | (int(tools::ToolLoopModifiers::kReplaceSelection) | |
| 1076 | int(tools::ToolLoopModifiers::kAddSelection) | |
| 1077 | int(tools::ToolLoopModifiers::kSubtractSelection))); |
| 1078 | autoSelectLayer = m_autoSelectLayer; |
| 1079 | |
| 1080 | // Shape tools (line, curves, rectangles, etc.) |
| 1081 | action = m_customizationDelegate->getPressedKeyAction(KeyContext::ShapeTool); |
| 1082 | if (int(action & KeyAction::MoveOrigin)) |
| 1083 | modifiers |= int(tools::ToolLoopModifiers::kMoveOrigin); |
| 1084 | if (int(action & KeyAction::SquareAspect)) |
| 1085 | modifiers |= int(tools::ToolLoopModifiers::kSquareAspect); |
| 1086 | if (int(action & KeyAction::DrawFromCenter)) |
| 1087 | modifiers |= int(tools::ToolLoopModifiers::kFromCenter); |
| 1088 | } |
| 1089 | else { |
| 1090 | // We update the selection mode only if we're not selecting. |
| 1091 | action = m_customizationDelegate->getPressedKeyAction(KeyContext::SelectionTool); |
| 1092 | |
| 1093 | gen::SelectionMode mode = Preferences::instance().selection.mode(); |
| 1094 | if (int(action & KeyAction::AddSelection)) |
| 1095 | mode = gen::SelectionMode::ADD; |
| 1096 | if (int(action & KeyAction::SubtractSelection) || m_secondaryButton) |
| 1097 | mode = gen::SelectionMode::SUBTRACT; |
| 1098 | switch (mode) { |
| 1099 | case gen::SelectionMode::DEFAULT: modifiers |= int(tools::ToolLoopModifiers::kReplaceSelection); break; |
| 1100 | case gen::SelectionMode::ADD: modifiers |= int(tools::ToolLoopModifiers::kAddSelection); break; |
| 1101 | case gen::SelectionMode::SUBTRACT: modifiers |= int(tools::ToolLoopModifiers::kSubtractSelection); break; |
| 1102 | } |
| 1103 | |
| 1104 | // For move tool |
| 1105 | action = m_customizationDelegate->getPressedKeyAction(KeyContext::MoveTool); |
| 1106 | if (int(action & KeyAction::AutoSelectLayer)) |
| 1107 | autoSelectLayer = true; |
| 1108 | } |
| 1109 | } |
| 1110 | |
| 1111 | ContextBar* ctxBar = App::instance()->contextBar(); |
| 1112 | |
| 1113 | if (int(m_toolLoopModifiers) != modifiers) { |
| 1114 | m_toolLoopModifiers = tools::ToolLoopModifiers(modifiers); |
| 1115 | |
| 1116 | // TODO the contextbar should be a observer of the current editor |
| 1117 | ctxBar->updateToolLoopModifiersIndicators(m_toolLoopModifiers); |
| 1118 | |
| 1119 | if (auto drawingState = dynamic_cast<DrawingState*>(m_state.get())) { |
| 1120 | drawingState->notifyToolLoopModifiersChange(this); |
nothing calls this directly
no test coverage detected