OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
BBLTopbarArt Class Reference
Inheritance diagram for BBLTopbarArt:
Collaboration diagram for BBLTopbarArt:

Public Member Functions

virtual void DrawBackground (wxDC &dc, wxWindow *wnd, const wxRect &rect) wxOVERRIDE
virtual void DrawButton (wxDC &dc, wxWindow *wnd, const wxAuiToolBarItem &item, const wxRect &rect) wxOVERRIDE

Detailed Description

Member Function Documentation

◆ DrawBackground()

void BBLTopbarArt::DrawBackground ( wxDC & dc,
wxWindow * wnd,
const wxRect & rect )
virtual
121{
122 dc.SetBrush(wxBrush(wxColour(38, 46, 48)));
123 wxRect clipRect = rect;
124 clipRect.y -= 8;
125 clipRect.height += 8;
126 dc.SetClippingRegion(clipRect);
127 dc.DrawRectangle(rect);
128 dc.DestroyClippingRegion();
129}

◆ DrawButton()

void BBLTopbarArt::DrawButton ( wxDC & dc,
wxWindow * wnd,
const wxAuiToolBarItem & item,
const wxRect & rect )
virtual
132{
133 int textWidth = 0, textHeight = 0;
134 wxFontMetrics fm;
135
136 if (m_flags & wxAUI_TB_TEXT)
137 {
138 dc.SetFont(m_font);
139 fm = dc.GetFontMetrics();
140 textHeight = fm.ascent + fm.descent;
141 dc.GetTextExtent(item.GetLabel(), &textWidth, nullptr);
142 }
143
144 int bmpX = 0, bmpY = 0;
145 int textX = 0, textY = 0;
146
147 // ORCA resolves the toolbar item bitmap using the actual window DPI context used for painting.
148 // GetBitmap() / GetDisabledBitmap() was using internal window pointer (m_window), not the paint-time wnd
149 // m_window was created before final DPI context was known so items not scales properly
150 const wxBitmap bmp = item.GetCurrentBitmapFor(wnd);
151
152 const wxSize bmpSize = bmp.IsOk() ? bmp.GetScaledSize() : wxSize(0, 0);
153
154 if (m_textOrientation == wxAUI_TBTOOL_TEXT_BOTTOM)
155 {
156 bmpX = rect.x +
157 (rect.width / 2) -
158 (bmpSize.x / 2);
159
160 bmpY = rect.y +
161 ((rect.height - textHeight) / 2) -
162 (bmpSize.y / 2);
163
164 textX = rect.x + (rect.width / 2) - (textWidth / 2) + 1;
165 textY = rect.y + rect.height - textHeight - 1;
166 }
167 else if (m_textOrientation == wxAUI_TBTOOL_TEXT_RIGHT)
168 {
169 bmpX = rect.x + wnd->FromDIP(3);
170
171 bmpY = rect.y +
172 (rect.height / 2) -
173 (bmpSize.y / 2);
174
175 textX = bmpX + wnd->FromDIP(3) + bmpSize.x;
176 textY = bmpY + bmpSize.y / 2 - textHeight / 2 - fm.externalLeading + 1;
177 }
178
179
180 if (!(item.GetState() & wxAUI_BUTTON_STATE_DISABLED))
181 {
182 if (item.GetState() & wxAUI_BUTTON_STATE_PRESSED)
183 {
184 dc.SetPen(wxPen(StateColor::darkModeColorFor("#009688"))); // ORCA
185 dc.SetBrush(wxBrush(StateColor::darkModeColorFor("#009688"))); // ORCA
186 dc.DrawRectangle(rect);
187 }
188 else if ((item.GetState() & wxAUI_BUTTON_STATE_HOVER) || item.IsSticky())
189 {
190 dc.SetPen(wxPen(StateColor::darkModeColorFor("#009688"))); // ORCA
191 dc.SetBrush(wxBrush(StateColor::darkModeColorFor("#009688"))); // ORCA
192
193 // draw an even lighter background for checked item hovers (since
194 // the hover background is the same color as the check background)
195 if (item.GetState() & wxAUI_BUTTON_STATE_CHECKED)
196 dc.SetBrush(wxBrush(StateColor::darkModeColorFor("#009688"))); // ORCA
197
198 dc.DrawRectangle(rect);
199 }
200 else if (item.GetState() & wxAUI_BUTTON_STATE_CHECKED)
201 {
202 // it's important to put this code in an else statement after the
203 // hover, otherwise hovers won't draw properly for checked items
204 dc.SetPen(wxPen(StateColor::darkModeColorFor("#009688"))); // ORCA
205 dc.SetBrush(wxBrush(StateColor::darkModeColorFor("#009688"))); // ORCA
206 dc.DrawRectangle(rect);
207 }
208 }
209
210 if (bmp.IsOk())
211 dc.DrawBitmap(bmp, bmpX, bmpY, true);
212
213 // set the item's text color based on if it is disabled
214#ifdef __WINDOWS__
215 dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
216#else
217 dc.SetTextForeground(*wxWHITE);
218#endif
219 if (item.GetState() & wxAUI_BUTTON_STATE_DISABLED)
220 {
221 dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
222 }
223
224 if ((m_flags & wxAUI_TB_TEXT) && !item.GetLabel().empty())
225 {
226 dc.DrawText(item.GetLabel(), textX, textY);
227 }
228}
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219

References StateColor::darkModeColorFor().

Here is the call graph for this function:

The documentation for this class was generated from the following file:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/BBLTopbar.cpp