void NCProgressWin::Paint( wal::GC& gc, const crect& paintRect ) { crect rect = ClientRect(); int w = rect.Width(); Draw3DButtonW2( gc, rect, 0x808080, false ); rect.Dec(); rect.Dec(); w -= 2; if ( !( _num < _from || _to <= _from || w <= 0 ) ) { int64_t size = _to - _from; int n = int( ( w * _num ) / size ); crect r = rect; r.right = n; unsigned color = 0xA00000; unsigned bColor = ColorTone( color, -80 ), aColor = ColorTone( color, +80 ); FillHorisont( gc, r, aColor, bColor ); _lastWidth = w; _lastPos = n; rect.left += n; } unsigned color = 0xB0B0B0; unsigned bColor = ColorTone( color, +50 ), aColor = ColorTone( color, -50 ); FillHorisont( gc, rect, aColor, bColor ); }
void Draw3DButtonW1( GC& gc, crect r, unsigned bg, bool up ) { static unsigned hp1, lp1; static unsigned lastBg = 0; static bool initialized = false; if ( !initialized || lastBg != bg ) { hp1 = ColorTone( bg, 200 ); lp1 = ColorTone( bg, -150 ); lastBg = bg; initialized = true; } unsigned php1, plp1; if ( up ) { php1 = hp1; plp1 = lp1; } else { php1 = lp1; plp1 = hp1; } gc.SetLine( plp1 ); gc.MoveTo( r.right - 1, r.top ); gc.LineTo( r.right - 1, r.bottom - 1 ); gc.LineTo( r.left, r.bottom - 1 ); gc.SetLine( php1 ); gc.LineTo( r.left, r.top ); gc.LineTo( r.right - 1, r.top ); }
void MenuBar::Paint(GC &gc, const crect &paintRect) { crect rect = ClientRect(); unsigned color = UiGetColor(uiBackground, 0, 0, 0xFFFFFF); unsigned bColor = ColorTone(color, -50), aColor = ColorTone(color,+50); FillHorisontalRect(gc, rect, aColor, bColor); for (int i = 0; i<list.count(); i++) DrawItem(gc,i); }
void ToolBar::Paint( wal::GC& gc, const crect& paintRect ) { crect cr = ClientRect(); crect rect = cr; unsigned colorBg = UiGetColor( uiBackground, 0, 0, 0x808080 ); //GetColor(0); unsigned splitColor1 = ColorTone( colorBg, -70 ); unsigned splitColor2 = ColorTone( colorBg, 70 ); if ( g_WcmConfig.styleShow3DUI ) { Draw3DButtonW2( gc, rect, colorBg, true ); rect.Dec(); rect.Dec(); } gc.SetFillColor( colorBg ); gc.FillRect( rect ); gc.Set( GetFont() ); int x = 2; for ( size_t i = 0; i < _list.size(); i++ ) { Node* p = _list[i].ptr(); if ( p ) { DrawNode( gc, p, _pressed == p ? DRAW_PRESSED : DRAW_NORMAL ); x += p->rect.Width(); } else { gc.SetFillColor( splitColor1 ); int x1 = x + SPLITTER_WIDTH / 2; gc.FillRect( crect( x1, rect.top, x1 + 1, rect.bottom ) ); gc.SetFillColor( splitColor2 ); gc.FillRect( crect( x1 + 2, rect.top, x1 + 2, rect.bottom ) ); x += SPLITTER_WIDTH; } } return; }
/* types: 1 -left 2 - right 3 - horisontal slider 4 - up 5 - down 6 - vert. slider */ void SBCDrawButton( GC& gc, crect rect, int type, unsigned bg, bool pressed ) { static unsigned short up[] = {6, 0x10, 0x38, 0x7c, 0xee, 0x1c7, 0x82}; static unsigned short down[] = {6, 0x82, 0x1c7, 0xee, 0x7c, 0x38, 0x10,}; static unsigned short left[] = {9, 0x10, 0x38, 0x1c, 0x0e, 0x07, 0x0e, 0x1c, 0x38, 0x10}; static unsigned short right[] = {9, 0x02, 0x07, 0x0E, 0x1c, 0x38, 0x1c, 0x0e, 0x07, 0x02}; DrawBorder( gc, rect, ColorTone( bg, -100 ) ); rect.Dec(); Draw3DButtonW1( gc, rect, bg, !pressed ); //rect.Dec(); rect.Dec(); gc.SetFillColor( bg ); gc.FillRect( rect ); int xPlus = 0; int yPlus = 0; if ( pressed ) { // xPlus = 1; yPlus = 1; } unsigned color = ColorTone( bg, -200 ); switch ( type ) { case 1: DrawPixelList( gc, left, rect.left + ( rect.Width() - 6 ) / 2 + xPlus, rect.top + ( rect.Height() - 9 ) / 2 + yPlus, color ); break; case 2: DrawPixelList( gc, right, rect.left + ( rect.Width() - 6 ) / 2 + xPlus, rect.top + ( rect.Height() - 9 ) / 2 + yPlus, color ); break; case 4: DrawPixelList( gc, up, rect.left + ( rect.Width() - 9 ) / 2 + xPlus, rect.top + ( rect.Height() - 6 ) / 2 + yPlus, color ); break; case 5: DrawPixelList( gc, down, rect.left + ( rect.Width() - 9 ) / 2 + xPlus, rect.top + ( rect.Height() - 6 ) / 2 + yPlus, color ); break; }; }
void ToolBar::DrawNode( wal::GC& gc, Node* pNode, int state ) { if ( !pNode ) { return; } int W = pNode->rect.Width(); int H = pNode->rect.Height(); if ( W <= 0 || H <= 0 ) { return; } int x = pNode->rect.left + 1 + XSPACE; int y = pNode->rect.top + 1 + YSPACE; unsigned bgColor = UiGetColor( uiBackground, uiItem, 0, 0x808080 ); //GetColor(0); unsigned frameColor = ColorTone( bgColor, -150 ); if ( state == DRAW_PRESSED ) { bgColor = ColorTone( bgColor, -50 ); } gc.SetFillColor( bgColor ); { crect r = pNode->rect; r.Dec(); gc.FillRect( r ); } if ( pNode->icon.ptr() && pNode->icon->Valid() ) { pNode->icon->DrawF( gc, x, y ); x += _iconSize; } if ( state != DRAW_NORMAL ) { DrawBorder( gc, pNode->rect, frameColor ); } }
//------------------------------------------------------------------------------ //## Basic TEST_F(Test_UI_UIElement, RenderEffects) { //* [ ] UISprite はデフォルトで BlendMode=Alpha { auto tex1 = Assets::loadTexture(LN_ASSETFILE("Sprite1.png")); //* [ ] Visible auto sprite1 = newObject<UISprite>(); sprite1->setTexture(tex1); sprite1->setPosition(0, 0, 0); sprite1->setVisible(false); //* [ ] BlendMode auto sprite2 = newObject<UISprite>(); sprite2->setTexture(tex1); sprite2->setBlendMode(BlendMode::Add); sprite2->setPosition(32, 0, 0); //* [ ] Opacity auto sprite3 = newObject<UISprite>(); sprite3->setTexture(tex1); sprite3->setPosition(64, 0, 0); sprite3->setOpacity(0.5); //* [ ] ColorScale auto sprite4 = newObject<UISprite>(); sprite4->setTexture(tex1); sprite4->setPosition(96, 0, 0); sprite4->setColorScale(Color(1, 0, 0, 1)); //* [ ] BlendColor auto sprite5 = newObject<UISprite>(); sprite5->setTexture(tex1); sprite5->setPosition(0, 32, 0); sprite5->setBlendColor(Color(1, 0, 0, 1)); //* [ ] Tone auto sprite6 = newObject<UISprite>(); sprite6->setTexture(tex1); sprite6->setPosition(32, 32, 0); sprite6->setTone(ColorTone(0.5, 0.3, 0.1, 1.0)); TestEnv::updateFrame(); ASSERT_SCREEN(LN_ASSETFILE("Result/Test_UI_UIElement-RenderEffects-1.png")); LN_TEST_CLEAN_SCENE; } }
//------------------------------------------------------------------------------ //## Basic TEST_F(Test_Visual_VisualComponent, BuiltinEffects) { // TODO: Builtin shader ごとに行う { auto tex1 = Assets::loadTexture(LN_ASSETFILE("Sprite1.png")); //* [ ] Hide auto sprite1 = Sprite::create(tex1, 3, 3); //sprite1->setShadingModel(ShadingModel::UnLighting); sprite1->setPosition(-6, 0, 0); sprite1->setVisible(false); //* [ ] Normal auto sprite2 = Sprite::create(tex1, 3, 3); //sprite2->setShadingModel(ShadingModel::UnLighting); sprite2->setPosition(-3, 0, 0); //* [ ] Opacity auto sprite3 = Sprite::create(tex1, 3, 3); //sprite3->setShadingModel(ShadingModel::UnLighting); sprite3->setPosition(-6, 3, 0); sprite3->setBlendMode(BlendMode::Alpha); sprite3->setOpacity(0.5); //* [ ] ColorScale auto sprite4 = Sprite::create(tex1, 3, 3); //sprite4->setShadingModel(ShadingModel::UnLighting); sprite4->setPosition(-3, 3, 0); sprite4->setColorScale(Color(1, 0, 0, 1)); //* [ ] BlendColor auto sprite5 = Sprite::create(tex1, 3, 3); //sprite5->setShadingModel(ShadingModel::UnLighting); sprite5->setPosition(0, 3, 0); sprite5->setBlendColor(Color(1, 0, 0, 1)); //* [ ] Tone auto sprite6 = Sprite::create(tex1, 3, 3); //sprite6->setShadingModel(ShadingModel::UnLighting); sprite6->setPosition(3, 3, 0); sprite6->setTone(ColorTone(0.5, 0.3, 0.1, 1.0)); TestEnv::updateFrame(); ASSERT_SCREEN(LN_ASSETFILE("Visual/Result/Test_Visual_VisualComponent-BuiltinEffects-1.png")); LN_TEST_CLEAN_SCENE; } }
void Button::Paint( GC& gc, const crect& paintRect ) { unsigned colorBg = UiGetColor(uiBackground, uiClassButton, 0, 0x808080); //GetColor(0); crect cr = this->ClientRect(); crect rect = cr; DrawBorder( gc, rect, ColorTone( colorBg, +20 ) ); rect.Dec(); DrawBorder( gc, rect, ColorTone( colorBg, -200 ) ); rect.Dec(); gc.SetFillColor( colorBg ); gc.FillRect( rect ); if ( pressed ) { #if USE_3D_BUTTONS Draw3DButtonW2( gc, rect, colorBg, false ); #endif rect.Dec(); rect.Dec(); } else { #if USE_3D_BUTTONS Draw3DButtonW2( gc, rect, colorBg, true ); #endif rect.Dec(); if ( InFocus() ) { DrawBorder( gc, rect, /*GetColor(IC_FOCUS_MARK)*/ UiGetColor( uiFocusFrameColor, 0, 0, 0 ) ); } #if USE_3D_BUTTONS rect.Dec(); #endif } //gc.SetTextColor( /*GetColor(IsEnabled() ? IC_TEXT : IC_GRAY_TEXT)*/ UiGetColor( uiColor, 0, 0, 0 ) ); gc.Set( GetFont() ); cpoint tsize = text.GetTextExtents(gc); /* int l = tsize.x + (icon.ptr() ? icon->Width() + ICONX_RIGHTSPACE : 0); int w = rect.Width() - LEFTSPACE - RIGHTSPACE; if (icon.ptr()) w-=ICONX_RIGHTSPACE; //int x = rect.left + LEFTSPACE + (w > l ? (w - l)/2 : 0) +(pressed?2:0); int x = rect.left + LEFTSPACE + (w-l)/2 +(pressed?2:0); */ int l = tsize.x + ( icon.ptr() ? icon->Width() + ICONX_RIGHTSPACE : 0 ); int w = rect.Width(); int x = rect.left + ( w > l ? ( w - l ) / 2 : 0 ) + ( pressed ? 2 : 0 ); if ( icon.ptr() ) { gc.DrawIcon( x, rect.top + ( rect.Height() - icon->Height() ) / 2 + ( pressed ? 2 : 0 ), icon.ptr() ); x += icon->Width() + ICONX_RIGHTSPACE; } gc.SetClipRgn( &rect ); text.DrawItem(gc, x, rect.top + (rect.Height() - tsize.y) / 2 + (pressed ? 2 : 0), UiGetColor(uiColor, uiClassButton, 0, 0), UiGetColor(uiHotkeyColor, uiClassButton, 0, 0)); }
void clSelectDriveDlgMenu::Paint( wal::GC& gc, const crect& paintRect ) { cfont* font = GetFont(); gc.Set( font ); int y = 0; int bgColor = UiGetColor( uiBackground, 0, 0, 0xB0B000 ); int count = _data->Count(); int Splitters = 0; int SplitterTop = 0; int SplitterBottom = 0; for ( int i = 0; i < count; i++ ) { if ( _data->list[i].cmd == 0 ) { gc.SetFillColor( bgColor ); gc.FillRect( crect( 0, y, _width, y + _splitterH ) ); crect rect( 0, y + 1, 0 + _width, y + 2 ); gc.SetFillColor( ColorTone( bgColor, -150 ) ); gc.FillRect( rect ); rect.top += 1; rect.bottom += 1; gc.SetFillColor( ColorTone( bgColor, +50 ) ); gc.FillRect( rect ); y += _splitterH; Splitters++; if ( Splitters == 1 ) { SplitterTop = y; } if ( Splitters == 2 ) { SplitterBottom = y - _splitterH; } } else { UiCondList ucl; if ( i == _current ) { ucl.Set( uiCurrentItem, true ); } unsigned bg = UiGetColor( uiBackground, uiItem, &ucl, 0xFFFFFF ); unsigned textColor = UiGetColor( uiColor, uiItem, &ucl, 0 ); unsigned fcColor = UiGetColor( uiFcColor, uiItem, &ucl, 0xFF ); unsigned commentColor = UiGetColor( uiCommentColor, uiItem, &ucl, 0 ); gc.SetFillColor( bg ); gc.FillRect( crect( 0, y, _width, y + _itemH ) ); cicon icon; if ( _data->list[i].icon >= 0 ) { icon.Load( _data->list[i].icon, 16, 16 ); } else { icon.Load( _data->list[i].cmd, 16, 16 ); } gc.DrawIcon( 0, y, &icon ); gc.SetTextColor( textColor ); int x = 16 + 5; const unicode_t* name = _data->list[i].name.data(); const unicode_t* comment1 = _data->list[i].comment1.data(); const unicode_t* comment2 = _data->list[i].comment2.data(); if ( name ) { gc.TextOutF( x, y, name ); gc.SetTextColor( fcColor ); gc.TextOutF( x, y, name, 1 ); } if ( comment1 ) { gc.SetTextColor( commentColor ); gc.TextOutF( x + _nameW + 5, y, comment1 ); } if ( comment2 ) { gc.SetTextColor( commentColor ); gc.TextOutF( x + _nameW + 5 + _comment1W + 30, y, comment2 ); } y += _itemH; } } if ( _comment2W && SplitterTop && SplitterBottom ) { int cx = _nameW + 5 + _comment1W + 30; gc.SetFillColor( ColorTone( bgColor, -150 ) ); gc.FillRect( crect( cx, SplitterTop, cx + _splitterW, SplitterBottom ) ); } }