From 62bcfaf0e4fd7d77873343d880fc526ec58cdaa6 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Thu, 27 Dec 2007 22:52:48 -0800 Subject: move Shape to FbTk --- src/FbMenu.cc | 5 +- src/FbMenu.hh | 6 +- src/FbTk/Makefile.am | 1 + src/FbTk/Shape.cc | 366 +++++++++++++++++++++++++++++++++++++++++++++++++ src/FbTk/Shape.hh | 87 ++++++++++++ src/FbTk/ThemeItems.cc | 37 ++++- src/FbWinFrame.cc | 8 +- src/FbWinFrame.hh | 5 +- src/FbWinFrameTheme.hh | 6 +- src/Makefile.am | 1 - src/MenuTheme.cc | 30 +--- src/MenuTheme.hh | 6 +- src/Shape.cc | 365 ------------------------------------------------ src/Shape.hh | 88 ------------ src/Toolbar.cc | 31 ++--- src/Toolbar.hh | 4 +- 16 files changed, 520 insertions(+), 526 deletions(-) create mode 100644 src/FbTk/Shape.cc create mode 100644 src/FbTk/Shape.hh delete mode 100644 src/Shape.cc delete mode 100644 src/Shape.hh diff --git a/src/FbMenu.cc b/src/FbMenu.cc index 040a881..8065294 100644 --- a/src/FbMenu.cc +++ b/src/FbMenu.cc @@ -27,13 +27,14 @@ #include "fluxbox.hh" #include "MenuTheme.hh" #include "Screen.hh" -#include "Shape.hh" + +#include "FbTk/Shape.hh" FbMenu::FbMenu(MenuTheme &tm, FbTk::ImageControl &imgctrl, FbTk::XLayer &layer): FbTk::Menu(tm, imgctrl), m_layeritem(fbwindow(), layer), - m_shape(new Shape(fbwindow(), tm.shapePlaces())) { + m_shape(new FbTk::Shape(fbwindow(), tm.shapePlaces())) { } diff --git a/src/FbMenu.hh b/src/FbMenu.hh index 53266bf..6e43d8f 100644 --- a/src/FbMenu.hh +++ b/src/FbMenu.hh @@ -29,7 +29,11 @@ #include class MenuTheme; + +namespace FbTk { class Shape; +} + /// a layered and shaped menu class FbMenu:public FbTk::Menu { public: @@ -44,7 +48,7 @@ public: void buttonReleaseEvent(XButtonEvent &be); private: FbTk::XLayerItem m_layeritem; - std::auto_ptr m_shape; + std::auto_ptr m_shape; }; #endif // FBMENU_HH diff --git a/src/FbTk/Makefile.am b/src/FbTk/Makefile.am index f5970fd..0fdb155 100644 --- a/src/FbTk/Makefile.am +++ b/src/FbTk/Makefile.am @@ -32,6 +32,7 @@ libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \ RefCount.hh SimpleCommand.hh SignalHandler.cc SignalHandler.hh \ Text.hh Text.cc \ Texture.cc Texture.hh TextureRender.hh TextureRender.cc \ + Shape.hh Shape.cc \ Theme.hh Theme.cc ThemeItems.cc Timer.hh Timer.cc \ XFontImp.cc XFontImp.hh \ Button.hh Button.cc \ diff --git a/src/FbTk/Shape.cc b/src/FbTk/Shape.cc new file mode 100644 index 0000000..c8cfb46 --- /dev/null +++ b/src/FbTk/Shape.cc @@ -0,0 +1,366 @@ +// Shape.cc +// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +#include "Shape.hh" + +#include "FbWindow.hh" +#include "App.hh" +#include "GContext.hh" +#include "FbPixmap.hh" + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif // HAVE_CONFIG_H + +#ifdef HAVE_CSTRING + #include +#else + #include +#endif + +#include + +#ifdef SHAPE +#include +#endif // SHAPE + +#include + +using std::min; + +namespace FbTk { + +namespace { +/* rows is an array of 8 bytes, i.e. 8x8 bits */ +Pixmap makePixmap(FbWindow &drawable, const unsigned char rows[]) { + + Display *disp = App::instance()->display(); + + const size_t data_size = 8 * 8; + // we use calloc here so we get consistent C alloc/free with XDestroyImage + // and no warnings in valgrind :) + char *data = (char *)calloc(data_size, sizeof (char)); + if (data == 0) + return 0; + + memset(data, 0xFF, data_size); + + XImage *ximage = XCreateImage(disp, + DefaultVisual(disp, drawable.screenNumber()), + 1, + XYPixmap, 0, + data, + 8, 8, + 32, 0); + if (ximage == 0) + return 0; + + XInitImage(ximage); + + for (int y=0; y<8; y++) { + for (int x=0; x<8; x++) { + XPutPixel(ximage, x, y, (rows[y] & (0x01 << x)) ? 0 : 1); // inverted, it is subtracted + } + } + + FbPixmap pm(drawable, 8, 8, 1); + GContext gc(pm); + + XPutImage(disp, pm.drawable(), gc.gc(), ximage, 0, 0, 0, 0, + 8, 8); + + XDestroyImage(ximage); + + return pm.release(); +} + +}; + +std::vector Shape::s_corners; + +Shape::Shape(FbWindow &win, int shapeplaces): + m_win(&win), + m_shapesource(0), + m_shapesource_xoff(0), + m_shapesource_yoff(0), + m_shapeplaces(shapeplaces) { + +#ifdef SHAPE + initCorners(win.screenNumber()); +#endif + + update(); +} + +Shape::~Shape() { + +#ifdef SHAPE + if (m_win != 0 && m_win->window()) { + // Reset shape of window + XShapeCombineMask(App::instance()->display(), + m_win->window(), + ShapeClip, + 0, 0, + 0, + ShapeSet); + XShapeCombineMask(App::instance()->display(), + m_win->window(), + ShapeBounding, + 0, 0, + 0, + ShapeSet); + } +#endif // SHAPE +} + +void Shape::initCorners(int screen_num) { + if (s_corners.size() == 0) + s_corners.resize(ScreenCount(App::instance()->display())); + + static const unsigned char left_bits[] = { 0xc0, 0xf8, 0xfc, 0xfe, 0xfe, 0xfe, 0xff, 0xff }; + static const unsigned char right_bits[] = { 0x03, 0x1f, 0x3f, 0x7f, 0x7f, 0x7f, 0xff, 0xff}; + static const unsigned char bottom_left_bits[] = { 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfc, 0xf8, 0xc0 }; + static const unsigned char bottom_right_bits[] = { 0xff, 0xff, 0x7f, 0x7f, 0x7f, 0x3f, 0x1f, 0x03 }; + + s_corners[screen_num].topleft = makePixmap(*m_win, left_bits); + s_corners[screen_num].topright = makePixmap(*m_win, right_bits); + s_corners[screen_num].botleft = makePixmap(*m_win, bottom_left_bits); + s_corners[screen_num].botright = makePixmap(*m_win, bottom_right_bits); + +} + +void Shape::setPlaces(int shapeplaces) { + m_shapeplaces = shapeplaces; +} + +void Shape::update() { + if (m_win == 0 || m_win->window() == 0) + return; + +#ifdef SHAPE + /** + * Set the client's shape in position, + * or wipe the shape and return. + */ + Display *display = App::instance()->display(); + int bw = m_win->borderWidth(); + int width = m_win->width(); + int height = m_win->height(); + + if (m_shapesource == 0 && m_shapeplaces == 0) { + /* clear the shape and return */ + XShapeCombineMask(display, + m_win->window(), ShapeClip, + 0, 0, + None, ShapeSet); + XShapeCombineMask(display, + m_win->window(), ShapeBounding, + 0, 0, + None, ShapeSet); + return; + } + + XRectangle rect; + rect.x = 0; + rect.y = 0; + rect.width = width; + rect.height = height; + + XShapeCombineRectangles(display, + m_win->window(), ShapeClip, + 0, 0, /* offsets */ + &rect, + 1, /* number of rectangles */ + ShapeSet, /* op */ + 2 /* ordering: YXSorted... only 1: doesn't matter */ ); + + rect.x = -bw; + rect.y = -bw; + rect.width = width+2*bw; + rect.height = height+2*bw; + + XShapeCombineRectangles(display, + m_win->window(), ShapeBounding, + 0, 0, /* offsets */ + &rect, + 1, /* number of rectangles */ + ShapeSet, /* op */ + 2 /* ordering: YXSorted... only 1: doesn't matter */ ); + + if (m_shapesource != 0) { + + /* + Copy the shape from the source. + We achieve this by subtracting the client-area size from the shape, and then + unioning in the client's mask. + */ + rect.x = m_shapesource_xoff; + rect.y = m_shapesource_yoff; + rect.width = m_shapesource->width(); + rect.height = m_shapesource->height(); + + XShapeCombineRectangles(display, + m_win->window(), ShapeClip, + 0, 0, /* offsets */ + &rect, + 1, /* number of rectangles */ + ShapeSubtract, /* op */ + 2 /* ordering: YXSorted... only 1: doesn't matter */ ); + + XShapeCombineShape(display, + m_win->window(), ShapeClip, + rect.x, rect.y, // xOff, yOff + m_shapesource->window(), + ShapeClip, ShapeUnion); + + /* + Now the bounding rectangle. Note that the frame has a shared border with the region above the + client (i.e. titlebar), so we don't want to wipe the shared border, hence the adjustments. + */ + rect.x = m_shapesource_xoff; // note that the full bounding region is already offset by a -borderwidth! + rect.y = m_shapesource_yoff; + rect.width = m_shapesource->width(); // we don't wipe the outer bounding region [i think] + rect.height = m_shapesource->height(); + + // we want to delete the client area, dont care about borders really + XShapeCombineRectangles(display, + m_win->window(), ShapeBounding, + 0, 0, /* offsets */ + &rect, + 1, /* number of rectangles */ + ShapeSubtract, /* op */ + 2 /* ordering: YXSorted... only 1: doesn't matter */ ); + + XShapeCombineShape(display, + m_win->window(), ShapeBounding, + rect.x , rect.y, // xOff, yOff + m_shapesource->window(), + ShapeBounding, ShapeUnion); + } + + + CornerPixmaps &corners = s_corners[m_win->screenNumber()]; +#define SHAPECORNER(corner, x, y, shapekind) \ + XShapeCombineMask(App::instance()->display(), \ + m_win->window(), \ + shapekind, \ + x, y, \ + corners.corner.drawable(), \ + ShapeSubtract); + + /** + * Set the top corners if the y offset is nonzero. + */ + if (m_shapesource == 0 || m_shapesource_yoff != 0) { + if (m_shapeplaces & TOPLEFT) { + SHAPECORNER(topleft, 0, 0, ShapeClip); + SHAPECORNER(topleft, -bw, -bw, ShapeBounding); + } + if (m_shapeplaces & TOPRIGHT) { + SHAPECORNER(topright, width-8, 0, ShapeClip); + SHAPECORNER(topright, width+bw-8, -bw, ShapeBounding); + } + } + + // note that the bottom corners y-vals are offset by 8 (the height of the corner pixmaps) + if (m_shapesource == 0 || (m_shapesource_yoff+(signed) m_shapesource->height()) < height + || m_shapesource_yoff >= height /* shaded */) { + if (m_shapeplaces & BOTTOMLEFT) { + SHAPECORNER(botleft, 0, height-8, ShapeClip); + SHAPECORNER(botleft, -bw, height+bw-8, ShapeBounding); + } + if (m_shapeplaces & BOTTOMRIGHT) { + SHAPECORNER(botright, width-8, height-8, ShapeClip); + SHAPECORNER(botright, width+bw-8, height+bw-8, ShapeBounding); + } + } + +#endif // SHAPE + +} + +void Shape::setWindow(FbWindow &win) { + m_win = &win; + update(); +} + +/** + * set the shape source to the given window. + * This is purely for client windows at the moment, where the offsets and height/width of the + * target window and the source window are used to determine whether to shape a given corner. + * + * (note: xoffset will always be zero, and widths always match, so we ignore those) + * + * i.e. if the yoffset is not zero, then the top corners are shaped. + * if the target height is bigger than the source plus yoffset, then the bottom corners are + * shaped. + * + * If *either* the top or bottom corners are not shaped due to this, but a shape source window + * is given, then the bounding shape has the borders alongside the source window deleted, otherwise + * they are left hanging outside the client's shape. + */ +void Shape::setShapeSource(FbWindow *win, int xoff, int yoff, bool always_update) { + if (win != 0 && !isShaped(*win)) { + win = 0; + if (m_shapesource == 0 && !always_update) + return; + } + + // even if source is same, want to update the shape on it + m_shapesource = win; + m_shapesource_xoff = xoff; + m_shapesource_yoff = yoff; + update(); +} + +void Shape::setShapeOffsets(int xoff, int yoff) { + m_shapesource_xoff = xoff; + m_shapesource_yoff = yoff; + update(); +} + +void Shape::setShapeNotify(const FbWindow &win) { +#ifdef SHAPE + XShapeSelectInput(App::instance()->display(), + win.window(), ShapeNotifyMask); +#endif // SHAPE +} + +bool Shape::isShaped(const FbWindow &win) { + int shaped = 0; + +#ifdef SHAPE + int not_used; + unsigned int not_used2; + XShapeQueryExtents(App::instance()->display(), + win.window(), + &shaped, /// bShaped + ¬_used, ¬_used, // xbs, ybs + ¬_used2, ¬_used2, // wbs, hbs + ¬_used, // cShaped + ¬_used, ¬_used, // xcs, ycs + ¬_used2, ¬_used2); // wcs, hcs +#endif // SHAPE + + return (shaped != 0 ? true : false); +} + +}; // end namespace FbTk diff --git a/src/FbTk/Shape.hh b/src/FbTk/Shape.hh new file mode 100644 index 0000000..be49652 --- /dev/null +++ b/src/FbTk/Shape.hh @@ -0,0 +1,87 @@ +// Shape.hh +// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +#ifndef SHAPE_HH +#define SHAPE_HH + +#include "FbPixmap.hh" + +#include +#include +#include + +namespace FbTk { +class FbWindow; + +/// creates round corners on windows +class Shape { +public: + enum ShapePlace { + NONE = 0, + BOTTOMRIGHT = 0x01, + TOPRIGHT = 0x02, + BOTTOMLEFT = 0x04, + TOPLEFT = 0x08 + }; + + Shape(FbWindow &win, int shapeplaces); + ~Shape(); + /// set new shape places + void setPlaces(int shapeplaces); + /// update our shape + void update(); + /// assign a new window + void setWindow(FbWindow &win); + /// Assign a window to merge our shape with. + /// (note that this is currently specific to frames) + void setShapeSource(FbWindow *win, int xoff, int yoff, bool always_update); + void setShapeOffsets(int xoff, int yoff); + unsigned int width() const; + unsigned int height() const; + unsigned int clipWidth() const; + unsigned int clipHeight() const; + // sets shape notify mask + static void setShapeNotify(const FbWindow &win); + /// @return true if window has shape + static bool isShaped(const FbWindow &win); +private: + FbWindow *m_win; ///< window to be shaped + FbWindow *m_shapesource; ///< window to pull shape from + int m_shapesource_xoff, m_shapesource_yoff; + + void initCorners(int screen_num); + + struct CornerPixmaps { + FbPixmap topleft; + FbPixmap topright; + FbPixmap botleft; + FbPixmap botright; + }; + + // unfortunately, we need a separate pixmap per screen + static std::vector s_corners; + int m_shapeplaces; ///< places to shape + +}; + +}; // end namespace FbTk + +#endif // SHAPE_HH diff --git a/src/FbTk/ThemeItems.cc b/src/FbTk/ThemeItems.cc index db314a3..d16955b 100644 --- a/src/FbTk/ThemeItems.cc +++ b/src/FbTk/ThemeItems.cc @@ -37,6 +37,7 @@ #include "GContext.hh" #include "PixmapWithMask.hh" #include "Image.hh" +#include "Shape.hh" #include "StringUtil.hh" #include @@ -99,15 +100,15 @@ void ThemeItem::setFromString(const char *str) { setDefaultValue(); } template<> -void FbTk::ThemeItem::load(const std::string *name, const std::string *altname) { } +void ThemeItem::load(const std::string *name, const std::string *altname) { } template<> -void FbTk::ThemeItem::setDefaultValue() { +void ThemeItem::setDefaultValue() { *(*this) = false; } template<> -void FbTk::ThemeItem::setFromString(char const *strval) { +void ThemeItem::setFromString(char const *strval) { if (strcasecmp(strval, "true")==0) *(*this) = true; else @@ -136,12 +137,12 @@ void ThemeItem::setDefaultValue() { string effect(ThemeManager::instance().resourceValue(name()+".effect", altName()+".Effect")); if (effect == "halo") { m_value.setHalo(true); - FbTk::Color halo_color(ThemeManager::instance().resourceValue(name()+".halo.color", altName()+".Halo.Color").c_str(), + Color halo_color(ThemeManager::instance().resourceValue(name()+".halo.color", altName()+".Halo.Color").c_str(), theme().screenNum()); m_value.setHaloColor(halo_color); } else if (effect == "shadow" ) { - FbTk::Color shadow_color(ThemeManager::instance().resourceValue(name()+".shadow.color", altName()+".Shadow.Color").c_str(), + Color shadow_color(ThemeManager::instance().resourceValue(name()+".shadow.color", altName()+".Shadow.Color").c_str(), theme().screenNum()); m_value.setShadow(true); @@ -168,12 +169,12 @@ void ThemeItem::setFromString(const char *str) { string effect(ThemeManager::instance().resourceValue(name()+".effect", altName()+".Effect")); if (effect == "halo") { m_value.setHalo(true); - FbTk::Color halo_color(ThemeManager::instance().resourceValue(name()+".halo.color", altName()+".Halo.Color").c_str(), + Color halo_color(ThemeManager::instance().resourceValue(name()+".halo.color", altName()+".Halo.Color").c_str(), theme().screenNum()); m_value.setHaloColor(halo_color); } else if (effect == "shadow" ) { - FbTk::Color shadow_color(ThemeManager::instance().resourceValue(name()+".shadow.color", altName()+".Shadow.Color").c_str(), + Color shadow_color(ThemeManager::instance().resourceValue(name()+".shadow.color", altName()+".Shadow.Color").c_str(), theme().screenNum()); m_value.setShadow(true); @@ -373,7 +374,29 @@ void ThemeItem::setFromString(char const *strval) { template<> void ThemeItem::load(const string *name, const string *altname) { } +template <> +void ThemeItem::load(const string *name, const string *altname) { } + +template <> +void ThemeItem::setDefaultValue() { + *(*this) = Shape::NONE; +} +template <> +void ThemeItem::setFromString(const char *str) { + int places = 0; + + if (StringUtil::strcasestr(str, "topleft") != 0) + places |= Shape::TOPLEFT; + if (StringUtil::strcasestr(str, "topright") != 0) + places |= Shape::TOPRIGHT; + if (StringUtil::strcasestr(str, "bottomleft") != 0) + places |= Shape::BOTTOMLEFT; + if (StringUtil::strcasestr(str, "bottomright") != 0) + places |= Shape::BOTTOMRIGHT; + + *(*this) = static_cast(places); +} } // end namespace FbTk diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 7734497..ce1670e 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -35,10 +35,6 @@ #include "IconButton.hh" -#ifdef SHAPE -#include "Shape.hh" -#endif // SHAPE - #include #include @@ -999,7 +995,7 @@ void FbWinFrame::reconfigure() { } if (m_disable_themeshape) - m_shape.setPlaces(Shape::NONE); + m_shape.setPlaces(FbTk::Shape::NONE); else m_shape.setPlaces(theme().shapePlace()); @@ -1012,7 +1008,7 @@ void FbWinFrame::setUseShape(bool value) { m_disable_themeshape = !value; if (m_disable_themeshape) - m_shape.setPlaces(Shape::NONE); + m_shape.setPlaces(FbTk::Shape::NONE); else m_shape.setPlaces(theme().shapePlace()); diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 69ff020..052c29d 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh @@ -34,14 +34,13 @@ #include "FbTk/TextButton.hh" #include "FbTk/DefaultValue.hh" #include "FbTk/Container.hh" -#include "Shape.hh" +#include "FbTk/Shape.hh" #include #include #include #include -class Shape; class FbWinFrameTheme; class BScreen; class IconButton; @@ -414,7 +413,7 @@ private: FbWinFrame &m_frame; }; ThemeListener m_themelistener; - Shape m_shape; + FbTk::Shape m_shape; bool m_disable_themeshape; }; diff --git a/src/FbWinFrameTheme.hh b/src/FbWinFrameTheme.hh index df3c312..af8ccb8 100644 --- a/src/FbWinFrameTheme.hh +++ b/src/FbWinFrameTheme.hh @@ -32,9 +32,9 @@ #include "FbTk/BorderTheme.hh" #include "FbTk/Subject.hh" #include "FbTk/GContext.hh" +#include "FbTk/Shape.hh" #include "IconbarTheme.hh" -#include "Shape.hh" class FbWinFrameTheme: public FbTk::Theme { public: @@ -83,7 +83,7 @@ public: inline Cursor topSideCursor() const { return m_cursor_top_side; } inline Cursor bottomSideCursor() const { return m_cursor_bottom_side; } - inline Shape::ShapePlace shapePlace() const { return *m_shape_place; } + inline FbTk::Shape::ShapePlace shapePlace() const { return *m_shape_place; } inline const FbTk::BorderTheme &border(bool focus) const { return (focus ? m_border_focus : m_border_unfocus); } unsigned int titleHeight() const { return *m_title_height; } @@ -106,7 +106,7 @@ private: FbTk::ThemeItem m_button_focus_color, m_button_unfocus_color; FbTk::ThemeItem m_font; - FbTk::ThemeItem m_shape_place; + FbTk::ThemeItem m_shape_place; FbTk::ThemeItem m_title_height, m_bevel_width, m_handle_width; FbTk::BorderTheme m_border_focus, m_border_unfocus; diff --git a/src/Makefile.am b/src/Makefile.am index 312d52a..c128f9f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -116,7 +116,6 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \ Xutil.hh Xutil.cc \ CurrentWindowCmd.hh CurrentWindowCmd.cc \ WorkspaceCmd.hh WorkspaceCmd.cc \ - Shape.hh Shape.cc \ MenuTheme.hh MenuTheme.cc \ CommandDialog.hh CommandDialog.cc SendToMenu.hh SendToMenu.cc \ AlphaMenu.hh AlphaMenu.cc ObjectResource.hh \ diff --git a/src/MenuTheme.cc b/src/MenuTheme.cc index 682239c..d7f8388 100644 --- a/src/MenuTheme.cc +++ b/src/MenuTheme.cc @@ -24,36 +24,8 @@ #include "MenuTheme.hh" #include "StringUtil.hh" -using std::string; - -namespace FbTk { - -template <> -void FbTk::ThemeItem::load(const string *name, const string *altname) { } - -template <> -void FbTk::ThemeItem::setDefaultValue() { - *(*this) = Shape::NONE; -} - -template <> -void FbTk::ThemeItem::setFromString(const char *str) { - int places = 0; - - if (StringUtil::strcasestr(str, "topleft") != 0) - places |= Shape::TOPLEFT; - if (StringUtil::strcasestr(str, "topright") != 0) - places |= Shape::TOPRIGHT; - if (StringUtil::strcasestr(str, "bottomleft") != 0) - places |= Shape::BOTTOMLEFT; - if (StringUtil::strcasestr(str, "bottomright") != 0) - places |= Shape::BOTTOMRIGHT; - - *(*this) = static_cast(places); -} -} // end namespace FbTk MenuTheme::MenuTheme(int screen_num):FbTk::MenuTheme(screen_num), m_shapeplace(*this, "menu.roundCorners", "Menu.RoundCorners") { - *m_shapeplace = Shape::NONE; + *m_shapeplace = FbTk::Shape::NONE; FbTk::ThemeManager::instance().loadTheme(*this); } diff --git a/src/MenuTheme.hh b/src/MenuTheme.hh index e43e3cb..d6a870b 100644 --- a/src/MenuTheme.hh +++ b/src/MenuTheme.hh @@ -25,15 +25,15 @@ #define MENUTHEME_HH #include "FbTk/MenuTheme.hh" -#include "Shape.hh" +#include "FbTk/Shape.hh" /// this class extends FbTk MenuTheme and adds shape item class MenuTheme:public FbTk::MenuTheme { public: explicit MenuTheme(int screen_num); - Shape::ShapePlace shapePlaces() const { return *m_shapeplace; } + FbTk::Shape::ShapePlace shapePlaces() const { return *m_shapeplace; } private: - FbTk::ThemeItem m_shapeplace; + FbTk::ThemeItem m_shapeplace; }; #endif // MENUTHEME_HH diff --git a/src/Shape.cc b/src/Shape.cc deleted file mode 100644 index 7198d00..0000000 --- a/src/Shape.cc +++ /dev/null @@ -1,365 +0,0 @@ -// Shape.cc -// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -// $Id$ - -#include "Shape.hh" - -#include "FbTk/FbWindow.hh" -#include "FbTk/App.hh" -#include "FbTk/GContext.hh" -#include "FbTk/FbPixmap.hh" - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif // HAVE_CONFIG_H - -#ifdef HAVE_CSTRING - #include -#else - #include -#endif - -#include - -#ifdef SHAPE -#include -#endif // SHAPE - -#include - -using std::min; - -namespace { -/* rows is an array of 8 bytes, i.e. 8x8 bits */ -Pixmap makePixmap(FbTk::FbWindow &drawable, const unsigned char rows[]) { - - Display *disp = FbTk::App::instance()->display(); - - const size_t data_size = 8 * 8; - // we use calloc here so we get consistent C alloc/free with XDestroyImage - // and no warnings in valgrind :) - char *data = (char *)calloc(data_size, sizeof (char)); - if (data == 0) - return 0; - - memset(data, 0xFF, data_size); - - XImage *ximage = XCreateImage(disp, - DefaultVisual(disp, drawable.screenNumber()), - 1, - XYPixmap, 0, - data, - 8, 8, - 32, 0); - if (ximage == 0) - return 0; - - XInitImage(ximage); - - for (int y=0; y<8; y++) { - for (int x=0; x<8; x++) { - XPutPixel(ximage, x, y, (rows[y] & (0x01 << x)) ? 0 : 1); // inverted, it is subtracted - } - } - - FbTk::FbPixmap pm(drawable, 8, 8, 1); - FbTk::GContext gc(pm); - - XPutImage(disp, pm.drawable(), gc.gc(), ximage, 0, 0, 0, 0, - 8, 8); - - XDestroyImage(ximage); - - return pm.release(); -} - -}; - -std::vector Shape::s_corners; - -Shape::Shape(FbTk::FbWindow &win, int shapeplaces): - m_win(&win), - m_shapesource(0), - m_shapesource_xoff(0), - m_shapesource_yoff(0), - m_shapeplaces(shapeplaces) { - -#ifdef SHAPE - initCorners(win.screenNumber()); -#endif - - update(); -} - -Shape::~Shape() { - -#ifdef SHAPE - if (m_win != 0 && m_win->window()) { - // Reset shape of window - XShapeCombineMask(FbTk::App::instance()->display(), - m_win->window(), - ShapeClip, - 0, 0, - 0, - ShapeSet); - XShapeCombineMask(FbTk::App::instance()->display(), - m_win->window(), - ShapeBounding, - 0, 0, - 0, - ShapeSet); - } -#endif // SHAPE -} - -void Shape::initCorners(int screen_num) { - if (s_corners.size() == 0) - s_corners.resize(ScreenCount(FbTk::App::instance()->display())); - - static const unsigned char left_bits[] = { 0xc0, 0xf8, 0xfc, 0xfe, 0xfe, 0xfe, 0xff, 0xff }; - static const unsigned char right_bits[] = { 0x03, 0x1f, 0x3f, 0x7f, 0x7f, 0x7f, 0xff, 0xff}; - static const unsigned char bottom_left_bits[] = { 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfc, 0xf8, 0xc0 }; - static const unsigned char bottom_right_bits[] = { 0xff, 0xff, 0x7f, 0x7f, 0x7f, 0x3f, 0x1f, 0x03 }; - - s_corners[screen_num].topleft = ::makePixmap(*m_win, left_bits); - s_corners[screen_num].topright = ::makePixmap(*m_win, right_bits); - s_corners[screen_num].botleft = ::makePixmap(*m_win, bottom_left_bits); - s_corners[screen_num].botright = ::makePixmap(*m_win, bottom_right_bits); - -} - -void Shape::setPlaces(int shapeplaces) { - m_shapeplaces = shapeplaces; -} - -void Shape::update() { - if (m_win == 0 || m_win->window() == 0) - return; - -#ifdef SHAPE - /** - * Set the client's shape in position, - * or wipe the shape and return. - */ - Display *display = FbTk::App::instance()->display(); - int bw = m_win->borderWidth(); - int width = m_win->width(); - int height = m_win->height(); - - if (m_shapesource == 0 && m_shapeplaces == 0) { - /* clear the shape and return */ - XShapeCombineMask(display, - m_win->window(), ShapeClip, - 0, 0, - None, ShapeSet); - XShapeCombineMask(display, - m_win->window(), ShapeBounding, - 0, 0, - None, ShapeSet); - return; - } - - XRectangle rect; - rect.x = 0; - rect.y = 0; - rect.width = width; - rect.height = height; - - XShapeCombineRectangles(display, - m_win->window(), ShapeClip, - 0, 0, /* offsets */ - &rect, - 1, /* number of rectangles */ - ShapeSet, /* op */ - 2 /* ordering: YXSorted... only 1: doesn't matter */ ); - - rect.x = -bw; - rect.y = -bw; - rect.width = width+2*bw; - rect.height = height+2*bw; - - XShapeCombineRectangles(display, - m_win->window(), ShapeBounding, - 0, 0, /* offsets */ - &rect, - 1, /* number of rectangles */ - ShapeSet, /* op */ - 2 /* ordering: YXSorted... only 1: doesn't matter */ ); - - if (m_shapesource != 0) { - - /* - Copy the shape from the source. - We achieve this by subtracting the client-area size from the shape, and then - unioning in the client's mask. - */ - rect.x = m_shapesource_xoff; - rect.y = m_shapesource_yoff; - rect.width = m_shapesource->width(); - rect.height = m_shapesource->height(); - - XShapeCombineRectangles(display, - m_win->window(), ShapeClip, - 0, 0, /* offsets */ - &rect, - 1, /* number of rectangles */ - ShapeSubtract, /* op */ - 2 /* ordering: YXSorted... only 1: doesn't matter */ ); - - XShapeCombineShape(display, - m_win->window(), ShapeClip, - rect.x, rect.y, // xOff, yOff - m_shapesource->window(), - ShapeClip, ShapeUnion); - - /* - Now the bounding rectangle. Note that the frame has a shared border with the region above the - client (i.e. titlebar), so we don't want to wipe the shared border, hence the adjustments. - */ - rect.x = m_shapesource_xoff; // note that the full bounding region is already offset by a -borderwidth! - rect.y = m_shapesource_yoff; - rect.width = m_shapesource->width(); // we don't wipe the outer bounding region [i think] - rect.height = m_shapesource->height(); - - // we want to delete the client area, dont care about borders really - XShapeCombineRectangles(display, - m_win->window(), ShapeBounding, - 0, 0, /* offsets */ - &rect, - 1, /* number of rectangles */ - ShapeSubtract, /* op */ - 2 /* ordering: YXSorted... only 1: doesn't matter */ ); - - XShapeCombineShape(display, - m_win->window(), ShapeBounding, - rect.x , rect.y, // xOff, yOff - m_shapesource->window(), - ShapeBounding, ShapeUnion); - } - - - CornerPixmaps &corners = s_corners[m_win->screenNumber()]; -#define SHAPECORNER(corner, x, y, shapekind) \ - XShapeCombineMask(FbTk::App::instance()->display(), \ - m_win->window(), \ - shapekind, \ - x, y, \ - corners.corner.drawable(), \ - ShapeSubtract); - - /** - * Set the top corners if the y offset is nonzero. - */ - if (m_shapesource == 0 || m_shapesource_yoff != 0) { - if (m_shapeplaces & TOPLEFT) { - SHAPECORNER(topleft, 0, 0, ShapeClip); - SHAPECORNER(topleft, -bw, -bw, ShapeBounding); - } - if (m_shapeplaces & TOPRIGHT) { - SHAPECORNER(topright, width-8, 0, ShapeClip); - SHAPECORNER(topright, width+bw-8, -bw, ShapeBounding); - } - } - - // note that the bottom corners y-vals are offset by 8 (the height of the corner pixmaps) - if (m_shapesource == 0 || (m_shapesource_yoff+(signed) m_shapesource->height()) < height - || m_shapesource_yoff >= height /* shaded */) { - if (m_shapeplaces & BOTTOMLEFT) { - SHAPECORNER(botleft, 0, height-8, ShapeClip); - SHAPECORNER(botleft, -bw, height+bw-8, ShapeBounding); - } - if (m_shapeplaces & BOTTOMRIGHT) { - SHAPECORNER(botright, width-8, height-8, ShapeClip); - SHAPECORNER(botright, width+bw-8, height+bw-8, ShapeBounding); - } - } - -#endif // SHAPE - -} - -void Shape::setWindow(FbTk::FbWindow &win) { - m_win = &win; - update(); -} - -/** - * set the shape source to the given window. - * This is purely for client windows at the moment, where the offsets and height/width of the - * target window and the source window are used to determine whether to shape a given corner. - * - * (note: xoffset will always be zero, and widths always match, so we ignore those) - * - * i.e. if the yoffset is not zero, then the top corners are shaped. - * if the target height is bigger than the source plus yoffset, then the bottom corners are - * shaped. - * - * If *either* the top or bottom corners are not shaped due to this, but a shape source window - * is given, then the bounding shape has the borders alongside the source window deleted, otherwise - * they are left hanging outside the client's shape. - */ -void Shape::setShapeSource(FbTk::FbWindow *win, int xoff, int yoff, bool always_update) { - if (win != 0 && !isShaped(*win)) { - win = 0; - if (m_shapesource == 0 && !always_update) - return; - } - - // even if source is same, want to update the shape on it - m_shapesource = win; - m_shapesource_xoff = xoff; - m_shapesource_yoff = yoff; - update(); -} - -void Shape::setShapeOffsets(int xoff, int yoff) { - m_shapesource_xoff = xoff; - m_shapesource_yoff = yoff; - update(); -} - -void Shape::setShapeNotify(const FbTk::FbWindow &win) { -#ifdef SHAPE - XShapeSelectInput(FbTk::App::instance()->display(), - win.window(), ShapeNotifyMask); -#endif // SHAPE -} - -bool Shape::isShaped(const FbTk::FbWindow &win) { - int shaped = 0; - -#ifdef SHAPE - int not_used; - unsigned int not_used2; - XShapeQueryExtents(FbTk::App::instance()->display(), - win.window(), - &shaped, /// bShaped - ¬_used, ¬_used, // xbs, ybs - ¬_used2, ¬_used2, // wbs, hbs - ¬_used, // cShaped - ¬_used, ¬_used, // xcs, ycs - ¬_used2, ¬_used2); // wcs, hcs -#endif // SHAPE - - return (shaped != 0 ? true : false); -} - diff --git a/src/Shape.hh b/src/Shape.hh deleted file mode 100644 index 5f26d05..0000000 --- a/src/Shape.hh +++ /dev/null @@ -1,88 +0,0 @@ -// Shape.hh -// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -// $Id$ - -#ifndef SHAPE_HH -#define SHAPE_HH - -#include "FbTk/FbPixmap.hh" - -#include -#include -#include - -namespace FbTk { -class FbWindow; -} - -/// creates round corners on windows -class Shape { -public: - enum ShapePlace { - NONE = 0, - BOTTOMRIGHT = 0x01, - TOPRIGHT = 0x02, - BOTTOMLEFT = 0x04, - TOPLEFT = 0x08 - }; - - Shape(FbTk::FbWindow &win, int shapeplaces); - ~Shape(); - /// set new shape places - void setPlaces(int shapeplaces); - /// update our shape - void update(); - /// assign a new window - void setWindow(FbTk::FbWindow &win); - /// Assign a window to merge our shape with. - /// (note that this is currently specific to frames) - void setShapeSource(FbTk::FbWindow *win, int xoff, int yoff, bool always_update); - void setShapeOffsets(int xoff, int yoff); - unsigned int width() const; - unsigned int height() const; - unsigned int clipWidth() const; - unsigned int clipHeight() const; - // sets shape notify mask - static void setShapeNotify(const FbTk::FbWindow &win); - /// @return true if window has shape - static bool isShaped(const FbTk::FbWindow &win); -private: - FbTk::FbWindow *m_win; ///< window to be shaped - FbTk::FbWindow *m_shapesource; ///< window to pull shape from - int m_shapesource_xoff, m_shapesource_yoff; - - void initCorners(int screen_num); - - struct CornerPixmaps { - FbTk::FbPixmap topleft; - FbTk::FbPixmap topright; - FbTk::FbPixmap botleft; - FbTk::FbPixmap botright; - }; - - // unfortunately, we need a separate pixmap per screen - static std::vector s_corners; - int m_shapeplaces; ///< places to shape - -}; - -#endif // SHAPE_HH diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 0b52702..60a958c 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -54,6 +54,7 @@ #include "FbTk/Transparent.hh" #include "FbTk/BoolMenuItem.hh" #include "FbTk/IntMenuItem.hh" +#include "FbTk/Shape.hh" // use GNU extensions @@ -65,8 +66,6 @@ #include "config.h" #endif // HAVE_CONFIG_H -#include "Shape.hh" - #include #include @@ -240,7 +239,7 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width): m_rc_height(scrn.resourceManager(), 0, scrn.name() + ".toolbar.height", scrn.altName() + ".Toolbar.Height"), m_rc_tools(scrn.resourceManager(), "workspacename, prevworkspace, nextworkspace, iconbar, systemtray, prevwindow, nextwindow, clock", scrn.name() + ".toolbar.tools", scrn.altName() + ".Toolbar.Tools"), - m_shape(new Shape(frame.window, 0)), + m_shape(new FbTk::Shape(frame.window, 0)), m_resize_lock(false) { _FB_USES_NLS; // we need to get notified when the theme is reloaded @@ -451,7 +450,7 @@ void Toolbar::reconfigure() { if (theme().shape() == false && m_shape.get()) m_shape.reset(0); else if (theme().shape() && m_shape.get() == 0) { - m_shape.reset(new Shape(frame.window, 0)); + m_shape.reset(new FbTk::Shape(frame.window, 0)); } // recalibrate size @@ -679,7 +678,7 @@ void Toolbar::setPlacement(Toolbar::Placement where) { frame.x_hidden = head_x; frame.y_hidden = head_y + bevel_width - border_width - frame.height; if (m_shape.get()) - m_shape->setPlaces(Shape::BOTTOMRIGHT | Shape::BOTTOMLEFT); + m_shape->setPlaces(FbTk::Shape::BOTTOMRIGHT | FbTk::Shape::BOTTOMLEFT); break; case BOTTOMLEFT: @@ -688,7 +687,7 @@ void Toolbar::setPlacement(Toolbar::Placement where) { frame.x_hidden = head_x; frame.y_hidden = head_y + head_h - bevel_width - border_width; if (m_shape.get()) - m_shape->setPlaces(Shape::TOPRIGHT | Shape::TOPLEFT); + m_shape->setPlaces(FbTk::Shape::TOPRIGHT | FbTk::Shape::TOPLEFT); break; case TOPCENTER: @@ -697,7 +696,7 @@ void Toolbar::setPlacement(Toolbar::Placement where) { frame.x_hidden = frame.x; frame.y_hidden = head_y + bevel_width - border_width - frame.height; if (m_shape.get()) - m_shape->setPlaces(Shape::BOTTOMRIGHT | Shape::BOTTOMLEFT); + m_shape->setPlaces(FbTk::Shape::BOTTOMRIGHT | FbTk::Shape::BOTTOMLEFT); break; case TOPRIGHT: frame.x = head_x + head_w - frame.width - border_width*2; @@ -705,7 +704,7 @@ void Toolbar::setPlacement(Toolbar::Placement where) { frame.x_hidden = frame.x; frame.y_hidden = head_y + bevel_width - border_width - frame.height; if (m_shape.get()) - m_shape->setPlaces(Shape::BOTTOMRIGHT | Shape::BOTTOMLEFT); + m_shape->setPlaces(FbTk::Shape::BOTTOMRIGHT | FbTk::Shape::BOTTOMLEFT); break; case BOTTOMRIGHT: @@ -714,7 +713,7 @@ void Toolbar::setPlacement(Toolbar::Placement where) { frame.x_hidden = frame.x; frame.y_hidden = head_y + head_h - bevel_width - border_width; if (m_shape.get()) - m_shape->setPlaces(Shape::TOPRIGHT | Shape::TOPLEFT); + m_shape->setPlaces(FbTk::Shape::TOPRIGHT | FbTk::Shape::TOPLEFT); break; case BOTTOMCENTER: // default is BOTTOMCENTER @@ -723,7 +722,7 @@ void Toolbar::setPlacement(Toolbar::Placement where) { frame.x_hidden = frame.x; frame.y_hidden = head_y + head_h - bevel_width - border_width; if (m_shape.get()) - m_shape->setPlaces(Shape::TOPRIGHT | Shape::TOPLEFT); + m_shape->setPlaces(FbTk::Shape::TOPRIGHT | FbTk::Shape::TOPLEFT); break; case LEFTCENTER: orient = FbTk::ROT270; @@ -732,7 +731,7 @@ void Toolbar::setPlacement(Toolbar::Placement where) { frame.x_hidden = frame.x - frame.width + bevel_width + border_width; frame.y_hidden = frame.y; if (m_shape.get()) - m_shape->setPlaces(Shape::TOPRIGHT | Shape::BOTTOMRIGHT); + m_shape->setPlaces(FbTk::Shape::TOPRIGHT | FbTk::Shape::BOTTOMRIGHT); break; case LEFTTOP: orient = FbTk::ROT270; @@ -741,7 +740,7 @@ void Toolbar::setPlacement(Toolbar::Placement where) { frame.x_hidden = frame.x - frame.width + bevel_width + border_width; frame.y_hidden = frame.y; if (m_shape.get()) - m_shape->setPlaces(Shape::TOPRIGHT | Shape::BOTTOMRIGHT); + m_shape->setPlaces(FbTk::Shape::TOPRIGHT | FbTk::Shape::BOTTOMRIGHT); break; case LEFTBOTTOM: orient = FbTk::ROT270; @@ -750,7 +749,7 @@ void Toolbar::setPlacement(Toolbar::Placement where) { frame.x_hidden = frame.x - frame.width + bevel_width + border_width; frame.y_hidden = frame.y; if (m_shape.get()) - m_shape->setPlaces(Shape::TOPRIGHT | Shape::BOTTOMRIGHT); + m_shape->setPlaces(FbTk::Shape::TOPRIGHT | FbTk::Shape::BOTTOMRIGHT); break; case RIGHTCENTER: orient = FbTk::ROT90; @@ -759,7 +758,7 @@ void Toolbar::setPlacement(Toolbar::Placement where) { frame.x_hidden = frame.x + frame.width - bevel_width - border_width; frame.y_hidden = frame.y; if (m_shape.get()) - m_shape->setPlaces(Shape::TOPLEFT | Shape::BOTTOMLEFT); + m_shape->setPlaces(FbTk::Shape::TOPLEFT | FbTk::Shape::BOTTOMLEFT); break; case RIGHTTOP: orient = FbTk::ROT90; @@ -768,7 +767,7 @@ void Toolbar::setPlacement(Toolbar::Placement where) { frame.x_hidden = frame.x + frame.width - bevel_width - border_width; frame.y_hidden = frame.y; if (m_shape.get()) - m_shape->setPlaces(Shape::TOPLEFT | Shape::BOTTOMLEFT); + m_shape->setPlaces(FbTk::Shape::TOPLEFT | FbTk::Shape::BOTTOMLEFT); break; case RIGHTBOTTOM: orient = FbTk::ROT90; @@ -777,7 +776,7 @@ void Toolbar::setPlacement(Toolbar::Placement where) { frame.x_hidden = frame.x + frame.width - bevel_width - border_width; frame.y_hidden = frame.y; if (m_shape.get()) - m_shape->setPlaces(Shape::TOPLEFT | Shape::BOTTOMLEFT); + m_shape->setPlaces(FbTk::Shape::TOPLEFT | FbTk::Shape::BOTTOMLEFT); break; } diff --git a/src/Toolbar.hh b/src/Toolbar.hh index 4062f83..1e6b6a5 100644 --- a/src/Toolbar.hh +++ b/src/Toolbar.hh @@ -46,11 +46,11 @@ class BScreen; class Strut; class FbMenu; -class Shape; class ToolbarItem; namespace FbTk { class ImageControl; +class Shape; } /// The toolbar. @@ -183,7 +183,7 @@ private: FbTk::Resource m_rc_placement; FbTk::Resource m_rc_height; FbTk::Resource m_rc_tools; - std::auto_ptr m_shape; + std::auto_ptr m_shape; typedef std::list StringList; StringList m_tools; -- cgit v0.11.2