ToolResult MouseDown(const PosInfo& info) override{
    Canvas& canvas = info.canvas;
    HotSpot hotSpot(floored(info.pos));

    if (info.modifiers.LeftMouse()){
      // Command for setting the hot spot to the current frame.

      auto frameIndex = canvas.GetSelectedFrame();
      const Image& frame = canvas.GetFrame(frameIndex);
      m_command.Set(set_frame_hotspot_command(frameIndex, New(hotSpot),
        Old(frame.GetHotSpot())));
      m_hotSpot = hotSpot;
      return ToolResult::COMMIT;
    }
    else if (info.modifiers.RightMouse()){
      // Command for setting the hot-spot to all frames.

      auto commands = make_vector(up_to(canvas.GetNumFrames()),
        [&](const auto& i){
          const Image& frame = canvas.GetFrame(i);
          return set_frame_hotspot_command(i,
            New(hotSpot),
            Old(frame.GetHotSpot()));});

      m_hotSpot = hotSpot;
      m_command.Set(perhaps_bunch(CommandType::FRAME,
        bunch_name("Set frame hot spots"),
        std::move(commands)));
      return ToolResult::COMMIT;
    }
    else{
      return ToolResult::NONE;
    }
  }
Пример #2
0
////////////////////////////////////////////////////////////////////////////////////////
// Reposition
////////////////////////////////////////////////////////////////////////////////////////
void	CVec4::Reposition(const CVec4 &Translation, float RotationDegrees)
{
	// Apply Any Rotation First
	//--------------------------
	if (RotationDegrees)
	{
		CVec4 Old(*this);
		float Rotation = RAVL_VEC_DEGTORAD(RotationDegrees);
		v[0] = Old.v[0]*cosf(Rotation) - Old.v[1]*sinf(Rotation);
		v[1] = Old.v[0]*sinf(Rotation) + Old.v[1]*cosf(Rotation);
	}

	// Now Apply Translation
	//-----------------------
	(*this) += Translation;
}
Пример #3
0
  TaskResult Commit(Layer layerType){
    if (m_active){
      EndEntry();
    }
    if (m_newTextObject){
      m_command.Set(add_or_draw(m_textObject, layerType));
      return TaskResult::COMMIT_AND_CHANGE;
    }

    const utf8_string& newText(m_textObject->GetTextBuffer().get());
    std::deque<CommandPtr> cmds;
    while (m_states.CanUndo()){
      // Fixme: Dificult to understand (first undo just moves between lists)
      TextChange& change = m_states.UndoToRedo();
      change.Undo();
      cmds.emplace_back(std::make_unique<TextCommand>(change));
    }

    if (newText != m_oldText){
      // Fixme: Do all changes, also text edits, via TextChange instead
      cmds.push_back(text_entry_command(m_textObject,
        New(newText),
        Old(m_oldText)));
    }

    if (cmds.empty()){
      // No changes - create no command.
      return TaskResult::CHANGE;
    }
    else{
      m_command.Set(perhaps_bunch(CommandType::OBJECT,
        bunch_name("Modify Text"),
        std::move(cmds)));
      return TaskResult::COMMIT_AND_CHANGE;
    }
  }