Commit graph

111 commits

Author SHA1 Message Date
sin-ack 3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
redsnout fd641f6f17 Calculator: Replace "Euler's Constant" with "Euler's Number" in menu
This is meant to address #14234 by renaming the "Euler's Constant"
menu item to "Euler's Number". This commit removes the existing
"eulers.png" and replaces with a new "eulers_number.png" for clarity.
2022-06-10 20:03:37 +01:00
Andrew Dykema 8c37e508f2 Calculator: Add Phi constant 2022-06-09 19:17:43 +01:00
Simon Wanner 206d6ece55 LibGfx: Move other font-related files to LibGfx/Font/ 2022-04-09 23:48:18 +02:00
Rob Ryan 0b5adfef8c Calculator: Update mimic_pressed for refactor into the Button class 2022-04-03 12:21:50 +02:00
Idan Horowitz 086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
ForLoveOfCats 697e1810bf Calculator: Add keyboard input for more operations 2022-03-03 22:06:14 +01:00
ForLoveOfCats 19f80f88bf Calculator: Avoid focusing any keypad button other than the equal button
Having the return key sometimes press the equal button when nothing is
focused and press a different button when there is focus felt confusing.

The equal button is still able to be focused for the tab cycle to have
something to go to in order to jump out of the textbox but no other
keypad button can be focused now.
2022-03-03 22:06:14 +01:00
ForLoveOfCats 0d0ba375e2 Calculator: Utilize Button mimic_pressed to show when keys are pressed 2022-03-03 22:06:14 +01:00
Lenny Maiorani 160bda7228 Applications: Use default constructors/destructors
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-02-14 22:06:55 +00:00
electrikmilk adf6be45fb Base+Calculator: Add icons
Adds icons for Pi and Euler's Constant to the Constants menu.
2022-02-13 22:09:18 +01:00
Idan Horowitz c8ab45e79f Userland: Run gml-format
This brings the existing GML files up to spec with the new requirements
2022-02-13 02:36:35 +02:00
Hendiadyoin1 3e135f347f Userland: Use AK::pow<I> where applicable 2022-02-06 17:52:33 +00:00
creator1creeper1 77ad98ab7c Calculator: Propagate errors using try_set_main_widget in main 2022-01-09 00:56:11 +01:00
Lucas CHOLLET 7532ef78ad Calculator: Round small number to prevent crash
Small numbers (smaller than 1e-19) can't be displayed in the calculator.
They provoke a division by zero in Keypad::set_value(), as 10^20
overflows.
2022-01-02 15:42:13 +01:00
Lucas CHOLLET 939bf3e864 Calculator: Remove KeypadValue::operator>
This method was declared but not implemented, and will probably never be
useful.
2022-01-02 15:42:13 +01:00
Lucas CHOLLET eb8df0ae2a Calculator: Display zero with only one character
This patch prevents zero to be displayed as "0.00". The value is now
always printed with only one character.
2022-01-02 15:42:13 +01:00
creator1creeper1 4b2b0a4d0e Calculator: Make double construction and conversion private
At this point, the double conversions should really only be
implementation details of the KeypadValue class. Therefore,
the constructor-from double and conversion-operator-to
double of KeypadValue are made private. Instead, the
required functionality is provided by KeypadValue itself.
The internal implementation is still done using doubles.
However, this opens us up to the possibility of having
loss-free square root, inversion and division in the future.
2021-12-22 00:43:13 -08:00
creator1creeper1 cacac7927b Calculator: Construct KeypadValue precisely from the Clipboard contents
Previously, we would use lossy strtod() conversion. This was bad,
especially since we switched from internally storing Calculator
state in a double to storing it in the KeypadValue class
some time ago. This commit adds a constructor for the KeypadValue
class that is not lossy by using strtoll(). It handles numbers
with and without decimal points as well as negative numbers
correctly.
2021-12-21 13:22:12 -08:00
Brian Gianforcaro cf4fa936be Everywhere: Use default execpromises argument for Core::System::pledge 2021-11-28 08:04:57 +01:00
Andreas Kling 973cb0a49e Calculator: Port to LibMain :^) 2021-11-24 00:25:23 +01:00
Ben Wiederhake f22c0ffe0c LibGUI+Everywhere: Make sync requests to Clipboard server more obvious 2021-11-21 11:49:06 +00:00
Musab Kılıç 8f9948ad66 Calculator: Add Constants menu 2021-10-31 12:10:44 +01:00
Musab Kılıç 2ef8cbe6cf Calculator: Fix copy button not copying the fractional part bug :^) 2021-10-31 12:10:33 +01:00
Musab Kılıç 8936d15efa Calculator: Improve KeypadValue conversion to handle integer values 2021-10-31 12:09:37 +01:00
Scott R. Parish eb368a5000 Calculator: The equal key will now also finish the operation
Prior to this if you typed "1+2=" you would not get the answer, instead
you'd be left with "2" on the screen; Calculator wanted you to hit the
enter key to get the answer. Now you can either use the enter or the
equal key to finish the operation and get the answer.
2021-08-26 17:35:15 +02:00
sin-ack e11d177618 Userland+LibGUI: Add shorthand versions of the Margins constructor
This allows for typing [8] instead of [8, 8, 8, 8] to specify the same
margin on all edges, for example. The constructors follow CSS' style of
specifying margins. The added constructors are:

- Margins(int all): Sets the same margin on all edges.
- Margins(int vertical, int horizontal): Sets the first argument to top
  and bottom margins, and the second argument to left and right margins.
- Margins(int top, int vertical, int bottom): Sets the first argument to
  the top margin, the second argument to the left and right margins,
  and the third argument to the bottom margin.
2021-08-18 10:30:50 +02:00
creator1creeper1 8f552c9979 Calculator: Use KeypadValue class instead of double
Calculator now uses the KeypadValue class instead of double in
its internal calculations. By not constantly converting to
double back-and-forth, we do not use precision simply by, for
example, negating a number. This fixes #7484.
2021-08-03 19:12:06 +04:30
creator1creeper1 97d2a5799e Calculator: Add KeypadValue class
This commit adds a basic KeypadValue class which abstracts away
Keypad's internal representation in a slightly simpler format.
This will allow arithmetic operations in the Calculator to not
lose any precision. In cases where losing precision is necessary,
an explicit conversion operator to double is provided, as well as
an explicit constructor from double.
2021-08-03 19:12:06 +04:30
LuK1337 5fa8a107df Calculator: Add menus before showing the window
Otherwise, space is reserved but menus aren't shown.
2021-07-31 08:08:31 +02:00
FrHun 55c0307288 Calculator: Improve UI margin consistency 2021-07-27 22:17:23 +02:00
Andreas Kling 687a12d7fb Userland: Add GUI::Window::add_menu() and use it everywhere
Applications previously had to create a GUI::Menubar object, add menus
to it, and then call GUI::Window::set_menubar().

This patch introduces GUI::Window::add_menu() which creates the menubar
automatically and adds items to it. Application code becomes slightly
simpler as a result. :^)
2021-07-21 21:24:26 +02:00
Hendiadyoin1 ed46d52252 Everywhere: Use AK/Math.h if applicable
AK's version should see better inlining behaviors, than the LibM one.
We avoid mixed usage for now though.

Also clean up some stale math includes and improper floatingpoint usage.
2021-07-19 16:34:21 +04:30
Gunnar Beutner 3bbe86d8ea Everywhere: Prefer using "..."sv over StringView { "..." } 2021-07-04 14:24:03 +02:00
Gunnar Beutner 631d36fd98 Everywhere: Add component declarations
This adds component declarations so that users can select to not build
certain parts of the OS.
2021-06-17 11:03:51 +02:00
Andreas Kling 3ed6a3fea8 Calculator: Fix offensive button misalignment
The UI of this application is still quite bad/uneven, but this at
least fixes the most egregious button misalignment.
2021-06-13 21:48:15 +02:00
Max Wipfli 6837634f31 Calculator: Remove unused headers 2021-05-23 23:18:54 +01:00
Max Wipfli bb38328d39 Calculator: Fix behavior when entering number starting with decimal
This fixes a bug where entering a number like ".15" would result in "15"
instead of "0.15"
2021-05-23 23:18:54 +01:00
Max Wipfli 7b53ca5309 Calculator: Use Checked to ensure entered values do not overflow
This replaces the types of m_int_value and m_frac_value with
Checked<u64> which makes it possible to check if the value overflowed
when entering a digit. If that happens, the digit will just be ignored.

This fixes #1263.
2021-05-23 23:18:54 +01:00
Max Wipfli 7a5407982f Calculator: Show decimal point immediately when typed 2021-05-23 23:18:54 +01:00
Max Wipfli 2675d25453 Calculator: Handle keydown events correctly with all keyboard layouts
This changes the keydown_event handler to use codepoints instead of key
codes for comparison if possible. This is so the functionality still
works as intended with keyboard layouts where e.g. typing '+' actually
results in KeyCode::Key_ExclamationPoint rather than KeyCode::Key_Plus.

This also removes the unnecessary call to atoi().
2021-05-23 23:18:54 +01:00
Andreas Kling 31d4bcf5bf Userland: Tighten a *lot* of pledges! :^)
Since applications using Core::EventLoop no longer need to create a
socket in /tmp/rpc/, and also don't need to listen for incoming
connections on this socket, we can remove a whole bunch of pledges!
2021-05-13 23:28:40 +02:00
Andreas Kling 4b0098e52f Everywhere: Rename app_menu to file_menu or game_menu 2021-05-01 17:40:54 +02:00
Linus Groh 5459c744f1 Everywhere: Add missing comma between copyright year and name 2021-04-29 00:59:26 +02:00
Brian Gianforcaro 1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling a2baab38fd Everywhere: It's now "Foobar", not "FooBar", and not "foo bar"
I hereby declare these to be full nouns that we don't split,
neither by space, nor by underscore:

- Breadcrumbbar
- Coolbar
- Menubar
- Progressbar
- Scrollbar
- Statusbar
- Taskbar
- Toolbar

This patch makes everything consistent by replacing every other variant
of these with the proper one. :^)
2021-04-13 16:58:15 +02:00
Andreas Kling 5d609e408b Calculator: Alt shortcuts and book title capitalization in menus 2021-04-10 16:09:23 +02:00
Andreas Kling 8e74c9dbb6 Calculator: Add a separator line between the menu and the main UI 2021-04-10 16:08:14 +02:00
Edgar Araújo ca90a2029d Everywhere: Change font properties to be described in GML 2021-03-29 09:10:23 +02:00
Edgar Araújo 243d7d9ecf Everywhere: Remove empty {} from GML objects 2021-03-29 09:10:23 +02:00
Andreas Kling 78b12e1521 Userland: Turn all application menus into window menus :^) 2021-03-25 22:14:09 +01:00
Andreas Kling ef1e5db1d0 Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)
Good-bye LogStream. Long live AK::Format!
2021-03-12 17:29:37 +01:00
Brendan Coles 9bc3c3c962 Calculator: Add support for copy+paste using system clipboard 2021-02-24 22:01:37 +01:00
Andreas Kling 5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
AnotherTest 7c2754c3a6 AK+Kernel+Userland: Enable some more compiletime format string checks
This enables format string checks for three more functions:
- String::formatted()
- Builder::appendff()
- KBufferBuilder::appendff()
2021-02-23 13:59:33 +01:00
Ben Wiederhake 0a2304ba05 Everywhere: Fix weird includes 2021-02-08 18:03:57 +01:00
Linus Groh 6b7c96589b Everywhere: Add missing parent window to about dialogs
Partially addresses #5177.
2021-01-30 13:42:39 +01:00
Linus Groh 5e95a777e0 Calculator: Give the '9' button a blue foreground color as well 2021-01-22 18:40:55 +01:00
Andreas Kling d312011708 Everywhere: Drop "shared_buffer" in most GUI programs, pledge "recvfd"
Now that WindowServer broadcasts the system theme using an anonymous
file, we need clients to pledge "recvfd" so they can receive it.

Some programs keep the "shared_buffer" pledge since it's still used for
a handful of things.
2021-01-16 19:30:32 +01:00
Andreas Kling 20915795a8 Everywhere: Pledge "sendfd" in WindowServer client programs
This is needed for the new way we transfer window backing stores.
2021-01-15 14:10:32 +01:00
Andreas Kling dc28c07fa5 Applications: Move to Userland/Applications/ 2021-01-12 12:05:23 +01:00