mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-06 07:11:10 +00:00
* Ignore Clipper, libpng, mcut and Boost.Polygon Internals in clang-tidy Each only works through a wrapper or umbrella header: libslic3r/clipper.hpp or clipper_z.hpp configure Clipper before including it, png.h pulls in libpng's config headers, and Boost.Polygon's headers only compile through polygon.hpp or voronoi.hpp. * Ignore minilzo's Config Headers in clang-tidy lzoconf.h and lzodefs.h are internal to minilzo.h, which is what the code includes. * Add Missing Includes Across the Remaining Sources and Tests Covers src/slic3r/Utils, src/slic3r/plugin, src/slic3r/Config, src/libvgcode, src/dev-utils, src/OrcaSlicer.cpp and tests/, the directories left after src/slic3r/GUI and src/libslic3r. Generated with clang-tidy misc-include-cleaner. libvgcode's own headers are included by relative path as in the rest of that library, and Catch2 and pybind11 with angle brackets as elsewhere in the repo. * Make the GUI and Test Headers Compile on Their Own Each now includes, or forward-declares, what it uses instead of relying on what its includers happened to include first. Headers that only compile on one platform, or that nothing built includes, are left alone. * Keep Windows and nanosvg Setup Ahead of the Added Includes OrcaSlicer.cpp and several tests set _WIN32_WINNT, WIN32_LEAN_AND_MEAN or NOMINMAX before including Windows.h, and the profile validator defines NANOSVG_IMPLEMENTATION before any libslic3r header. The added includes had landed above those blocks, which broke the Windows build. * Add the GUI Includes the First Pass Missed Covers headers that only became editable once they compiled on their own, and wx symbols whose suggested header changed as the clang-tidy ignore list grew after the src/slic3r/GUI pass. * Keep the Added Test Includes Below the NOMINMAX Guard test_marchingsquares.cpp and test_texture_displacement.cpp had includes inside #ifndef NOMINMAX, which the tests inherit as defined on Windows from libslic3r, so those were skipped there. .clang-tidy also ignores the MSVC STL and UCRT internals, Boost.Multiprecision's fwd.hpp and CPython's Windows include directory, as in #16068.
150 lines
4.1 KiB
C++
150 lines
4.1 KiB
C++
#ifndef slic3r_GUI_Button_hpp_
|
|
#define slic3r_GUI_Button_hpp_
|
|
|
|
#include "../wxExtensions.hpp"
|
|
#include "StaticBox.hpp"
|
|
#include <wx/anybutton.h>
|
|
#include <wx/gdicmn.h>
|
|
#include "slic3r/GUI/Widgets/StateColor.hpp"
|
|
#include <wx/string.h>
|
|
#include <wx/checklst.h>
|
|
#include <wx/event.h>
|
|
#include <wx/dc.h>
|
|
#include <wx/tipwin.h>
|
|
#include <wx/colour.h>
|
|
|
|
class ButtonProps
|
|
{
|
|
public:
|
|
static int ChoiceButtonGap() { return 10; };
|
|
static int WindowButtonGap() { return 10; };
|
|
};
|
|
|
|
enum class ButtonStyle {
|
|
Regular,
|
|
Confirm,
|
|
Alert,
|
|
Disabled,
|
|
};
|
|
|
|
enum class ButtonType {
|
|
Compact, // Font10 FullyRounded For spaces with less areas
|
|
Window, // Font12 FullyRounded For regular buttons in windows and not related with parameter boxes
|
|
Choice, // Font14 Semi-Rounded For dialog/window choice buttons
|
|
Parameter, // Font14 Semi-Rounded For buttons that near parameter boxes
|
|
Icon, // ------ Semi-Rounded For buttons that only has icons. icons should be 16x16 and iconSize has to be defined as 16 while
|
|
// creation of button
|
|
Expanded, // Font14 Semi-Rounded For full length buttons. ex. buttons in static box
|
|
};
|
|
|
|
class Button : public StaticBox
|
|
{
|
|
wxTipWindow::Ref tipWindow;
|
|
wxRect textSize;
|
|
wxSize minSize; // set by outer
|
|
wxSize paddingSize;
|
|
int m_icon_spacing = 5;
|
|
ScalableBitmap active_icon;
|
|
|
|
StateColor text_color;
|
|
|
|
bool pressedDown = false;
|
|
bool m_selected = true;
|
|
bool canFocus = true;
|
|
bool isCenter = true;
|
|
bool vertical = false;
|
|
bool m_show_indicator = false;
|
|
wxColour m_indicator_color = wxColour("#009688");
|
|
|
|
static const int buttonWidth = 200;
|
|
static const int buttonHeight = 50;
|
|
|
|
public:
|
|
Button();
|
|
|
|
Button(wxWindow* parent, wxString text, wxString icon = "", long style = 0, int iconSize = 0, wxWindowID btn_id = wxID_ANY);
|
|
|
|
bool Create(wxWindow* parent, wxString text, wxString icon = "", long style = 0, int iconSize = 0, wxWindowID btn_id = wxID_ANY);
|
|
|
|
void SetLabel(const wxString& label) override;
|
|
|
|
bool SetFont(const wxFont& font) override;
|
|
|
|
void SetIcon(const wxString& icon);
|
|
void SetIcon(const wxBitmap& icon);
|
|
|
|
void SetMinSize(const wxSize& size) override;
|
|
void SetMaxSize(const wxSize& size) override;
|
|
|
|
void SetPaddingSize(const wxSize& size);
|
|
|
|
void SetIconSpacing(int spacing);
|
|
|
|
void SetStyle(const ButtonStyle style /*= ButtonStyle::Regular*/, const ButtonType type /*= ButtonType::None*/);
|
|
|
|
void SetTextColor(StateColor const& color);
|
|
|
|
void SetTextColorNormal(wxColor const& color);
|
|
|
|
void SetSelected(bool selected = true) { m_selected = selected; }
|
|
|
|
// Show a small coloured dot to the right of the label (used by TabCtrl tabs to flag that
|
|
// the tab's category has a selected/toggled setting).
|
|
void SetIndicator(bool on);
|
|
|
|
// Only meant to be used by inspector, not public API
|
|
ButtonStyle GetStyle() const { return m_style; }
|
|
ButtonType GetType() const { return m_type; }
|
|
bool IsSelected() const { return m_selected; }
|
|
|
|
bool Enable(bool enable = true) override;
|
|
void EnableTooltipEvenDisabled(); // The tip will be shown even if the button is disabled
|
|
|
|
void SetCanFocus(bool canFocus) override;
|
|
|
|
void SetValue(bool state);
|
|
|
|
bool GetValue() const;
|
|
|
|
void SetCenter(bool isCenter);
|
|
|
|
void SetVertical(bool vertical = true);
|
|
|
|
void Rescale();
|
|
|
|
protected:
|
|
#ifdef __WIN32__
|
|
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) override;
|
|
#endif
|
|
|
|
bool AcceptsFocus() const override;
|
|
|
|
private:
|
|
bool m_has_style = false;
|
|
ButtonStyle m_style;
|
|
ButtonType m_type;
|
|
|
|
void paintEvent(wxPaintEvent& evt);
|
|
|
|
void render(wxDC& dc);
|
|
|
|
void messureSize();
|
|
|
|
// some useful events
|
|
void mouseDown(wxMouseEvent& event);
|
|
void mouseReleased(wxMouseEvent& event);
|
|
void mouseCaptureLost(wxMouseCaptureLostEvent& event);
|
|
void keyDownUp(wxKeyEvent& event);
|
|
|
|
//
|
|
void sendButtonEvent();
|
|
|
|
// parent motion
|
|
void OnParentMotion(wxMouseEvent& event);
|
|
void OnParentLeave(wxMouseEvent& event);
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
};
|
|
|
|
#endif // !slic3r_GUI_Button_hpp_
|