-
Notifications
You must be signed in to change notification settings - Fork 15
Themes support for components #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
4a5d8a5
Allow ReferenceCountedObject to send around const pointers
kunitoki 0132fa1
Allow fonts to be constructed without a rive::Factory
kunitoki af88187
Add ApplicationThheme and initial theme (v1)
kunitoki 94b5835
Code formatting
yup-bot bbd4d38
Fix ide grouping
kunitoki d58539d
Code formatting
yup-bot 27f9450
Fix formatting
kunitoki e4822d4
Code formatting
yup-bot 2d7bb67
Fix formatted comment tricking the clang formatter
kunitoki c06f8c3
Code formatting
yup-bot 929aa2d
Added tests
kunitoki 25e8fc3
Get rid of formatting issues
kunitoki 157d810
Code formatting
yup-bot 24cfc18
Allow using Identifier in std::unordered_map
kunitoki e34cc87
Allow components to work with colors
kunitoki 0e20445
Code formatting
yup-bot 7ddfdce
Avoid getting crazy with clang format
kunitoki cfeac25
Code formatting
yup-bot 53a1104
Code formatting
kunitoki 1c29716
Code formatting
yup-bot 3ee53ea
Merge branch 'main' into dev/themes
kunitoki e449cb0
Code formatting
yup-bot 4bb408e
Merge branch 'main' into dev/themes
kunitoki 24005e2
Code formatting
yup-bot c7883ea
Merge branch 'main' into dev/themes
kunitoki c006fca
Code formatting
yup-bot 0a045a9
More themes work
kunitoki 2a5d42f
Code formatting
yup-bot d494894
Merge branch 'main' into dev/themes
kunitoki 133f1db
Merge branch 'main' into dev/themes
kunitoki f233cdd
Merge branch 'main' into dev/themes
kunitoki d36d4ca
Code formatting
yup-bot 74b7302
Missing includes in cmake (bad merge?)
kunitoki bebb29b
Merge issue
kunitoki 4cf38f7
Fix theming
kunitoki 9b75e53
Remove stuff
kunitoki eea58ab
Merge branch 'main' into dev/themes
kunitoki f53053f
Fix issue
kunitoki 4c6c1ef
More fixes
kunitoki 940e289
Merge branch 'main' into dev/themes
kunitoki 8dbf7b9
Code formatting
yup-bot a1baf14
Merge branch 'main' into dev/themes
kunitoki f99d6df
Fix building themes
kunitoki 0ace69b
Fixes
kunitoki 58e1177
Code formatting
yup-bot 6e64abe
More work on component styles
kunitoki cbe581e
More tweaks
kunitoki eb86e61
Cosmetics
kunitoki d9543ae
Code formatting
yup-bot a6d4e8e
Move to roboto flex
kunitoki 731509f
Fix issue
kunitoki c00ab8f
Add more tests
kunitoki bae5faa
More fixes
kunitoki 610f34b
Code formatting
yup-bot fade381
Fix compilation on windows
kunitoki f79a600
More doxygen
kunitoki e2d44cb
More doxygen
kunitoki 5f538cf
Code formatting
yup-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| /* | ||
| ============================================================================== | ||
|
|
||
| This file is part of the YUP library. | ||
| Copyright (c) 2024 - [email protected] | ||
|
|
||
| YUP is an open source library subject to open-source licensing. | ||
|
|
||
| The code included in this file is provided under the terms of the ISC license | ||
| http://www.isc.org/downloads/software-support-policy/isc-license. Permission | ||
| to use, copy, modify, and/or distribute this software for any purpose with or | ||
| without fee is hereby granted provided that the above copyright notice and | ||
| this permission notice appear in all copies. | ||
|
|
||
| YUP IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER | ||
| EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE | ||
| DISCLAIMED. | ||
|
|
||
| ============================================================================== | ||
| */ | ||
|
|
||
| namespace yup | ||
| { | ||
|
|
||
| //============================================================================== | ||
|
|
||
| extern const uint8_t RobotoRegularFont_data[]; | ||
| extern const std::size_t RobotoRegularFont_size; | ||
|
|
||
| //============================================================================== | ||
|
|
||
| ApplicationTheme::Ptr createThemeVersion1() | ||
| { | ||
| auto theme = new ApplicationTheme; | ||
|
|
||
| Font font; | ||
| if (auto result = font.loadFromData (MemoryBlock (&RobotoRegularFont_data[0], RobotoRegularFont_size)); result.failed()) | ||
| yup::Logger::outputDebugString (result.getErrorMessage()); | ||
|
|
||
| theme->setDefaultFont (std::move (font)); | ||
|
|
||
| theme->setComponentTheme<Slider::Theme> ({ [theme] (Graphics& g, const Slider& s) | ||
| { | ||
| auto bounds = s.getLocalBounds().reduced (s.proportionOfWidth (0.1f)); | ||
| const auto center = bounds.getCenter(); | ||
|
|
||
| constexpr auto fromRadians = degreesToRadians (135.0f); | ||
| constexpr auto toRadians = fromRadians + degreesToRadians (270.0f); | ||
|
|
||
| Path backgroundPath; | ||
| backgroundPath.addEllipse (bounds.reduced (s.proportionOfWidth (0.105f))); | ||
|
|
||
| g.setFillColor (Color (0xff3d3d3d)); | ||
| g.fillPath (backgroundPath); | ||
|
|
||
| g.setStrokeColor (Color (0xff2b2b2b)); | ||
| g.setStrokeWidth (s.proportionOfWidth (0.0175f)); | ||
| g.strokePath (backgroundPath); | ||
|
|
||
| Path backgroundArc; | ||
| backgroundArc.addCenteredArc (center, | ||
| bounds.getWidth() / 2.0f, | ||
| bounds.getHeight() / 2.0f, | ||
| 0.0f, | ||
| fromRadians, | ||
| toRadians, | ||
| true); | ||
|
|
||
| g.setStrokeCap (StrokeCap::Round); | ||
| g.setStrokeColor (Color (0xff636363)); | ||
| g.setStrokeWidth (s.proportionOfWidth (0.075f)); | ||
| g.strokePath (backgroundArc); | ||
|
|
||
| const auto toCurrentRadians = fromRadians + degreesToRadians (270.0f) * s.getValue(); | ||
|
|
||
| Path foregroundArc; | ||
| foregroundArc.addCenteredArc (center, | ||
| bounds.getWidth() / 2.0f, | ||
| bounds.getHeight() / 2.0f, | ||
| 0.0f, | ||
| fromRadians, | ||
| toCurrentRadians, | ||
| true); | ||
|
|
||
| g.setStrokeCap (StrokeCap::Round); | ||
| g.setStrokeColor (s.isMouseOver() ? Color (0xff4ebfff).brighter (0.3f) : Color (0xff4ebfff)); | ||
| g.setStrokeWidth (s.proportionOfWidth (0.075f)); | ||
| g.strokePath (foregroundArc); | ||
|
|
||
| const auto reducedBounds = bounds.reduced (s.proportionOfWidth (0.175f)); | ||
| const auto pos = center.getPointOnCircumference ( | ||
| reducedBounds.getWidth() / 2.0f, | ||
| reducedBounds.getHeight() / 2.0f, | ||
| toCurrentRadians); | ||
|
|
||
| Path foregroundLine; | ||
| foregroundLine.addLine (Line<float> (pos, center).keepOnlyStart (0.25f)); | ||
|
|
||
| g.setStrokeCap (StrokeCap::Round); | ||
| g.setStrokeColor (Color (0xffffffff)); | ||
| g.setStrokeWidth (s.proportionOfWidth (0.03f)); | ||
| g.strokePath (foregroundLine); | ||
|
|
||
| StyledText text; | ||
| text.appendText (theme->getDefaultFont(), s.proportionOfHeight (0.1f), s.proportionOfHeight (0.1f), String (s.getValue(), 3).toRawUTF8()); | ||
| text.layout (s.getLocalBounds().reduced (5).removeFromBottom (s.proportionOfWidth (0.1f)), StyledText::center); | ||
|
|
||
| g.setStrokeColor (Color (0xffffffff)); | ||
| g.strokeFittedText (text, s.getLocalBounds().reduced (5).removeFromBottom (s.proportionOfWidth (0.1f))); | ||
|
|
||
| if (s.hasFocus()) | ||
| { | ||
| g.setStrokeColor (Color (0xffff5f2b)); | ||
| g.setStrokeWidth (s.proportionOfWidth (0.0175f)); | ||
| g.strokeRect (s.getLocalBounds()); | ||
| } | ||
| } }); | ||
|
|
||
| return theme; | ||
| } | ||
|
|
||
| } // namespace yup | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /* | ||
| ============================================================================== | ||
|
|
||
| This file is part of the YUP library. | ||
| Copyright (c) 2024 - [email protected] | ||
|
|
||
| YUP is an open source library subject to open-source licensing. | ||
|
|
||
| The code included in this file is provided under the terms of the ISC license | ||
| http://www.isc.org/downloads/software-support-policy/isc-license. Permission | ||
| to use, copy, modify, and/or distribute this software for any purpose with or | ||
| without fee is hereby granted provided that the above copyright notice and | ||
| this permission notice appear in all copies. | ||
|
|
||
| YUP IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER | ||
| EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE | ||
| DISCLAIMED. | ||
|
|
||
| ============================================================================== | ||
| */ | ||
|
|
||
| namespace yup | ||
| { | ||
|
|
||
| //============================================================================== | ||
|
|
||
| ApplicationTheme::Ptr createThemeVersion1(); | ||
|
|
||
| } // namespace yup |
33 changes: 33 additions & 0 deletions
33
modules/yup_gui/themes/theme_v1/yup_ThemeVersion1_Resources.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| ============================================================================== | ||
|
|
||
| This file is part of the YUP library. | ||
| Copyright (c) 2024 - [email protected] | ||
|
|
||
| YUP is an open source library subject to open-source licensing. | ||
|
|
||
| The code included in this file is provided under the terms of the ISC license | ||
| http://www.isc.org/downloads/software-support-policy/isc-license. Permission | ||
| to use, copy, modify, and/or distribute this software for any purpose with or | ||
| without fee is hereby granted provided that the above copyright notice and | ||
| this permission notice appear in all copies. | ||
|
|
||
| YUP IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER | ||
| EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE | ||
| DISCLAIMED. | ||
|
|
||
| ============================================================================== | ||
| */ | ||
|
|
||
| namespace yup | ||
| { | ||
|
|
||
| //============================================================================== | ||
|
|
||
| const uint8_t RobotoRegularFont_data[] = { | ||
| #include "RobotoRegularFont.inc" | ||
| }; | ||
|
|
||
| const std::size_t RobotoRegularFont_size = sizeof (RobotoRegularFont_data); | ||
|
|
||
| } // namespace yup |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.