made windows and the image buttons transparent, at last
fix for issue #793, see http://bugs.campware.org/view.php?id=793
This commit is contained in:
parent
a7baf17231
commit
7cbec7fbf2
11 changed files with 274 additions and 30 deletions
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.8 $
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.9 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/BlueBin.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -55,16 +55,31 @@ using namespace LiveSupport::Widgets;
|
|||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
BlueBin :: BlueBin(Colors::ColorName backgroundColor,
|
||||
Ptr<CornerImages>::Ref cornerImages)
|
||||
Ptr<CornerImages>::Ref cornerImages,
|
||||
bool transparentBorder)
|
||||
throw ()
|
||||
{
|
||||
set_flags(Gtk::NO_WINDOW);
|
||||
|
||||
this->cornerImages = cornerImages;
|
||||
this->cornerImages = cornerImages;
|
||||
this->transparentBorder = transparentBorder;
|
||||
|
||||
child = 0;
|
||||
|
||||
bgColor = Colors::getColor(backgroundColor);
|
||||
|
||||
// generate the transparency mask bitmaps for the corners.
|
||||
cornerBitmaps.reset(new CornerBitmaps());
|
||||
Glib::RefPtr<Gdk::Pixmap> pixmap;
|
||||
|
||||
cornerImages->topLeftImage->render_pixmap_and_mask(pixmap,
|
||||
cornerBitmaps->topLeftBitmap, 100);
|
||||
cornerImages->topRightImage->render_pixmap_and_mask(pixmap,
|
||||
cornerBitmaps->topRightBitmap, 100);
|
||||
cornerImages->bottomLeftImage->render_pixmap_and_mask(pixmap,
|
||||
cornerBitmaps->bottomLeftBitmap, 100);
|
||||
cornerImages->bottomRightImage->render_pixmap_and_mask(pixmap,
|
||||
cornerBitmaps->bottomRightBitmap, 100);
|
||||
}
|
||||
|
||||
|
||||
|
@ -225,12 +240,11 @@ BlueBin :: on_realize() throw ()
|
|||
|
||||
if (!gdkWindow) {
|
||||
// create the Gdk::Window, if it didn't exist before
|
||||
Gtk::Allocation allocation = get_allocation();
|
||||
|
||||
GdkWindowAttr attributes;
|
||||
memset(&attributes, 0, sizeof(attributes));
|
||||
|
||||
Gtk::Allocation allocation = get_allocation();
|
||||
|
||||
// set initial position and size of the Gdk::Window
|
||||
attributes.x = allocation.get_x();
|
||||
attributes.y = allocation.get_y();
|
||||
|
@ -282,11 +296,43 @@ BlueBin :: on_expose_event(GdkEventExpose* event) throw ()
|
|||
return false;
|
||||
}
|
||||
|
||||
int width = get_width();
|
||||
int height = get_height();
|
||||
|
||||
if (transparentBorder) {
|
||||
unsigned int bitmapSize = 1 + (width * height);
|
||||
|
||||
char * bitmapData = new char[bitmapSize];
|
||||
memset(bitmapData, 0xff, bitmapSize);
|
||||
|
||||
Glib::RefPtr<Gdk::Bitmap> mask = Gdk::Bitmap::create(bitmapData,
|
||||
width,
|
||||
height);
|
||||
delete[] bitmapData;
|
||||
|
||||
Glib::RefPtr<Gdk::GC> gc = Gdk::GC::create(mask);
|
||||
Glib::RefPtr<Gdk::Bitmap> borderMask;
|
||||
|
||||
mask->draw_drawable(gc, cornerBitmaps->topLeftBitmap, 0, 0, 0, 0);
|
||||
|
||||
mask->draw_drawable(gc, cornerBitmaps->topRightBitmap, 0, 0,
|
||||
width - cornerImages->topRightImage->get_width(),
|
||||
0);
|
||||
|
||||
mask->draw_drawable(gc, cornerBitmaps->bottomLeftBitmap, 0, 0,
|
||||
0,
|
||||
height - cornerImages->bottomLeftImage->get_height());
|
||||
|
||||
mask->draw_drawable(gc, cornerBitmaps->bottomRightBitmap, 0, 0,
|
||||
width - cornerImages->bottomRightImage->get_width(),
|
||||
height - cornerImages->bottomRightImage->get_height());
|
||||
|
||||
get_parent_window()->shape_combine_mask(mask, 0, 0);
|
||||
}
|
||||
|
||||
if (gdkWindow) {
|
||||
gdkWindow->clear();
|
||||
|
||||
int width = get_width();
|
||||
int height = get_height();
|
||||
int x;
|
||||
int maxX;
|
||||
int y;
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.5 $
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ImageButton.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -61,6 +61,10 @@ ImageButton :: ImageButton(Glib::RefPtr<Gdk::Pixbuf> image)
|
|||
state = passiveState;
|
||||
this->passiveImage = image;
|
||||
this->rollImage.clear();
|
||||
|
||||
// read the mask from a transparent PNG, and set it to this widget
|
||||
Glib::RefPtr<Gdk::Pixmap> pixmap;
|
||||
passiveImage->render_pixmap_and_mask(pixmap, passiveMask, 100);
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,6 +80,11 @@ ImageButton :: ImageButton(Glib::RefPtr<Gdk::Pixbuf> passiveImage,
|
|||
state = passiveState;
|
||||
this->passiveImage = passiveImage;
|
||||
this->rollImage = rollImage;
|
||||
|
||||
// read the mask from a transparent PNG, and set it to this widget
|
||||
Glib::RefPtr<Gdk::Pixmap> pixmap;
|
||||
passiveImage->render_pixmap_and_mask(pixmap, passiveMask, 100);
|
||||
rollImage->render_pixmap_and_mask(pixmap, rollMask, 100);
|
||||
}
|
||||
|
||||
|
||||
|
@ -260,17 +269,23 @@ ImageButton :: on_expose_event(GdkEventExpose* event) throw ()
|
|||
gdkWindow->clear();
|
||||
|
||||
Glib::RefPtr<Gdk::Pixbuf> image;
|
||||
Glib::RefPtr<Gdk::Bitmap> mask;
|
||||
|
||||
switch (state) {
|
||||
case passiveState:
|
||||
default:
|
||||
image = passiveImage;
|
||||
mask = passiveMask;
|
||||
break;
|
||||
|
||||
case rollState:
|
||||
image = rollImage ? rollImage : passiveImage;
|
||||
mask = rollMask ? rollMask : passiveMask;
|
||||
break;
|
||||
}
|
||||
|
||||
// set the transparency mask
|
||||
get_window()->shape_combine_mask(mask, 0, 0);
|
||||
|
||||
// just draw the button image at the centre of the available space
|
||||
int x = (get_width() - image->get_width()) / 2;
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.13 $
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.14 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/TestWindow.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -66,7 +66,7 @@ TestWindow :: TestWindow (void)
|
|||
|
||||
// init the imageButton
|
||||
imageButton = Gtk::manage(
|
||||
widgetFactory->createButton(WidgetFactory::deleteButton));
|
||||
widgetFactory->createButton(WidgetFactory::hugePlayButton));
|
||||
|
||||
// create a button
|
||||
button = Gtk::manage(widgetFactory->createButton("Hello, World!"));
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.11 $
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.12 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/WhiteWindow.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -146,7 +146,7 @@ WhiteWindow :: constructWindow(Colors::ColorName backgroundColor,
|
|||
}
|
||||
|
||||
// add the corners
|
||||
blueBin = Gtk::manage(new BlueBin(backgroundColor, cornerImages));
|
||||
blueBin = Gtk::manage(new BlueBin(backgroundColor, cornerImages, true));
|
||||
blueBin->add(*layout);
|
||||
Gtk::Window::add(*blueBin);
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.13 $
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.14 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/WidgetFactory.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -138,6 +138,18 @@ static const std::string smallStopButtonPassiveName
|
|||
static const std::string smallStopButtonRollName
|
||||
= "imageButton/smallStopRoll.png";
|
||||
|
||||
/**
|
||||
* The name of the passive image for the huge play button.
|
||||
*/
|
||||
static const std::string hugePlayButtonPassiveName
|
||||
= "imageButton/hugePlay.png";
|
||||
|
||||
/**
|
||||
* The name of the rollover image for the huge play button.
|
||||
*/
|
||||
static const std::string hugePlayButtonRollName
|
||||
= "imageButton/hugePlayRoll.png";
|
||||
|
||||
/**
|
||||
* The name of the combo box left image.
|
||||
*/
|
||||
|
@ -333,6 +345,11 @@ WidgetFactory :: createButton(ImageButtonType type) throw ()
|
|||
rollImage = loadImage(smallStopButtonRollName);
|
||||
break;
|
||||
|
||||
case hugePlayButton:
|
||||
passiveImage = loadImage(hugePlayButtonPassiveName);
|
||||
rollImage = loadImage(hugePlayButtonRollName);
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue