-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] New version of color button (QgsColorButtonV2) based off
QToolButton. Features: - context menu items have been moved to the attached menu button - new gui widget QgsColorSwatchGrid, which displays a grid of colors - new class for QgsColorScheme, which generates colors to show in a color swatch grid - new class QgsColorSchemeRegistry, with a global instance containing default color schemes. QgsColorButtonV2 accepts a color scheme registry, to control which schemes to show in the popup menu as color swatch grids. - color button can have a default color - color button can also be quickly set to a totally transparent color - c++ and python unit tests for all core components
- Loading branch information
1 parent
c3bd82a
commit bfff4bd
Showing
27 changed files
with
2,982 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/**List of colors paired with a friendly display name identifying the color*/ | ||
typedef QList< QPair< QColor, QString > > QgsNamedColorList; | ||
|
||
/** \ingroup core | ||
* \class QgsColorScheme | ||
* \brief Abstract base class for color schemes | ||
* | ||
* A color scheme for display in QgsColorButtonV2. Color schemes return lists | ||
* of colors with an optional associated color name. The colors returned | ||
* can be generated using an optional base color. | ||
* \note Added in version 2.5 | ||
*/ | ||
class QgsColorScheme | ||
{ | ||
%TypeHeaderCode | ||
#include <qgscolorscheme.h> | ||
%End | ||
|
||
public: | ||
|
||
QgsColorScheme(); | ||
|
||
virtual ~QgsColorScheme(); | ||
|
||
/**Gets the name for the color scheme | ||
* @returns color scheme name | ||
*/ | ||
virtual QString schemeName() const = 0; | ||
|
||
/**Gets a list of colors from the scheme. The colors can optionally | ||
* be generated using the supplied context and base color. | ||
* @param context string specifiying an optional context for the returned | ||
* colors. For instance, a "recent colors" scheme may filter returned colors | ||
* by context so that colors used only in a "composer" context are returned. | ||
* @param baseColor base color for the scheme's colors. Some color schemes | ||
* may take advantage of this to filter or modify their returned colors | ||
* to colors related to the base color. | ||
* @returns a list of QPairs of color and color name | ||
*/ | ||
virtual QgsNamedColorList fetchColors( const QString context = QString(), | ||
const QColor baseColor = QColor() ) = 0; | ||
|
||
virtual QgsColorScheme* clone() const = 0 /Factory/; | ||
|
||
}; // class QgsColorScheme | ||
|
||
/** \ingroup core | ||
* \class QgsRecentColorScheme | ||
* \brief A color scheme which contains the most recently used colors. | ||
* \note Added in version 2.5 | ||
*/ | ||
class QgsRecentColorScheme : QgsColorScheme | ||
{ | ||
%TypeHeaderCode | ||
#include <qgscolorscheme.h> | ||
%End | ||
|
||
public: | ||
|
||
QgsRecentColorScheme(); | ||
|
||
virtual ~QgsRecentColorScheme(); | ||
|
||
virtual QString schemeName() const; | ||
|
||
virtual QgsNamedColorList fetchColors( const QString context = QString(), | ||
const QColor baseColor = QColor() ); | ||
|
||
QgsColorScheme* clone() const /Factory/; | ||
}; // class QgsRecentColorScheme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
/** \ingroup core | ||
* \class QgsColorSchemeRegistry | ||
* \brief Registry of color schemes | ||
* | ||
* A registry of QgsColorScheme color schemes. This class can be created directly, or | ||
* accessed via a global instance. | ||
* \note Added in version 2.5 | ||
*/ | ||
class QgsColorSchemeRegistry | ||
{ | ||
%TypeHeaderCode | ||
#include <qgscolorschemeregistry.h> | ||
%End | ||
public: | ||
|
||
/**Returns the global instance pointer, creating the object on the first call. | ||
*/ | ||
static QgsColorSchemeRegistry * instance(); | ||
|
||
/**Constructor for an empty color scheme registry | ||
*/ | ||
QgsColorSchemeRegistry(); | ||
|
||
virtual ~QgsColorSchemeRegistry(); | ||
|
||
/**Adds all color schemes from the global instance to this color scheme. | ||
* @see addDefaultSchemes | ||
* @see addColorScheme | ||
*/ | ||
void populateFromInstance(); | ||
|
||
/**Adds all default color schemes to this color scheme. | ||
* @see populateFromInstance | ||
* @see addColorScheme | ||
*/ | ||
void addDefaultSchemes(); | ||
|
||
/**Adds a color scheme to the registry. Ownership of the scheme is transferred | ||
* to the registry. | ||
* @param scheme color scheme to add | ||
* @see populateFromInstance | ||
* @see removeColorScheme | ||
*/ | ||
void addColorScheme( QgsColorScheme* scheme /Transfer/ ); | ||
|
||
/**Removes all matching color schemes from the registry | ||
* @param scheme color scheme to remove | ||
* @returns true if scheme was found and removed | ||
* @see addColorScheme | ||
*/ | ||
bool removeColorScheme( QgsColorScheme* scheme ); | ||
|
||
/**Returns all color schemes in the registry | ||
* @returns list of color schemes | ||
*/ | ||
QList<QgsColorScheme *> schemes() const; | ||
|
||
}; // class QgsColorSchemeRegistry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.