Пример #1
0
MovingPixelsState::MovingPixelsState(Editor* editor, Message* msg, Image* imge, int x, int y, int opacity)
{
  // Copy the mask to the extra cel image
  Document* document = editor->getDocument();
  Sprite* sprite = editor->getSprite();
  Image* tmpImage = NewImageFromMask(document);
  x = document->getMask()->x;
  y = document->getMask()->y;
  m_pixelsMovement = new PixelsMovement(document, sprite, tmpImage, x, y, opacity);
  delete tmpImage;

  // If the CTRL key is pressed start dragging a copy of the selection
  if (key[KEY_LCONTROL] || key[KEY_RCONTROL]) // TODO configurable
    m_pixelsMovement->copyMask();
  else
    m_pixelsMovement->cutMask();

  editor->screenToEditor(msg->mouse.x, msg->mouse.y, &x, &y);
  m_pixelsMovement->catchImage(x, y);

  // Setup mask color
  setTransparentColor(app_get_statusbar()->getTransparentColor());

  app_get_statusbar()->addListener(this);
  app_get_statusbar()->showMovePixelsOptions();

  editor->captureMouse();
}
Пример #2
0
void LLPanel::initFromParams(const LLPanel::Params& p)
{
    //setting these here since panel constructor not called with params
    //and LLView::initFromParams will use them to set visible and enabled  
	setVisible(p.visible);
	setEnabled(p.enabled);
	setFocusRoot(p.focus_root);
	setSoundFlags(p.sound_flags);

	 // control_name, tab_stop, focus_lost_callback, initial_value, rect, enabled, visible
	LLUICtrl::initFromParams(p);
	
	// visible callback 
	if (p.visible_callback.isProvided())
	{
		setVisibleCallback(initCommitCallback(p.visible_callback));
	}
	
	for (LLInitParam::ParamIterator<LocalizedString>::const_iterator it = p.strings.begin();
		it != p.strings.end();
		++it)
	{
		mUIStrings[it->name] = it->value;
	}

	setLabel(p.label());
	setHelpTopic(p.help_topic);
	setShape(p.rect);
	parseFollowsFlags(p);

	setToolTip(p.tool_tip());
	setFromXUI(p.from_xui);
	
	mHoverCursor = getCursorFromString(p.hover_cursor);
	
	if (p.has_border)
	{
		addBorder(p.border);
	}
	// let constructors set this value if not provided
	if (p.use_bounding_rect.isProvided())
	{
		setUseBoundingRect(p.use_bounding_rect);
	}
	setDefaultTabGroup(p.default_tab_group);
	setMouseOpaque(p.mouse_opaque);
	
	setBackgroundVisible(p.background_visible);
	setBackgroundOpaque(p.background_opaque);
	setBackgroundColor(p.bg_opaque_color().get());
	setTransparentColor(p.bg_alpha_color().get());
	mBgOpaqueImage = p.bg_opaque_image();
	mBgAlphaImage = p.bg_alpha_image();
	mBgOpaqueImageOverlay = p.bg_opaque_image_overlay;
	mBgAlphaImageOverlay = p.bg_alpha_image_overlay;

	mAcceptsBadge = p.accepts_badge;
}
Пример #3
0
ImageConverter::ImageConverter(LameImage image)
{
    // set defaults
    _range = 55;
    _offset = 0;
    setColorTable();
    setTransparentColor();
    setScaleFactor();
    loadImage(image);
}
Пример #4
0
bool USplashWindow::showTransparent(huys::Color clr, DWORD dwDelayedTime)
{
    assert(this->create());
    setTransparentColor(clr);
    update();
    show();
    ::SetForegroundWindow(*this);
    setTimer(ID_SPLASH_TIMER, dwDelayedTime);
    return true;
}
Пример #5
0
void LLPanel::setPanelParameters(LLXMLNodePtr node, LLView* parent)
{
	/////// Rect, follows, tool_tip, enabled, visible attributes ///////
	initFromXML(node, parent);

	/////// Border attributes ///////
	BOOL border = mBorder != NULL;
	node->getAttributeBOOL("border", border);
	if (border)
	{
		LLViewBorder::EBevel bevel_style = LLViewBorder::BEVEL_OUT;
		LLViewBorder::getBevelFromAttribute(node, bevel_style);

		LLViewBorder::EStyle border_style = LLViewBorder::STYLE_LINE;
		std::string border_string;
		node->getAttributeString("border_style", border_string);
		LLStringUtil::toLower(border_string);

		if (border_string == "texture")
		{
			border_style = LLViewBorder::STYLE_TEXTURE;
		}

		S32 border_thickness = LLPANEL_BORDER_WIDTH;
		node->getAttributeS32("border_thickness", border_thickness);

		addBorder(bevel_style, border_style, border_thickness);
	}
	else
	{
		removeBorder();
	}

	/////// Background attributes ///////
	BOOL background_visible = mBgVisible;
	node->getAttributeBOOL("background_visible", background_visible);
	setBackgroundVisible(background_visible);
	
	BOOL background_opaque = mBgOpaque;
	node->getAttributeBOOL("background_opaque", background_opaque);
	setBackgroundOpaque(background_opaque);

	LLColor4 color;
	color = mBgColorOpaque;
	LLUICtrlFactory::getAttributeColor(node,"bg_opaque_color", color);
	setBackgroundColor(color);

	color = mBgColorAlpha;
	LLUICtrlFactory::getAttributeColor(node,"bg_alpha_color", color);
	setTransparentColor(color);

	std::string label = getLabel();
	node->getAttributeString("label", label);
	setLabel(label);
}
Пример #6
0
//---------------------------------------------------------------------------------
void LLIMWellWindow::ObjectRowPanel::onMouseLeave(S32 x, S32 y, MASK mask)
{
	setTransparentColor(LLUIColorTable::instance().getColor("SysWellItemUnselected"));
}
Пример #7
0
//---------------------------------------------------------------------------------
void LLIMWellWindow::RowPanel::onMouseEnter(S32 x, S32 y, MASK mask)
{
	setTransparentColor(LLUIColorTable::instance().getColor("SysWellItemSelected"));
}
Пример #8
0
//---------------------------------------------------------------------------------
void LLSysWellItem::onMouseLeave(S32 x, S32 y, MASK mask)
{
	setTransparentColor(LLUIColorTable::instance().getColor( "SysWellItemUnselected" ));
}
Пример #9
0
TextBox::TextBox(int x, int y, const Color &textColor, const std::string &text,
	FontName fontName, TextureManager &textureManager)
	: Surface(x, y, 1, 1)
{
	this->fontName = fontName;

	// Split "text" into lines of text.
	this->textLines = [&text]()
	{
		auto temp = std::vector<std::string>();

		// Add one empty string to start.
		temp.push_back(std::string());

		const char newLine = '\n';
		int textLineIndex = 0;
		for (auto &c : text)
		{
			if (c != newLine)
			{
				// std::string has push_back! Yay! Intuition + 1.
				temp.at(textLineIndex).push_back(c);
			}
			else
			{
				temp.push_back(std::string());
				textLineIndex++;
			}
		}

		return temp;
	}();

	// Calculate the proper dimensions of the text box.
	// No need for a "FontSurface" type... just do the heavy lifting in this class.
	auto font = Font(fontName);
	int upperCharWidth = font.getUpperCharacterWidth();
	int upperCharHeight = font.getUpperCharacterHeight();
	int lowerCharWidth = font.getLowerCharacterWidth();
	int lowerCharHeight = font.getLowerCharacterHeight();

	const int newWidth = [](const std::vector<std::string> &lines,
		int upperCharWidth, int lowerCharWidth)
	{
		// Find longest line (in pixels) out of all lines.
		int longestLength = 0;
		for (auto &line : lines)
		{
			// Sum of all character lengths in the current line.
			int linePixels = 0;
			for (auto &c : line)
			{
				linePixels += islower(c) ? lowerCharWidth : upperCharWidth;
			}

			// Check against the current longest line.
			if (linePixels > longestLength)
			{
				longestLength = linePixels;
			}
		}

		// In pixels.
		return longestLength;
	}(this->textLines, upperCharWidth, lowerCharWidth);

	const int newHeight = static_cast<int>(this->textLines.size()) * upperCharHeight;

	// Resize the surface with the proper dimensions for fitting all the text.
	SDL_FreeSurface(this->surface);
	this->surface = [](int width, int height, int colorBits)
	{
		return SDL_CreateRGBSurface(0, width, height, colorBits, 0, 0, 0, 0);
	}(newWidth, newHeight, Surface::DEFAULT_BPP);

	// Make this surface transparent.
	this->setTransparentColor(Color::Transparent);
	this->fill(Color::Transparent);
	
	// Blit each character surface in at the right spot.
	auto point = Int2();
	auto fontSurface = textureManager.getSurface(font.getFontTextureName());
	int upperCharOffsetWidth = font.getUpperCharacterOffsetWidth();
	int upperCharOffsetHeight = font.getUpperCharacterOffsetHeight();
	int lowerCharOffsetWidth = font.getLowerCharacterOffsetWidth();
	int lowerCharOffsetHeight = font.getLowerCharacterOffsetHeight();
	for (auto &line : this->textLines)
	{
		for (auto &c : line)
		{
			int width = islower(c) ? lowerCharWidth : upperCharWidth;
			int height = islower(c) ? lowerCharHeight : upperCharHeight;
			auto letterSurface = [&]()
			{
				auto cellPosition = Font::getCharacterCell(c);
				int offsetWidth = islower(c) ? lowerCharOffsetWidth : upperCharOffsetWidth;
				int offsetHeight = islower(c) ? lowerCharOffsetHeight : upperCharOffsetHeight;

				// Make a copy surface of the font character.
				auto pixelPosition = Int2(
					cellPosition.getX() * (width + offsetWidth),
					cellPosition.getY() * (height + offsetHeight));
				auto clipRect = Rectangle(pixelPosition.getX(), pixelPosition.getY(),
					width, height);

				auto surface = Surface(width, height);
				fontSurface.blit(surface, Int2(), clipRect);

				return surface;
			}();

			// Set the letter surface to have transparency.
			letterSurface.setTransparentColor(Color::Magenta);

			// Set the letter colors to the desired color.
			auto letterPixels = static_cast<unsigned int*>(letterSurface.getSurface()->pixels);
			auto mappedColor = SDL_MapRGBA(letterSurface.getSurface()->format, 
				textColor.getR(), textColor.getG(), textColor.getB(), textColor.getA());

			int area = letterSurface.getWidth() * letterSurface.getHeight();
			for (int i = 0; i < area; ++i)
			{
				auto pixel = &letterPixels[i];
				
				// If transparent, then color it? I dunno, but it works.
				if ((*pixel) == 0)
				{
					*pixel = mappedColor;
				}
			}

			// Draw the letter onto this texture.
			letterSurface.blit(*this, point);

			// Move drawing position to the right of the current character.
			point.setX(point.getX() + width);
		}

		// Move drawing point back to the left and down by one capital character size.
		point.setX(0);
		point.setY(point.getY() + upperCharHeight);
	}

	assert(this->surface->w > 1);
	assert(this->surface->h > 1);
	assert(this->textLines.size() > 0);
	assert(this->fontName == fontName);
}
Пример #10
0
void MovingPixelsState::onChangeTransparentColor(const Color& color)
{
  setTransparentColor(color);
}
Пример #11
0
 void Surface::setTransparentColor(Color *color)
 {
     setTransparentColor(color->getRed(), color->getGreen(), color->getBlue());
 }