| 120 | } |
| 121 | |
| 122 | bool ToolBar::onProcessMessage(Message* msg) |
| 123 | { |
| 124 | switch (msg->type()) { |
| 125 | |
| 126 | case kMouseDownMessage: { |
| 127 | MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg); |
| 128 | ToolBox* toolbox = App::instance()->toolBox(); |
| 129 | int groups = toolbox->getGroupsCount(); |
| 130 | Rect toolrc; |
| 131 | |
| 132 | ToolGroupList::iterator it = toolbox->begin_group(); |
| 133 | for (int c=0; c<groups; ++c, ++it) { |
| 134 | ToolGroup* tool_group = *it; |
| 135 | Tool* tool = m_selectedInGroup[tool_group]; |
| 136 | |
| 137 | toolrc = getToolGroupBounds(c); |
| 138 | if (mouseMsg->position().y >= toolrc.y && |
| 139 | mouseMsg->position().y < toolrc.y+toolrc.h) { |
| 140 | selectTool(tool); |
| 141 | |
| 142 | openPopupWindow(c, tool_group); |
| 143 | |
| 144 | // We capture the mouse so the user can continue navigating |
| 145 | // the ToolBar to open other groups while he is pressing the |
| 146 | // mouse button. |
| 147 | captureMouse(); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | toolrc = getToolGroupBounds(PreviewVisibilityIndex); |
| 152 | if (mouseMsg->position().y >= toolrc.y && |
| 153 | mouseMsg->position().y < toolrc.y+toolrc.h) { |
| 154 | // Toggle preview visibility |
| 155 | PreviewEditorWindow* preview = |
| 156 | App::instance()->mainWindow()->getPreviewEditor(); |
| 157 | bool state = preview->isPreviewEnabled(); |
| 158 | preview->setPreviewEnabled(!state); |
| 159 | } |
| 160 | break; |
| 161 | } |
| 162 | |
| 163 | case kMouseMoveMessage: { |
| 164 | MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg); |
| 165 | ToolBox* toolbox = App::instance()->toolBox(); |
| 166 | int groups = toolbox->getGroupsCount(); |
| 167 | Tool* new_hot_tool = NULL; |
| 168 | int new_hot_index = NoneIndex; |
| 169 | Rect toolrc; |
| 170 | |
| 171 | ToolGroupList::iterator it = toolbox->begin_group(); |
| 172 | |
| 173 | for (int c=0; c<groups; ++c, ++it) { |
| 174 | ToolGroup* tool_group = *it; |
| 175 | Tool* tool = m_selectedInGroup[tool_group]; |
| 176 | |
| 177 | toolrc = getToolGroupBounds(c); |
| 178 | if (mouseMsg->position().y >= toolrc.y && |
| 179 | mouseMsg->position().y < toolrc.y+toolrc.h) { |
nothing calls this directly
no test coverage detected