static void render_glyph(int32 x, int32 y, uint8 glyph, uint8 attr) { // we're ASCII only if (glyph > 127) glyph = 127; if (sConsole.depth >= 8) { uint8* base = (uint8*)(sConsole.frame_buffer + sConsole.bytes_per_row * y * CHAR_HEIGHT + x * CHAR_WIDTH * sConsole.bytes_per_pixel); uint8* color = get_palette_entry(foreground_color(attr)); uint8* backgroundColor = get_palette_entry(background_color(attr)); for (y = 0; y < CHAR_HEIGHT; y++) { uint8 bits = FONT[CHAR_HEIGHT * glyph + y]; for (x = 0; x < CHAR_WIDTH; x++) { for (int32 i = 0; i < sConsole.bytes_per_pixel; i++) { if (bits & 1) base[x * sConsole.bytes_per_pixel + i] = color[i]; else { base[x * sConsole.bytes_per_pixel + i] = backgroundColor[i]; } } bits >>= 1; } base += sConsole.bytes_per_row; } } else {
ON_BOOL32 myInitGL( const ON_Viewport& viewport, GLUnurbsObj*& nobj ) { // set the model view transform SetGLModelViewMatrix( viewport ); // this stuff works with MSVC 4.2's Open GL. Changes may be needed for other // GLs. //ON_Color background_color(0,128,128); ON_Color background_color(0,63,127); //background_color = glb_model->m_settings.m_RenderSettings.m_background_color; glClearColor( (float)background_color.FractionRed(), (float)background_color.FractionGreen(), (float)background_color.FractionBlue(), 1.0f ); glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE ); glDisable( GL_CULL_FACE ); // Rhino viewports have camera "Z" pointing at the camera in a right // handed coordinate system. glClearDepth( 0.0f ); glEnable( GL_DEPTH_TEST ); glDepthFunc( GL_GEQUAL ); glEnable( GL_LIGHTING ); glEnable( GL_DITHER ); //glEnable( GL_AUTO_NORMAL ); //glEnable( GL_NORMALIZE ); // default material ON_GL( (ON_Material*)NULL ); // GL rendering of NURBS objects requires a GLUnurbsObj. nobj = gluNewNurbsRenderer(); if ( !nobj ) return false; gluNurbsProperty( nobj, GLU_SAMPLING_TOLERANCE, 20.0f ); gluNurbsProperty( nobj, GLU_PARAMETRIC_TOLERANCE, 0.5f ); gluNurbsProperty( nobj, GLU_DISPLAY_MODE, (GLfloat)GLU_FILL ); //gluNurbsProperty( nobj, GLU_DISPLAY_MODE, GLU_OUTLINE_POLYGON ); //gluNurbsProperty( nobj, GLU_DISPLAY_MODE, GLU_OUTLINE_PATCH ); gluNurbsProperty( nobj, GLU_SAMPLING_METHOD, (GLfloat)GLU_PATH_LENGTH ); //gluNurbsProperty( nobj, GLU_SAMPLING_METHOD, GLU_PARAMETRIC_ERROR ); //gluNurbsProperty( nobj, GLU_SAMPLING_METHOD, GLU_DOMAIN_DISTANCE ); gluNurbsProperty( nobj, GLU_CULLING, (GLfloat)GL_FALSE ); // register GL NURBS error callback { // hack to get around C vs C++ type checking trauma RHINO_GL_NURBS_ERROR fn; fn = (RHINO_GL_NURBS_ERROR)myNurbsErrorCallback; gluNurbsCallback( nobj, GLU_ERROR, fn ); } return true; }
void Visualizer::Render() { glfwMakeContextCurrent(window_); view_control_ptr_->SetViewMatrices(); glEnable(GL_MULTISAMPLE); glDisable(GL_BLEND); auto &background_color = render_option_ptr_->background_color_; glClearColor((GLclampf)background_color(0), (GLclampf)background_color(1), (GLclampf)background_color(2), 1.0f); glClearDepth(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); for (const auto &renderer_ptr : geometry_renderer_ptrs_) { renderer_ptr->Render(*render_option_ptr_, *view_control_ptr_); } for (const auto &renderer_ptr : utility_renderer_ptrs_) { renderer_ptr->Render(*render_option_ptr_, *view_control_ptr_); } glfwSwapBuffers(window_); }
RenderQueue* BREW::CreateToggleButtonDrawable( SharedPtr<const ToggleButton> button ) const { sf::Color border_color( GetProperty<sf::Color>( "BorderColor", button ) ); int border_color_shift( GetProperty<int>( "BorderColorShift", button ) ); sf::Color background_color( GetProperty<sf::Color>( "BackgroundColor", button ) ); sf::Color color( GetProperty<sf::Color>( "Color", button ) ); float border_width( GetProperty<float>( "BorderWidth", button ) ); const std::string& font_name( GetProperty<std::string>( "FontName", button ) ); unsigned int font_size( GetProperty<unsigned int>( "FontSize", button ) ); const sf::Font& font( *GetResourceManager().GetFont( font_name ) ); if( ( button->GetState() == Button::ACTIVE ) || button->IsActive() ) { border_color_shift = -border_color_shift; } RenderQueue* queue( new RenderQueue ); // Pane. queue->Add( Renderer::Get().CreatePane( sf::Vector2f( 0.f, 0.f ), sf::Vector2f( button->GetAllocation().width, button->GetAllocation().height ), border_width, background_color, border_color, border_color_shift ) ); // Label. if( button->GetLabel().getSize() > 0 ) { sf::Vector2f metrics = GetTextMetrics( button->GetLabel(), font, font_size ); metrics.y = GetFontLineHeight( font, font_size ); sf::Text text( button->GetLabel(), font, font_size ); float offset = ( ( button->GetState() == Button::ACTIVE ) || button->IsActive() ) ? border_width : 0.f; text.setPosition( button->GetAllocation().width / 2.f - metrics.x / 2.f + offset, button->GetAllocation().height / 2.f - metrics.y / 2.f + offset ); text.setColor( color ); queue->Add( Renderer::Get().CreateText( text ) ); } return queue; }
void LLPreviewTexture::draw() { updateDimensions(); LLPreview::draw(); if (!isMinimized()) { LLGLSUIDefault gls_ui; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); const LLRect& border = mClientRect; LLRect interior = mClientRect; interior.stretch( -PREVIEW_BORDER_WIDTH ); // ...border gl_rect_2d( border, LLColor4(0.f, 0.f, 0.f, 1.f)); gl_rect_2d_checkerboard( interior ); if ( mImage.notNull() ) { // Draw the texture glColor3f( 1.f, 1.f, 1.f ); gl_draw_scaled_image(interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), mImage); // Pump the texture priority F32 pixel_area = mLoadingFullImage ? (F32)MAX_IMAGE_AREA : (F32)(interior.getWidth() * interior.getHeight() ); mImage->addTextureStats( pixel_area ); if(pixel_area > 0.f) { //boost the previewed image priority to the highest to make it to get loaded first. mImage->setAdditionalDecodePriority(1.0f) ; } std::string assetid(mImageID.asString()); if (mIsCopyable) childSetText("uuid", assetid); if (uploaderkey.isNull()&&(mImage->mDecodedComment.find("a")!=mImage->mDecodedComment.end())) { uploaderkey = LLUUID(mImage->mDecodedComment["a"]); childSetText("uploader", mImage->mDecodedComment["a"]); gCacheName->get(uploaderkey, FALSE, callbackLoadAvatarName); } if (color.empty()&&(mImage->mDecodedComment.find("c")!=mImage->mDecodedComment.end())) { color = mImage->mDecodedComment["c"]; } if (time.empty()&&(mImage->mDecodedComment.find("z")!=mImage->mDecodedComment.end())) { time=mImage->mDecodedComment["z"]; std::string year = time.substr(0,4); std::string month = time.substr(4,2); std::string day = time.substr(6,2); std::string hour = time.substr(8,2); std::string minute = time.substr(10,2); std::string second = time.substr(12,2); time = llformat("%s/%s/%s - %s:%s:%s",year.c_str(),month.c_str(),day.c_str(),hour.c_str(),minute.c_str(),second.c_str()); childSetText("uploadtime", time); } // Don't bother decoding more than we can display, unless // we're loading the full image. if (!mLoadingFullImage) { S32 int_width = interior.getWidth(); S32 int_height = interior.getHeight(); mImage->setKnownDrawSize(int_width, int_height); } else { // Don't use this feature mImage->setKnownDrawSize(0, 0); } if( mLoadingFullImage ) { // *TODO: Translate LLFontGL::getFontSansSerif()->renderUTF8(std::string("Receiving:"), 0, interior.mLeft + 4, interior.mBottom + 4, LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::DROP_SHADOW); F32 data_progress = mImage->mDownloadProgress; // Draw the progress bar. const S32 BAR_HEIGHT = 12; const S32 BAR_LEFT_PAD = 80; S32 left = interior.mLeft + 4 + BAR_LEFT_PAD; S32 bar_width = getRect().getWidth() - left - RESIZE_HANDLE_WIDTH - 2; S32 top = interior.mBottom + 4 + BAR_HEIGHT; S32 right = left + bar_width; S32 bottom = top - BAR_HEIGHT; LLColor4 background_color(0.f, 0.f, 0.f, 0.75f); LLColor4 decoded_color(0.f, 1.f, 0.f, 1.0f); LLColor4 downloaded_color(0.f, 0.5f, 0.f, 1.0f); gl_rect_2d(left, top, right, bottom, background_color); if (data_progress > 0.0f) { // Downloaded bytes right = left + llfloor(data_progress * (F32)bar_width); if (right > left) { gl_rect_2d(left, top, right, bottom, downloaded_color); } } } else if( !mSavedFileTimer.hasExpired() ) { // *TODO: Translate LLFontGL::getFontSansSerif()->renderUTF8(std::string("File Saved"), 0, interior.mLeft + 4, interior.mBottom + 4, LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::DROP_SHADOW); } } } }
void LLPreviewTexture::draw() { updateDimensions(); LLPreview::draw(); if (!isMinimized()) { LLGLSUIDefault gls_ui; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); const LLRect& border = mClientRect; LLRect interior = mClientRect; interior.stretch( -PREVIEW_BORDER_WIDTH ); // ...border gl_rect_2d( border, LLColor4(0.f, 0.f, 0.f, 1.f)); gl_rect_2d_checkerboard( interior ); if ( mImage.notNull() ) { // Automatically bring up SaveAs dialog if we opened this to save the texture. if (mPreviewToSave) { mPreviewToSave = FALSE; saveAs(); } // Draw the texture gGL.diffuseColor3f( 1.f, 1.f, 1.f ); gl_draw_scaled_image(interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), mImage); // Pump the texture priority F32 pixel_area = mLoadingFullImage ? (F32)MAX_IMAGE_AREA : (F32)(interior.getWidth() * interior.getHeight() ); mImage->addTextureStats( pixel_area ); // Don't bother decoding more than we can display, unless // we're loading the full image. if (!mLoadingFullImage) { S32 int_width = interior.getWidth(); S32 int_height = interior.getHeight(); mImage->setKnownDrawSize(int_width, int_height); } else { // Don't use this feature mImage->setKnownDrawSize(0, 0); } if( mLoadingFullImage ) { LLFontGL::getFontSansSerif()->renderUTF8(LLTrans::getString("Receiving"), 0, interior.mLeft + 4, interior.mBottom + 4, LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW); F32 data_progress = mImage->getDownloadProgress() ; // Draw the progress bar. const S32 BAR_HEIGHT = 12; const S32 BAR_LEFT_PAD = 80; S32 left = interior.mLeft + 4 + BAR_LEFT_PAD; S32 bar_width = getRect().getWidth() - left - RESIZE_HANDLE_WIDTH - 2; S32 top = interior.mBottom + 4 + BAR_HEIGHT; S32 right = left + bar_width; S32 bottom = top - BAR_HEIGHT; LLColor4 background_color(0.f, 0.f, 0.f, 0.75f); LLColor4 decoded_color(0.f, 1.f, 0.f, 1.0f); LLColor4 downloaded_color(0.f, 0.5f, 0.f, 1.0f); gl_rect_2d(left, top, right, bottom, background_color); if (data_progress > 0.0f) { // Downloaded bytes right = left + llfloor(data_progress * (F32)bar_width); if (right > left) { gl_rect_2d(left, top, right, bottom, downloaded_color); } } } else if( !mSavedFileTimer.hasExpired() ) { LLFontGL::getFontSansSerif()->renderUTF8(LLTrans::getString("FileSaved"), 0, interior.mLeft + 4, interior.mBottom + 4, LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW); } } } }
RenderQueue* BREW::CreateProgressBarDrawable( SharedPtr<const ProgressBar> progress_bar ) const { sf::Color border_color( GetProperty<sf::Color>( "BorderColor", progress_bar ) ); sf::Color bar_border_color( GetProperty<sf::Color>( "BarBorderColor", progress_bar ) ); sf::Color background_color( GetProperty<sf::Color>( "BackgroundColor", progress_bar ) ); sf::Color progress_color( GetProperty<sf::Color>( "BarColor", progress_bar ) ); int border_color_shift( GetProperty<int>( "BorderColorShift", progress_bar ) ); int bar_border_color_shift( GetProperty<int>( "BarBorderColorShift", progress_bar ) ); float border_width( GetProperty<float>( "BorderWidth", progress_bar ) ); float bar_border_width( GetProperty<float>( "BarBorderWidth", progress_bar ) ); RenderQueue* queue( new RenderQueue ); // Pane. queue->Add( Renderer::Get().CreatePane( sf::Vector2f( 0.f, 0.f ), sf::Vector2f( progress_bar->GetAllocation().width, progress_bar->GetAllocation().height ), border_width, background_color, border_color, -border_color_shift ) ); if( progress_bar->GetFraction() > 0.f ) { sf::FloatRect bar_rect; if( progress_bar->GetOrientation() == ProgressBar::HORIZONTAL ) { float frac_width( std::max( 2.f * bar_border_width, progress_bar->GetAllocation().width * progress_bar->GetFraction() ) ); bar_rect = sf::FloatRect( border_width, border_width, std::max( 0.f, frac_width - 2.f * border_width ), std::max( 0.f, progress_bar->GetAllocation().height - 2.f * border_width ) ); } else { float frac_height( std::max( 2.f * bar_border_width, progress_bar->GetAllocation().height * progress_bar->GetFraction() ) ); bar_rect = sf::FloatRect( border_width, std::max( 0.f, progress_bar->GetAllocation().height - frac_height + border_width ), std::max( 0.f, progress_bar->GetAllocation().width - 2.f * border_width ), std::max( 0.f, frac_height - 2.f * border_width ) ); } // Bar Pane. queue->Add( Renderer::Get().CreatePane( sf::Vector2f( bar_rect.left, bar_rect.top ), sf::Vector2f( bar_rect.width, bar_rect.height ), bar_border_width, progress_color, bar_border_color, bar_border_color_shift ) ); } return queue; }
void LLPreviewTexture::draw() { if (mUpdateDimensions) { updateDimensions(); } LLPreview::draw(); if (!isMinimized()) { LLGLSUIDefault gls_ui; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); const LLRect& border = mClientRect; LLRect interior = mClientRect; interior.stretch( -PREVIEW_BORDER_WIDTH ); // ...border gl_rect_2d( border, LLColor4(0.f, 0.f, 0.f, 1.f)); gl_rect_2d_checkerboard( calcScreenRect(), interior ); if ( mImage.notNull() ) { // Draw the texture gGL.diffuseColor3f( 1.f, 1.f, 1.f ); gl_draw_scaled_image(interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), mImage); static const LLCachedControl<bool> use_rmse_auto_mask("SHUseRMSEAutoMask",false); static const LLCachedControl<F32> auto_mask_max_rmse("SHAutoMaskMaxRMSE",.09f); if (mAlphaMaskResult != mImage->getIsAlphaMask(use_rmse_auto_mask ? auto_mask_max_rmse : -1.f)) { mAlphaMaskResult = !mAlphaMaskResult; if (!mAlphaMaskResult) { childSetColor("alphanote", LLColor4::green); childSetText("alphanote", getString("No Alpha")); } else { childSetColor("alphanote", LLColor4::red); childSetText("alphanote", getString("Has Alpha")); } } // Pump the texture priority F32 pixel_area = mLoadingFullImage ? (F32)MAX_IMAGE_AREA : (F32)(interior.getWidth() * interior.getHeight() ); mImage->addTextureStats( pixel_area ); if(pixel_area > 0.f) { //boost the previewed image priority to the highest to make it to get loaded first. mImage->setAdditionalDecodePriority(1.0f) ; } // Don't bother decoding more than we can display, unless // we're loading the full image. if (!mLoadingFullImage) { S32 int_width = interior.getWidth(); S32 int_height = interior.getHeight(); mImage->setKnownDrawSize(int_width, int_height); } else { // Don't use this feature mImage->setKnownDrawSize(0, 0); } if( mLoadingFullImage ) { LLFontGL::getFontSansSerif()->renderUTF8(LLTrans::getString("Receiving"), 0, interior.mLeft + 4, interior.mBottom + 4, LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW); F32 data_progress = mImage->getDownloadProgress(); // Draw the progress bar. const S32 BAR_HEIGHT = 12; const S32 BAR_LEFT_PAD = 80; S32 left = interior.mLeft + 4 + BAR_LEFT_PAD; S32 bar_width = getRect().getWidth() - left - RESIZE_HANDLE_WIDTH - 2; S32 top = interior.mBottom + 4 + BAR_HEIGHT; S32 right = left + bar_width; S32 bottom = top - BAR_HEIGHT; LLColor4 background_color(0.f, 0.f, 0.f, 0.75f); LLColor4 decoded_color(0.f, 1.f, 0.f, 1.0f); LLColor4 downloaded_color(0.f, 0.5f, 0.f, 1.0f); gl_rect_2d(left, top, right, bottom, background_color); if (data_progress > 0.0f) { // Downloaded bytes right = left + llfloor(data_progress * (F32)bar_width); if (right > left) { gl_rect_2d(left, top, right, bottom, downloaded_color); } } } else if(!mSavedFileTimer.hasExpired()) { LLFontGL::getFontSansSerif()->renderUTF8(LLTrans::getString("FileSaved"), 0, interior.mLeft + 4, interior.mBottom + 4, LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW); } } } }
RenderQueue* BREW::CreateWindowDrawable( SharedPtr<const Window> window ) const { RenderQueue* queue( new RenderQueue ); sf::Color background_color( GetProperty<sf::Color>( "BackgroundColor", window ) ); sf::Color border_color( GetProperty<sf::Color>( "BorderColor", window ) ); sf::Color title_background_color( GetProperty<sf::Color>( "TitleBackgroundColor", window ) ); sf::Color title_text_color( GetProperty<sf::Color>( "Color", window ) ); int border_color_shift( GetProperty<int>( "BorderColorShift", window ) ); float border_width( GetProperty<float>( "BorderWidth", window ) ); float title_padding( GetProperty<float>( "TitlePadding", window ) ); float shadow_distance( GetProperty<float>( "ShadowDistance", window ) ); float handle_size( GetProperty<float>( "HandleSize", window ) ); sf::Uint8 shadow_alpha( GetProperty<sf::Uint8>( "ShadowAlpha", window ) ); unsigned int title_font_size( GetProperty<unsigned int>( "FontSize", window ) ); const sf::Font& title_font( *GetResourceManager().GetFont( GetProperty<std::string>( "FontName", window ) ) ); float title_size( GetFontLineHeight( title_font, title_font_size ) + 2 * title_padding ); if( window->HasStyle( Window::SHADOW ) ) { // Shadow. sf::Color shadow_color( 0, 0, 0, shadow_alpha ); sf::FloatRect shadow_rect( shadow_distance, shadow_distance, window->GetAllocation().width, window->GetAllocation().height ); queue->Add( Renderer::Get().CreateRect( shadow_rect, shadow_color ) ); } if( window->HasStyle( Window::BACKGROUND ) ) { // Pane. queue->Add( Renderer::Get().CreatePane( sf::Vector2f( 0.f, 0.f ), sf::Vector2f( window->GetAllocation().width, window->GetAllocation().height ), border_width, background_color, border_color, border_color_shift ) ); } if( window->HasStyle( Window::RESIZE ) ) { queue->Add( Renderer::Get().CreateTriangle( sf::Vector2f( window->GetAllocation().width, window->GetAllocation().height - handle_size ), sf::Vector2f( window->GetAllocation().width - handle_size, window->GetAllocation().height ), sf::Vector2f( window->GetAllocation().width, window->GetAllocation().height ), title_background_color ) ); } if( !window->HasStyle( Window::TITLEBAR ) ) { title_size = 0; } if( title_size > 0 ) { queue->Add( Renderer::Get().CreateRect( sf::FloatRect( border_width + .1f, border_width + .1f, window->GetAllocation().width - 2 * border_width, title_size ), title_background_color ) ); // Find out visible text, count in "...". float avail_width( window->GetAllocation().width - 2.f * border_width - 2.f * title_padding ); sf::Text title_text( window->GetTitle(), title_font, title_font_size ); if( title_text.getLocalBounds().width > avail_width ) { sf::Text dots( "...", title_font, title_font_size ); const sf::String& title_string( window->GetTitle() ); sf::String visible_title; avail_width = window->GetAllocation().width - 2.f * border_width - 2.f * title_padding - dots.getLocalBounds().width; for( std::size_t ch_index = 0; ch_index < title_string.getSize(); ++ch_index ) { avail_width -= static_cast<float>( title_font.getGlyph( title_string[ch_index], title_font_size, false ).advance ); if( avail_width < 0.f ) { visible_title += "..."; break; } visible_title += title_string[ch_index]; } title_text.setString( visible_title ); } // Calculate title text position. sf::Vector2f title_position( border_width + title_padding, border_width + title_size / 2.f - static_cast<float>( title_font_size ) / 2.f ); title_text.setPosition( title_position ); title_text.setColor( title_text_color ); queue->Add( Renderer::Get().CreateText( title_text ) ); } return queue; }
void _SeqIndexMetric::DrawOn( BView* view, BRect clip, SeqSongWinPropertiesI& props, float fontHeight) { BRect b(0, mFrame.top, clip.right, mFrame.bottom); float borderL = 1, borderR = 0; float bottomIndent = 5; float stringIndent = 4; float bot = mFrame.top + fontHeight + 2 + bottomIndent + stringIndent; if (bot < mFrame.bottom) b.bottom = bot; rgb_color bgc = background_color(); /* Drawn this way just to get pixel-perfect: The very right edge of * the view should always be drawn with the background color, regardless * of whether or not the track is selected, because a couple pixels * show through behind the mode buttons. */ if (props.Selections() && props.Selections()->IncludesTrack(mTrackId) ) { if (props.IsRecording() ) bgc = recording_highlight_color(); else bgc = highlight_color(); draw_background(view, b, bgc, borderL, borderR, bottomIndent); draw_background(view, BRect(b.right - 4, b.top, b.right, b.bottom), background_color(), borderL, borderR, bottomIndent); } else draw_background(view, b, bgc, borderL, borderR, bottomIndent); /* Clean up the cap */ float absBottom = b.bottom - bottomIndent + 2; view->SetHighColor(0, 0, 0); view->StrokeLine( BPoint(0, b.top + 3), BPoint(0, absBottom) ); /* Cap off if I'm larger then normal. */ float fullBottom = mFrame.bottom - bottomIndent + 2; if (fullBottom > absBottom && clip.right >= mFrame.right) { view->StrokeLine(BPoint(mFrame.right, absBottom), BPoint(mFrame.right, fullBottom)); } /* Draw the label */ view->SetLowColor(bgc); view->SetHighColor( Prefs().Color(AM_ARRANGE_FG_C) ); if (mLabel.Length() > 0) view->DrawString(mLabel.String(), BPoint( b.left + borderL + 2, b.bottom - bottomIndent - stringIndent) ); /* Draw the group indicator. */ if (mGroups > 0) { const char* gname = group_name_from(mGroups); if (gname) { BPoint mutePt = MuteRect().LeftTop(); float w = view->StringWidth("G9"); view->DrawString(gname, BPoint(mutePt.x - w - 1, b.bottom - bottomIndent - stringIndent)); // view->FillRect(BRect(b.left + borderL + 2, mFrame.top, b.left + borderL + 8, mFrame.bottom)); } } /* Draw the mode buttons. */ if (mModeW > 0 && clip.right >= mFrame.right - mModeW) { BPoint mutePt = MuteRect().LeftTop(), soloPt = SoloRect().LeftTop(); drawing_mode mode = view->DrawingMode(); view->SetDrawingMode(B_OP_ALPHA); view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); if (mModeFlags&AmTrack::MUTE_MODE && gMuteOn) view->DrawBitmapAsync(gMuteOn, mutePt); else if (gMuteOff) view->DrawBitmapAsync(gMuteOff, mutePt); if (mModeFlags&AmTrack::SOLO_MODE && gSoloOn) view->DrawBitmapAsync(gSoloOn, soloPt); else if (gSoloOff) view->DrawBitmapAsync(gSoloOff, soloPt); view->SetDrawingMode(mode); } }
/* * keyboard_input * DESCRIPTION: Processes all keyboard input. Letters get printed to screen while read fn. is * running, some other keys have special functions. * INPUTS: key -- 8 bit scancode passed in from keyboard handler * OUTPUTS: none * RETURN VALUE: none * SIDE EFFECTS: none */ void keyboard_input(uint8_t key) { // Only process keyboard input if read fn. is executing if(!reading) return; switch(key) { // Ctrl pressed case 0x1D: ctrl = 1; return; // Ctrl realeased case 0x9D: ctrl = 0; return; // Up arrow pressed case 0x48: scroll(-1); return; // Down arrow pressed case 0x50: scroll(1); return; // Page Up pressed case 0x49: scroll(-12); return; // Page Down pressed case 0x51: scroll(12); return; // Caps Lock pressed/released case 0x3A: caps_lock = 1 - caps_lock; return; // Left shift pressed case 0x2A: shift = 1; return; // Left shift released case 0xAA: shift = 0; return; // Right shift pressed case 0x36: shift = 1; return; // Right shift released case 0xB6: shift = 0; return; // F7 pressed case 0x41: font_color(); return; // F8 pressed case 0x42: background_color(); return; } uint8_t kbd_data; // Decide which kbd array to use. if(shift || caps_lock) kbd_data = shift_chars[key]; else kbd_data = chars[key]; if(ctrl) { // Clear screen on <Ctrl + l> if(kbd_data == 'l') { clear(); line_pos = 0; } return; } // Return if scancode is for key release. if((0x80 & key) != 0) return; // Only process valid characters. if(kbd_data != 0) { if(kbd_data == '\b') { // Don't allow backspacing farther than beginning of typed buffer. if(line_pos == 0) return; line_pos--; } else if(kbd_data == '\n') { reading = 0; typed[line_pos] = '\n'; enter_pressed = 1; } // Printable characters else { // Only allow 1024 characters in buffer. if(line_pos >= 10) return; typed[line_pos] = kbd_data; line_pos++; } putc(kbd_data); } }
RenderQueue* BREW::CreateFrameDrawable( SharedPtr<const Frame> frame ) const { sf::Color border_color( GetProperty<sf::Color>( "BorderColor", frame ) ); sf::Color color( GetProperty<sf::Color>( "Color", frame ) ); sf::Color background_color( GetProperty<sf::Color>( "BackgroundColor", frame ) ); float border_width( GetProperty<float>( "BorderWidth", frame ) ); const std::string& font_name( GetProperty<std::string>( "FontName", frame ) ); unsigned int font_size( GetProperty<unsigned int>( "FontSize", frame ) ); const sf::Font& font( *GetResourceManager().GetFont( font_name ) ); float label_padding( GetProperty<float>( "LabelPadding", frame ) ); float line_height = GetLineHeight( font, font_size ); RenderQueue* queue( new RenderQueue ); // Right queue->Add( Renderer::Get().CreateLine( sf::Vector2f( frame->GetAllocation().width - border_width, line_height / 2.f ), sf::Vector2f( frame->GetAllocation().width - border_width, frame->GetAllocation().height - border_width ), border_color, border_width ) ); // Bottom queue->Add( Renderer::Get().CreateLine( sf::Vector2f( frame->GetAllocation().width, frame->GetAllocation().height - border_width ), sf::Vector2f( 0.f, frame->GetAllocation().height - border_width ), border_color, border_width ) ); // Left queue->Add( Renderer::Get().CreateLine( sf::Vector2f( 0.f, frame->GetAllocation().height - border_width ), sf::Vector2f( 0.f, line_height / 2.f ), border_color, border_width ) ); float label_start_x = line_height; float label_end_x = line_height; float alignment = frame->GetAlignment().x; if( frame->GetLabel().getSize() > 0 ) { sf::Vector2f metrics = GetTextMetrics( frame->GetLabel(), font, font_size ); metrics.x += ( 2 * label_padding ); label_start_x += ( alignment * ( frame->GetAllocation().width - 2 * line_height - metrics.x ) ); label_end_x += ( metrics.x + alignment * ( frame->GetAllocation().width - 2 * line_height - metrics.x ) ); sf::Text text( frame->GetLabel(), font, font_size ); text.setPosition( label_start_x + label_padding, .0f ); text.setColor( color ); queue->Add( Renderer::Get().CreateText( text, background_color ) ); } // Top Left queue->Add( Renderer::Get().CreateLine( sf::Vector2f( 0.f, line_height / 2.f ), sf::Vector2f( label_start_x, line_height / 2.f ), border_color, border_width ) ); // Top Right queue->Add( Renderer::Get().CreateLine( sf::Vector2f( label_end_x, line_height / 2.f ), sf::Vector2f( frame->GetAllocation().width - border_width, line_height / 2.f ), border_color, border_width ) ); return queue; }
RenderQueue* BREW::CreateSpinButtonDrawable( SharedPtr<const SpinButton> spinbutton ) const { sf::Color border_color( GetProperty<sf::Color>( "BorderColor", spinbutton ) ); sf::Color background_color( GetProperty<sf::Color>( "BackgroundColor", spinbutton ) ); sf::Color text_color( GetProperty<sf::Color>( "Color", spinbutton ) ); sf::Color cursor_color( GetProperty<sf::Color>( "Color", spinbutton ) ); float text_padding( GetProperty<float>( "Padding", spinbutton ) ); float cursor_thickness( GetProperty<float>( "Thickness", spinbutton ) ); float border_width( GetProperty<float>( "BorderWidth", spinbutton ) ); int border_color_shift( GetProperty<int>( "BorderColorShift", spinbutton ) ); const sf::Font& font( *GetResourceManager().GetFont( GetProperty<std::string>( "FontName", spinbutton ) ) ); const unsigned int& font_size( GetProperty<unsigned int>( "FontSize", spinbutton ) ); float stepper_aspect_ratio( GetProperty<float>( "StepperAspectRatio", spinbutton ) ); sf::Color stepper_color( GetProperty<sf::Color>( "StepperBackgroundColor", spinbutton ) ); sf::Color stepper_border_color( GetProperty<sf::Color>( "BorderColor", spinbutton ) ); sf::Color stepper_arrow_color( GetProperty<sf::Color>( "StepperArrowColor", spinbutton ) ); RenderQueue* queue( new RenderQueue ); // Pane. queue->Add( Renderer::Get().CreatePane( sf::Vector2f( 0.f, 0.f ), sf::Vector2f( spinbutton->GetAllocation().width, spinbutton->GetAllocation().height ), border_width, background_color, border_color, -border_color_shift ) ); float button_width = ( spinbutton->GetAllocation().height / 2.f ) * stepper_aspect_ratio; // Up Stepper. queue->Add( Renderer::Get().CreatePane( sf::Vector2f( spinbutton->GetAllocation().width - button_width - border_width, border_width ), sf::Vector2f( button_width, spinbutton->GetAllocation().height / 2.f - border_width ), border_width, stepper_color, stepper_border_color, spinbutton->IsIncreaseStepperPressed() ? -border_color_shift : border_color_shift ) ); // Up Stepper Triangle. queue->Add( Renderer::Get().CreateTriangle( sf::Vector2f( spinbutton->GetAllocation().width - button_width / 2.f - border_width, ( spinbutton->IsIncreaseStepperPressed() ? 1.f : 0.f ) + border_width + spinbutton->GetAllocation().height / 6.f ), sf::Vector2f( spinbutton->GetAllocation().width - button_width / 4.f * 3.f - border_width, ( spinbutton->IsIncreaseStepperPressed() ? 1.f : 0.f ) + border_width + spinbutton->GetAllocation().height / 3.f ), sf::Vector2f( spinbutton->GetAllocation().width - button_width / 4.f - border_width, ( spinbutton->IsIncreaseStepperPressed() ? 1.f : 0.f ) + border_width + spinbutton->GetAllocation().height / 3.f ), stepper_arrow_color ) ); // Down Stepper. queue->Add( Renderer::Get().CreatePane( sf::Vector2f( spinbutton->GetAllocation().width - button_width - border_width, spinbutton->GetAllocation().height / 2.f ), sf::Vector2f( button_width, spinbutton->GetAllocation().height / 2.f - border_width ), border_width, stepper_color, stepper_border_color, spinbutton->IsDecreaseStepperPressed() ? -border_color_shift : border_color_shift ) ); // Down Stepper Triangle. queue->Add( Renderer::Get().CreateTriangle( sf::Vector2f( spinbutton->GetAllocation().width - button_width / 2.f - border_width, ( spinbutton->IsDecreaseStepperPressed() ? 1.f : 0.f ) + spinbutton->GetAllocation().height - border_width - spinbutton->GetAllocation().height / 6.f ), sf::Vector2f( spinbutton->GetAllocation().width - button_width / 4.f - border_width, ( spinbutton->IsDecreaseStepperPressed() ? 1.f : 0.f ) + spinbutton->GetAllocation().height - border_width - spinbutton->GetAllocation().height / 3.f ), sf::Vector2f( spinbutton->GetAllocation().width - button_width / 4.f * 3.f - border_width, ( spinbutton->IsDecreaseStepperPressed() ? 1.f : 0.f ) + spinbutton->GetAllocation().height - border_width - spinbutton->GetAllocation().height / 3.f ), stepper_arrow_color ) ); float line_height = GetFontLineHeight( font, font_size ); sf::Text vis_label( spinbutton->GetVisibleText(), font, font_size ); vis_label.setColor( text_color ); vis_label.setPosition( text_padding, spinbutton->GetAllocation().height / 2.f - line_height / 2.f ); queue->Add( Renderer::Get().CreateText( vis_label ) ); // Draw cursor if spinbutton is active and cursor is visible. if( spinbutton->HasFocus() && spinbutton->IsCursorVisible() ) { sf::String cursor_string( spinbutton->GetVisibleText() ); if( spinbutton->GetCursorPosition() - spinbutton->GetVisibleOffset() < cursor_string.getSize() ) { cursor_string.erase( spinbutton->GetCursorPosition() - spinbutton->GetVisibleOffset(), cursor_string.getSize() ); } // Get metrics. sf::Vector2f metrics( GetTextMetrics( cursor_string, font, font_size ) ); queue->Add( Renderer::Get().CreateRect( sf::FloatRect( metrics.x + text_padding, spinbutton->GetAllocation().height / 2.f - line_height / 2.f, cursor_thickness, line_height ), cursor_color ) ); } return queue; }
struct html_editor::action_type html_editor::m_action_definitions[] = { #define QN QT_TR_NOOP #define NA QWebPage::NoWebAction // {name, shortcut, icon, WebAction {QN("Bold"), QN("Ctrl+B"), "icon-bold.png", SLOT(bold()), NA } ,{QN("Italic"), QN("Ctrl+I"), "icon-italic.png", SLOT(italic()), NA } ,{QN("Underline"), QN("Ctrl+U"), "icon-underline.png", SLOT(underline()), NA } ,{QN("Strike through"), QN("Ctrl+S"), "icon-strikethrough.png", SLOT(strikethrough()) , NA} ,{QN("Superscript"), NULL, "icon-superscript.png", SLOT(superscript()), NA } ,{QN("Subscript"), NULL, "icon-subscript.png", SLOT(subscript()), NA } // separator before 6 ,{QN("Set foreground color"), NULL, "icon-foreground-color.png", SLOT(foreground_color()), NA } ,{QN("Set background color"), NULL, "icon-background-color.png", SLOT(background_color()), NA } ,{QN("Insert image"), NULL, "icon-image.png", SLOT(insert_image()), NA } ,{QN("Insert link"), NULL, "icon-link.png", SLOT(insert_link()), NA } ,{QN("Insert horizontal rule"), NULL, "icon-hr.png", SLOT(insert_hr()), NA } ,{QN("Insert unordered list"), NULL, "icon-bullet-list.png", SLOT(insert_unordered_list()), NA } ,{QN("Insert ordered list"), NULL, "icon-ordered-list.png", SLOT(insert_ordered_list()), NA } ,{QN("Remove format"), NULL, "icon-eraser.png", SLOT(remove_format()), NA } ,{QN("Cut"), NULL, "icon-cut.png", NULL, QWebPage::Cut } ,{QN("Copy"), NULL, "icon-copy.png", NULL, QWebPage::Copy } ,{QN("Paste"), NULL, "icon-paste.png", NULL, QWebPage::Paste } ,{QN("Undo"), QN("Ctrl+Z"), "icon-undo.png", NULL, QWebPage::Undo } ,{QN("Redo"), NULL, "icon-redo.png", NULL, QWebPage::Redo } ,{QN("Align left"), NULL, "icon-align-left.png", SLOT(align_left()), NA } ,{QN("Justify"), NULL, "icon-justify.png", SLOT(justify()), NA } ,{QN("Align right"), NULL, "icon-align-right.png", SLOT(align_right()), NA } ,{QN("Center"), NULL, "icon-center.png", SLOT(center()), NA }