bool UIWebView::OnEvent(const TBWidgetEvent &ev)
{
    if (ev.type == EVENT_TYPE_POINTER_DOWN || ev.type == EVENT_TYPE_POINTER_UP)
    {
        webClient_->SendMouseClickEvent(ev.target_x, ev.target_y, 0, ev.type == EVENT_TYPE_POINTER_UP, 0, ev.count);
        return true;
    }
    else if (ev.type == EVENT_TYPE_POINTER_MOVE)
    {
        webClient_->SendMouseMoveEvent(ev.target_x, ev.target_y, 0);
        return true;
    }
    else if (ev.type == EVENT_TYPE_WHEEL)
    {
        webClient_->SendMouseWheelEvent(ev.target_x, ev.target_y, 0, ev.delta_x, ev.delta_y);
        return true;
    }
    else if (ev.type == EVENT_TYPE_SHORTCUT)
    {

#ifdef ATOMIC_PLATFORM_OSX
        // On OSX, these shortcuts are not being invoked with key combinations (Handle KeyDown/KeyUp)
        if (ev.ref_id == TBIDC("copy"))
        {
            webClient_->ShortcutCopy();
            return true;
        }
        else if (ev.ref_id == TBIDC("paste"))
        {
            webClient_->ShortcutPaste();
            return true;
        }
        else if (ev.ref_id == TBIDC("cut"))
        {
            webClient_->ShortcutCut();
            return true;
        }
#endif


        // Handled by key combinations in Handle KeyDown/KeyUp
        /*
        else if (ev.ref_id == TBIDC("selectall"))
        {
            webClient_->ShortcutSelectAll();
            return true;
        }
        else if (ev.ref_id == TBIDC("undo"))
        {
            webClient_->ShortcutUndo();
            return true;
        }
        else if (ev.ref_id == TBIDC("redo"))
        {
            webClient_->ShortcutRedo();
            return true;
        }
        */
    }
    else if (ev.type == EVENT_TYPE_KEY_DOWN || ev.type == EVENT_TYPE_KEY_UP)
    {
        // We consume all key events as they are handled by the UI event system directly
        return true;
    }

    return UIWidget::OnEvent(ev);
}
示例#2
0
bool UINewProject::OnEvent(const TBWidgetEvent &ev)
{
    Editor* editor = GetSubsystem<Editor>();
    UIModalOps* ops = GetSubsystem<UIModalOps>();

    if (ev.type == EVENT_TYPE_CLICK)
    {
        if (ev.target->GetID() == TBIDC("cancel"))
        {
            ops->Hide();
            return true;
        }

        int projectType = -1;

        if (ev.target->GetID() == TBIDC("project_empty"))
        {
            projectType = 0;
        }
        else if (ev.target->GetID() == TBIDC("project_2d"))
        {
            projectType = 1;
        }
        else if (ev.target->GetID() == TBIDC("project_3d"))
        {
// BEGIN LICENSE MANAGEMENT
            LicenseSystem* licenseSystem = GetSubsystem<LicenseSystem>();

            if (licenseSystem->IsStandardLicense())
            {
                SharedPtr<UINewProject> keepAlive(this);
                UIModalOps* ops = GetSubsystem<UIModalOps>();
                ops->Hide();
                ops->ShowInfoModule3D();
                return true;
            }
// END LICENSE MANAGEMENT

            projectType = 2;
        }

        if (projectType != -1)
        {
            FileSystem* fileSystem = GetSubsystem<FileSystem>();

        #ifdef CLOCKWORK_PLATFORM_OSX
            String templateSourceDir = fileSystem->GetAppBundleResourceFolder();
        #else
            String templateSourceDir = fileSystem->GetProgramDir();
        #endif

            if (projectType == 0)
                templateSourceDir += "/ProjectTemplates/EmptyProject";
            else if (projectType == 1)
                templateSourceDir += "/ProjectTemplates/Project2D";
            else
                templateSourceDir += "/ProjectTemplates/Project3D";

            SharedPtr<UINewProject> keepAlive(this);
            UIModalOps* ops = GetSubsystem<UIModalOps>();
            ops->Hide();
            ops->ShowCreateProject(templateSourceDir);

            return true;

        }

    }

    return false;
}
 void UpdateTextSkin(const String& skin)
 {
     if (textField_)
         textField_->SetSkinBg(TBIDC(skin.CString()));
 }
示例#4
0
core::AppState Client::onInit() {
	eventBus()->subscribe<network::NewConnectionEvent>(*this);
	eventBus()->subscribe<network::DisconnectEvent>(*this);
	eventBus()->subscribe<voxel::WorldCreatedEvent>(*this);

	GLDebug::enable(GLDebug::Medium);

	core::AppState state = UIApp::onInit();
	if (state != core::Running)
		return state;

	if (!_network->start())
		return core::Cleanup;

	core::Var::get(cfg::ClientName, "noname");
	core::Var::get(cfg::ClientPassword, "nopassword");

	if (!_worldShader.init()) {
		return core::Cleanup;
	}
	if (!_meshShader->init()) {
		return core::Cleanup;
	}
	if (!_waterShader->init()) {
		return core::Cleanup;
	}

	_waterTexture = video::TexturePtr(new video::Texture("texture/water.png"));
	_waterTexture->load();
	const glm::vec3 vertices[4] = { glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(1.0f,
			1.0f, 0.0f) };
	const glm::ivec3 indices[2] = { glm::ivec3( 0, 1, 2 ), glm::ivec3( 1, 3, 2 ) };
	glGenVertexArrays(1, &_waterData.vertexArrayObject);
	core_assert(_waterData.vertexArrayObject > 0);
	glBindVertexArray(_waterData.vertexArrayObject);

	glGenBuffers(1, &_waterData.vertexBuffer);
	core_assert(_waterData.vertexBuffer > 0);
	glBindBuffer(GL_ARRAY_BUFFER, _waterData.vertexBuffer);
	glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(glm::vec3), vertices, GL_STATIC_DRAW);

	glGenBuffers(1, &_waterData.indexBuffer);
	core_assert(_waterData.indexBuffer > 0);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _waterData.indexBuffer);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, 2 * sizeof(glm::ivec2), indices, GL_STATIC_DRAW);

	const int posLoc = _waterShader->enableVertexAttribute("a_pos");
	glVertexAttribPointer(posLoc, 3, GL_FLOAT, GL_FALSE, sizeof(voxel::VoxelVertexDecoded),
			GL_OFFSET(offsetof(voxel::VoxelVertexDecoded, position)));

	glBindVertexArray(0);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
	glBindBuffer(GL_ARRAY_BUFFER, 0);

	_waterData.noOfIndices = 2;
	_waterData.scale = 1.0f;
	_waterData.indexType = GL_UNSIGNED_INT;

	GL_checkError();

	_camera.init(_width, _height);

	registerMoveCmd("+move_right", MOVERIGHT);
	registerMoveCmd("+move_left", MOVELEFT);
	registerMoveCmd("+move_forward", MOVEFORWARD);
	registerMoveCmd("+move_backward", MOVEBACKWARD);

	const int ColorTextureSize = 256;
	uint8_t colorTexture[ColorTextureSize * ColorTextureSize * 3];
	noise::Simplex::SeamlessNoise2DRGB(colorTexture, ColorTextureSize, 3, 0.3f, 0.7f);
	_colorTexture = video::TexturePtr(new video::Texture(colorTexture, ColorTextureSize, ColorTextureSize, 3));

	_clearColor = glm::vec3(0.0, 0.6, 0.796);

	_root.SetSkinBg(TBIDC("background"));
	new frontend::LoginWindow(this);

	SDL_GL_SetSwapInterval(core::Var::get(cfg::ClientVSync, "false")->boolVal());

	return state;
}
ListViewItemWidget::ListViewItemWidget(ListViewItem *item, ListViewItemSource *source,
                                       TBSelectItemViewer *sourceviewer, int index)
    : source_(source)
    , sourceviewer_(sourceviewer)
    , index_(index)
    , item_(item)
    , expandBox_(0)
    , textField_(0)
    , icon_(0)
{
    SetLayoutDistribution(LAYOUT_DISTRIBUTION_GRAVITY);
    SetLayoutDistributionPosition(LAYOUT_DISTRIBUTION_POSITION_LEFT_TOP);
    SetPaintOverflowFadeout(false);

    item_->widget_ = this;

    for (int i = 0; i < item->depth_; i++)
    {
        LayoutParams lp;
        lp.SetWidth(6);
        lp.SetHeight(4);
        TBWidget* spacer = new TBWidget();
        spacer->SetLayoutParams(lp);
        GetContentRoot()->AddChild(spacer);
    }

    if (item_->children_.Size())
    {
        expandBox_ = new TBCheckBox();
        expandBox_->SetSkinBg(TBIDC("TBCheckBox.uilistview"));
        expandBox_->SetValue(item_->GetExpanded());
        expandBox_->SetID(item->id);
        GetContentRoot()->AddChild(expandBox_);
    }
    else
    {
        LayoutParams lp;
        lp.SetWidth(12);
        lp.SetHeight(4);
        TBWidget* spacer = new TBWidget();
        spacer->SetLayoutParams(lp);
        GetContentRoot()->AddChild(spacer);
    }

    if (item->icon_.Length())
    {
        icon_ = new TBSkinImage(TBIDC(item->icon_.CString()));
        icon_->SetIgnoreInput(true);
        GetContentRoot()->AddChild(icon_);
    }

    TBFontDescription fd;
    fd.SetID(TBIDC("Vera"));
    fd.SetSize(11);

    TBTextField* tfield = textField_ = new TBTextField();
    tfield->SetIgnoreInput(true);

    tfield->SetSkinBg(item->textSkin_.Length() ? TBIDC(item->textSkin_.CString()) : TBIDC("Folder"));
    tfield->SetText(item->str);
    tfield->SetFontDescription(fd);

    SetSkinBg(TBIDC("TBSelectItem"));
    GetContentRoot()->AddChild(tfield);

    SetID(item->id);
}
 void UpdateIcon(const String& icon)
 {
     if (icon_)
         icon_->SetSkinBg(TBIDC(icon.CString()));
 }
示例#7
0
bool AnimationsWindow::OnEvent(const TBWidgetEvent &ev)
{
	if (ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("Animate!"))
		Animate();
	return DemoWindow::OnEvent(ev);
}
示例#8
0
bool MainWindow::OnEvent(const TBWidgetEvent &ev)
{
	if (ev.type == EVENT_TYPE_CLICK)
	{
		if (ev.target->GetID() == TBIDC("new"))
		{
			new MainWindow(GetParentRoot());
			return true;
		}
		if (ev.target->GetID() == TBIDC("msg"))
		{
			PostMessage(TBIDC("instantmsg"), nullptr);
			return true;
		}
		else if (ev.target->GetID() == TBIDC("busymsg"))
		{
			if (ev.target->GetValue() == 1)
			{
				// Post the first "busy" message when we check the checkbox.
				assert(!GetMessageByID(TBIDC("busy")));
				if (!GetMessageByID(TBIDC("busy")))
				{
					PostMessage(TBIDC("busy"), nullptr);
					TBMessageWindow *msg_win = new TBMessageWindow(this, TBIDC("test_dialog"));
					msg_win->Show("Message window", "The message loop is now constantly busy with messages to process.\n\n"
								"The main thread should be working hard, but input & animations should still be running smoothly.");
				}
			}
			else
			{
				// Remove any pending "busy" message when we uncheck the checkbox.
				assert(GetMessageByID(TBIDC("busy")));
				if (TBMessage *busymsg = GetMessageByID(TBIDC("busy")))
					DeleteMessage(busymsg);
			}
			return true;
		}
		else if (ev.target->GetID() == TBIDC("delayedmsg"))
		{
			PostMessageDelayed(TBIDC("delayedmsg"), nullptr, 2000);
			return true;
		}
		else if (ev.target->GetID() == TBIDC("TBWindow.close"))
		{
			// Intercept the TBWindow.close message and stop it from bubbling
			// to TBWindow (prevent the window from closing)
			TBMessageWindow *msg_win = new TBMessageWindow(this, TBIDC("confirm_close_dialog"));
			TBMessageWindowSettings settings(TB_MSG_YES_NO, TBIDC("Icon48"));
			settings.dimmer = true;
			settings.styling = true;
			msg_win->Show("Are you sure?", "Really <color #0794f8>close</color> the window?", &settings);
			return true;
		}
		else if (ev.target->GetID() == TBIDC("confirm_close_dialog"))
		{
			if (ev.ref_id == TBIDC("TBMessageWindow.yes"))
				Close();
			return true;
		}
		else if (ev.target->GetID() == TBIDC("reload skin bitmaps"))
		{
			int reload_count = 10;
			double t1 = TBSystem::GetTimeMS();
			for (int i = 0; i < reload_count; i++)
				g_tb_skin->ReloadBitmaps();
			double t2 = TBSystem::GetTimeMS();

			TBStr message;
			message.SetFormatted("Reloading the skin graphics %d times took %dms", reload_count, (int)(t2 - t1));
			TBMessageWindow *msg_win = new TBMessageWindow(ev.target, TBID());
			msg_win->Show("GFX load performance", message);
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test context lost"))
		{
			g_renderer->InvokeContextLost();
			g_renderer->InvokeContextRestored();
			TBMessageWindow *msg_win = new TBMessageWindow(ev.target, TBID());
			msg_win->Show("Context lost & restore",
							"Called InvokeContextLost and InvokeContextRestored.\n\n"
							"Does everything look fine?");
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test-layout"))
		{
			TBStr resource_file("demo01/ui_resources/");
			resource_file.Append(ev.target->data.GetString());
			new LayoutWindow(GetParentRoot(), resource_file);
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test-connections"))
		{
			new ConnectionWindow(GetParentRoot());
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test-list"))
		{
			new AdvancedListWindow(GetParentRoot(), &advanced_source);
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test-image"))
		{
			new ImageWindow(GetParentRoot());
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test-page"))
		{
			new PageWindow(GetParentRoot());
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test-animations"))
		{
			new AnimationsWindow(GetParentRoot());
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test-scroll-container"))
		{
			new ScrollContainerWindow(GetParentRoot());
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test-skin-conditions"))
		{
			(new DemoWindow(GetParentRoot()))->LoadResourceFile("demo01/ui_resources/test_skin_conditions01.tb.txt");
			(new DemoWindow(GetParentRoot()))->LoadResourceFile("demo01/ui_resources/test_skin_conditions02.tb.txt");
			return true;
		}
		else if (ev.target->GetID() == TBIDC("test-resource-edit"))
		{
			ResourceEditWindow *res_edit_win = new ResourceEditWindow();
			res_edit_win->Load("demo01/ui_resources/resource_edit_test.tb.txt");
			GetParent()->AddChild(res_edit_win);
			return true;
		}
		else if (ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("debug settings"))
		{
#ifdef TB_RUNTIME_DEBUG_INFO
			ShowDebugInfoSettingsWindow(GetParentRoot());
#else
			TBMessageWindow *msg_win = new TBMessageWindow(ev.target, TBID());
			msg_win->Show("Debug settings",
							"Debug settings is only available in builds "
							"compiled with TB_RUNTIME_DEBUG_INFO defined.\n\n"
							"Debug builds enable this by default.");
#endif
			return true;
		}
	}
	return DemoWindow::OnEvent(ev);
}
示例#9
0
bool ScrollContainerWindow::OnEvent(const TBWidgetEvent &ev)
{
	if (ev.type == EVENT_TYPE_CLICK)
	{
		if (ev.target->GetID() == TBIDC("add img"))
		{
			TBButton *button = TBSafeCast<TBButton>(ev.target);
			TBSkinImage *skin_image = new TBSkinImage;
			skin_image->SetSkinBg(TBIDC("Icon16"));
			button->GetContentRoot()->AddChild(skin_image, WIDGET_Z_BOTTOM);
			return true;
		}
		else if (ev.target->GetID() == TBIDC("new buttons"))
		{
			for(int i = 0; i < ev.target->data.GetInt(); i++)
			{
				TBStr str;
				str.SetFormatted("Remove %d", i);
				TBButton *button = new TBButton;
				button->SetID(TBIDC("remove button"));
				button->SetText(str);
				ev.target->GetParent()->AddChild(button);
			}
			return true;
		}
		else if (ev.target->GetID() == TBIDC("new buttons delayed"))
		{
			for(int i = 0; i < ev.target->data.GetInt(); i++)
			{
				TBMessageData *data = new TBMessageData();
				data->id1 = ev.target->GetParent()->GetID();
				data->v1.SetInt(i);
				PostMessageDelayed(TBIDC("new button"), data, 100 + i * 500);
			}
			return true;
		}
		else if (ev.target->GetID() == TBIDC("remove button"))
		{
			ev.target->GetParent()->RemoveChild(ev.target);
			delete ev.target;
			return true;
		}
		else if (ev.target->GetID() == TBIDC("showpopupmenu1"))
		{
			if (TBMenuWindow *menu = new TBMenuWindow(ev.target, TBIDC("popupmenu1")))
				menu->Show(&popup_menu_source, TBPopupAlignment());
			return true;
		}
		else if (ev.target->GetID() == TBIDC("popupmenu1"))
		{
			TBStr str;
			str.SetFormatted("Menu event received!\nref_id: %d", (int)ev.ref_id);
			TBMessageWindow *msg_win = new TBMessageWindow(this, TBIDC("popup_dialog"));
			msg_win->Show("Info", str);
			return true;
		}
	}
	return DemoWindow::OnEvent(ev);
}
示例#10
0
bool EditWindow::OnEvent(const TBWidgetEvent &ev)
{
    if (ev.type == EVENT_TYPE_CLICK)
    {
        TBEditField *edit = GetWidgetByIDAndType<TBEditField>(TBIDC("editfield"));
        if (!edit)
            return false;

        if (ev.target->GetID() == TBIDC("clear"))
        {
            edit->SetText("");
            return true;
        }
        else if (ev.target->GetID() == TBIDC("undo"))
        {
            edit->GetStyleEdit()->Undo();
            return true;
        }
        else if (ev.target->GetID() == TBIDC("redo"))
        {
            edit->GetStyleEdit()->Redo();
            return true;
        }
        else if (ev.target->GetID() == TBIDC("menu"))
        {
            static TBGenericStringItemSource source;
            if (!source.GetNumItems())
            {
                source.AddItem(new TBGenericStringItem("Default font", TBIDC("default font")));
                source.AddItem(new TBGenericStringItem("Default font (larger)", TBIDC("large font")));
                source.AddItem(new TBGenericStringItem("RGB font (Neon)", TBIDC("rgb font Neon")));
                source.AddItem(new TBGenericStringItem("RGB font (Orangutang)", TBIDC("rgb font Orangutang")));
                source.AddItem(new TBGenericStringItem("RGB font (Orange)", TBIDC("rgb font Orange")));
                source.AddItem(new TBGenericStringItem("-"));
                source.AddItem(new TBGenericStringItem("Glyph cache stresstest (CJK)", TBIDC("CJK")));
                source.AddItem(new TBGenericStringItem("-"));
                source.AddItem(new TBGenericStringItem("Toggle wrapping", TBIDC("toggle wrapping")));
                source.AddItem(new TBGenericStringItem("-"));
                source.AddItem(new TBGenericStringItem("Align left", TBIDC("align left")));
                source.AddItem(new TBGenericStringItem("Align center", TBIDC("align center")));
                source.AddItem(new TBGenericStringItem("Align right", TBIDC("align right")));
            }

            if (TBMenuWindow *menu = new TBMenuWindow(ev.target, TBIDC("popup_menu")))
                menu->Show(&source, TBPopupAlignment());
            return true;
        }
        else if (ev.target->GetID() == TBIDC("popup_menu"))
        {
            if (ev.ref_id == TBIDC("default font"))
                edit->SetFontDescription(TBFontDescription());
            else if (ev.ref_id == TBIDC("large font"))
            {
                TBFontDescription fd = g_font_manager->GetDefaultFontDescription();
                fd.SetSize(28);
                edit->SetFontDescription(fd);
            }
            else if (ev.ref_id == TBIDC("rgb font Neon"))
            {
                TBFontDescription fd = edit->GetCalculatedFontDescription();
                fd.SetID(TBIDC("Neon"));
                edit->SetFontDescription(fd);
            }
            else if (ev.ref_id == TBIDC("rgb font Orangutang"))
            {
                TBFontDescription fd = edit->GetCalculatedFontDescription();
                fd.SetID(TBIDC("Orangutang"));
                edit->SetFontDescription(fd);
            }
            else if (ev.ref_id == TBIDC("rgb font Orange"))
            {
                TBFontDescription fd = edit->GetCalculatedFontDescription();
                fd.SetID(TBIDC("Orange"));
                edit->SetFontDescription(fd);
            }
            else if (ev.ref_id == TBIDC("CJK"))
            {
                TBTempBuffer buf;
                for (int i = 0, cp = 0x4E00; cp <= 0x9FCC; cp++, i++)
                {
                    char utf8[8];
                    int len = utf8::encode(cp, utf8);
                    buf.Append(utf8, len);
                    if (i % 64 == 63)
                        buf.Append("\n", 1);
                }
                edit->GetStyleEdit()->SetText(buf.GetData(), buf.GetAppendPos());
            }
            else if (ev.ref_id == TBIDC("toggle wrapping"))
                edit->SetWrapping(!edit->GetWrapping());
            else if (ev.ref_id == TBIDC("align left"))
                edit->SetTextAlign(TB_TEXT_ALIGN_LEFT);
            else if (ev.ref_id == TBIDC("align center"))
                edit->SetTextAlign(TB_TEXT_ALIGN_CENTER);
            else if (ev.ref_id == TBIDC("align right"))
                edit->SetTextAlign(TB_TEXT_ALIGN_RIGHT);
            return true;
        }
    }
    return DemoWindow::OnEvent(ev);
}
示例#11
0
void ResourceEditWindow::OnMessageReceived(TBMessage *msg)
{
	if (msg->message == TBIDC("update_widget_list"))
		UpdateWidgetList(true);
}
示例#12
0
void TBScroller::OnMessageReceived(TBMessage *msg)
{
	if (msg->message == TBIDC("scroll"))
	{
		int actual_scroll_x = 0, actual_scroll_y = 0;
		GetTargetChildTranslation(actual_scroll_x, actual_scroll_y);
		if (actual_scroll_x != m_expected_scroll_x ||
			actual_scroll_y != m_expected_scroll_y)
		{
			// Something else has affected the target child translation.
			// This should abort the scroll.
			// This could happen f.ex if something shrunk the scroll limits,
			// some other action changed scroll position, or if another
			// scroller started operating on a sub child that when reacing
			// its scroll limit, started scrolling its chain of parents.
			Stop();
			return;
		}

		// Calculate the time elapsed from scroll start. Clip within the
		// duration for each axis.
		double now_ms = TBSystem::GetTimeMS();
		float elapsed_time_x = (float)(now_ms - m_scroll_start_ms);
		float elapsed_time_y = elapsed_time_x;
		elapsed_time_x = MIN(elapsed_time_x, m_scroll_duration_x_ms);
		elapsed_time_y = MIN(elapsed_time_y, m_scroll_duration_y_ms);

		// Get the new scroll position from the current distance in each axis.
		int scroll_x = m_func.GetDistanceAtTimeInt(m_scroll_start_speed_ppms_x, elapsed_time_x);
		int scroll_y = m_func.GetDistanceAtTimeInt(m_scroll_start_speed_ppms_y, elapsed_time_y);
		scroll_x += m_scroll_start_scroll_x;
		scroll_y += m_scroll_start_scroll_y;

		// Get the scroll delta and invoke ScrollByRecursive.
		int curr_scroll_x, curr_scroll_y;
		GetTargetScrollXY(curr_scroll_x, curr_scroll_y);
		const int dx = scroll_x - curr_scroll_x;
		const int dy = scroll_y - curr_scroll_y;

		int idx = dx, idy = dy;
		m_target->ScrollByRecursive(idx, idy);

		// Update expected translation
		GetTargetChildTranslation(m_expected_scroll_x, m_expected_scroll_y);

		if ((dx && actual_scroll_x == m_expected_scroll_x) &&
			(dy && actual_scroll_y == m_expected_scroll_y))
		{
			// We didn't get anywhere despite we tried,
			// so we're done (reached the end).
			Stop();
			return;
		}

		if (!StopIfAlmostStill())
		{
			double next_fire_time = msg->GetFireTime() + PAN_MSG_DELAY_MS;
			// avoid timer catch-up if program went sleeping for a while.
			next_fire_time = MAX(next_fire_time, now_ms);
			PostMessageOnTime(TBIDC("scroll"), nullptr, next_fire_time);
		}
	}
}
示例#13
0
bool TBScroller::IsScrolling()
{
	return GetMessageByID(TBIDC("scroll")) ? true : false;
}