Example #1
0
void GlyphTreeNode::CreateBranches(const std::shared_ptr<FontSymbol> &symbol)
{
    unsigned int dw = this->width - symbol->GetWidth();
    unsigned int dh = this->height - symbol->GetHeight();

    if (dw < dh)
    {
        this->leafLeft = GetAllocator().New();
        this->leafLeft->Set(this->x + symbol->GetWidth(), this->y,
                            this->width - symbol->GetWidth(), this->height);

        this->leafRight = GetAllocator().New();
        this->leafRight->Set(this->x, this->y + symbol->GetHeight(),
                             this->width, this->height - symbol->GetHeight());
    }
    else
    {
        this->leafLeft = GetAllocator().New();
        this->leafLeft->Set(this->x, this->y + symbol->GetHeight(),
                            this->width, this->height - symbol->GetHeight());

        this->leafRight = GetAllocator().New();
        this->leafRight->Set(this->x + symbol->GetWidth(), this->y,
                             this->width - symbol->GetWidth(), this->height);
    }
}
 touchmind::VISITOR_RESULT operator()(std::shared_ptr<touchmind::model::node::NodeModel> node) {
   D2D1_RECT_F layoutRect = D2D1::RectF(node->GetX() + m_insets.left, node->GetY() + m_insets.top,
                                        node->GetX() + node->GetWidth() - m_insets.right,
                                        node->GetY() + node->GetHeight() - m_insets.bottom);
   if (m_nodeIdToView.count(node->GetId()) != 0) {
     std::shared_ptr<touchmind::view::node::BaseNodeView> &nodeView = m_nodeIdToView[node->GetId()];
     nodeView->SetHandled();
     auto editControlIndex = m_nodeViewManager->GetEditControlIndexFromNodeId(node->GetId());
     std::shared_ptr<touchmind::control::DWriteEditControl> editControl
         = m_pEditControlManager->GetEditControl(editControlIndex);
     if (editControl != nullptr) {
       editControl->SetLayoutRect(layoutRect);
     }
   } else {
     touchmind::control::EDIT_CONTROL_INDEX editControlIndex;
     HRESULT hr = m_nodeViewManager->_CreateEditControl(layoutRect, node->GetText(), &editControlIndex);
     if (SUCCEEDED(hr)) {
       auto nodeView = touchmind::view::node::NodeViewFactory::Create(node);
       nodeView->SetNodeViewManager(m_nodeViewManager);
       nodeView->SetEditControlManager(m_pEditControlManager);
       nodeView->SetEditControlIndex(editControlIndex);
       nodeView->SetHandled();
       m_nodeIdToView.insert({node->GetId(), nodeView});
     } else {
       LOG(SEVERITY_LEVEL_WARN) << L"Failed to create an edit control";
     }
   }
   return touchmind::VISITOR_RESULT_CONTINUE;
 }
Example #3
0
CpuShortestPath::CpuShortestPath(std::shared_ptr<Texture2> const& weights)
    :
    mSize(static_cast<int>(weights->GetWidth())),
    mWeights(mSize, mSize),
    mNodes(mSize, mSize)
{
    mWeights.SetRawPixels(weights->GetData());
}
Example #4
0
File: Image.cpp Project: aikei/sgw
sgw::Image::Image(std::shared_ptr<Texture> texture)
    : Rect(Vec2(0,0),Size(texture->GetWidth(),texture->GetHeight()))
{
    m_spTexture = texture;
    m_textureType = TextureType::TEXTURE_TYPE_QUAD;
    m_type = sgw::BaseShape::SHAPE_IMAGE;
    m_bFilled = true;
    m_flushListType = FlushList::TYPE_FILLED_TRIANGLES;
}
Example #5
0
 int Canvas2D::RegisterImage(std::shared_ptr<ImageBase> image) {
     if ((int) image->GetWidth() == width_ && (int) image->GetHeight() == height_) {
         image_ = image;
         return 0;
     } else {
         std::cerr << "RegisterImage(): Error: image dimensions do not match canvas size" << std::endl;
         return -1;
     }
 }
Example #6
0
void touchmind::layout::LayoutManager::SetLevelWidth(const std::shared_ptr<touchmind::model::node::NodeModel> &node, int level)
{
    if (mw_maxLevelWidth.count(level) == 0) {
        mw_maxLevelWidth[level] = 0.0f;
    }
    if (mw_maxLevelWidth[level] < node->GetWidth()) {
        mw_maxLevelWidth[level] = node->GetWidth();
    }
}
Example #7
0
FLOAT touchmind::layout::LayoutManager::GetNodeSize(const std::shared_ptr<touchmind::model::node::NodeModel> &node)
{
    switch (m_configuration->GetLayoutOrientation()) {
    case LAYOUT_ORIENTATION_TOP:
    case LAYOUT_ORIENTATION_BOTTOM:
        return node->GetWidth();
    case LAYOUT_ORIENTATION_RIGHT:
    case LAYOUT_ORIENTATION_LEFT:
        return node->GetHeight();
    }
    return 0;
}
Example #8
0
	std::shared_ptr<Sprite> Sprite::Create(const std::shared_ptr<Texture2D> &texture)
	{
		int w = texture->GetWidth();
		int h = texture->GetHeight();

		return Create(
			texture,
			Rect(0, 0, (float) w, (float) h),
			Vector2((float) (w/2), (float) (h/2)),
			100,
			Vector4(0, 0, 0, 0));
	}
HRESULT gameOfLife3D::draw3d::Draw3DWithCPU::Initialize(
    graphics::D3DInteropHelper *pD3DInteropHelper,
    std::shared_ptr<gameOfLife3D::lifeSimulator::AbstractLifeSimulator> pLifeSimulator, UINT maxNumberOfGenerations,
    FLOAT marginRate) {
  m_pLifeSimulator = pLifeSimulator;
  m_maxNumberOfGenerations = maxNumberOfGenerations;

  XMFLOAT3 p0;
  XMFLOAT3 p1;
  Draw3DUtil::CalculateP0P1(pLifeSimulator->GetWidth(), pLifeSimulator->GetHeight(), maxNumberOfGenerations, p0, p1);

  m_pVertexGenerator = nullptr;
  m_pVertexGenerator = std::make_shared<gameOfLife3D::draw3d::VertexGenerator>();
  m_pVertexGenerator->SetWidth(pLifeSimulator->GetWidth());
  m_pVertexGenerator->SetHeight(pLifeSimulator->GetHeight());
  m_pVertexGenerator->SetP0(p0);
  m_pVertexGenerator->SetP1(p1);
  m_pVertexGenerator->SetMaxNumberOfGenerations(maxNumberOfGenerations);
  m_pVertexGenerator->SetMarginRate(marginRate);
  m_pVertexGenerator->Initialize(pD3DInteropHelper);
  return S_OK;
}
Example #10
0
	void SpriteBatch::Impl::RenderBatch(std::shared_ptr<Texture> texture, SpriteInfo const* const* sprites, size_t count)
	{
		// Activate batch texture
		pixelShader->SetTexture(0, texture);

		while (count > 0)
		{
			size_t batchSize = count;
			size_t remainingSpace = MaxBatchSize - m_vertexBufferOffset;

			if (batchSize > remainingSpace)
			{
				if (remainingSpace < MinBatchSize)
				{
					m_vertexBufferOffset = 0;
					batchSize = std::min(count, MaxBatchSize);
				}
				else
				{
					batchSize = remainingSpace;
				}
			}

			VertexPositionColorTexture* vertices = nullptr;
			vertexBuffer->Map(m_vertexBufferOffset == 0 ? BufferMapType::Discard : BufferMapType::NoOverwrite, (void**) &vertices);
			vertices += m_vertexBufferOffset * VerticesPerSprite;

			for (size_t i = 0; i < batchSize; ++i)
			{
				float2 textureSize((float)texture->GetWidth(), (float)texture->GetHeight());
				float2 inverseTextureSize(1.0f / textureSize.x, 1.0f / textureSize.y);
				RenderSprite(sprites[i], vertices, textureSize, inverseTextureSize);

				vertices += VerticesPerSprite;
			}
			
			vertexBuffer->Unmap();

			// Draw indexed sprites!
			u32 startIndex = m_vertexBufferOffset * IndicesPerSprite;
			u32 indexCount = batchSize * IndicesPerSprite;

			device->DrawIndexed(indexCount, startIndex, 0);

			// Advance buffer position
			m_vertexBufferOffset += batchSize;

			sprites += batchSize;
			count -= batchSize;
		}
	}
Example #11
0
 touchmind::VISITOR_RESULT operator()(std::shared_ptr<touchmind::model::node::NodeModel> node) {
     static wchar_t *colors[] = {
         L"red", L"green", L"yellow", L"blue", L"orange", L"gray"
     };
     out << L"<!-- " << node->GetText() << L" -->" << std::endl;
     out << L"<v:rect style=\"position:absolute;margin-top:" << (node->GetY() + offsetY)
         << L";margin-left:" << (node->GetX() + offsetX)
         << L";width:" << node->GetWidth()
         << L";height:" << node->GetHeight()
         << L";z-index:2\" fillcolor=\""
         << colors[node->GetLevel()]
         << L"\" strokecolor=\"black\" strokeweight=\"1pt\"/>" << std::endl;
     return touchmind::VISITOR_RESULT_CONTINUE;
 }
Example #12
0
	void CharacterSpawn::SetObjectImageColor(std::shared_ptr<Image> &image)
	{
		if (image->GetImage() != nullptr)
		{
			hasImage_ = true;
			image_ = image;
			height_ = image->GetHeight();
			width_ = image->GetWidth();
		}
		else
		{
			hasColor_ = true;
			chosenColor_ = image->GetColor();
		}
	}
Example #13
0
void touchmind::print::XPSPrint::_PrintNode(const std::shared_ptr<touchmind::model::node::NodeModel> &node)
{
    CComPtr<IXpsOMVisualCollection> canvasVisuals = nullptr;
    CHK_RES(canvasVisuals, m_pXpsCanvas->GetVisuals(&canvasVisuals));

    CComPtr<IXpsOMSolidColorBrush> fillBrush = nullptr;
    COLORREF bgColor = touchmind::util::ColorUtil::ToColorref(node->GetBackgroundColor());
    XPS_COLOR bodyColor;
    bodyColor.colorType        = XPS_COLOR_TYPE_SRGB;
    bodyColor.value.sRGB.alpha = 0xff;
    bodyColor.value.sRGB.red   = GetRValue(bgColor);
    bodyColor.value.sRGB.green = GetGValue(bgColor);
    bodyColor.value.sRGB.blue  = GetBValue(bgColor);
    CHK_RES(fillBrush,
            m_pXpsFactory->CreateSolidColorBrush(&bodyColor, nullptr, &fillBrush));

    CComPtr<IXpsOMSolidColorBrush> strokeBrush = nullptr;
    ZeroMemory(&bodyColor, sizeof(bodyColor));
    bodyColor.colorType        = XPS_COLOR_TYPE_SRGB;
    bodyColor.value.sRGB.alpha = 0xff;
    bodyColor.value.sRGB.red   = 0;
    bodyColor.value.sRGB.green = 0;
    bodyColor.value.sRGB.blue  = 0;
    CHK_RES(strokeBrush,
            m_pXpsFactory->CreateSolidColorBrush(&bodyColor, nullptr, &strokeBrush));

    XPS_RECT rect = {node->GetX(), node->GetY(), node->GetWidth(), node->GetHeight()};
    CComPtr<IXpsOMGeometryFigure> xpsFigure = nullptr;
    if (node->GetNodeShape() == NODE_SHAPE_RECTANGLE) {
        XPSGeometryBuilder::CreateRectangleGeometry(m_pXpsFactory, rect, &xpsFigure);
    } else {
        XPSGeometryBuilder::CreateRoundedRectangleGeometry(m_pXpsFactory, rect, 10.0f, &xpsFigure);
    }

    CComPtr<IXpsOMGeometry> xpsGeometry = nullptr;
    CHK_RES(xpsGeometry, m_pXpsFactory->CreateGeometry(&xpsGeometry));

    CComPtr<IXpsOMGeometryFigureCollection> xpsFigureCollection = nullptr;
    CHK_HR(xpsGeometry->GetFigures(&xpsFigureCollection));
    CHK_HR(xpsFigureCollection->Append(xpsFigure));

    CComPtr<IXpsOMPath> path = nullptr;
    CHK_RES(path, m_pXpsFactory->CreatePath(&path));
    CHK_HR(path->SetFillBrushLocal(fillBrush));
    CHK_HR(path->SetStrokeBrushLocal(strokeBrush));
    CHK_HR(path->SetGeometryLocal(xpsGeometry));
    CHK_HR(canvasVisuals->Append(path));
}
Example #14
0
	std::shared_ptr<Sprite> Sprite::Create(
			const std::shared_ptr<Texture2D> &texture,
			const Rect &rect,
			const Vector2 &pivot,
			float pixels_per_unit,
			const Vector4 &border)
	{
		std::shared_ptr<Sprite> sprite(new Sprite());
		sprite->m_texture = texture;
		sprite->m_rect = rect;
		sprite->m_pivot = pivot;
		sprite->m_pixels_per_unit = pixels_per_unit;
		sprite->m_border = border;

		float v_ppu = 1 / pixels_per_unit;

		float v_w = 1.0f / texture->GetWidth();
		float v_h = 1.0f / texture->GetHeight();

		float left = -pivot.x;
		float top = -pivot.y;

		Rect vertices(left * v_ppu, top * v_ppu, rect.width * v_ppu, rect.height * v_ppu);
		Rect uv(rect.left * v_w, rect.top * v_h, rect.width * v_w, rect.height * v_h);

		sprite->m_vertices[0] = Vector2(vertices.left, -vertices.top);
		sprite->m_vertices[1] = Vector2(vertices.left, -(vertices.top + vertices.height));
		sprite->m_vertices[2] = Vector2(vertices.left + vertices.width, -(vertices.top + vertices.height));
		sprite->m_vertices[3] = Vector2(vertices.left + vertices.width, -vertices.top);

		sprite->m_uv[0] = Vector2(uv.left, uv.top);
		sprite->m_uv[1] = Vector2(uv.left, uv.top + uv.height);
		sprite->m_uv[2] = Vector2(uv.left + uv.width, uv.top + uv.height);
		sprite->m_uv[3] = Vector2(uv.left + uv.width, uv.top);

		sprite->m_triangles[0] = 0;
		sprite->m_triangles[1] = 1;
		sprite->m_triangles[2] = 2;
		sprite->m_triangles[3] = 0;
		sprite->m_triangles[4] = 2;
		sprite->m_triangles[5] = 3;

		return sprite;
	}
Example #15
0
void touchmind::win::CanvasPanel::EditNode(const std::shared_ptr<touchmind::model::node::NodeModel> &node) {
    m_pScrollBarHelper->MoveWindowTo(node->GetX() + node->GetWidth() / 2.0f, node->GetY() + node->GetHeight() / 2.0f);

    Insets insets = GetTouchMindApp()->GetConfiguration()->GetInsets();
    D2D1_POINT_2F nodeClientPoint;
    nodeClientPoint.x = node->GetX();
    nodeClientPoint.y = node->GetY();
    POINT nodeWindowPoint;

    touchmind::util::CoordinateConversion::ConvertModelToWindowCoordinate(m_hwnd, GetScrollBarHelper(), nodeClientPoint,
            &nodeWindowPoint);
    m_pEdittingNode = node;
    m_pNodeViewManager->SynchronizeWithModel();
    auto editControlIndex = m_pNodeViewManager->GetEditControlIndexFromNodeId(m_pEdittingNode->GetId());
    if (editControlIndex >= 0) {
        auto editControl = m_pEditControlManager->GetEditControl(editControlIndex);
        m_pEditControlManager->SetFocus(editControlIndex);
    }
    Invalidate();
}
Example #16
0
Texture::Texture(std::shared_ptr<RawTexture> rt):
	m_rt(rt),
	m_texcoord(0),
	m_x(0),
	m_y(0),
	m_width(rt? rt->GetWidth() : 0),
	m_height(rt? rt->GetHeight() : 0)
{
	glGenBuffers(1, &m_texcoord);
	glBindBuffer(GL_ARRAY_BUFFER, m_texcoord);

	GLdouble tc[4][2] = {
		{0.0, 0.0},
		{0.0, 1.0},
		{1.0, 0.0},
		{1.0, 1.0}
	};

	glBufferData(GL_ARRAY_BUFFER, sizeof(tc) * sizeof(GLdouble), tc, GL_STATIC_DRAW);
}
Example #17
0
void OpenCV::Push(std::shared_ptr<Image> image)
{
    cv::Mat checkerImg(image->GetHeight(), image->GetWidth(), CV_8UC4, image->GetSample());
    cv::vector<cv::Point2f> imagePoint;

    // 交点
    if(!cv::findChessboardCorners(checkerImg, m_patternSize, imagePoint)){
        // 交点検出失敗
        return;
    }

    cv::drawChessboardCorners(checkerImg, m_patternSize, (cv::Mat)(imagePoint), true);            
    m_images.push_back(image);
    m_checkerImgs.push_back(checkerImg);
    m_imagePoints.push_back(imagePoint);
    m_worldPoints.push_back(cv::vector<cv::Point3f>());
    for(int j=0; j<m_patternSize.area(); ++j){
        m_worldPoints.back().push_back(cv::Point3f(
                    static_cast<float>(j%m_patternSize.width*10),
                    static_cast<float>(j/m_patternSize.width*10),
                    0.0));
    }

    if(m_imagePoints.size()>8){
        m_images.erase(m_images.begin());
        m_checkerImgs.erase(m_checkerImgs.begin());
        m_imagePoints.erase(m_imagePoints.begin());
        m_worldPoints.erase(m_worldPoints.begin());
    }

    // calibration
    m_rotationVectors.clear();
    m_translationVectors.clear();
    cv::calibrateCamera(m_worldPoints, m_imagePoints, m_checkerImgs[0].size(),
            m_cameraMatrix, m_distCoeffs, m_rotationVectors, m_translationVectors);

	// XMLファイルへの書き出し
    cv::FileStorage fs("camera.xml", CV_STORAGE_WRITE);
    cv::write(fs, "intrinsic", m_cameraMatrix);
    cv::write(fs, "distortion", m_distCoeffs);
}
Example #18
0
SFApp::SFApp(std::shared_ptr<SFWindow> window) : is_running(true), window(window) {
    int canvas_w = window->GetWidth();
    int canvas_h = window->GetHeight();

    player = make_shared<SFAsset>(SFASSET_PLAYER, window);
    auto player_pos = Point2(canvas_w / 2 - player->GetBoundingBox()->GetWidth() / 2, canvas_h - player->GetBoundingBox()->GetHeight());
    player->SetPosition(player_pos);

    const int number_of_aliens = 10;
    for (int i = 0; i < number_of_aliens; i++) {
        // place an alien at width/number_of_aliens * i
        auto alien = make_shared<SFAsset>(SFASSET_ALIEN, window);
        auto pos = Point2((canvas_w / number_of_aliens) * i + alien->GetBoundingBox()->GetWidth() / 2, 200.0f);
        alien->SetPosition(pos);
        aliens.push_back(alien);
    }

    auto coin = make_shared<SFAsset>(SFASSET_COIN, window);
    auto pos = Point2((canvas_w / 4), 100);
    coin->SetPosition(pos);
    coins.push_back(coin);
}
Example #19
0
	void SpriteBatch::Draw(std::shared_ptr<Texture> texture, float x, float y)
	{
		Draw(texture, x, y, (float)texture->GetWidth(), (float)texture->GetHeight());
	}
Example #20
0
GpuShortestPath::GpuShortestPath(ProgramFactory& factory,
    std::shared_ptr<Texture2> const& weights, Environment const& env,
    bool& created)
    :
    mSize(static_cast<int>(weights->GetWidth()))
{
    created = false;
    mLogSize = Log2OfPowerOfTwo(mSize);

    mDistance = std::make_shared<Texture2>(DF_R32_FLOAT, mSize, mSize);
    mDistance->SetUsage(Resource::SHADER_OUTPUT);
    memset(mDistance->GetData(), 0, mDistance->GetNumBytes());

    mPrevious = std::make_shared<Texture2>(DF_R32G32_SINT, mSize, mSize);
    mPrevious->SetUsage(Resource::SHADER_OUTPUT);
    mPrevious->SetCopyType(Resource::COPY_STAGING_TO_CPU);

    mSegment = std::make_shared<ConstantBuffer>(3 * sizeof(int), true);

    factory.PushDefines();
    factory.defines.Set("ISIZE", mSize);
    mInitializeDiagToRow = factory.CreateFromFile(
        env.GetPath("InitializeDiagToRow.hlsl"));
    if (!mInitializeDiagToRow)
    {
        return;
    }
    std::shared_ptr<ComputeShader> cshader =
        mInitializeDiagToRow->GetCShader();
    cshader->Set("weights", weights);
    cshader->Set("previous", mPrevious);
    cshader->Set("sum", mDistance);

    mInitializeDiagToCol = factory.CreateFromFile(
        env.GetPath("InitializeDiagToCol.hlsl"));
    if (!mInitializeDiagToCol)
    {
        return;
    }
    cshader = mInitializeDiagToCol->GetCShader();
    cshader->Set("weights", weights);
    cshader->Set("previous", mPrevious);
    cshader->Set("sum", mDistance);

    mPartialSumDiagToRow.resize(mLogSize);
    mPartialSumDiagToCol.resize(mLogSize);
    for (int i = 0; i < mLogSize; ++i)
    {
        factory.defines.Set("LOGN", mLogSize);
        factory.defines.Set("P", i + 1);
        mPartialSumDiagToRow[i] = factory.CreateFromFile(
            env.GetPath("PartialSumsDiagToRow.hlsl"));
        if (!mPartialSumDiagToRow[i])
        {
            return;
        }
        mPartialSumDiagToRow[i]->GetCShader()->Set("sum", mDistance);

        mPartialSumDiagToCol[i] = factory.CreateFromFile(
            env.GetPath("PartialSumsDiagToCol.hlsl"));
        if (!mPartialSumDiagToCol[i])
        {
            return;
        }
        mPartialSumDiagToCol[i]->GetCShader()->Set("sum", mDistance);
    }

    mUpdate = factory.CreateFromFile(env.GetPath("UpdateShader.hlsl"));
    if (!mUpdate)
    {
        return;
    }
    cshader = mUpdate->GetCShader();
    cshader->Set("Segment", mSegment);
    cshader->Set("weights", weights);
    cshader->Set("distance", mDistance);
    cshader->Set("previous", mPrevious);

    factory.PopDefines();
    created = true;
}
Example #21
0
Texture::Texture(
	std::shared_ptr<Texture> tex,
	int x,
	int y,
	int width,
	int height):
	m_rt(tex->GetRawTexture()),
	m_x(tex->GetX() + x),
	m_y(tex->GetY() + y),
	m_width(width),
	m_height(height)
{
	int x2 = m_x + m_width;
	int y2 = m_y + m_height;

	if (m_x < tex->GetX())
	{
		m_x = tex->GetX();
	}
	else if (tex->GetX() + tex->GetWidth() < m_x)
	{
		m_x = tex->GetX() + tex->GetWidth();
	}

	if (x2 < tex->GetX())
	{
		x2 = tex->GetX();
	}
	else if (tex->GetX() + tex->GetWidth() < x2)
	{
		x2 = tex->GetX() + tex->GetWidth();
	}

	if (m_y < tex->GetY())
	{
		m_y = tex->GetY();
	}
	else if (tex->GetY() + tex->GetHeight() < m_y)
	{
		m_y = tex->GetY() + tex->GetHeight();
	}

	if (y2 < tex->GetY())
	{
		y2 = tex->GetY();
	}
	else if (tex->GetY() + tex->GetHeight() < y2)
	{
		y2 = tex->GetY() + tex->GetHeight();
	}

	m_width  = x2 - m_x;
	m_height = y2 - m_y;


	glGenBuffers(1, &m_texcoord);
	glBindBuffer(GL_ARRAY_BUFFER, m_texcoord);

	GLdouble tc[4][2] = {
		{GetCoordLeft() , GetCoordTop()   },
		{GetCoordLeft() , GetCoordBottom()},
		{GetCoordRight(), GetCoordTop()   },
		{GetCoordRight(), GetCoordBottom()}
	};

	glBufferData(GL_ARRAY_BUFFER, sizeof(tc) * sizeof(GLdouble), tc, GL_STATIC_DRAW);
}
Example #22
0
 void SetTexture(const std::shared_ptr<Texture2D>& textureIn)
 {
     texture = textureIn;
     sourceRect = Rectangle{0, 0, textureIn->GetWidth(), textureIn->GetHeight()};
     originPivot = Vector2{0.5f, 0.5f};
 }
Example #23
0
void touchmind::layout::LayoutManager::SecondWalk(
    const std::shared_ptr<touchmind::model::node::NodeModel> &tree,
    const std::shared_ptr<touchmind::model::node::NodeModel> &node,
    int level,
    FLOAT x,
    FLOAT y)
{
    if (level <= m_configuration->GetMaxDepth()) {
        FLOAT xTmp = mw_rootXOffset + _GetLayoutWorkData(node)->prelim + x;
        FLOAT yTmp = mw_rootYOffset + y;
        FLOAT maxSizeTmp = 0;
        FLOAT nodeSizeTmp = 0;
        bool flag = false;

        switch (m_configuration->GetLayoutOrientation()) {
        case LAYOUT_ORIENTATION_TOP:
        case LAYOUT_ORIENTATION_BOTTOM:
            maxSizeTmp = mw_maxLevelHeight[level];
            nodeSizeTmp = node->GetHeight();
            break;
        case LAYOUT_ORIENTATION_RIGHT:
        case LAYOUT_ORIENTATION_LEFT:
            maxSizeTmp = mw_maxLevelWidth[level];
            flag = true;
            nodeSizeTmp = node->GetWidth();
            break;
        }
        switch (m_configuration->GetNodeJustification()) {
        case NODE_JUSTIFICATION_TOP:
            node->SetX(xTmp);
            node->SetY(yTmp);
            break;
        case NODE_JUSTIFICATION_CENTER:
            node->SetX(xTmp);
            node->SetY(yTmp + (maxSizeTmp - nodeSizeTmp) / 2);
            break;
        case NODE_JUSTIFICATION_BOTTOM:
            node->SetX(xTmp);
            node->SetY(yTmp + maxSizeTmp - nodeSizeTmp);
            break;
        }
        if (flag) {
            FLOAT swapTmp = node->GetX();
            node->SetX(node->GetY());
            node->SetY(swapTmp);
        }
        switch (m_configuration->GetLayoutOrientation()) {
        case LAYOUT_ORIENTATION_BOTTOM:
            node->SetY(-node->GetY() - nodeSizeTmp);
            break;
        case LAYOUT_ORIENTATION_RIGHT:
            node->SetX(-node->GetX() - nodeSizeTmp);
            break;
        }
        if (node->GetChildrenCount() != 0) {
            SecondWalk(tree, node->GetFirstChild(), level + 1, x + _GetLayoutWorkData(node)->modifier,
                       y + maxSizeTmp + m_configuration->GetLevelSeparation());
        }
        std::shared_ptr<touchmind::model::node::NodeModel> rightSibling = node->GetRightSibling();
        if (rightSibling != nullptr) {
            SecondWalk(tree, rightSibling, level, x, y);
        }
    }
}
Example #24
0
    void Update()
    {
        if(m_text==m_ss.str()){
            return;
        }

        m_text=m_ss.str();

        m_image->Clear();
        BYTE *data=m_image->GetSample();
        int pitch=m_image->GetWidth()*4;

        // フォントの生成
        LOGFONT lf = {m_fontsize, 0, 0, 0, 0, 0, 0, 0, 
            SHIFTJIS_CHARSET, OUT_TT_ONLY_PRECIS,
            CLIP_DEFAULT_PRECIS, PROOF_QUALITY, FIXED_PITCH | FF_MODERN, _T("MS 明朝")};
        HFONT hFont=CreateFontIndirect(&lf);
        if(!(hFont)){
            return;
        }

        // デバイスコンテキスト取得
        // デバイスにフォントを持たせないとGetGlyphOutline関数はエラーとなる
        HDC hdc = GetDC(NULL);
        HFONT oldFont = (HFONT)SelectObject(hdc, hFont);

        std::vector<BYTE> gryph;
        int x_pos=0;
        int y_pos=0;
        int col_size=m_fontsize/2;
        for(auto c=m_text.begin(); c!=m_text.end(); ++c){

            if(y_pos>=m_row*m_fontsize){
                break;
            }

            if(*c==L'\n'){
                y_pos+=m_fontsize+5;
                x_pos=0;
                continue;
            }

            if(x_pos+col_size>=m_col*col_size){
                y_pos+=m_fontsize+5;
                x_pos=0;
            }

            // フォントビットマップ取得
            TEXTMETRIC TM;
            GetTextMetrics( hdc, &TM );
            GLYPHMETRICS GM;
            CONST MAT2 Mat = {{0,1},{0,0},{0,0},{0,1}};
            DWORD size = GetGlyphOutline(hdc, *c, GGO_GRAY4_BITMAP, &GM, 0, NULL, &Mat);

            if(size>0){
                gryph.resize(size);
                GetGlyphOutline(hdc, *c, GGO_GRAY4_BITMAP, &GM, gryph.size(), &gryph[0], &Mat);

                // フォント情報の書き込み
                // iOfs_x, iOfs_y : 書き出し位置(左上)
                // iBmp_w, iBmp_h : フォントビットマップの幅高
                // Level : α値の段階 (GGO_GRAY4_BITMAPなので17段階)
                int iOfs_x = x_pos+GM.gmptGlyphOrigin.x;
                int iOfs_y = y_pos+TM.tmAscent - GM.gmptGlyphOrigin.y;
                int iBmp_w = GM.gmBlackBoxX + (4-(GM.gmBlackBoxX%4))%4;
                int iBmp_h = GM.gmBlackBoxY;
                int Level = 17;
                DWORD Alpha, Color;
                for(int y=iOfs_y; y<iOfs_y+iBmp_h; y++){
                    for(size_t x=iOfs_x; x<iOfs_x+GM.gmBlackBoxX; x++){
                        Alpha = (255 * gryph[x-iOfs_x + iBmp_w*(y-iOfs_y)]) / (Level-1);
                        Color = 0x00ffffff | (Alpha<<24);
                        memcpy((BYTE*)data + pitch*y + 4*x, &Color, sizeof(DWORD));
                    }
                }
                x_pos+=iBmp_w;
            }
            else{
                x_pos+=col_size;
            }
        }

        // デバイスコンテキストとフォントハンドルの開放
        SelectObject(hdc, oldFont);
        DeleteObject(hFont);
        ReleaseDC(NULL, hdc);
    }
Example #25
0
 int GetWidth(){
     return m_image->GetWidth();
 }
Example #26
0
//Set the texture page this subimage is on (uses whole page)
void Sprite_Subimage::SetTexturePage(std::shared_ptr<TexturePage> page)
{
    SetTexturePage(page, page->GetWidth(), page->GetHeight(),0,0,page->GetWidth(), page->GetHeight(),0,0);
}
Example #27
0
 InputDialog::Builder::Builder(std::shared_ptr<n8::Window> pWindow) : DialogBuilderInterface(pWindow) {
     int x = pWindow->GetWidth()/2 - Style::DEFAULT_DIALOG_WIDTH/2;
     int y = pWindow->GetHeight()/2 - Style::DEFAULT_DIALOG_HEIGHT/2;
     mDialog = std::make_shared<InputDialog>(pWindow, "", x, y, Style::DEFAULT_DIALOG_WIDTH, Style::DEFAULT_DIALOG_HEIGHT);
     DialogBuilderInterface::mDialog = mDialog;
 }
Example #28
0
_Use_decl_annotations_
std::shared_ptr<GlTexture> GlTexture::Create(const std::shared_ptr<TextureContent>& content)
{
    return std::shared_ptr<GlTexture>(GDKNEW GlTexture(content->GetWidth(), content->GetHeight(), content->GetFormat(), content->GetPixels()));
}
Example #29
0
bool GlyphTreeNode::Fits(const std::shared_ptr<FontSymbol> &symbol) const
{
    return symbol->GetWidth() <= this->width && symbol->GetHeight() <= this->height;
}