本文整理汇总了C++中TBLinkListOf类的典型用法代码示例。如果您正苦于以下问题:C++ TBLinkListOf类的具体用法?C++ TBLinkListOf怎么用?C++ TBLinkListOf使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TBLinkListOf类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InvokeWidgetFocusChanged
void TBWidgetListener::InvokeWidgetFocusChanged(TBWidget *widget, bool focused)
{
TBLinkListOf<TBWidgetListenerGlobalLink>::Iterator global_i = g_listeners.IterateForward();
TBLinkListOf<TBWidgetListener>::Iterator local_i = widget->m_listeners.IterateForward();
while (TBWidgetListener *listener = local_i.GetAndStep())
listener->OnWidgetFocusChanged(widget, focused);
while (TBWidgetListenerGlobalLink *link = global_i.GetAndStep())
static_cast<TBWidgetListener*>(link)->OnWidgetFocusChanged(widget, focused);
}
示例2: InvokeWidgetRemove
void TBWidgetListener::InvokeWidgetRemove(TBWidget *parent, TBWidget *child)
{
TBLinkListOf<TBWidgetListenerGlobalLink>::Iterator global_i = g_listeners.IterateForward();
TBLinkListOf<TBWidgetListener>::Iterator local_i = parent->m_listeners.IterateForward();
while (TBWidgetListener *listener = local_i.GetAndStep())
listener->OnWidgetRemove(parent, child);
while (TBWidgetListenerGlobalLink *link = global_i.GetAndStep())
static_cast<TBWidgetListener*>(link)->OnWidgetRemove(parent, child);
}
示例3: InvokeWidgetInvokeEvent
bool TBWidgetListener::InvokeWidgetInvokeEvent(TBWidget *widget, const TBWidgetEvent &ev)
{
bool handled = false;
TBLinkListOf<TBWidgetListenerGlobalLink>::Iterator global_i = g_listeners.IterateForward();
TBLinkListOf<TBWidgetListener>::Iterator local_i = widget->m_listeners.IterateForward();
while (TBWidgetListener *listener = local_i.GetAndStep())
handled |= listener->OnWidgetInvokeEvent(widget, ev);
while (TBWidgetListenerGlobalLink *link = global_i.GetAndStep())
handled |= static_cast<TBWidgetListener*>(link)->OnWidgetInvokeEvent(widget, ev);
return handled;
}
示例4: next
namespace tb {
// We can't use a linked list object since we don't know if its constructor
// would run before of after any widget factory constructor that add itself
// to it. Using a manual one way link list is very simple.
TBAddonFactory *g_registered_addon_factories = nullptr;
TBAddonFactory::TBAddonFactory()
: next(g_registered_addon_factories)
{
g_registered_addon_factories = this;
}
// ======================================================================================
TBLinkListOf<TBAddon> m_addons;
bool TBInitAddons()
{
TBAddonFactory *f = g_registered_addon_factories;
while (f)
{
TBAddon *addon = f->Create();
if (!addon || !addon->Init())
{
delete addon;
TBDebugOut("Failed initiating addon\n");
return false;
}
m_addons.AddLast(addon);
f = f->next;
}
return true;
}
void TBShutdownAddons()
{
while (TBAddon *addon = m_addons.GetLast())
{
addon->Shutdown();
m_addons.Delete(addon);
}
}
}; // namespace tb
示例5: AbortAnimations
void TBWidgetsAnimationManager::AbortAnimations(TBWidget *widget, TB_TYPE_ID type_id)
{
TBLinkListOf<TBWidgetAnimationObject>::Iterator iter = widget_animations.IterateForward();
while (TBWidgetAnimationObject *wao = iter.GetAndStep())
{
if (wao->m_widget == widget)
{
// Skip this animation if we asked for a specific (and
// different) animation type.
if (type_id != nullptr && !wao->IsOfTypeId(type_id))
continue;
// Abort the animation. This will both autoremove itself
// and delete it, so no need to do it here.
TBAnimationManager::AbortAnimation(wao, true);
}
}
}
示例6: LERP
namespace tb {
TBLinkListOf<TBWidgetAnimationObject> widget_animations;
#define LERP(src, dst, progress) (src + (dst - src) * progress)
// == TBWidgetAnimationObject =============================================================
TBWidgetAnimationObject::TBWidgetAnimationObject(TBWidget *widget)
: m_widget(widget)
{
widget_animations.AddLast(this);
}
TBWidgetAnimationObject::~TBWidgetAnimationObject()
{
widget_animations.Remove(this);
}
// == TBWidgetAnimationOpacity ============================================================
TBWidgetAnimationOpacity::TBWidgetAnimationOpacity(TBWidget *widget, float src_opacity, float dst_opacity, bool die)
: TBWidgetAnimationObject(widget)
, m_src_opacity(src_opacity)
, m_dst_opacity(dst_opacity)
, m_die(die)
{
}
void TBWidgetAnimationOpacity::OnAnimationStart()
{
// Make sure we don't stay idle if nothing is scheduled (hack).
// FIX: fix this properly
m_widget->Invalidate();
m_widget->SetOpacity(m_src_opacity);
}
void TBWidgetAnimationOpacity::OnAnimationUpdate(float progress)
{
m_widget->SetOpacity(LERP(m_src_opacity, m_dst_opacity, progress));
}
void TBWidgetAnimationOpacity::OnAnimationStop(bool aborted)
{
// If we're aborted, it may be because the widget is being deleted
if (m_die && !aborted)
{
TBWidgetSafePointer the_widget(m_widget);
if (m_widget->GetParent())
m_widget->GetParent()->RemoveChild(m_widget);
if (the_widget.Get())
delete the_widget.Get();
}
else
m_widget->SetOpacity(m_dst_opacity);
}
// == TBWidgetAnimationRect ===============================================================
TBWidgetAnimationRect::TBWidgetAnimationRect(TBWidget *widget, const TBRect &src_rect, const TBRect &dst_rect)
: TBWidgetAnimationObject(widget)
, m_src_rect(src_rect)
, m_dst_rect(dst_rect)
, m_mode(MODE_SRC_TO_DST)
{
}
TBWidgetAnimationRect::TBWidgetAnimationRect(TBWidget *widget, const TBRect &delta_rect, MODE mode)
: TBWidgetAnimationObject(widget)
, m_delta_rect(delta_rect)
, m_mode(mode)
{
assert(mode == MODE_DELTA_IN || mode == MODE_DELTA_OUT);
}
void TBWidgetAnimationRect::OnAnimationStart()
{
// Make sure we don't stay idle if nothing is scheduled (hack).
// FIX: fix this properly
m_widget->Invalidate();
if (m_mode == MODE_SRC_TO_DST)
m_widget->SetRect(m_src_rect);
}
void TBWidgetAnimationRect::OnAnimationUpdate(float progress)
{
if (m_mode == MODE_DELTA_IN || m_mode == MODE_DELTA_OUT)
{
m_dst_rect = m_src_rect = m_widget->GetRect();
if (m_dst_rect.Equals(TBRect()))
{
// Widget hasn't been laid out yet,
// the animation was started too soon.
TBAnimationManager::AbortAnimation(this, true);
return;
}
if (m_mode == MODE_DELTA_IN)
{
//.........这里部分代码省略.........
示例7: while
namespace tb {
TBLinkListOf<TBWidgetListenerGlobalLink> g_listeners;
// == TBWidgetListener ================================================================================
void TBWidgetListener::AddGlobalListener(TBWidgetListener *listener)
{
g_listeners.AddLast(listener);
}
void TBWidgetListener::RemoveGlobalListener(TBWidgetListener *listener)
{
g_listeners.Remove(listener);
}
void TBWidgetListener::InvokeWidgetDelete(TBWidget *widget)
{
TBLinkListOf<TBWidgetListenerGlobalLink>::Iterator global_i = g_listeners.IterateForward();
TBLinkListOf<TBWidgetListener>::Iterator local_i = widget->m_listeners.IterateForward();
while (TBWidgetListener *listener = local_i.GetAndStep())
listener->OnWidgetDelete(widget);
while (TBWidgetListenerGlobalLink *link = global_i.GetAndStep())
static_cast<TBWidgetListener*>(link)->OnWidgetDelete(widget);
}
bool TBWidgetListener::InvokeWidgetDying(TBWidget *widget)
{
bool handled = false;
TBLinkListOf<TBWidgetListenerGlobalLink>::Iterator global_i = g_listeners.IterateForward();
TBLinkListOf<TBWidgetListener>::Iterator local_i = widget->m_listeners.IterateForward();
while (TBWidgetListener *listener = local_i.GetAndStep())
handled |= listener->OnWidgetDying(widget);
while (TBWidgetListenerGlobalLink *link = global_i.GetAndStep())
handled |= static_cast<TBWidgetListener*>(link)->OnWidgetDying(widget);
return handled;
}
void TBWidgetListener::InvokeWidgetAdded(TBWidget *parent, TBWidget *child)
{
TBLinkListOf<TBWidgetListenerGlobalLink>::Iterator global_i = g_listeners.IterateForward();
TBLinkListOf<TBWidgetListener>::Iterator local_i = parent->m_listeners.IterateForward();
while (TBWidgetListener *listener = local_i.GetAndStep())
listener->OnWidgetAdded(parent, child);
while (TBWidgetListenerGlobalLink *link = global_i.GetAndStep())
static_cast<TBWidgetListener*>(link)->OnWidgetAdded(parent, child);
}
void TBWidgetListener::InvokeWidgetRemove(TBWidget *parent, TBWidget *child)
{
TBLinkListOf<TBWidgetListenerGlobalLink>::Iterator global_i = g_listeners.IterateForward();
TBLinkListOf<TBWidgetListener>::Iterator local_i = parent->m_listeners.IterateForward();
while (TBWidgetListener *listener = local_i.GetAndStep())
listener->OnWidgetRemove(parent, child);
while (TBWidgetListenerGlobalLink *link = global_i.GetAndStep())
static_cast<TBWidgetListener*>(link)->OnWidgetRemove(parent, child);
}
void TBWidgetListener::InvokeWidgetFocusChanged(TBWidget *widget, bool focused)
{
TBLinkListOf<TBWidgetListenerGlobalLink>::Iterator global_i = g_listeners.IterateForward();
TBLinkListOf<TBWidgetListener>::Iterator local_i = widget->m_listeners.IterateForward();
while (TBWidgetListener *listener = local_i.GetAndStep())
listener->OnWidgetFocusChanged(widget, focused);
while (TBWidgetListenerGlobalLink *link = global_i.GetAndStep())
static_cast<TBWidgetListener*>(link)->OnWidgetFocusChanged(widget, focused);
}
bool TBWidgetListener::InvokeWidgetInvokeEvent(TBWidget *widget, const TBWidgetEvent &ev)
{
bool handled = false;
TBLinkListOf<TBWidgetListenerGlobalLink>::Iterator global_i = g_listeners.IterateForward();
TBLinkListOf<TBWidgetListener>::Iterator local_i = widget->m_listeners.IterateForward();
while (TBWidgetListener *listener = local_i.GetAndStep())
handled |= listener->OnWidgetInvokeEvent(widget, ev);
while (TBWidgetListenerGlobalLink *link = global_i.GetAndStep())
handled |= static_cast<TBWidgetListener*>(link)->OnWidgetInvokeEvent(widget, ev);
return handled;
}
// == TBWidgetSafePointer ===================================================================================
void TBWidgetSafePointer::Set(TBWidget *widget)
{
if (m_widget == widget)
return;
if (m_widget)
m_widget->RemoveListener(this);
m_widget = widget;
if (m_widget)
m_widget->AddListener(this);
}
void TBWidgetSafePointer::OnWidgetDelete(TBWidget *widget)
{
if (widget == m_widget)
Set(nullptr);
}
} // namespace tb
示例8: TBShutdownAddons
void TBShutdownAddons()
{
while (TBAddon *addon = m_addons.GetLast())
{
addon->Shutdown();
m_addons.Delete(addon);
}
}
示例9: TBInitAddons
bool TBInitAddons()
{
TBAddonFactory *f = g_registered_addon_factories;
while (f)
{
TBAddon *addon = f->Create();
if (!addon || !addon->Init())
{
delete addon;
TBDebugOut("Failed initiating addon\n");
return false;
}
m_addons.AddLast(addon);
f = f->next;
}
return true;
}
示例10:
TBWidgetAnimationObject::~TBWidgetAnimationObject()
{
widget_animations.Remove(this);
}
示例11: RemoveGlobalListener
void TBWidgetListener::RemoveGlobalListener(TBWidgetListener *listener)
{
g_listeners.Remove(listener);
}
示例12: AddGlobalListener
void TBWidgetListener::AddGlobalListener(TBWidgetListener *listener)
{
g_listeners.AddLast(listener);
}