Permalink
Browse files

Vertical toolbar icons in GTK

  • Loading branch information...
JesperWe committed Jun 15, 2012
1 parent 7affc33 commit 36f7cfd98c3e4e9b21603db1de0cf2d75151af22
Showing with 24 additions and 16 deletions.
  1. +2 −2 src/compasswin.cpp
  2. +22 −14 src/styles.cpp
View
@@ -195,13 +195,13 @@ wxBitmap ocpnFloatingCompassWindow::CreateBmp()
wxImage rose_img = BMPRose.ConvertToImage();
wxImage rot_image = rose_img.Rotate( rose_angle, rot_ctr, true, &after_rotate );
BMPRose = wxBitmap( rot_image ).GetSubBitmap( wxRect(0, 0, BMPRose.GetWidth(), BMPRose.GetHeight()) );
BMPRose = wxBitmap( rot_image ).GetSubBitmap( wxRect( -after_rotate.x, -after_rotate.y, BMPRose.GetWidth(), BMPRose.GetHeight()) );
}
wxBitmap iconBm;
if( style->HasBackground() ) {
iconBm = MergeBitmaps( compassBg, BMPRose, wxSize( after_rotate.x, after_rotate.y ) );
iconBm = MergeBitmaps( compassBg, BMPRose, wxSize( 0, 0 ) );
} else {
iconBm = BMPRose;
}
View
@@ -84,11 +84,11 @@ wxBitmap MergeBitmaps( wxBitmap back, wxBitmap front, wxSize offset )
// Do alpha blending, associative version of "over" operator.
for( int i = 0; i < back.GetWidth(); i++ ) {
for( int j = 0; j < back.GetHeight(); j++ ) {
for( int i = 0; i < back.GetHeight(); i++ ) {
for( int j = 0; j < back.GetWidth(); j++ ) {
int fX = i - offset.x;
int fY = j - offset.y;
int fX = j - offset.x;
int fY = i - offset.y;
bool inFront = true;
if( fX < 0 || fY < 0 ) inFront = false;
@@ -124,6 +124,7 @@ wxBitmap MergeBitmaps( wxBitmap back, wxBitmap front, wxSize offset )
mdc.DrawBitmap( front, offset.x, offset.y, true );
mdc.SelectObject( wxNullBitmap );
#endif
return merged;
}
@@ -212,20 +213,22 @@ wxBitmap Style::GetToolIcon( wxString toolname, int iconType, bool rollover )
if( size.x == 0 ) size = toolSize[currentOrientation];
wxRect location( tool->iconLoc, size );
if( rollover ) location = wxRect( tool->rolloverLoc, size );
if( currentOrientation ) {
location.x -= verticalIconOffset.x;
location.y -= verticalIconOffset.y;
}
wxBitmap bm = graphics->GetSubBitmap( location );
if( hasBackground ) {
if( currentOrientation ) bm = MergeBitmaps( GetNormalBG(), bm, verticalIconOffset );
else
bm = MergeBitmaps( GetNormalBG(), bm, wxSize( 0, 0 ) );
bm = MergeBitmaps( GetNormalBG(), bm, wxSize( 0, 0 ) );
} else {
wxBitmap bg( GetToolSize().x, GetToolSize().y );
wxMemoryDC mdc( bg );
mdc.SetBackground( wxBrush( GetGlobalColor( _T("GREY2") ), wxSOLID ) );
mdc.Clear();
mdc.SelectObject( wxNullBitmap );
if( currentOrientation ) bm = MergeBitmaps( bg, bm, verticalIconOffset );
else
bm = MergeBitmaps( bg, bm, wxSize( 0, 0 ) );
bm = MergeBitmaps( bg, bm, wxSize( 0, 0 ) );
}
if( rollover ) {
tool->rollover = SetBitmapBrightness( bm );
@@ -250,7 +253,10 @@ wxBitmap Style::GetToolIcon( wxString toolname, int iconType, bool rollover )
offset = GetToggledToolSize() - GetToolSize();
offset /= 2;
}
if( currentOrientation ) offset += verticalIconOffset;
if( currentOrientation ) {
location.x -= verticalIconOffset.x;
location.y -= verticalIconOffset.y;
}
wxBitmap bm = MergeBitmaps( GetToggledBG(), graphics->GetSubBitmap( location ),
offset );
if( rollover ) {
@@ -269,10 +275,12 @@ wxBitmap Style::GetToolIcon( wxString toolname, int iconType, bool rollover )
if( size.x == 0 ) size = toolSize[currentOrientation];
wxRect location( tool->disabledLoc, size );
wxBitmap bm = graphics->GetSubBitmap( location );
if( currentOrientation ) {
location.x -= verticalIconOffset.x;
location.y -= verticalIconOffset.y;
}
if( hasBackground ) {
if( currentOrientation ) bm = MergeBitmaps( GetNormalBG(), bm, verticalIconOffset );
else
bm = MergeBitmaps( GetNormalBG(), bm, wxSize( 0, 0 ) );
bm = MergeBitmaps( GetNormalBG(), bm, wxSize( 0, 0 ) );
}
tool->disabled = SetBitmapBrightness( bm );
tool->disabledLoaded = true;

0 comments on commit 36f7cfd

Please sign in to comment.