Пример #1
0
void IconDes::InvertSelect()
{
	if(!IsCurrent())
		return;
	ImageBuffer ib(Current().selection);
	RGBA *s = ib;
	const RGBA *e = s + ib.GetLength();
	while(s < e) {
		s->r = s->g = s->b = s->a = ~s->r;
		s++;
	}
	Current().selection = ib;
	Refresh();
}
Пример #2
0
void IconDes::LeftUp(Point p, dword keyflags)
{
	if(!IsCurrent())
		return;
	if(IsPasting() && HasCapture())
		Refresh();
	else
	if(HasCapture() && selectrect)
		Move();
	else
		Current().base_image.Clear();
	SetBar();
	SyncShow();
}
Пример #3
0
void
GL::EnableScissorTest(const IntRect& aScissorRect)
{
  MOZ_ASSERT(IsCurrent());

  if (!mScissorTestEnabled) {
    Enable(GL_SCISSOR_TEST);
    mScissorTestEnabled = true;
  }

  if (!mScissorRect.IsEqualInterior(aScissorRect)) {
    Scissor(aScissorRect.x, aScissorRect.y, aScissorRect.width, aScissorRect.height);
    mScissorRect = aScissorRect;
  }
}
Пример #4
0
	/* virtual */ void Join()
	{
		struct OTTDThreadStartupMessage *reply;

		/* You cannot join yourself */
		assert(!IsCurrent());

		KPutStr("[OpenTTD] Join threads...\n");
		KPutStr("[OpenTTD] Wait for child to quit...\n");
		WaitPort(m_replyport);

		GetMsg(m_replyport);
		DeleteMsgPort(m_replyport);
		m_thr = 0;
	}
Пример #5
0
void IconDes::Select()
{
	if(!IsCurrent())
		return;
	ReleaseCapture();
	FinishPaste();
	doselection = !doselection;
	rgbactrl.Mask(doselection);
	if(doselection && SelectionRect() == GetImageSize()) {
		SetSelect(0);
		rgbactrl.MaskSet(255);
	}
	Refresh();
	SetBar();
}
Пример #6
0
void wxVListBoxComboPopup::OnDrawBg( wxDC& dc,
                                     const wxRect& rect,
                                     int item,
                                     int flags ) const
{
    wxOwnerDrawnComboBox* combo = (wxOwnerDrawnComboBox*) m_combo;

    wxASSERT_MSG( combo->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)),
                  wxT("you must subclass wxVListBoxComboPopup for drawing and measuring methods") );

    if ( IsCurrent((size_t)item) && !(flags & wxODCB_PAINTING_CONTROL) )
        flags |= wxODCB_PAINTING_SELECTED;

    combo->OnDrawBackground(dc,rect,item,flags);
}
Пример #7
0
void IconDes::ApplyImage(Image m, dword flags, bool alpha)
{
	if(!IsCurrent())
		return;
	Slot& c = Current();
	Size isz = GetImageSize();
	RGBA cc = CurrentColor();
	int empty = doselection ? cc.r : 0;
	ImageBuffer ib(CurrentImage());
	for(int y = 0; y < isz.cy; y++) {
		const RGBA *s = c.base_image[y];
		RGBA *t = ib[y];
		const RGBA *d = m[y];
		const RGBA *k = doselection ? d : c.selection[y];
		for(int x = 0; x < isz.cx; x++) {
			RGBA c = *s;
			if(alpha) {
				cc.a = d->r;
				AlphaBlendStraight(&c, &cc, 1);
			}
			else {
				if(d->r == 255) {
					if(flags & K_ALT)
						c.a = cc.a;
					else
					if(flags & K_CTRL) {
						RGBA h = cc;
						h.a = c.a;
						c = h;
					}
					else
						c = cc;
				}
				if(d->r == 128)
					c.a = c.r = c.g = c.b = empty;
			}
			if(c != *t && (doselection || k->r)) {
				*t = c;
				RefreshPixel(x, y);
			}
			t++;
			s++;
			d++;
			k++;
		}
	}
	CurrentImage() = ib;
}
Пример #8
0
void IconDes::MouseMove(Point p, dword keyflags)
{
	if(!HasCapture() || !IsCurrent())
		return;
	p = GetPos(p);
	if(IsPasting()) {
		Current().pastepos = p - startpoint;
		MakePaste();
		return;
	}
	if(selectrect)
		EmptyRectTool(p, keyflags);
	else
	if(tool)
		(this->*tool)(p, keyflags);
}
Пример #9
0
	/* virtual */ bool Exit()
	{
		struct OTTDThreadStartupMessage *msg;

		/* You can only exit yourself */
		assert(IsCurrent());

		KPutStr("[Child] Aborting...\n");

		if (NewGetTaskAttrs(NULL, &msg, sizeof(struct OTTDThreadStartupMessage *), TASKINFOTYPE_STARTUPMSG, TAG_DONE) && msg != NULL) {
			/* For now we terminate by throwing an error, gives much cleaner cleanup */
			throw OTTDThreadExitSignal();
		}

		return true;
	}
Пример #10
0
void
GL::EnableClipPlanes(const ConvexPolygon& aPolygon, UniqueId aPolygonId)
{
  MOZ_ASSERT(IsCurrent());
  MOZ_ASSERT(aPolygon.NumSides() <= mMaxClipPlanes);

  if (mClipPolygonId == aPolygonId) {
    return;
  }

  if (aPolygon.IsEmpty()) {
    if (!mNumClipPlanes) {
      Enable(GL_CLIP_PLANE0);
    } else {
      for (size_t i = 1; i < mNumClipPlanes; i++) {
        Disable(GL_CLIP_PLANE0 + i);
      }
    }

    mNumClipPlanes = 1;

    // We specify a single clip plane equation that fails for all vertices.
    const double planeEquation[] = {0, 0, 0, -1};
    ClipPlane(GL_CLIP_PLANE0, planeEquation);

    mClipPolygonId = aPolygonId;

    return;
  }

  for (size_t i = mNumClipPlanes; i < aPolygon.NumSides(); i++) {
    Enable(GL_CLIP_PLANE0 + i);
  }
  for (size_t i = aPolygon.NumSides(); i < mNumClipPlanes; i++) {
    Disable(GL_CLIP_PLANE0 + i);
  }

  mNumClipPlanes = aPolygon.NumSides();

  for (size_t i = 0; i < aPolygon.NumSides(); i++) {
    const Line& line = aPolygon.Sides()[i];
    const double planeEquation[] = {line.A, line.B, 0, -line.C};
    ClipPlane(GL_CLIP_PLANE0 + i, planeEquation);
  }

  mClipPolygonId = aPolygonId;
}
Пример #11
0
void IconDes::Undo()
{
	if(!IsCurrent())
		return;
	Slot& c = Current();
	Vector<Image> undo = UnpackImlData(c.undo);
	if(undo.GetCount() == 0)
		return;
	Vector<Image> redo = UnpackImlData(c.redo);
	redo.Add(c.image);
	c.image = undo.Pop();
	c.supersampling = sRemoveSsFlag(c.image);
	c.undo = PackImlData(undo);
	c.redo = PackImlData(redo);
	SyncImage();
	SetBar();
}
Пример #12
0
void wxVListBox::OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const
{
    // use wxRendererNative for more native look unless we use custom bg colour
    if ( !DoDrawSolidBackground(m_colBgSel, dc, rect, n) )
    {
        int flags = 0;
        if ( IsSelected(n) )
            flags |= wxCONTROL_SELECTED;
        if ( IsCurrent(n) )
            flags |= wxCONTROL_CURRENT;
        if ( wxWindow::FindFocus() == const_cast<wxVListBox*>(this) )
            flags |= wxCONTROL_FOCUSED;

        wxRendererNative::Get().DrawItemSelectionRect(
            const_cast<wxVListBox *>(this), dc, rect, flags);
    }
}
Пример #13
0
void
GL::ConfigurePathStencilTest(GLubyte aClipBits)
{
  MOZ_ASSERT(IsCurrent());

  if (mPathStencilFuncBits == aClipBits) {
    return;
  }

  if (!aClipBits) {
    PathStencilFuncNV(GL_ALWAYS, 0, 0);
  } else {
    PathStencilFuncNV(GL_EQUAL, aClipBits, aClipBits);
  }

  mPathStencilFuncBits = aClipBits;
}
Пример #14
0
void IconDes::SyncImage()
{
	ReleaseCapture();
	SyncShow();
	if(IsCurrent()) {
		Slot& c = Current();
		SyncShow();
		c.pastepos = Null;
		if(c.selection.GetSize() != c.image.GetSize())
			SetSelect(255);
		if(single_mode)
			info.SetLabel(Format("%d x %d", c.image.GetWidth(), c.image.GetHeight()));
	}
	selectrect = false;
	SetBar();
	Refresh();
}
Пример #15
0
void IconDes::MaskFill(ImageBuffer& ib, RGBA color, int mask)
{
	if(!IsCurrent())
		return;
	if(doselection)
		Fill(ib, color, ib.GetLength());
	else {
		RGBA *t = ib;
		RGBA *e = ib + ib.GetLength();
		const RGBA *s = Current().selection;
		while(t < e) {
			if((s++)->r == mask)
				*t = color;
			t++;
		}
	}
}
Пример #16
0
void GotoFileList::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const {
	const bool isCurrent = IsCurrent(n);

	if (isCurrent) dc.SetTextForeground(m_hlTextColor);
	else dc.SetTextForeground(m_textColor);

	const FileEntry& file_entry = *m_items[n].file_entry;

	// m_project_root
	wxFileName displayPath(file_entry.path);
	displayPath.MakeRelativeTo(this->m_project_root);
	//displayPath.SetFullName(file_entry.name);

	const wxString& name = displayPath.GetFullPath();

	const int path_size = displayPath.GetPath().size() + 1;

	const std::vector<unsigned int>& hl = m_items[n].hlChars;
	std::vector<unsigned int> offsets(hl.size());
	for(unsigned int i = 0; i < hl.size(); i++) {
		offsets[i] = hl[i] + path_size;
	}

	/*// Calc extension width
	static const wxString ext = wxT("..  ");
	dc.SetFont(m_font);
	int w, h;
	dc.GetTextExtent(ext, &w, &h);
	const unsigned int extwidth = w;

	// See if we have to resize the action name to fit
	// note that this is not 100% correct as bold chars take up a bit more space.
	unsigned int len = name.length();
	dc.GetTextExtent(name, &w, &h);
	if (w > (int)rightBorder) {
		do {
			name.resize(--len);
			dc.GetTextExtent(name, &w, &h);
		} while (len > 0 && w + extwidth > (int)rightBorder);
		name += ext;
	}*/

	// Draw action name
	DrawItemText(dc, rect, name, offsets, isCurrent);
}
Пример #17
0
void IconDes::SyncShow()
{
	iconshow.image.Clear();
	if(IsCurrent()) {
		Slot& c = Current();
		Image image = c.image;
		if(c.supersampling) {
			int l = c.image.GetLength();
			if(l > 0 && l <= 256 * 256)
				image = DownSample3x(image);
			else
				image = IconDesImg::LargeImage();
		}
		iconshow.image = image;
		ilist.Set(2, image);
	}
	iconshow.Refresh();
}
Пример #18
0
void
GL::SetColor(const Color& aColor)
{
  MOZ_ASSERT(IsCurrent());

  if (!memcmp(&mColor, &aColor, sizeof(Color))) {
    return;
  }

  if (aColor.a == 1) {
    Color4f(aColor.r, aColor.g, aColor.b, 1);
  } else {
    const float a = aColor.a;
    Color4f(a * aColor.r, a * aColor.g, a * aColor.b, a);
  }

  mColor = aColor;
}
Пример #19
0
void IconDes::SaveUndo()
{
	if(!IsCurrent())
		return;
	Slot& c = Current();
	Vector<Image> undo = UnpackImlData(c.undo);
	int maxn = minmax((single_mode ? 4000000 : 400000) / max(c.image.GetLength(), 1), 4, 128);
	while(undo.GetCount() > maxn)
		undo.Remove(0);
	if(undo.GetCount() && undo.Top() == c.image)
		return;
	sSetSsFlag(c.image, c.supersampling);
	undo.Add(c.image);
	c.undo = PackImlData(undo);
	c.redo.Clear();
	SetBar();
	undo.Clear();
	sRemoveSsFlag(c.image);
}
Пример #20
0
void
GL::SetTransform(const Matrix& aTransform, UniqueId aTransformId)
{
  MOZ_ASSERT(IsCurrent());

  if (mTransformIdStack.top() == aTransformId) {
    return;
  }

  const GLfloat matrix[] = {
    aTransform._11,  aTransform._12,  0,  0,
    aTransform._21,  aTransform._22,  0,  0,
    0,               0,               1,  0,
    aTransform._31,  aTransform._32,  0,  1
  };

  MatrixLoadfEXT(GL_MODELVIEW, matrix);

  mTransformIdStack.top() = aTransformId;
}
Пример #21
0
Rect  IconDes::SelectionRect()
{
	if(!IsCurrent())
		return Null;
	Size isz = GetImageSize();
	int minx = isz.cx - 1;
	int maxx = 0;
	int miny = isz.cy - 1;
	int maxy = 0;
	for(int y = 0; y < isz.cy; y++) {
		const RGBA *k = Current().selection[y];
		for(int x = 0; x < isz.cx; x++)
			if((k++)->r == 255) {
				if(x < minx) minx = x;
				if(x > maxx) maxx = x;
				if(y < miny) miny = y;
				if(y > maxy) maxy = y;
			}
	}
	return Rect(minx, miny, maxx + 1, maxy + 1);
}
Пример #22
0
NAMESPACE_UPP

void IconDes::LeftDown(Point p, dword flags)
{
	SetFocus();
	if(!IsCurrent())
		return;
	SaveUndo();
	startpoint = GetPos(p);
	if(IsPasting()) {
		if(Rect(Current().pastepos, Current().paste_image.GetSize()).Contains(startpoint)) {
			startpoint -= Current().pastepos;
			SetCapture();
		}
		else
			FinishPaste();
		return;
	}
	SetCapture();
	Current().base_image = CurrentImage();
	if(flags & K_SHIFT) {
		ImageBuffer ib(CurrentImage());
		if(!doselection) {
			RGBA c = CurrentColor();
			c.r += 127;
			MaskFill(ib, c, 0);
		}
		FloodFill(ib, CurrentColor(), startpoint, ib.GetSize());
		SetCurrentImage(ib);
		if(!doselection)
			MaskSelection();
		return;
	}
	if(selectrect)
		EmptyRectTool(startpoint, flags);
	else
	if(tool)
		(this->*tool)(startpoint, flags);
}
Пример #23
0
Image IconDes::Copy(const Rect& r)
{
	if(!IsCurrent() || r.IsEmpty())
		return Image();
	ImageBuffer ib(r.GetSize());
	Slot& c = Current();
	for(int y = r.top; y < r.bottom; y++) {
		const RGBA *s = c.image[y] + r.left;
		const RGBA *e = c.image[y] + r.right;
		const RGBA *k = c.selection[y] + r.left;
		RGBA *t = ib[y - r.top];
		while(s < e) {
			*t = *s;
			if(!k->r)
				*t = RGBAZero();
			t++;
			k++;
			s++;
		}
	}
	return ib;
}
Пример #24
0
void wxVListBox::OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const
{
    // we need to render selected and current items differently
    const bool isSelected = IsSelected(n),
               isCurrent = IsCurrent(n);
    if ( isSelected || isCurrent )
    {
        if ( isSelected )
        {
            dc.SetBrush(wxBrush(m_colBgSel, wxSOLID));
        }
        else // !selected
        {
            dc.SetBrush(*wxTRANSPARENT_BRUSH);
        }

        dc.SetPen(*(isCurrent ? wxBLACK_PEN : wxTRANSPARENT_PEN));

        dc.DrawRectangle(rect);
    }
    //else: do nothing for the normal items
}
Пример #25
0
int wxWindow::GetStateFlags() const
{
    int flags = 0;
    if ( !IsEnabled() )
        flags |= wxCONTROL_DISABLED;

    // the following states are only possible if our application is active - if
    // it is not, even our default/focused controls shouldn't appear as such
    if ( wxTheApp->IsActive() )
    {
        if ( IsCurrent() )
            flags |= wxCONTROL_CURRENT;
        if ( IsFocused() )
            flags |= wxCONTROL_FOCUSED;
        if ( IsPressed() )
            flags |= wxCONTROL_PRESSED;
        if ( IsDefault() )
            flags |= wxCONTROL_ISDEFAULT;
    }

    return flags;
}
Пример #26
0
void IconDes::Set(Point p, RGBA rgba, dword flags)
{
	if(!IsCurrent())
		return;
	if(InImage(p)) {
		ImageBuffer ib(CurrentImage());
		RGBA& t = ib[p.y][p.x];
		if(t != rgba && (doselection || Current().selection[p.y][p.x].r)) {
			if(flags & K_ALT)
				t.a = rgba.a;
			else
			if(flags & K_CTRL) {
				rgba.a = t.a;
				t = rgba;
			}
			else
				t = rgba;
			RefreshPixel(p);
		}
		CurrentImage() = ib;
	}
}
Пример #27
0
void IconDes::Move()
{
	if(!IsCurrent())
		return;
	Slot& c = Current();
	selectrect = false;
	if(IsPasting())
		FinishPaste();
	else {
		doselection = false;
		rgbactrl.Mask(false);
		rgbactrl.Hide();
		Rect r = SelectionRect();
		Image m = Copy(r);
		Delete();
		SetSelect(255);
		c.base_image = c.image;
		c.paste_image = m;
		c.pastepos = r.TopLeft();
		MakePaste();
	}
	SetBar();
}
Пример #28
0
void
GL::SetFramebufferToTexture(GLenum aFramebufferTarget,
                            GLenum aTextureTarget, GLuint aTextureId)
{
  MOZ_ASSERT(IsCurrent());

  switch (aTextureTarget) {
    case GL_TEXTURE_1D:
      NamedFramebufferTexture1DEXT(mTextureFramebuffer1D, GL_COLOR_ATTACHMENT0,
                                   GL_TEXTURE_1D, aTextureId, 0);
      SetFramebuffer(aFramebufferTarget, mTextureFramebuffer1D);
      break;

    case GL_TEXTURE_2D:
      NamedFramebufferTexture2DEXT(mTextureFramebuffer2D, GL_COLOR_ATTACHMENT0,
                                   GL_TEXTURE_2D, aTextureId, 0);
      SetFramebuffer(aFramebufferTarget, mTextureFramebuffer2D);
      break;

    default:
      MOZ_ASSERT(!"Invalid texture target.");
      break;
  }
}
void
KeyframeEffectReadOnly::UpdateTargetRegistration()
{
  if (!mTarget) {
    return;
  }

  bool isRelevant = mAnimation && mAnimation->IsRelevant();

  // Animation::IsRelevant() returns a cached value. It only updates when
  // something calls Animation::UpdateRelevance. Whenever our timing changes,
  // we should be notifying our Animation before calling this, so
  // Animation::IsRelevant() should be up-to-date by the time we get here.
  MOZ_ASSERT(isRelevant == IsCurrent() || IsInEffect(),
             "Out of date Animation::IsRelevant value");

  if (isRelevant) {
    EffectSet* effectSet =
      EffectSet::GetOrCreateEffectSet(mTarget->mElement, mTarget->mPseudoType);
    effectSet->AddEffect(*this);
  } else {
    UnregisterTarget();
  }
}
FText FOneSkyLocalizationServiceState::GetDisplayTooltip() const
{
	if( !IsCurrent() )
	{
		return LOCTEXT("NotCurrent_Tooltip", "The text(s) are not at the latest revision");
	}

	switch(State)
	{
	default:
	case EOneSkyState::Unknown:
		return LOCTEXT("Unknown_Tooltip", "The text(s) status is unknown to OneSky");
	case EOneSkyState::Untranslated:
		return LOCTEXT("Untranslated_Tooltip", "The text(s) is known to OneSky, but there is no translation for the given culture.");
	case EOneSkyState::NotAccepted:
		return LOCTEXT("NotAccepted_Tooltip", "The text(s) is know to OneSky and there is a translation for the given culture but it is not accepted.");
	case EOneSkyState::NotFinalized:
		return LOCTEXT("NotFinalized_Tooltip", "The text(s) is know to OneSky, and a translation for the given culture has been accepted, but not finalized.");
	case EOneSkyState::Finalized:
		return LOCTEXT("Finalized_Tooltip", "The text(s) is know to OneSky, and a translation for the given culture has been accepted and finalized.");
	case EOneSkyState::Deprecated:
		return LOCTEXT("Deprecated_Tooltip", "The text(s) is know to OneSky, and a translation existed previously but it has been deprecated.");
	};
}