コード例 #1
0
ファイル: helpwindow.cpp プロジェクト: ChakaZulu/tuxbox_apps
int eHelpWindow::eventHandler(const eWidgetEvent &event)
{
	switch (event.type)
	{
	case eWidgetEvent::evtAction:
		if (event.action == &i_helpwindowActions->up)
		{
			if (doscroll && entryBeg[cur] != entryBeg[0] ) // valid it
			{
				--curPage;
				scrollbox->move(ePoint(0, -entryBeg[--cur]));
				updateScrollbar();
			}
		}
		else if (event.action == &i_helpwindowActions->down)
		{
			if (doscroll && entryBeg[cur] != entryBeg[lastEntry] ) // valid it
			{
				++curPage;
				scrollbox->move(ePoint(0, -entryBeg[++cur]));
				updateScrollbar();
			}
		}
		else if (event.action == &i_helpwindowActions->close)
			close(0);
		else
			break;
		return 1;
	default:
		break;
	}
	return eWindow::eventHandler(event);
}
コード例 #2
0
ファイル: TextArea.cpp プロジェクト: Hiroyuki-Nagata/mona
	/**
	 キャレット移動
	 @param text
	 */
	void TextArea::moveCaret(int x, int y)
	{
 		SetPos( XY2P(x, y) );
 		OffsetChange();
		updateScrollbar();
		repaint();
	}
コード例 #3
0
void MusicListView::onMusicListAdded(const MetaPtrList metalist)
{
    Q_D(MusicListView);
    for (auto meta : metalist) {
        d->addMedia(meta);
    }
    updateScrollbar();
}
コード例 #4
0
ファイル: Tab.cpp プロジェクト: CRasterImage/Lamp
void Tab::setScrollPos(float pos, bool snap)
{
   m_goto_scroll_offset = math<float>::min(0, math<float>::max(-(m_crest_rect.y2 - m_window_size.y), pos));
   if(snap || !g_lamp_settings.getSmoothScroll())
   {
      m_scroll_offset = m_goto_scroll_offset;
      updateScrollbar();
   }
}
コード例 #5
0
ファイル: TextArea.cpp プロジェクト: Hiroyuki-Nagata/mona
	/**
	 大きさを設定する
	 @param x x座標
	 @param y y座標
	 @param width 幅
	 @param height 高さ
	*/
	void TextArea::setBounds(int x, int y, int width, int height)
	{
//		TextField::setBounds( x, y, getWidth(), getHeight() );
		TextField::setBounds( x, y, width, height );
		int draw_left = 4;
		int draw_top = 4;
		_max_line = (getHeight() - draw_top) / getFontMetrics()->getHeight(WIDTH_BASE) - 1;
		_max_col = (width - draw_left) / getFontMetrics()->getWidth(WIDTH_BASE) - 1;
		updateScrollbar(false, true);
	}
コード例 #6
0
ファイル: TextArea.cpp プロジェクト: Hiroyuki-Nagata/mona
	/** 1文字削除 */
	void TextArea::deleteCharacter()
	{
		int pos = XY2P(_ptr_x,_ptr_y);
		if( text[pos] == '\0' ) return;
		if( _ptr_x > _offset_x + _max_col - 1 ) _offset_x = _ptr_x - _max_col + 1;
		if( _ptr_y <= _offset_y ) _offset_y = (_ptr_y != 0) ? _ptr_y - 1 : _ptr_y;
		if( _ptr_x <= _offset_x ) _offset_x = (_ptr_x != 0) ? _ptr_x - 1 : _ptr_x;
		while( (text[pos] = text[pos+1]) != '\0' ) pos++;
		_text_len -= 1;
		updateScrollbar(true);
	}
コード例 #7
0
ファイル: TextArea.cpp プロジェクト: Hiroyuki-Nagata/mona
	/**
	 テキスト設定
	 @param text
	 */
	void TextArea::setText(const char* text)
	{
		if( (int)strlen(text) >= _buffer_size ) return;
		memset(this->text, 0, sizeof(this->text));
		strcpy(this->text, text);
		_text_len = strlen(text);
		SetPos(-1);
		OffsetChange();
		updateScrollbar(true);
		
		//if( firstpaint == true ) repaint();
	}
コード例 #8
0
ファイル: TextArea.cpp プロジェクト: Hiroyuki-Nagata/mona
	/** 1文字挿入 */
	void TextArea::insertCharacter(char c)
	{
		if( _text_len >= _buffer_size ) return;
		int pos = XY2P(_ptr_x,_ptr_y);
		for(int i=_text_len; i>=pos; i--)
			text[i+1] = text[i];
		text[pos] = c;
		_text_len++;
		SetPos(pos+1);
		OffsetChange();
		updateScrollbar(true);
	}
コード例 #9
0
ファイル: Tab.cpp プロジェクト: CRasterImage/Lamp
void Tab::updateShape(const ivec2& window_size)
{
   int border_size = getBorderSize();
   int scrollbar_width = g_lamp_settings.getScrollbarWidth();
   m_window_size = window_size;

   Rectf scrollbar_rect((float)m_window_size.x - scrollbar_width, 0, (float)m_window_size.x, (float)m_window_size.y);
   m_scrollbar->AsScrollbar()->setShape(scrollbar_rect);
      
   Rectf post_rect(0, 0, (float)m_window_size.x, (float)m_window_size.y);
   post_rect.x1 += border_size;
   post_rect.y1 += border_size;
   post_rect.x2 -= std::max(border_size, scrollbar_width);
      
   for(std::list<PostRef>::iterator it = m_threads.begin();
       it != m_threads.end();
       it++)
   {
      float thread_height = 0;
      (*it)->updateShape(post_rect, thread_height);
      post_rect.offset(vec2(0, thread_height + border_size));
   }

   gl::Texture2dRef crest_image = g_skin.getImage(image_type::SHACK_CREST);
   if(crest_image)
   {
      m_crest_rect.y1 = post_rect.y1;
      
      float tab_width = m_window_size.x - (float)scrollbar_width;

      float mid_width = tab_width / 2.0f;
      float image_width = (float)crest_image->getWidth();
      float image_height = (float)crest_image->getHeight();
      if(image_width > tab_width)
      {
         float scale = tab_width / image_width;
         image_width *= scale;
         image_height *= scale;
      }
      m_crest_rect.x1 = mid_width - (image_width / 2.0f);
      m_crest_rect.x2 = m_crest_rect.x1 + image_width;
      m_crest_rect.y2 = m_crest_rect.y1 + image_height;
   }

   updateScrollbar();
}
コード例 #10
0
ファイル: Tab.cpp プロジェクト: CRasterImage/Lamp
void Tab::offsetScroll(float offset, bool snap, bool relative_to_goto)
{
   if(relative_to_goto)
   {
      m_goto_scroll_offset = math<float>::min(0, math<float>::max(-(m_crest_rect.y2 - m_window_size.y), (m_goto_scroll_offset + offset)));
   }
   else
   {
      m_goto_scroll_offset = math<float>::min(0, math<float>::max(-(m_crest_rect.y2 - m_window_size.y), (m_scroll_offset + offset)));
   }

   if(snap || !g_lamp_settings.getSmoothScroll())
   {
      m_scroll_offset = m_goto_scroll_offset;
      updateScrollbar();
   }
}
コード例 #11
0
void MusicListView::onMusiclistChanged(PlaylistPtr playlist)
{
    Q_D(MusicListView);

    if (playlist.isNull()) {
        qWarning() << "can not change to emptry playlist";
        return;
    }

    d->model->removeRows(0, d->model->rowCount());
    for (auto meta : playlist->allmusic()) {
//        qDebug() << meta->hash << meta->title;
        d->addMedia(meta);
    }

    d->model->setPlaylist(playlist);
    updateScrollbar();
}
コード例 #12
0
void MusicListView::onMusicListRemoved(const MetaPtrList metalist)
{
    Q_D(MusicListView);

    setAutoScroll(false);
    for (auto meta : metalist) {
        if (meta.isNull()) {
            continue;
        }

        for (int i = 0; i < d->model->rowCount(); ++i) {
            auto index = d->model->index(i, 0);
            auto itemHash = d->model->data(index).toString();
            if (itemHash == meta->hash) {
                d->model->removeRow(i);
            }
        }
    }
    updateScrollbar();
    setAutoScroll(true);
}
コード例 #13
0
ファイル: TextArea.cpp プロジェクト: Hiroyuki-Nagata/mona
	/** イベント処理 */
	void TextArea::processEvent(Event* event)
	{
		// 非活性の時はイベントを受け付けない
		if (getEnabled() == false) return;

		// キー押下
		if (event->getType() == KeyEvent::KEY_PRESSED) {
			int keycode = ((KeyEvent *)event)->getKeycode();
			if (keycode == KeyEvent::VKEY_BACKSPACE) {
				if (_ptr_x > 0 || _ptr_y > 0) {
					// バックスペース
					SetPos( XY2P(_ptr_x,_ptr_y) - 1 );
					OffsetChange();
					deleteCharacter();
					/*if (firstpaint == true)*/ repaint();
				}
			} else if (keycode == KeyEvent::VKEY_DELETE) {
				// 一文字削除
				if (text[XY2P(_ptr_x,_ptr_y)] != '\0' ) {
					deleteCharacter();
					/*if (firstpaint == true)*/ repaint();
				}
			} else if (keycode == KeyEvent::VKEY_INSERT) {
				// 上書き設定変更
				_overwrite = !_overwrite;
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode == KeyEvent::VKEY_LEFT) {
				// ←移動
				if( _ptr_x != 0 || _ptr_y != 0 ) {
					SetPos( XY2P(_ptr_x,_ptr_y) - 1 );
					OffsetChange();
					updateScrollbar();
					/*if (firstpaint == true)*/ repaint();
				}
			} else if (keycode == KeyEvent::VKEY_RIGHT) {
				// →移動
				if (text[XY2P(_ptr_x,_ptr_y)] != '\0' ) {
					SetPos( XY2P(_ptr_x,_ptr_y) + 1 );
					OffsetChange();
					updateScrollbar();
					/*if (firstpaint == true)*/ repaint();
				}
			} else if (keycode == KeyEvent::VKEY_UP) {
				// ↑移動
				if (_ptr_y > 0) {
					SetPos( XY2P(_ptr_x,_ptr_y-1) );
					OffsetChange();
					updateScrollbar();
					/*if (firstpaint == true)*/ repaint();
				}
			} else if (keycode == KeyEvent::VKEY_DOWN) {
				// ↓移動
				if (_ptr_y < LineCount()-1) {
					SetPos( XY2P(_ptr_x,_ptr_y+1) );
					OffsetChange();
					updateScrollbar();
					/*if (firstpaint == true)*/ repaint();
				}
			} else if (keycode == KeyEvent::VKEY_PGUP) {
				// 前ページ
				_ptr_y -= _max_line - 1;
				if( _ptr_y < 0 ) _ptr_y = 0;
				_offset_y -= _max_line - 1;
				if( _offset_y < 0 ) _offset_y = 0;
				SetPos( XY2P(_ptr_x,_ptr_y) );
				OffsetChange();
				updateScrollbar();
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode == KeyEvent::VKEY_PGDOWN) {
				// 次ページ
				_ptr_y += _max_line - 1;
				if( _ptr_y > LineCount() ) _ptr_y = LineCount();
				_offset_y += _max_line - 1;
				if( _offset_y > LineCount() - _max_line / 2 ) _offset_y = LineCount() - _max_line / 2;
				if( _offset_y < 0 ) _offset_y = 0;
				SetPos( XY2P(_ptr_x,_ptr_y) );
				OffsetChange();
				updateScrollbar();
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode == KeyEvent::VKEY_HOME) {
				// 行の先頭へ移動
				SetPos( Y2P(_ptr_y) );
				OffsetChange();
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode == KeyEvent::VKEY_END) {
				// 行の末尾へ移動
				SetPos( Y2P(_ptr_y+1) - 1 );
				OffsetChange();
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode == KeyEvent::VKEY_TAB) {
				// タブの挿入
				insertCharacter( '\t' );
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode == KeyEvent::VKEY_ENTER) {
				// 改行
				insertCharacter( '\n' );
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode < 128) {
				// 1文字挿入
				if (_overwrite && text[XY2P(_ptr_x,_ptr_y)] != '\n') deleteCharacter();
				insertCharacter(keycode);
				/*if (firstpaint == true)*/ repaint();
			}
		// マウスで押された
		} else if (event->getType() == MouseEvent::MOUSE_PRESSED) {
			int ry = ((MouseEvent*)event)->getY();
			int rx = ((MouseEvent*)event)->getX();
			int fh = getFontMetrics()->getHeight(WIDTH_BASE);
			int fw = getFontMetrics()->getWidth(WIDTH_BASE);
			
			int draw_left = 4 - (fw >> 1);
			int draw_top = 4;
			if( _draw_line ) {
				draw_left += 2 + _keta * fw;
			}
			draw_left -= _offset_x * fw;
			draw_top -= _offset_y * fh;

			SetPos( XY2P( ( rx - draw_left ) / fw, ( ry - draw_top ) / fh ) );
			OffsetChange();
			/*if (firstpaint == true)*/ repaint();
		// フォーカス状態変更
		} else if (event->getType() == Event::FOCUS_IN || event->getType() == Event::FOCUS_OUT) {
コード例 #14
0
int eEventDisplay::eventHandler(const eWidgetEvent &event)
{
	int addtype=-1;
	switch (event.type)
	{
		case eWidgetEvent::evtAction:
			if (event.action == &i_cursorActions->left)
			{
				if (events)
					prevEvent();
				else
					close(1); // this go the prev event and call exec()   (in epgwindow.cpp)
			}
			else if (event.action == &i_cursorActions->right)
			{
				if (events)
					nextEvent();
				else
					close(2);  // this go the next event and call exec()   (in epgwindow.cpp)
			}
			else if (total && event.action == &i_cursorActions->up)
			{
				ePoint curPos = long_description->getPosition();
				if ( curPos.y() < 0 )
				{
					long_description->move( ePoint( curPos.x(), curPos.y() + pageHeight ) );
					updateScrollbar();
				}
			}
			else if (total && event.action == &i_cursorActions->down)
			{
				ePoint curPos = long_description->getPosition();
				if ( (total - pageHeight ) >= abs( curPos.y() - pageHeight ) )
				{
					long_description->move( ePoint( curPos.x(), curPos.y() - pageHeight ) );
					updateScrollbar();
				}
			}
			else if (event.action == &i_enigmaEventViewActions->close)
				close(0);
			else if ( (addtype = i_epgSelectorActions->checkTimerActions( event.action )) != -1 )
				;
			else if ( event.action == &i_epgSelectorActions->removeTimerEvent)
			{
				if ((evt || events) && eTimerManager::getInstance()->removeEventFromTimerList( this, &ref, evt?evt:*events ) )
					timer_icon->hide();
			}
			else
				break;
			if ( valid >= 7 && addtype != -1 && (evt || events) && !eTimerManager::getInstance()->eventAlreadyInList(this, evt?*evt:*events, ref) )
			{
				hide();
				eTimerEditView v( evt?*evt:*events, addtype, ref );
				v.show();
				v.exec();
				v.hide();
				checkTimerIcon(evt?evt:*events);
				show();
			}
		return 1;
		default:
			break;
	}
	return eWindow::eventHandler(event);
}
コード例 #15
0
void eEventDisplay::setEvent(EITEvent *event)
{
	valid=0;
	// update evt.. when setEvent is called from outside..
	if ( evt )  
		evt = event;

	long_description->hide();
	long_description->move( ePoint(0,0) );
	if (event)
	{
		eString _title=0, _long_description="";
		eString _eventDate="";
		eString _eventTime="";

		if ( ref.path )
		{
			_eventDate.sprintf(_("Original duration: %d min"), event->duration/60 );
			eSize s = eventDate->getSize();
			eSize s2 = eventTime->getSize();
			s2.setHeight(0);
			s+=s2;
			eventDate->resize(s);
		}
		else
		{
			tm *begin=event->start_time!=-1?localtime(&event->start_time):0;
			if (begin)
			{
				valid |= 1;
				_eventTime.sprintf("%02d:%02d", begin->tm_hour, begin->tm_min);
				_eventDate=eString().sprintf("%02d.%02d.%4d", begin->tm_mday, begin->tm_mon+1, begin->tm_year+1900);
			}
			time_t endtime=event->start_time+event->duration;
			tm *end=event->start_time!=-1?localtime(&endtime):0;
			if (end)
			{
				valid |= 2;
				_eventTime+=eString().sprintf(" - %02d:%02d", end->tm_hour, end->tm_min);
			}
		}

		LocalEventData led;
		eString lang=0;
		if (led.language_exists(event,led.primary_language))
			lang=led.primary_language;
		else if (led.language_exists(event,led.secondary_language))
			lang=led.secondary_language;
		else if (led.language_exists(event,"eng"))
			lang="eng";

		for (ePtrList<Descriptor>::iterator d(event->descriptor); d != event->descriptor.end(); ++d)
		{
			if (d->Tag()==DESCR_SHORT_EVENT)
			{
				ShortEventDescriptor *s=(ShortEventDescriptor*)*d;
                
				valid |= 4;

				if (!lang || !strncmp(lang.c_str(), s->language_code, 3))
				{
					_title=s->event_name;
#ifndef DISABLE_LCD	
					if (LCDElement)
					LCDElement->setText(s->text);
#endif
					if ((s->text.length() > 0) && (s->text!=_title))
					{
						valid |= 8;
						_long_description+=s->text;
						_long_description+="\n\n";
					}
				} 
			}
			else if (d->Tag()==DESCR_EXTENDED_EVENT)
			{
				ExtendedEventDescriptor *ss=(ExtendedEventDescriptor*)*d;
				valid |= 16;
				if (!lang || !strncmp(lang.c_str(), ss->language_code, 3))
					_long_description+=ss->text;
			}
		}
		if (!_title)
			_title = _("no information is available");
		if ( !ref.path )
			channel->setText(service);

		eventTime->setText(_eventTime);
		eventDate->setText(_eventDate);

		setText(_title);

		if (!_long_description)
			long_description->setText(_("no description is available"));
		else
			long_description->setText(_long_description);

		checkTimerIcon(event);
	} 
	else
	{
		setText(service);
		long_description->setText(_("no description is available"));
	}
	updateScrollbar();
	long_description->show();
}
コード例 #16
0
void eEventDisplay::setEPGSearchEvent(eServiceReferenceDVB &Ref, EITEvent *event, eString Service)
{
	ref = Ref;
	service = Service;
	time_t time = event->start_time+event->duration/2;

	EITEvent *tmp = event->event_id != -1 ? eEPGCache::getInstance()->lookupEvent( ref, event->event_id ) : 0;
	if ( !tmp )
		tmp = eEPGCache::getInstance()->lookupEvent( ref, time );
	evt = tmp;
	valid=0;
	long_description->hide();
	long_description->move( ePoint(0,0) );
	if (evt)
	{
		eString _title=0, _long_description="";
		eString _eventDate="";
		eString _eventTime="";
		tm *begin=event->start_time!=-1?localtime(&event->start_time):0;
		if (begin)
		{
			valid |= 1;
			_eventTime.sprintf("%02d:%02d", begin->tm_hour, begin->tm_min);
			_eventDate=eString().sprintf("%02d.%02d.%4d", begin->tm_mday, begin->tm_mon+1, begin->tm_year+1900);
		}
		time_t endtime=event->start_time+event->duration;
		tm *end=event->start_time!=-1?localtime(&endtime):0;
		if (end)
		{
			valid |= 2;
			_eventTime+=eString().sprintf(" - %02d:%02d", end->tm_hour, end->tm_min);
		}
		for (ePtrList<Descriptor>::iterator d(evt->descriptor); d != evt->descriptor.end(); ++d)
		{
			if (d->Tag()==DESCR_SHORT_EVENT)
			{
				ShortEventDescriptor *s=(ShortEventDescriptor*)*d;
				valid |= 4;
				_title=s->event_name;
#ifndef DISABLE_LCD
				if (LCDElement)
				LCDElement->setText(s->text);
#endif
				if ((s->text.length() > 0) && (s->text!=_title))
				{
					valid |= 8;
					_long_description+=s->text;
					_long_description+="\n\n";
				}
			}
			else if (d->Tag()==DESCR_EXTENDED_EVENT)
			{
				ExtendedEventDescriptor *ss=(ExtendedEventDescriptor*)*d;
				valid |= 16;
				_long_description+=ss->text;
			}
			else if (d->Tag() == DESCR_LINKAGE)
			{
				if ( !ref.path )
				{
					LinkageDescriptor *ld=(LinkageDescriptor*)*d;
					if (ld->linkage_type==0xB0)
					{
						eServiceReferenceDVB MySubService(ref.getDVBNamespace(),
							eTransportStreamID(ld->transport_stream_id),
							eOriginalNetworkID(ld->original_network_id),
							eServiceID(ld->service_id), 7);
						ref = MySubService;
					}
				}
			}
		}
		if (!_title)
			_title = _("no information is available");
		if ( !ref.path )
			channel->setText(service);
		eventTime->setText(_eventTime);
		eventDate->setText(_eventDate);
		setText(_title);
		if (!_long_description)
			long_description->setText(_("no description is available"));
		else
			long_description->setText(_long_description);
		checkTimerIcon(evt);
	}
	else
	{
		setText(service);
		long_description->setText(_("no description is available"));
	}
	updateScrollbar();
	long_description->show();
}
コード例 #17
0
ファイル: TextArea.cpp プロジェクト: Hiroyuki-Nagata/mona
	/**
	 スクロールバー設定
	 */
	void TextArea::linkScrollbar(Scrollbar* v_scrollbar)
	{
		_v_scrollbar = v_scrollbar;
		updateScrollbar(true, true);
		_v_scrollbar->setBlocksize( 2 );
	}
コード例 #18
0
ファイル: Tab.cpp プロジェクト: CRasterImage/Lamp
void Tab::render(gl::FboRef text_fbo)
{
   m_scrollbar->AsScrollbar()->render(text_fbo);

   gl::translate(0, m_scroll_offset);

   bool new_posts_above_screen = false;
   bool new_posts_below_screen = false;

   for(std::list<PostRef>::iterator it = m_threads.begin();
       it != m_threads.end();
       it++)
   {
      float minY, maxY;
      (*it)->getThreadYRange(minY, maxY);
      if(minY + m_scroll_offset > m_window_size.y)
      {
         // off-screen.  Skip the rendering part
         if(m_perform_newness_glow_check && !new_posts_below_screen && (*it)->anyNew())
         {
            new_posts_below_screen = true;
         }
      }
      else if(maxY + m_scroll_offset < 0)
      {
         // off-screen.  Skip the rendering part
         if(m_perform_newness_glow_check && !new_posts_above_screen && (*it)->anyNew())
         { 
            new_posts_above_screen = true;
         }
      }
      else
      {
         (*it)->render(text_fbo, 
                       -m_scroll_offset, 
                       -m_scroll_offset + m_window_size.y,
                       new_posts_above_screen,
                       new_posts_below_screen);
      }
   }

   gl::Texture2dRef crest_image = g_skin.getImage(image_type::SHACK_CREST);
   if(crest_image &&
     !(m_crest_rect.y1 + m_scroll_offset > m_window_size.y ||
       m_crest_rect.y2 + m_scroll_offset < 0))
   {
      gl::color(1, 1, 1, 1);
      gl::draw(crest_image, m_crest_rect);
   }

   if(m_perform_newness_glow_check && new_posts_above_screen)
   {
      gl::color(1, 1, 1, 1);
      ci::ColorA new_color(g_skin.getColor(Skin::NEW_POST), 0.33f);
      ci::ColorA new_color_fade(g_skin.getColor(Skin::NEW_POST), 0.0f);

      gl::VertBatch batch(GL_TRIANGLES);

      batch.color(new_color);
      batch.vertex(vec2(0.0f, -m_scroll_offset));

      batch.color(new_color_fade);
      batch.vertex(vec2(0.0f, -m_scroll_offset + 20.0f));

      batch.color(new_color_fade);
      batch.vertex(vec2(m_window_size.x / 8.0f, -m_scroll_offset));

      batch.color(new_color);
      batch.vertex(vec2(m_window_size.x, -m_scroll_offset));

      batch.color(new_color_fade);
      batch.vertex(vec2(m_window_size.x, -m_scroll_offset + 20.0f));

      batch.color(new_color_fade);
      batch.vertex(vec2((m_window_size.x / 8.0f) * 7.0f, -m_scroll_offset));

      batch.draw();
   }

   if(m_perform_newness_glow_check && new_posts_below_screen)
   {
      gl::color(1, 1, 1, 1);
      ci::ColorA new_color(g_skin.getColor(Skin::NEW_POST), 0.33f);
      ci::ColorA new_color_fade(g_skin.getColor(Skin::NEW_POST), 0.0f);

      gl::VertBatch batch(GL_TRIANGLES);

      batch.color(new_color);
      batch.vertex(vec2(0.0f, -m_scroll_offset + m_window_size.y));

      batch.color(new_color_fade);
      batch.vertex(vec2(0.0f, -m_scroll_offset + m_window_size.y - 20.0f));

      batch.color(new_color_fade);
      batch.vertex(vec2(m_window_size.x / 8.0f, -m_scroll_offset + m_window_size.y));

      batch.color(new_color);
      batch.vertex(vec2(m_window_size.x, -m_scroll_offset + m_window_size.y));

      batch.color(new_color_fade);
      batch.vertex(vec2(m_window_size.x, -m_scroll_offset + m_window_size.y - 20.0f));

      batch.color(new_color_fade);
      batch.vertex(vec2((m_window_size.x / 8.0f) * 7.0f, -m_scroll_offset + m_window_size.y));

      batch.draw();
   }

   if(m_scroll_offset != m_goto_scroll_offset)
   {
      float scroll_percentage = g_lamp_settings.getSmoothScrollSpeed();
      m_scroll_offset = ((m_scroll_offset * (1.0f - scroll_percentage)) + (m_goto_scroll_offset * scroll_percentage));
      if(fabs(m_scroll_offset - m_goto_scroll_offset) <= 1.0f)
      {
         m_scroll_offset = m_goto_scroll_offset;
      }
      updateScrollbar();
      needsRedraw();
   }
}
コード例 #19
0
ファイル: helpwindow.cpp プロジェクト: ChakaZulu/tuxbox_apps
void eHelpWindow::init_eHelpWindow(ePtrList<eAction> &parseActionHelpList, int helpID)
{
	int xpos=60, ypos=0, labelheight, imgheight;

	scrollbar = CreateSkinnedProgress("scrollbar",0,100);

	visible = new eWidget(this);
	visible->setName("visible");

	BuildSkin("eHelpWindow");

	scrollbox = new eWidget(visible);
	scrollbox->move(ePoint(0, 0));
	scrollbox->resize(eSize(visible->width(), visible->height()*8));

	const std::set<eString> &styles=eActionMapList::getInstance()->getCurrentStyles();

	lastEntry=0;
	entryBeg[lastEntry++]=0;
	int pageend=visible->height();

	for ( ePtrList<eAction>::iterator it( parseActionHelpList.begin() ); it != parseActionHelpList.end() ; it++ )
	{
		std::map< eString, keylist >::iterator b;
		
		for (std::set<eString>::const_iterator si(styles.begin()); si != styles.end(); ++si)
		{
			b=it->keys.find(*si);
			if (b == it->keys.end())
				continue;

			keylist &keys = b->second;
			for ( keylist::iterator i( keys.begin() ); i != keys.end() ; i++ )
			{
				imgheight=0;
				if ( strstr( i->producer->getDescription(), eSystemInfo::getInstance()->getHelpStr() ) )
				{
					if (i->picture)
					{
						gPixmap *image=eSkin::getActive()->queryImage(i->picture);

						if (image)
						{
							label = new eLabel(scrollbox);
							label->setFlags(eLabel::flagVCenter);
							label->move(ePoint(0, ypos));
							label->resize(eSize(xpos,image->y));
							label->setBlitFlags(BF_ALPHATEST);
							label->setPixmap(image);
							label->setPixmapPosition(ePoint((xpos-10)/2-image->x/2, 0));
						}
					}

					label = new eLabel(scrollbox);
					label->setFlags(eLabel::flagVCenter);
					label->setFlags(RS_WRAP);
					label->move(ePoint(xpos, ypos));
					label->resize(eSize(visible->width()-xpos-20, 200));
							// since they are inited before language is set,
							// call gettext again.
					label->setText(gettext(it->getDescription()));
					labelheight=label->getExtend().height();
					label->resize(eSize(visible->width()-xpos-20, labelheight));

					ypos+=(labelheight>imgheight?labelheight:imgheight)+20;
					if ( ypos-20 > pageend )
					{
						pageend=ypos-(labelheight>imgheight?labelheight:imgheight)-20;
						entryBeg[lastEntry++]=pageend;
						pageend+=visible->height();
					}
					break;  // add only once :)
				}
			}
		}
	}

	if (helpID)
	{
		eString helptext=loadHelpText(helpID);

		label = new eLabel(scrollbox);
		label->setFlags(eLabel::flagVCenter);
		label->setFlags(RS_WRAP);
		label->move(ePoint(0, ypos));
		label->resize(eSize(visible->width(), 200));
		label->setText(helptext);
		labelheight = label->getExtend().height();
		label->resize(eSize(visible->width(), labelheight));
		int tmp = ypos+labelheight;
		while ( tmp > pageend )
		{
			entryBeg[lastEntry++]=ypos;
			ypos+=visible->height();
			pageend=ypos;
		}
	}

	--lastEntry;
	cur = 0;
	doscroll=ypos>visible->height();

	if (!doscroll)
		scrollbar->hide();
	else
	  updateScrollbar();
	  
	addActionMap(&i_helpwindowActions->map);
}