Skip to content

Commit c87ace3

Browse files
authored
Merge pull request #54 from beyluta/development
Development
2 parents 9f211c3 + e0d72fa commit c87ace3

21 files changed

Lines changed: 532 additions & 53 deletions

‎Assets/Templates/calculator.html‎

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
<!-- Sample HTML Template made for the Open-Source software WinWidgets -->
2+
<style>
3+
@import url("https://fonts.googleapis.com/css2?family=Jaldi&display=swap");
4+
5+
body,
6+
html {
7+
background: rgb(19, 19, 19);
8+
display: flex;
9+
justify-content: center;
10+
align-items: center;
11+
font-family: Jaldi, sans-serif, monospace;
12+
overflow: hidden;
13+
user-select: none;
14+
-moz-user-select: none;
15+
}
16+
17+
.calculator-body {
18+
display: flex;
19+
flex-direction: column;
20+
gap: 8px;
21+
width: 360px;
22+
z-index: 1;
23+
font-weight: semibold;
24+
}
25+
26+
.buttons {
27+
display: flex;
28+
flex-direction: row;
29+
gap: 8px;
30+
}
31+
32+
.button {
33+
display: flex;
34+
justify-content: center;
35+
align-items: center;
36+
background: black;
37+
opacity: 0.8;
38+
color: white;
39+
padding: 10px 0;
40+
width: 0.5rem;
41+
border-radius: 10px;
42+
flex: 1 1 10px;
43+
transition: background-color 0.1s ease-in-out, border 0.1s ease-in-out;
44+
cursor: pointer;
45+
border: 1px solid black;
46+
}
47+
48+
.button:hover {
49+
background-color: rgb(19, 19, 19);
50+
border: 1px solid rgb(209, 67, 15);
51+
}
52+
53+
.display {
54+
background: black;
55+
opacity: 0.8;
56+
color: white;
57+
width: 100%;
58+
padding: 20px;
59+
border-radius: 10px;
60+
min-height: 20px;
61+
display: flex;
62+
align-items: center;
63+
}
64+
65+
.equals {
66+
background: rgb(209, 67, 15);
67+
}
68+
</style>
69+
70+
<script>
71+
var isMouseOverDOM = false;
72+
73+
var keyPressTime = new Date();
74+
75+
var toExec = " ";
76+
77+
var expressionRegistry = {
78+
"tan(":"Math.tan(",
79+
"sin(":"Math.sin(",
80+
"cos(":"Math.cos(",
81+
"deg":"*Math.PI/180",
82+
"ln(":"Math.log(",
83+
"lg(":"Math.log10(",
84+
"^":"**",
85+
"°":"*Math.PI*180",
86+
"rad":"*180/Math.PI",
87+
"e":"Math.E",
88+
"π":"Math.PI",
89+
"abs(":"Math.abs(",
90+
"^3":"**3",
91+
"^-1":"**-1",
92+
"√(":"Math.sqrt(",
93+
"%":"/100"
94+
};
95+
96+
document.addEventListener('mouseover', () => isMouseOverDOM = true);
97+
98+
document.addEventListener('mouseout', () => isMouseOverDOM = false);
99+
100+
function onClear() {
101+
document.getElementById("calculation").innerText = "";
102+
toExec = "";
103+
document.getElementById("toExec").innerText = toExec;
104+
}
105+
106+
function onEqualsClicked() {
107+
const calc = document.getElementById("calculation");
108+
calc.innerText = eval(toExec);
109+
toExec = calc.innerText;
110+
}
111+
112+
function onButtonClicked(e) {
113+
document.getElementById("calculation").innerText += e;
114+
toExec += e;
115+
//document.getElementById("toExec").innerText = toExec;
116+
}
117+
118+
function onSpecialClicked(e){
119+
document.getElementById("calculation").innerText += e;
120+
toExec += expressionRegistry[e];
121+
//document.getElementById("toExec").innerText = toExec;
122+
}
123+
124+
function onNativeKeyEvents(key) {
125+
/*
126+
** 1- Checking if the input type is a keyboard event
127+
** 2- Checking if the time between the last key press and the current one is greater than 150ms
128+
** 3- Checking if the mouse is over the DOM
129+
*/
130+
if (key.eventType == "keyboardEvent" && (new Date() - keyPressTime) > 150 && isMouseOverDOM) {
131+
//Getting the key code
132+
var code = parseInt(key.keycode);
133+
// Just input validation
134+
if ((code >= 40 && code <= 43)||(code >= 47 && code <= 57)) {
135+
const char = String.fromCharCode(parseInt(key.keycode));
136+
keyPressTime = new Date();
137+
onButtonClicked(char);
138+
}
139+
}
140+
}
141+
142+
143+
144+
</script>
145+
146+
<!DOCTYPE html>
147+
<html>
148+
<head>
149+
<meta name="applicationTitle" content="Calculator" />
150+
<meta name="windowSize" content="450 500" />x
151+
<meta name="windowBorderRadius" content="10" />
152+
<meta name="previewSize" content="450 400" />
153+
<meta name="windowOpacity" content="240" />
154+
</head>
155+
<body>
156+
<div class="calculator-body">
157+
<div class="display" id="calculation"></div>
158+
<div class="buttons">
159+
<div class="button" onclick="onSpecialClicked('abs(')">abs</div>
160+
<div class="button" onclick="onSpecialClicked('^3')">^3</div>
161+
<div class="button" onclick="onSpecialClicked('^-1')">^-1</div>
162+
<div class="button" onclick="onSpecialClicked('√(')">√</div>
163+
<div class="button" onclick="onSpecialClicked('^2')">x^2</div>
164+
<div class="button" onclick="onSpecialClicked('^')">^x</sup></div>
165+
</div>
166+
<div class="buttons">
167+
<div class="button" onclick="onSpecialClicked('lg(')">lg</div>
168+
<div class="button" onclick="onSpecialClicked('ln(')">ln</div>
169+
<div class="button" onclick="onSpecialClicked('sin(')">sin</div>
170+
<div class="button" onclick="onSpecialClicked('cos(')">cos</div>
171+
<div class="button" onclick="onSpecialClicked('tan(')">tan</div>
172+
<div class="button" onclick="onSpecialClicked('°')">°</div>
173+
</div>
174+
<div class="buttons">
175+
<div class="button" onclick="onSpecialClicked('asin(')">asin</div>
176+
<div class="button" onclick="onSpecialClicked('acos(')">acos</div>
177+
<div class="button" onclick="onSpecialClicked('atan(')">atan</div>
178+
<div class="button" onclick="onButtonClicked('(')">(</div>
179+
<div class="button" onclick="onButtonClicked(')')">)</div>
180+
<div class="button" onclick="onSpecialClicked('rad')">rad</div>
181+
</div>
182+
<div class="buttons">
183+
<div class="button" onclick="onButtonClicked('7')">7</div>
184+
<div class="button" onclick="onButtonClicked('8')">8</div>
185+
<div class="button" onclick="onButtonClicked('9')">9</div>
186+
<div class="button" onclick="onSpecialClicked('%')">%</div>
187+
<div class="button" onclick="onClear()">C</div>
188+
</div>
189+
<div class="buttons">
190+
<div class="button" onclick="onButtonClicked('4')">4</div>
191+
<div class="button" onclick="onButtonClicked('5')">5</div>
192+
<div class="button" onclick="onButtonClicked('6')">6</div>
193+
<div class="button" onclick="onButtonClicked('*')">*</div>
194+
<div class="button" onclick="onButtonClicked('/')">/</div>
195+
</div>
196+
<div class="buttons">
197+
<div class="button" onclick="onButtonClicked('1')">1</div>
198+
<div class="button" onclick="onButtonClicked('2')">2</div>
199+
<div class="button" onclick="onButtonClicked('3')">3</div>
200+
<div class="button" onclick="onButtonClicked('+')">+</div>
201+
<div class="button" onclick="onButtonClicked('-')">-</div>
202+
</div>
203+
<div class="buttons">
204+
<div class="button" onclick="onButtonClicked('0')">0</div>
205+
<div class="button" onclick="onButtonClicked('.')">.</div>
206+
<div class="button" onclick="onButtonClicked('π')">π</div>
207+
<div class="button" onclick="onButtonClicked('e')">e</div>
208+
<div class="button equals" onclick="onEqualsClicked()">=</div>
209+
</div>
210+
</div>
211+
</body>
212+
</html>

‎Assets/index.html‎

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,18 @@ <h3>Application</h3>
110110
<div class="setting flex-row">
111111
<div
112112
class="switch flex-row"
113-
onclick="changeStartup(this)"
113+
onclick="setOptionState(this)"
114114
setting="startup"
115115
>
116116
<div class="circle"></div>
117117
</div>
118-
<p>Run the application on startup</p>
118+
<p>Run the Application on Startup</p>
119119
</div>
120120

121121
<div class="setting flex-row">
122122
<div
123123
class="switch flex-row"
124-
onclick="changeStartupWidgets(this)"
124+
onclick="setOptionState(this)"
125125
setting="widgetStartup"
126126
>
127127
<div class="circle"></div>
@@ -136,6 +136,45 @@ <h3>Application</h3>
136136
Run Widgets on Startup
137137
</p>
138138
</div>
139+
140+
<div class="setting flex-row">
141+
<div
142+
class="switch flex-row"
143+
onclick="setOptionState(this)"
144+
setting="managerHideOnStart"
145+
>
146+
<div class="circle"></div>
147+
</div>
148+
<p class="hideWidgetManagerOnStart">
149+
<svg
150+
xmlns="http://www.w3.org/2000/svg"
151+
height="1em"
152+
viewBox="0 0 512 512"
153+
>
154+
<path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>
155+
Hide Widget-Manager when WinWidgets starts
156+
</p>
157+
</div>
158+
159+
<div class="setting flex-row">
160+
<div
161+
class="switch flex-row"
162+
onclick="setOptionState(this)"
163+
setting="widgetHideOnFullscreenApplication"
164+
>
165+
<div class="circle"></div>
166+
</div>
167+
<p class="hideWidgetsOnFullscreenApplication">
168+
<svg
169+
xmlns="http://www.w3.org/2000/svg"
170+
height="1em"
171+
viewBox="0 0 512 512"
172+
>
173+
<path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>
174+
175+
Close Widgets when other Application is in Fullscreen
176+
</p>
177+
</div>
139178
</div>
140179
</div>
141180

‎Assets/script.js‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,11 @@ function setSwitchState(element) {
7272
}
7373
}
7474

75-
function changeStartup(element) {
75+
function setOptionState(element) {
7676
setSwitchState(element);
7777
CefSharp.PostMessage(element.getAttribute("setting"));
7878
}
7979

80-
function changeStartupWidgets(element) {
81-
setSwitchState(element);
82-
CefSharp.PostMessage(element.getAttribute("setting"));
83-
}
84-
8580
window.onload = () => {
8681
const searchWidget = document.getElementById("searchwidget");
8782

‎Assets/style.css‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,39 @@ svg {
281281
position: absolute;
282282
bottom: 0;
283283
left: 0;
284+
z-index: 999;
285+
}
286+
287+
.setting > .hideWidgetsOnFullscreenApplication:hover::after {
288+
content: "Widgets will be closed to save computer resources. They will be reopened when the fullscreen application is closed.";
289+
color: white;
290+
padding: 8px 10px;
291+
width: max-content;
292+
max-width: 400px;
293+
border-radius: 4px;
294+
transform: translateY(90px);
295+
background: var(--black);
296+
display: block;
297+
position: absolute;
298+
bottom: 0;
299+
left: 0;
300+
z-index: 999;
301+
}
302+
303+
.setting > .hideWidgetManagerOnStart:hover::after {
304+
content: "The main Widget-Manager window will be hidden by default when the application starts.";
305+
color: white;
306+
padding: 8px 10px;
307+
width: max-content;
308+
max-width: 400px;
309+
border-radius: 4px;
310+
transform: translateY(70px);
311+
background: var(--black);
312+
display: block;
313+
position: absolute;
314+
bottom: 0;
315+
left: 0;
316+
z-index: 999;
284317
}
285318

286319
.switch {

‎CONTRIBUTORS.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
Beyluta | <beyluta1@gmail.com> - <https://pedroribeiro.site> - <https://github.com/beyluta>
99
mateuszstalmach | <https://github.com/mateuszstalmach>
1010
EPICTROLLTOAST | <https://github.com/EPICTROLLTOAST>
11+
Yopai | <https://github.com/Yopai>

‎Components/MenuHandler.Component.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public MenuHandlerComponent(WidgetComponent widget)
1818
public void OnBeforeContextMenu(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
1919
{
2020
this.menuHandlerService.ClearModel(model);
21-
this.menuHandlerService.AddOption("Toggle Move", 0, model);
22-
this.menuHandlerService.AddOption("Toggle Always on Top", 1, model);
23-
this.menuHandlerService.AddOption("Close Widget", 2, model);
21+
this.menuHandlerService.AddOption("Move", 0, false, model);
22+
this.menuHandlerService.AddOption("Always on Top", 1, widgetComponent.window.TopMost, model);
23+
this.menuHandlerService.AddOption("Close Widget", 2, false, model);
2424
}
2525

2626
public bool OnContextMenuCommand(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags)

0 commit comments

Comments
 (0)