size_t CLogCacheStatistics::GetSizeOf (const CStringDictionary& container)
{
    return GetSizeOf (container.packedStrings)
         + GetSizeOf (container.offsets)
         + GetSizeOf (container.hashIndex)
         + sizeof (container);
}
size_t CLogCacheStatistics::GetSizeOf (const CTokenizedStringContainer& container)
{
    return GetSizeOf (container.words)
         + GetSizeOf (container.pairs)
         + GetSizeOf (container.stringData)
         + GetSizeOf (container.offsets)
         + sizeof (container);
}
size_t CLogCacheStatistics::GetSizeOf (const CCachedLogInfo& container)
{
    return GetSizeOf (container.revisions)
         + GetSizeOf (container.logInfo)
         + GetSizeOf (container.skippedRevisions)

         + sizeof (container.fileName)
         + container.fileName.capacity() * sizeof (wchar_t)

         + sizeof (container);
}
Exemple #4
0
void
BorderBrush::operator()(PaintEventArgs&& e)
{
	auto& sender(e.GetSender());

	DrawRect(e.Target, e.ClipArea, Rect(e.Location, GetSizeOf(sender)),
		IsFocused(sender) ? Style.ActiveColor : Style.InactiveColor);
}
Exemple #5
0
void
PaintChild(IWidget& wgt, PaintEventArgs&& e)
{
	auto& sender(e.GetSender());

	if(Clip(e.ClipArea, Rect(e.Location += GetLocationOf(sender),
		GetSizeOf(sender))))
		wgt.GetRenderer().Paint(sender, std::move(e));
}
size_t CLogCacheStatistics::GetSizeOf (const CSkipRevisionInfo& container)
{
    size_t result = GetSizeOf (container.data)
                  + GetSizeOf (container.index)
                  + sizeof (container);

    for (size_t i = 0, count = container.data.size(); i < count; ++i)
    {
        const CSkipRevisionInfo::SPerPathRanges* entry = container.data[i];
        if (entry != NULL)
        {
            typedef CSkipRevisionInfo::SPerPathRanges::TRanges::_Tree_val T;
            result += entry->ranges.size() * sizeof (std::_Tree_val<T>)
                    + sizeof (*entry);
        }
    }

    return result;
}
Exemple #7
0
void
ProgressBar::Refresh(PaintEventArgs&& e)
{
	const auto& g(e.Target);
	auto pt(e.Location);
	auto& r(e.ClipArea);
	Size s(GetSizeOf(*this));

	if(YB_LIKELY(s.Width > 2 && s.Height > 2))
	{
		yunseq(s.Width -= 2, s.Height -= 2, pt.X += 1, pt.Y += 1);

		const SDst w_bar(round(value * s.Width / max_value));

		FillRect(g, r, {pt, w_bar, s.Height}, ForeColor);
		pt.X += w_bar;
		if(s.Width > w_bar)
			// TODO: Finish drawing with non-solid brushes.
			if(const auto p = Background.target<SolidBrush>())
				FillRect(g, r, Rect(pt, s.Width - w_bar, s.Height), p->Color);
	}
}
Exemple #8
0
void
Widget::SetRenderer(unique_ptr<Renderer> p)
{
	renderer_ptr = p ? std::move(p) : make_unique<Renderer>();
	renderer_ptr->SetSize(GetSizeOf(*this));
}
Exemple #9
0
DropDownList::DropDownList(const Rect& r, const shared_ptr<ListType>& h)
    : Button(r),
      lbContent( {}, h)
{
    const auto detacher([this](UIEventArgs&& e) {
        if(!dynamic_cast<RoutedEventArgs*>(&e))
            DetachTopWidget();
    });

    yunseq(
        Margin.Left = 4,
        Margin.Right = 18,
        HorizontalAlignment = TextAlignment::Left,
        lbContent.GetView().DependencyPtr = this,
    FetchEvent<TouchDown>(*this) += [this](CursorEventArgs&& e) {
        if(!FetchContainerPtr(lbContent))
        {
            Point pt;

            if(const auto p
                    = dynamic_cast<Panel*>(&FetchTopLevel(e.GetSender(), pt)))
            {
                // NOTE: Get height of top widget, top and bottom spaces.
                const SDst h0(GetSizeOf(*p).Height);
                // XXX: Conversion to 'SPos' might be implementation-defined.
                const SDst h1(SDst(max<SPos>(0, pt.Y))), h2(SDst(max<SPos>(0,
                        SPos(h0) - pt.Y - SPos(GetHeight()))));

                if(IsInOpenInterval(h1, h0) || IsInOpenInterval(h2, h0))
                {
                    lbContent.ResizeForPreferred(Size(0, max(h1, h2)),
                                                 Size(GetWidth(), 0));

                    const SDst h3(lbContent.GetHeight());

                    // NOTE: Bottom space is preferred.
                    // XXX: Conversion to 'SPos' might be
                    //	implementation-defined.
                    pt.Y += SPos(h2 < h3 ? -h3 : GetHeight());
                    SetLocationOf(lbContent, pt);
                    lbContent.AdjustViewLength();
                    {
                        const auto& lst(lbContent.GetList());
                        const auto i(std::find(lst.cbegin(), lst.cend(), Text));

                        if(i != lst.cend())
                            lbContent.SetSelected(size_t(i - lst.cbegin()));
                        else
                            lbContent.ClearSelected();
                    }
                    p->Add(lbContent, 224U); // TODO: Use non-magic number.
                    RequestFocusCascade(lbContent);
                    e.Handled = true;
                }
            }
        }
    },
    FetchEvent<LostFocus>(*this) += detacher,
                                    FetchEvent<LostFocus>(lbContent) += detacher,
    lbContent.GetConfirmed() += [this](IndexEventArgs&& e) {
        YAssert(e.Value < lbContent.GetList().size(), "Invalid index found.");

        Text = lbContent.GetList()[e.Value];
        // XXX: This seems to be redundant if the detached top widget would be
        //	always invalidated, however there is no such guarantee.
        Invalidate(e.GetSender()),
                   Invalidate(*this);
        DetachTopWidget();
    }
    );
}
Exemple #10
0
SDst
AMUnitList::GetItemHeightCore() const
{
	return GetSizeOf(GetUnitRef()).Height;
}
size_t CLogCacheStatistics::GetSizeOf (const CRevisionIndex& container)
{
    return GetSizeOf (container.indices)
         + sizeof (container);
}
size_t CLogCacheStatistics::GetSizeOf (const CRevisionInfoContainer& container)
{
    return GetSizeOf (container.presenceFlags)
         + GetSizeOf (container.authors)
         + GetSizeOf (container.timeStamps)
         + GetSizeOf (container.rootPaths)
         + GetSizeOf (container.sumChanges)
         + GetSizeOf (container.changesOffsets)
         + GetSizeOf (container.copyFromOffsets)
         + GetSizeOf (container.mergedRevisionsOffsets)
         + GetSizeOf (container.userRevPropOffsets)
         + GetSizeOf (container.changes)
         + GetSizeOf (container.changedPaths)
         + GetSizeOf (container.copyFromPaths)
         + GetSizeOf (container.copyFromRevisions)
         + GetSizeOf (container.mergedFromPaths)
         + GetSizeOf (container.mergedToPaths)
         + GetSizeOf (container.mergedRangeStarts)
         + GetSizeOf (container.mergedRangeDeltas)
         + GetSizeOf (container.userRevPropValues)

         + GetSizeOf (container.authorPool)
         + GetSizeOf (container.paths)
         + GetSizeOf (container.comments)
         + GetSizeOf (container.userRevPropsPool)
         + GetSizeOf (container.userRevPropValues)

         + sizeof (container);
}
size_t CLogCacheStatistics::GetSizeOf (const CPathDictionary& container)
{
    return GetSizeOf (container.pathElements)
         + GetSizeOf (container.paths)
         + sizeof (container);
}
size_t CLogCacheStatistics::GetSizeOf (const CIndexPairDictionary& container)
{
    return GetSizeOf (container.data)
         + GetSizeOf (container.hashIndex)
         + sizeof (container);
}
void CLogCacheStatistics::CollectData (const CCachedLogInfo& source)
{
    // run-time properties

    ramSize = GetSizeOf (source);
    dirty = source.IsModified();

    // revisions

    revisionCount
        = (revision_t) (  source.revisions.indices.size()
                        - std::count ( source.revisions.indices.begin()
                                     , source.revisions.indices.end()
                                     , NO_INDEX));
    maxRevision = source.revisions.GetLastCachedRevision()-1;

    // container sizes

    authorCount = source.logInfo.authorPool.size() -1;
    pathElementCount = source.logInfo.paths.pathElements.size();
    pathCount = source.logInfo.paths.size();

    skipDeltaCount = 0;
    for ( size_t i = 0, count = source.skippedRevisions.data.size(); i < count; ++i)
    {
        const CSkipRevisionInfo::SPerPathRanges* entry
            = source.skippedRevisions.data[i];
        if (entry != NULL)
            skipDeltaCount += (index_t)entry->ranges.size();
    }

    wordTokenCount = source.logInfo.comments.words.size();
    pairTokenCount = source.logInfo.comments.pairs.size();
    textSize = (index_t)source.logInfo.comments.stringData.size();
    uncompressedSize = source.logInfo.comments.UncompressedWordCount();

    // changes

    changesRevisionCount = 0;
    changesMissingRevisionCount = 0;
    changesCount = 0;

    for (size_t i = 0, count = source.logInfo.size(); i < count; ++i)
    {
        index_t changeCount = source.logInfo.changesOffsets[i+1]
                            - source.logInfo.changesOffsets[i];
        if (changeCount > 0)
        {
            ++changesRevisionCount;
            changesCount += changeCount;
        }
        else
        {
            if ((  source.logInfo.presenceFlags[i]
                 & CRevisionInfoContainer::HAS_CHANGEDPATHS) == 0)
                ++changesMissingRevisionCount;
        }
    }

    // merge info

    mergeInfoRevisionCount = 0;
    mergeInfoMissingRevisionCount = 0;
    mergeInfoCount = 0;

    for (size_t i = 0, count = source.logInfo.size(); i < count; ++i)
    {
        index_t mergeCount = source.logInfo.mergedRevisionsOffsets[i+1]
                           - source.logInfo.mergedRevisionsOffsets[i];
        if (mergeCount > 0)
        {
            ++mergeInfoRevisionCount;
            mergeInfoCount += mergeCount;
        }
        else
        {
            if ((  source.logInfo.presenceFlags[i]
                 & CRevisionInfoContainer::HAS_MERGEINFO) == 0)
                ++mergeInfoMissingRevisionCount;
        }
    }

    // user revision properties

    userRevPropRevisionCount = 0;
    userRevPropMissingRevisionCount = 0;
    userRevPropCount = 0;

    for (size_t i = 0, count = source.logInfo.size(); i < count; ++i)
    {
        index_t propCount = source.logInfo.userRevPropOffsets[i+1]
                          - source.logInfo.userRevPropOffsets[i];
        if (propCount > 0)
        {
            ++userRevPropRevisionCount;
            userRevPropCount += propCount;
        }
        else
        {
            if ((  source.logInfo.presenceFlags[i]
                 & CRevisionInfoContainer::HAS_USERREVPROPS) == 0)
                ++userRevPropMissingRevisionCount;
        }
    }
}