Exemplo n.º 1
0
void
EraseObject (int type, void *lptr, void *ptr)
{
  switch (type)
    {
    case VIA_TYPE:
    case PIN_TYPE:
      ErasePin ((PinType *) ptr);
      break;
    case TEXT_TYPE:
    case ELEMENTNAME_TYPE:
      EraseText ((LayerType *)lptr, (TextType *) ptr);
      break;
    case POLYGON_TYPE:
      ErasePolygon ((PolygonType *) ptr);
      break;
    case ELEMENT_TYPE:
      EraseElement ((ElementType *) ptr);
      break;
    case LINE_TYPE:
    case ELEMENTLINE_TYPE:
    case RATLINE_TYPE:
      EraseLine ((LineType *) ptr);
      break;
    case PAD_TYPE:
      ErasePad ((PadType *) ptr);
      break;
    case ARC_TYPE:
    case ELEMENTARC_TYPE:
      EraseArc ((ArcType *) ptr);
      break;
    default:
      Message ("hace: Internal ERROR, trying to erase an unknown type\n");
    }
}
Exemplo n.º 2
0
/* ---------------------------------------------------------------------------
 * removes a text from a layer
 */
void *
RemoveText (LayerTypePtr Layer, TextTypePtr Text)
{
  /* erase from screen */
  if (Layer->On)
    {
      EraseText (Layer, Text);
      if (!Bulk)
	Draw ();
    }
  MoveObjectToRemoveUndoList (TEXT_TYPE, Layer, Text, Text);
  return NULL;
}
Exemplo n.º 3
0
void *ChangeTextJoin( LayerTypePtr Layer, TextTypePtr Text )
{
  int esi;
  EraseText( Layer, Text );
  AddObjectToClearPolyUndoList( 16, (void*)Layer, (void*)Text, (void*)Text, 0 );
  RestoreToPolygon( &PCB->Data, 16, (void*)Layer, (void*)Text );
  AddObjectToFlagUndoList( 4, (void*)Layer, (void*)Text, (void*)Text );
  Text->Flags.f ^= 32;
  AddObjectToClearPolyUndoList( 16, (void*)Layer, (void*)Text, (void*)Text, 1 );
  ClearFromPolygon( &PCB->Data, 16, (void*)Layer, (void*)Text );
  DrawText( Layer, Text, 0 );
  return (void*)Text;
}
Exemplo n.º 4
0
/*!
 * \brief Removes a text from a layer.
 */
void *
RemoveText (LayerType *Layer, TextType *Text)
{
  /* erase from screen */
  if (Layer->On)
    {
      EraseText (Layer, Text);
      r_delete_entry (Layer->text_tree, (BoxType *) Text);
      if (!Bulk)
	Draw ();
    }
  MoveObjectToRemoveUndoList (TEXT_TYPE, Layer, Text, Text);
  return NULL;
}
Exemplo n.º 5
0
/* ---------------------------------------------------------------------------
 * moves a text object
 */
static void *
MoveText (LayerTypePtr Layer, TextTypePtr Text)
{
  RestoreToPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
  r_delete_entry (Layer->text_tree, (BoxType *)Text);
  if (Layer->On)
    {
      EraseText (Layer, Text);
      MOVE_TEXT_LOWLEVEL (Text, DeltaX, DeltaY);
      DrawText (Layer, Text);
      Draw ();
    }
  else
    MOVE_TEXT_LOWLEVEL (Text, DeltaX, DeltaY);
  r_insert_entry (Layer->text_tree, (BoxType *)Text, 0);
  ClearFromPolygon (PCB->Data, TEXT_TYPE, Layer, Text);
  return (Text);
}
Exemplo n.º 6
0
/* ---------------------------------------------------------------------------
 * moves a text object between layers
 */
static void *
MoveTextToLayer (LayerType *layer, TextType *text)
{
  if (TEST_FLAG (LOCKFLAG, text))
    {
      Message (_("Sorry, the object is locked\n"));
      return NULL;
    }
  if (Dest != layer)
    {
      AddObjectToMoveToLayerUndoList (TEXT_TYPE, layer, text, text);
      if (layer->On)
	EraseText (layer, text);
      text = MoveTextToLayerLowLevel (layer, text, Dest);
      if (Dest->On)
	DrawText (Dest, text);
      if (layer->On || Dest->On)
	Draw ();
    }
  return text;
}
Exemplo n.º 7
0
void Movie::PostExec(bool progressing)
{
	hasButton = false;
	if (!active)
		return;

	m_execedFrame = -1;
	bool postExeced = m_postExecCount == lwf->execCount;
	if (progressing && playing && !m_jumped && !postExeced) {
		++m_currentFrameInternal;
		currentFrame = m_currentFrameInternal + 1;
	}
	for (;;) {
		if (m_currentFrameInternal < 0 ||
				m_currentFrameInternal >= totalFrames) {
			m_currentFrameInternal = 0;
			currentFrame = m_currentFrameInternal + 1;
		}
		if (m_currentFrameInternal == m_execedFrame)
			break;

		m_currentFrameCurrent = m_currentFrameInternal;
		m_execedFrame = m_currentFrameCurrent;
		const Data *d = lwf->data.get();
		const Format::Frame &frame = d->frames[
			data->frameOffset + m_currentFrameCurrent];

		int controlAnimationOffset;
		IObject *instance;

		if (m_lastControlOffset == frame.controlOffset &&
				m_lastControls == frame.controls) {

			controlAnimationOffset = m_lastControlAnimationOffset;

			if (m_skipped) {
				instance = m_instanceHead;
				while (instance) {
					if (instance->IsMovie()) {
						Movie *movie = (Movie *)instance;
						movie->m_attachMovieExeced = false;
						movie->m_attachMoviePostExeced = false;
					} else if (instance->IsButton()) {
						((Button *)instance)->EnterFrame();
					}
					instance = instance->linkInstance;
				}
				hasButton = m_lastHasButton;
			} else {
				for (int dlDepth = 0; dlDepth < data->depths; ++dlDepth) {
					Object *obj = m_displayList[dlDepth].get();
					if (obj) {
						if (!postExeced) {
							obj->matrixIdChanged = false;
							obj->colorTransformIdChanged = false;
						}
						if (obj->IsMovie()) {
							Movie *movie = (Movie *)obj;
							movie->m_attachMovieExeced = false;
							movie->m_attachMoviePostExeced = false;
						} else if (obj->IsButton()) {
							((Button *)obj)->EnterFrame();
							hasButton = true;
						}
					}
				}
				m_lastHasButton = hasButton;
				m_skipped = true;
			}

		} else {
			++m_movieExecCount;
			m_instanceHead = 0;
			m_instanceTail = 0;
			m_lastControlOffset = frame.controlOffset;
			m_lastControls = frame.controls;
			controlAnimationOffset = -1;
			for (int i = 0; i < frame.controls; ++i) {
				const Format::Control &control =
					d->controls[frame.controlOffset + i];

				switch (control.controlType) {
				case Format::Control::MOVE:
					{
						const Format::Place &p = d->places[control.controlId];
						ExecObject(p.depth, p.objectId,
							p.matrixId, 0, p.instanceId, p.blendMode);
					}
					break;

				case Format::Control::MOVEM:
					{
						const Format::ControlMoveM &ctrl =
							d->controlMoveMs[control.controlId];
						const Format::Place &p = d->places[ctrl.placeId];
						ExecObject(p.depth, p.objectId,
							ctrl.matrixId, 0, p.instanceId, p.blendMode);
					}
					break;

				case Format::Control::MOVEC:
					{
						const Format::ControlMoveC &ctrl =
							d->controlMoveCs[control.controlId];
						const Format::Place &p = d->places[ctrl.placeId];
						ExecObject(p.depth, p.objectId, p.matrixId,
							ctrl.colorTransformId, p.instanceId, p.blendMode);
					}
					break;

				case Format::Control::MOVEMC:
					{
						const Format::ControlMoveMC &ctrl =
							d->controlMoveMCs[control.controlId];
						const Format::Place &p = d->places[ctrl.placeId];
						ExecObject(p.depth, p.objectId, ctrl.matrixId,
							ctrl.colorTransformId, p.instanceId, p.blendMode);
					}
					break;

				case Format::Control::ANIMATION:
					if (controlAnimationOffset == -1)
						controlAnimationOffset = i;
					break;

				case Format::Control::CONTROL_MAX:
					// SUPPRESS WARNING
					break;
				}
			}

			m_lastControlAnimationOffset = controlAnimationOffset;
			m_lastHasButton = hasButton;

			for (int dlDepth = 0; dlDepth < data->depths; ++dlDepth) {
				Object *obj = m_displayList[dlDepth].get();
				if (obj && obj->execCount != m_movieExecCount) {
					if (m_texts && obj->IsText())
						EraseText(obj->objectId);
					obj->Destroy();
					m_displayList[dlDepth].reset();
				}
			}
		}

		m_attachMovieExeced = true;
		if (!m_attachedMovies.empty()) {
			AttachedMovieList::iterator it(m_attachedMovieList.begin()),
				itend(m_attachedMovieList.end());
			for (; it != itend; ++it)
				if (it->second)
					it->second->Exec();
		}

		m_attachMoviePostExeced = true;
		instance = m_instanceHead;
		while (instance) {
			if (instance->IsMovie()) {
				Movie *movie = (Movie *)instance;
				movie->PostExec(progressing);
				if (!hasButton && movie->hasButton)
					hasButton = true;
			}
			instance = instance->linkInstance;
		}

		if (!m_attachedMovies.empty()) {
			DetachDict::const_iterator
				dit(m_detachedMovies.begin()), ditend(m_detachedMovies.end());
			for (; dit != ditend; ++dit) {
				AttachedMovies::iterator it = m_attachedMovies.find(dit->first);
				if (it != m_attachedMovies.end())
					DeleteAttachedMovie(this, it->second, true, false);
			}
			m_detachedMovies.clear();

			AttachedMovieList::iterator it(m_attachedMovieList.begin()),
				itend(m_attachedMovieList.end());
			for (; it != itend; ++it) {
				if (it->second) {
					it->second->PostExec(progressing);
					if (!hasButton && it->second->hasButton)
						hasButton = true;
				}
			}
		}

		if (!m_attachedLWFs.empty())
			hasButton = true;

		if (!m_postLoaded) {
			m_postLoaded = true;
#if defined(LWF_USE_LUA)
			if (m_isRoot && !m_rootPostLoadFunc.empty())
				lwf->CallFunctionLua(m_rootPostLoadFunc, this);
			if (!m_postLoadFunc.empty())
				lwf->CallFunctionLua(m_postLoadFunc, this);
#endif
			if (!m_handler.Empty())
				m_handler.Call(METype::POSTLOAD, this);
		}

		if (controlAnimationOffset != -1 &&
				m_execedFrame == m_currentFrameInternal) {
			bool animationPlayed = m_animationPlayedFrame ==
				m_currentFrameCurrent && !m_jumped;
			if (!animationPlayed) {
				for (int i = controlAnimationOffset;
						i < frame.controls; ++i) {
					const Format::Control &control =
						d->controls[frame.controlOffset + i];
					lwf->PlayAnimation(control.controlId, this);
				}
			}
		}

		m_animationPlayedFrame = m_currentFrameCurrent;
		if (m_currentFrameCurrent == m_currentFrameInternal)
			m_jumped = false;
	}

#if defined(LWF_USE_LUA)
	if (m_isRoot && !m_rootEnterFrameFunc.empty())
		lwf->CallFunctionLua(m_rootEnterFrameFunc, this);
	if (!m_enterFrameFunc.empty())
		lwf->CallFunctionLua(m_enterFrameFunc, this);
#endif
	PlayAnimation(ClipEvent::ENTERFRAME);
	if (!m_handler.Empty())
		m_handler.Call(METype::ENTERFRAME, this);
	m_postExecCount = lwf->execCount;
}
Exemplo n.º 8
0
void Movie::ExecObject(int dlDepth, int objId,
	int matrixId, int colorTransformId, int instId, int dlBlendMode)
{
	// Ignore error
	if (objId == -1)
		return;
	const Data *d = lwf->data.get();
	const Format::Object &dataObject = d->objects[objId];
	int dataObjectId = dataObject.objectId;
	shared_ptr<Object> obj = m_displayList[dlDepth];

	if (obj && (obj->type != dataObject.objectType ||
			obj->objectId != dataObjectId || (obj->IsMovie() &&
			((IObject *)obj.get())->instanceId != instId))) {
		if (m_texts && obj->IsText())
			EraseText(obj->objectId);
		obj->Destroy();
		obj.reset();
	}

	if (!obj) {
		switch (dataObject.objectType) {
		case OType::BUTTON:
			obj = make_shared<Button>(lwf,
				this, dataObjectId, instId, matrixId, colorTransformId);
			break;

		case OType::GRAPHIC:
			obj = make_shared<Graphic>(lwf, this, dataObjectId);
			break;

		case OType::MOVIE:
			obj = make_shared<Movie>(lwf, this,
				dataObjectId, instId, matrixId, colorTransformId);
			((Movie *)obj.get())->blendMode = dlBlendMode;
			break;

		case OType::BITMAP:
			obj = make_shared<Bitmap>(lwf, this, dataObjectId);
			break;

		case OType::BITMAPEX:
			obj = make_shared<BitmapEx>(lwf, this, dataObjectId);
			break;

		case OType::TEXT:
			obj = make_shared<Text>(lwf, this, dataObjectId, instId);
			break;

		case OType::PARTICLE:
			obj = make_shared<Particle>(lwf, this, dataObjectId);
			break;

		case OType::PROGRAMOBJECT:
			obj = make_shared<ProgramObject>(lwf, this, dataObjectId);
			break;
		}
	}

	if (obj->IsMovie() || obj->IsButton()) {
		IObject *instance = (IObject *)obj.get();
		instance->linkInstance = 0;
		if (!m_instanceHead)
			m_instanceHead = instance;
		else
			m_instanceTail->linkInstance = instance;
		m_instanceTail = instance;
		if (obj->IsButton())
			hasButton = true;
	}

	if (m_texts && obj->IsText())
		InsertText(obj->objectId);

	m_displayList[dlDepth] = obj;
	obj->execCount = m_movieExecCount;
	obj->Exec(matrixId, colorTransformId);
}