Audacity 3.2.0
Functions
anonymous_namespace{AColor.cpp} Namespace Reference

Functions

void DrawNinePatch (wxDC &dc, wxBitmap &bitmap, const wxRect &r, int mid=1)
 
int GetButtonImageIndex (bool up, bool selected, bool highlight)
 

Function Documentation

◆ DrawNinePatch()

void anonymous_namespace{AColor.cpp}::DrawNinePatch ( wxDC &  dc,
wxBitmap &  bitmap,
const wxRect &  r,
int  mid = 1 
)

Definition at line 82 of file AColor.cpp.

83 {
84 assert(bitmap.GetWidth() == mid + (bitmap.GetWidth() - mid) / 2 + (bitmap.GetWidth() - mid) / 2);
85 assert(bitmap.GetHeight() == mid + (bitmap.GetHeight() - mid) / 2 + (bitmap.GetHeight() - mid) / 2);
86 assert(r.width >= bitmap.GetWidth() - mid);
87 assert(r.height >= bitmap.GetHeight() - mid);
88 wxMemoryDC memDC;
89 memDC.SelectObject(bitmap);
90
91 // image slices
92
93 const auto uw0 = (bitmap.GetWidth() - mid) / 2;
94 const auto uw1 = mid;
95 const auto uw2 = bitmap.GetWidth() - uw0 - uw1;
96
97 const auto vh0 = (bitmap.GetHeight() - mid) / 2;
98 const auto vh1 = mid;
99 const auto vh2 = bitmap.GetHeight() - vh1 - vh0;
100
101 const auto u0 = 0;
102 const auto u1 = uw0;
103 const auto u2 = uw0 + uw1;
104
105 const auto v0 = 0;
106 const auto v1 = vh0;
107 const auto v2 = vh0 + vh1;
108
109 //Button geometry
110
111 const auto xw0 = std::min(uw0, r.width / 2);
112 const auto xw2 = std::min(uw2, r.width / 2);
113 const auto xw1 = std::max(r.width - xw0 - xw2, 0);
114
115 const auto yh0 = std::min(vh0, r.height / 2);
116 const auto yh2 = std::min(vh2, r.height / 2);
117 const auto yh1 = std::max(r.height - yh0 - yh2, 0);
118
119 const auto x0 = r.x;
120 const auto x1 = r.x + xw0;
121 const auto x2 = r.x + xw0 + xw1;
122
123 const auto y0 = r.y;
124 const auto y1 = r.y + yh0;
125 const auto y2 = r.y + yh0 + yh1;
126
127 //Draw corners
128 dc.StretchBlit(x0, y0, xw0, yh0, &memDC, u0, v0, uw0, vh0, wxCOPY, true);
129 dc.StretchBlit(x2, y0, xw2, yh0, &memDC, u2, v0, uw2, vh0, wxCOPY, true);
130 dc.StretchBlit(x0, y2, xw0, yh2, &memDC, u0, v2, uw0, vh2, wxCOPY, true);
131 dc.StretchBlit(x2, y2, xw2, yh2, &memDC, u2, v2, uw2, vh2, wxCOPY, true);
132
133 if(xw1 > 0 && yh1 > 0)//Draw middle
134 {
135 dc.StretchBlit(x1, y0, xw1, yh0, &memDC, u1, v0, uw1, vh0, wxCOPY, true);
136
137 dc.StretchBlit(x0, y1, xw0, yh1, &memDC, u0, v1, uw0, vh1, wxCOPY, true);
138 dc.StretchBlit(x1, y1, xw1, yh1, &memDC, u1, v1, uw1, vh1, wxCOPY, true);
139 dc.StretchBlit(x2, y1, xw2, yh1, &memDC, u2, v1, uw2, vh1, wxCOPY, true);
140
141 dc.StretchBlit(x1, y2, xw1, yh2, &memDC, u1, v2, uw1, vh2, wxCOPY, true);
142 }
143 }
int min(int a, int b)

References min().

Referenced by AColor::ButtonStretch(), and AColor::DrawFrame().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetButtonImageIndex()

int anonymous_namespace{AColor.cpp}::GetButtonImageIndex ( bool  up,
bool  selected,
bool  highlight 
)

Definition at line 145 of file AColor.cpp.

146 {
147 // There are eight button states in the TCP.
148 // A theme might not differentiate among them all. That's up to
149 // the theme designer.
150 // Button highlighted (i.e. hovered over) or not.
151 // Track selected or not
152 // Button up or down.
153 // Highlight in most themes is lighter than not highlighted.
154 if ( highlight && selected)
155 return up ? bmpHiliteUpButtonExpandSel : bmpHiliteButtonExpandSel;
156 if ( highlight )
157 return up ? bmpHiliteUpButtonExpand : bmpHiliteButtonExpand;
158 if( selected )
159 return up ? bmpUpButtonExpandSel : bmpDownButtonExpandSel;
160 return up ? bmpUpButtonExpand : bmpDownButtonExpand;
161 }

Referenced by AColor::Bevel2(), and AColor::ButtonStretch().

Here is the caller graph for this function: