コード例 #1
0
bool Slider::OnMouseButtonEvent(bool bPressed, int iMouseButton, unsigned int x, unsigned int y)
{
   if (bPressed && IsInsideSliderArea(Point(x, y)))
   {
      // set focus to ourselves
      GetWindowManager().SetFocus(shared_from_this());
      m_bFocused = true;

      // start sliding
      m_bMouseButtonDown = true;

      // calc drag x offset
      Rect rect = Window::GetRect();
      unsigned int uiMid = DividerPoint();

      m_iDragOffset = x - int(rect.Left() + uiMid);

      // start mouse motion tracking until mouse button is up
      GetWindowManager().TrackMouseUp(shared_from_this(), iMouseButton);
   }
   else
      m_bMouseButtonDown = false;

   return true;
}
コード例 #2
0
AutoPtr<IView> PlatLogoActivity::MakeView()
{
    AutoPtr<IDisplayMetrics> metrics;
    CDisplayMetrics::New((IDisplayMetrics**)&metrics);
    AutoPtr<IDisplay> display;
    GetWindowManager()->GetDefaultDisplay((IDisplay**)&display);
    display->GetMetrics(metrics);

    AutoPtr<ILinearLayout> view;
    CLinearLayout::New(this, (ILinearLayout**)&view);
    view->SetOrientation(ILinearLayout::VERTICAL);
    AutoPtr<IViewGroupLayoutParams> params;
    CViewGroupLayoutParams::New(
                IViewGroupLayoutParams::WRAP_CONTENT,
                IViewGroupLayoutParams::WRAP_CONTENT,
                (IViewGroupLayoutParams**)&params);
    view->SetLayoutParams(params);
    Float density;
    metrics->GetDensity(&density);
    Int32 p = (Int32)(8 * density);
    view->SetPadding(p, p, p, p);

    AutoPtr<ITypefaceHelper> tfHelper;
    CTypefaceHelper::AcquireSingleton((ITypefaceHelper**)&tfHelper);
    AutoPtr<ITypeface> light;
    tfHelper->Create(String("sans-serif-light"), ITypeface::NORMAL, (ITypeface**)&light);
    AutoPtr<ITypeface> normal;
    tfHelper->Create(String("sans-serif"), ITypeface::BOLD, (ITypeface**)&normal);

    Float size = 14 * density;
    AutoPtr<ILinearLayoutLayoutParams> lp;
    CLinearLayoutLayoutParams::New(
            ILinearLayoutLayoutParams::WRAP_CONTENT,
            ILinearLayoutLayoutParams::WRAP_CONTENT,
            (ILinearLayoutLayoutParams**)&lp);
    lp->SetGravity(IGravity::CENTER_HORIZONTAL);
    lp->SetBottomMargin((Int32) (-4*density));

    AutoPtr<ITextView> tv;
    CTextView::New(this, (ITextView**)&tv);
    if (light != NULL) tv->SetTypeface(light);
    tv->SetTextSize(1.25f*size);
    tv->SetTextColor(0xFFFFFFFF);
    tv->SetShadowLayer(4*density, 0, 2*density, 0x66000000);
//    tv->SetText(String("Android ") + Build::VERSION::RELEASE);
    view->AddView(tv, lp);

    tv = NULL;
    CTextView::New(this, (ITextView**)&tv);
    if (normal != NULL) tv->SetTypeface(normal);
    tv->SetTextSize(size);
    tv->SetTextColor(0xFFFFFFFF);
    tv->SetShadowLayer(4*density, 0, 2*density, 0x66000000);
    AutoPtr<ICharSequence> txt;
    CStringWrapper::New(String("JELLY BEAN"), (ICharSequence**)&txt);
    tv->SetText(txt);
    view->AddView(tv, lp);

    return view;
}
コード例 #3
0
ECode PlatLogoActivity::OnCreate(
    /* [in] */ IBundle* savedInstanceState)
{
    Activity::OnCreate(savedInstanceState);

//     mToast = Toast.makeText(this, "", Toast.LENGTH_LONG);
    mToast->SetView(MakeView());

    AutoPtr<IDisplayMetrics> metrics;
    CDisplayMetrics::New((IDisplayMetrics**)&metrics);
    AutoPtr<IDisplay> display;
    GetWindowManager()->GetDefaultDisplay((IDisplay**)&display);
    display->GetMetrics(metrics);

    CImageView::New(this, (IImageView**)&mContent);
    mContent->SetImageResource(0/*com.android.internal.R.drawable.platlogo_alt*/);
    mContent->SetScaleType(Elastos::Droid::Widget::ImageViewScaleType_CENTER_INSIDE);

    Float density;
    metrics->GetDensity(&density);
    Int32 p = (Int32)(32 * density);
    mContent->SetPadding(p, p, p, p);

    mContent->SetOnClickListener((IViewOnClickListener*)new LocalViewOnClickListener(this));

    mContent->SetOnLongClickListener((IViewOnLongClickListener*)new LocalViewOnLongClickListener(this));

    SetContentView(mContent);
    return NOERROR;
}
コード例 #4
0
bool EditField::OnMouseButtonEvent(bool bPressed, int iMouseButton, unsigned int /*x*/, unsigned int /*y*/)
{
   if (bPressed && iMouseButton == buttonLeft)
   {
      // set focus to ourselves
      GetWindowManager().SetFocus(shared_from_this());
      m_bFocused = true;
   }
   return true;
}
コード例 #5
0
void GameClient::Start()
{
   Init(800, 600, false);

   // enable audio events
   m_uiAudioManager.Connect(GetWindowManager(), m_fileSystem);

   //std::shared_ptr<MainGameScene> spMainGameScene(new MainGameScene(*this, *this, m_game));
   //ChangeScene(spMainGameScene);

   Run();
}
コード例 #6
0
bool EditField::OnKeyboardEvent(bool bKeyDown, unsigned int sym, unsigned int mod)
{
   if (!bKeyDown)
      return true;

   switch (sym)
   {
   case SDLK_LEFT:
      if (m_uiCaretPos > 0)
         m_uiCaretPos--;
      UpdateCaretPos();
      break;

   case SDLK_RIGHT:
      if (m_uiCaretPos < static_cast<unsigned int>(m_cszText.GetLength()))
         m_uiCaretPos++;
      UpdateCaretPos();
      break;

   case SDLK_HOME:
      m_uiCaretPos = 0;
      UpdateCaretPos();
      break;

   case SDLK_END:
      m_uiCaretPos = m_cszText.GetLength();
      UpdateCaretPos();
      break;

   case SDLK_DELETE:
      if (m_uiCaretPos < static_cast<unsigned int>(m_cszText.GetLength()))
      {
         m_cszText.Delete(m_uiCaretPos);
         UpdateTexture();
      }
      break;

   case SDLK_BACKSPACE:
      if (m_uiCaretPos > 0)
      {
         m_cszText.Delete(--m_uiCaretPos);
         UpdateTexture();
      }
      break;

   case SDLK_ESCAPE:
      GetWindowManager().SetFocus();
      m_bFocused = false;
      break;

   default:
      if (IsAllowedChar(sym, mod))
      {
         unsigned int ch = sym;
         if (sym >= SDLK_a && sym <= SDLK_z && (mod & KMOD_SHIFT) != 0)
            ch -= 32; // make uppercase

         m_cszText.Insert(m_uiCaretPos++, static_cast<TCHAR>(ch));
         UpdateTexture();
      }
      break;
   }

   // update text attribute
   SetAttr(EditFieldAttr::Text, m_cszText, true);

   return true;
}
コード例 #7
0
ファイル: App.cpp プロジェクト: axlib/axlib
void ax::App::AddTopLevel(std::shared_ptr<ax::Window> win)
{
	GetWindowManager()->GetWindowTree()->AddTopLevel(win);

	ax::core::WindowManager* wm = GetWindowManager();

	// Connect all child to parent window manager.
	ax::NodeVisitor::VisitFromNode(win.get(), [wm](ax::Window* window) {
		if (window->GetWindowManager() == nullptr) {
			window->SetWindowManager(wm);
			window->event.OnAssignToWindowManager(0);
		}
	});

	win->dimension.GetFrameBuffer()->AssignCustomFBDrawFunction([win](ax::GL::FrameBuffer& fb) {

		ax::Size global_size = ax::App::GetInstance().GetFrameSize();

#ifdef AX_EOS_CORE
		ax::App& app(ax::App::GetInstance());
		ax::CoreEOS* core = static_cast<ax::CoreEOS*>(app.GetCore());
		//		core->DrawOnMainFBO();
		glViewport(0, 0, global_size.x, global_size.y);

		// Bind main frame buffer.
		glBindFramebuffer(GL_FRAMEBUFFER, core->GetMainFrameBufferID());
#endif

		glBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR);
		ax::GC::shader_fb.Activate();
		glEnable(GL_TEXTURE_2D);

		ax::FPoint pos(0.0, 0.0);

		const ax::Size& ss(win->dimension.GetShownRect().size);
		const ax::FSize size(ss.Cast<float>());

		// Bind framebuffer texture.
		glBindTexture(GL_TEXTURE_2D, win->dimension.GetFrameBuffer()->GetFrameBufferTexture());

		float vertices[8]
			= { pos.x, pos.y, pos.x, pos.y + size.h, pos.x + size.w, pos.y + size.h, pos.x + size.w, pos.y };

		float tex_coords[8] = { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0 };

		ax::Point win_abs_pos = win->dimension.GetAbsoluteRect().position;

		// Projection matrix.
		glm::mat4 projMat = glm::ortho((float)0.0, (float)global_size.w, (float)global_size.h, (float)0.0);

		// View matrix.
		glm::mat4 view = glm::translate(glm::mat4(1.0f), glm::vec3(win_abs_pos.x, win_abs_pos.y, 0.0f));

		glm::mat4 model(1.0f);

		glm::mat4 model_view_proj = projMat * view * model;

		GLuint prog_id = ax::GC::shader_fb.GetProgramId();
		GLuint MatrixID = glGetUniformLocation(prog_id, "mvp_matrix");
		glUniformMatrix4fv(MatrixID, 1, GL_FALSE, (float*)&model_view_proj[0][0]);

		// Vertex coordinate.
		glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, vertices);
		glEnableVertexAttribArray(0);

		// Texture coordinate.
		glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, tex_coords);
		glEnableVertexAttribArray(1);

		glDrawArrays(GL_TRIANGLE_FAN, 0, 4);

		glDisableVertexAttribArray(0);
		glDisableVertexAttribArray(1);
		// glDisableVertexAttribArray(5);

		glDisable(GL_TEXTURE_2D);

	});

	//	return win;
}
コード例 #8
0
ファイル: App.cpp プロジェクト: axlib/axlib
std::shared_ptr<ax::Window> ax::App::GetTopLevel()
{
	return GetWindowManager()->GetWindowTree()->GetTopLevel();
}
コード例 #9
0
ファイル: Log.cpp プロジェクト: CSRedRat/desura-app
void RegLogWithWindow()
{
	GetWindowManager().registerWindow(logForm);
}
コード例 #10
0
ファイル: Log.cpp プロジェクト: Alasaad/Desurium
void RegLogWithWindow()
{
	if (GetWindowManager())
			GetWindowManager()->registerWindow(logForm);
}