MAC alpha support
This commit is contained in:
parent
1a063f6a78
commit
9d395aa0c5
|
@ -257,33 +257,39 @@ void SetPenMinWidth( int minwidth )
|
|||
}
|
||||
|
||||
|
||||
/* Routine de changement de couleurs et epaisseur de la plume courante */
|
||||
/**
|
||||
* Function GRSetColorPen
|
||||
* sets a pen style, width, color, and alpha into the given device context.
|
||||
*/
|
||||
void GRSetColorPen( wxDC* DC, int Color, int width, int style )
|
||||
{
|
||||
Color &= MASKCOLOR; // Pour 32 couleurs Max
|
||||
|
||||
if( width < PenMinWidth )
|
||||
width = PenMinWidth;
|
||||
|
||||
if( ForceBlackPen && Color != WHITE )
|
||||
Color = BLACK;
|
||||
|
||||
if( (lastcolor != Color) || (lastwidth != width) || (s_Last_Pen_Style != style)
|
||||
|| (lastDC != DC ) )
|
||||
{
|
||||
wxPen DrawPen;
|
||||
DrawPen.SetColour(
|
||||
ColorRefs[Color].m_Red,
|
||||
ColorRefs[Color].m_Green,
|
||||
ColorRefs[Color].m_Blue
|
||||
);
|
||||
Color = BLACK;
|
||||
}
|
||||
|
||||
DrawPen.SetWidth( width );
|
||||
DrawPen.SetStyle( style );
|
||||
if( lastcolor != Color
|
||||
|| lastwidth != width
|
||||
|| s_Last_Pen_Style != style
|
||||
|| lastDC != DC )
|
||||
{
|
||||
wxPen pen;
|
||||
|
||||
wxColour wx_color = MakeColour( Color );
|
||||
|
||||
pen.SetColour( wx_color );
|
||||
pen.SetWidth( width );
|
||||
pen.SetStyle( style );
|
||||
|
||||
DC->SetPen( pen );
|
||||
|
||||
lastcolor = Color;
|
||||
lastwidth = width;
|
||||
lastDC = DC;
|
||||
|
||||
// if ( &DC->GetPen() != DrawPen )
|
||||
DC->SetPen( DrawPen );
|
||||
lastcolor = Color; lastwidth = width; lastDC = DC;
|
||||
s_Last_Pen_Style = style;
|
||||
}
|
||||
}
|
||||
|
@ -337,7 +343,11 @@ void GRMouseWarp( WinEDA_DrawPanel* panel, const wxPoint& pos )
|
|||
void GRSetDrawMode( wxDC* DC, int draw_mode )
|
||||
{
|
||||
if( draw_mode & GR_OR )
|
||||
#if defined(__WXMAC__) && wxMAC_USE_CORE_GRAPHICS
|
||||
DC->SetLogicalFunction( wxCOPY );
|
||||
#else
|
||||
DC->SetLogicalFunction( wxOR );
|
||||
#endif
|
||||
else if( draw_mode & GR_XOR )
|
||||
DC->SetLogicalFunction( wxXOR );
|
||||
else if( draw_mode & GR_NXOR )
|
||||
|
@ -861,7 +871,9 @@ void GRSPoly( EDA_Rect* ClipBox, wxDC* DC, int n, int* Points, int Fill,
|
|||
}
|
||||
else
|
||||
{
|
||||
startx = Points[n * 2 - 2]; starty = Points[n * 2 - 1];
|
||||
startx = Points[n * 2 - 2];
|
||||
starty = Points[n * 2 - 1];
|
||||
|
||||
GRSetBrush( DC, Color );
|
||||
DC->DrawLines( n, (wxPoint*) Points );
|
||||
}
|
||||
|
|
|
@ -11,12 +11,38 @@
|
|||
|
||||
/* Definitions des Numeros des Couleurs ( palette de 32) */
|
||||
#define NBCOLOR 32
|
||||
#define MASKCOLOR 31 // masque pour bits significatifs
|
||||
|
||||
/* bit indicateur d'affichage (vu / non vu) des items : (defini dans les valeurs des couleurs*/
|
||||
#define ITEM_NOT_SHOW 0x40000
|
||||
/* Definition du bit de surbrillance */
|
||||
#define HIGHT_LIGHT_FLAG 0x80000
|
||||
#define MASKCOLOR 31 ///< mask for color index into ColorRefs[]
|
||||
|
||||
/// bit indicateur d'affichage (vu / non vu) des items : (defini dans les valeurs des couleurs
|
||||
#define ITEM_NOT_SHOW (1<<18) // 0x40000
|
||||
|
||||
/// Definition du bit de surbrillance
|
||||
#define HIGHT_LIGHT_FLAG (1<<19) // 0x80000
|
||||
|
||||
|
||||
/**
|
||||
* Function SetAlpha
|
||||
* ORs in the alpha blend parameter in to a color index.
|
||||
*/
|
||||
static inline void SetAlpha( int* aColor, int aBlend )
|
||||
{
|
||||
const int MASKALPHA = 0xFF;
|
||||
|
||||
*aColor = (*aColor & ~(MASKALPHA << 24)) | ((aBlend & MASKALPHA) << 24);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function GetAlpha
|
||||
* returns the alpha blend parameter from a color index.
|
||||
*/
|
||||
static inline int GetAlpha( int aColor )
|
||||
{
|
||||
const int MASKALPHA = 0xFF;
|
||||
return (aColor >> 24) & MASKALPHA;
|
||||
}
|
||||
|
||||
|
||||
enum EDA_Colors
|
||||
{
|
||||
|
@ -47,14 +73,19 @@ enum EDA_Colors
|
|||
LASTCOLOR
|
||||
};
|
||||
|
||||
class StructColors
|
||||
|
||||
struct StructColors
|
||||
{
|
||||
public:
|
||||
unsigned char m_Blue, m_Green, m_Red, m_Numcolor;
|
||||
unsigned char m_Blue;
|
||||
unsigned char m_Green;
|
||||
unsigned char m_Red;
|
||||
unsigned char m_Numcolor;
|
||||
|
||||
const wxChar* m_Name;
|
||||
int m_LightColor;
|
||||
};
|
||||
|
||||
|
||||
extern StructColors ColorRefs[NBCOLOR];
|
||||
#ifdef MAIN
|
||||
StructColors ColorRefs[NBCOLOR] =
|
||||
|
@ -87,4 +118,29 @@ StructColors ColorRefs[NBCOLOR] =
|
|||
#endif /* ifdef MAIN */
|
||||
|
||||
|
||||
/**
|
||||
* Function MakeColour
|
||||
* returns a wxWidgets wxColor from a KICAD color index with alpha value.
|
||||
* Note that alpha support is not available on every wxWidgets platform. On
|
||||
* such platform the behavior is the same as for wxALPHA_OPAQUE and that
|
||||
* means the alpha value has no effect and will be ignored. wxGtk 2.8.4 is
|
||||
* not supporting alpha.
|
||||
* @return wxColour - given a KICAD color index with alpha value
|
||||
*/
|
||||
static inline wxColour MakeColour( int aColor )
|
||||
{
|
||||
int alpha = GetAlpha( aColor );
|
||||
|
||||
alpha = alpha ? alpha : wxALPHA_OPAQUE;
|
||||
|
||||
int ndx = aColor & MASKCOLOR;
|
||||
|
||||
return wxColour(
|
||||
ColorRefs[ndx].m_Red,
|
||||
ColorRefs[ndx].m_Green,
|
||||
ColorRefs[ndx].m_Blue,
|
||||
(unsigned char) alpha
|
||||
);
|
||||
}
|
||||
|
||||
#endif /* ifndef _COLORS_H */
|
||||
|
|
|
@ -670,9 +670,12 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
|
|||
else
|
||||
color |= HIGHT_LIGHT_FLAG;
|
||||
}
|
||||
|
||||
if( color & HIGHT_LIGHT_FLAG )
|
||||
color = ColorRefs[color & MASKCOLOR].m_LightColor;
|
||||
|
||||
SetAlpha( &color, 150 );
|
||||
|
||||
zoom = panel->GetZoom();
|
||||
|
||||
l_piste = m_Width >> 1;
|
||||
|
@ -682,6 +685,7 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
|
|||
rayon = l_piste;
|
||||
if( rayon < zoom )
|
||||
rayon = zoom;
|
||||
|
||||
GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, color );
|
||||
if( rayon > (4 * zoom) )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue