MCPcopy Create free account
hub / github.com/ALTaleX531/OpenGlass / BindEvents

Method BindEvents

OpenGlassGUI/MainFrame.Core.cpp:793–1826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

791 }
792
793 void MainFrame::BindEvents()
794 {
795 Bind(wxEVT_CLOSE_WINDOW, &MainFrame::OnClose, this);
796 Bind(wxEVT_CHAR_HOOK, [this](wxKeyEvent& e) {
797 const int keyCode = e.GetKeyCode();
798 if ((e.ControlDown() && (keyCode == 'S' || keyCode == 's')) || keyCode == WXK_F2)
799 {
800 if (m_isDirty)
801 {
802 SaveSettings();
803 return;
804 }
805 e.Skip();
806 return;
807 }
808 if (keyCode == WXK_ESCAPE)
809 {
810 if (m_isDirty)
811 {
812 RevertSettings();
813 return;
814 }
815 e.Skip();
816 return;
817 }
818 e.Skip();
819 });
820
821 auto updateDword = [this](const std::wstring& name, DWORD val, ChangeType type = ChangeType::Both) {
822 RegistryConfig* config = GetConfigForKey(name);
823 if (!config)
824 {
825 return;
826 }
827 TrackSettingChange(name);
828 config->SetDword(name, val);
829 SetDirty(true);
830 NotifySettingsChange(type);
831 };
832 auto blurRadiusToDeviation = [](int radius) -> DWORD {
833 int val = (radius * 10 + 2) / 3;
834 if (val < 0) val = 0;
835 if (val > 100) val = 100;
836 return static_cast<DWORD>(val);
837 };
838 auto blurDeviationToRadius = [](DWORD deviation) -> int {
839 int val = (static_cast<int>(deviation) * 3 + 5) / 10;
840 if (val < 0) val = 0;
841 if (val > 30) val = 30;
842 return val;
843 };
844
845 auto colorToDwordWithAlpha = [](const wxColour& c) -> DWORD {
846 return (c.Alpha() << 24) | (c.Red() << 16) | (c.Green() << 8) | c.Blue();
847 };
848 auto colorToDwordBgr = [](const wxColour& c) -> DWORD {
849 return (c.Red()) | (c.Green() << 8) | (c.Blue() << 16);
850 };

Callers

nothing calls this directly

Calls 7

SetDwordMethod · 0.80
HasValueMethod · 0.80
GetDwordMethod · 0.80
SetStringMethod · 0.80
DeleteValueMethod · 0.80
GetStringMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected