mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-12-16 01:48:56 +08:00
235 lines
18 KiB
HTML
235 lines
18 KiB
HTML
|
|
<!-- HTML header for doxygen 1.9.8-->
|
||
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||
|
|
<head>
|
||
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||
|
|
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||
|
|
<meta name="generator" content="Doxygen 1.12.0"/>
|
||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||
|
|
<title>FTXUI: examples/component/linear_gradient_gallery.cpp</title>
|
||
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||
|
|
<script type="text/javascript" src="jquery.js"></script>
|
||
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
||
|
|
<script type="text/javascript" src="doxygen-awesome-fragment-copy-button.js"></script>
|
||
|
|
<script type="text/javascript" src="doxygen-awesome-paragraph-link.js"></script>
|
||
|
|
<script type="text/javascript" src="doxygen-awesome-interactive-toc.js"></script>
|
||
|
|
<script type="text/javascript" src="doxygen-awesome-tabs.js"></script>
|
||
|
|
<script type="text/javascript">
|
||
|
|
DoxygenAwesomeFragmentCopyButton.init()
|
||
|
|
DoxygenAwesomeParagraphLink.init()
|
||
|
|
DoxygenAwesomeInteractiveToc.init()
|
||
|
|
DoxygenAwesomeTabs.init()
|
||
|
|
</script>
|
||
|
|
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||
|
|
<script type="text/javascript" src="navtreedata.js"></script>
|
||
|
|
<script type="text/javascript" src="navtree.js"></script>
|
||
|
|
<script type="text/javascript" src="resize.js"></script>
|
||
|
|
<script type="text/javascript" src="cookie.js"></script>
|
||
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
||
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
||
|
|
<script type="text/javascript" src="search/search.js"></script>
|
||
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||
|
|
<link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
|
||
|
|
<link href="stylesheet.css" rel="stylesheet" type="text/css"/>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||
|
|
<div id="titlearea">
|
||
|
|
<table cellspacing="0" cellpadding="0">
|
||
|
|
<tbody>
|
||
|
|
<tr id="projectrow">
|
||
|
|
<td id="projectalign">
|
||
|
|
<div id="projectname">FTXUI<span id="projectnumber"> 6.1.9</span>
|
||
|
|
</div>
|
||
|
|
<div id="projectbrief">C++ functional terminal UI.</div>
|
||
|
|
</td>
|
||
|
|
</tr>
|
||
|
|
</tbody>
|
||
|
|
</table>
|
||
|
|
</div>
|
||
|
|
<!-- end header part -->
|
||
|
|
<!-- Generated by Doxygen 1.12.0 -->
|
||
|
|
<script type="text/javascript">
|
||
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||
|
|
var searchBox = new SearchBox("searchBox", "search/",'.html');
|
||
|
|
/* @license-end */
|
||
|
|
</script>
|
||
|
|
<script type="text/javascript">
|
||
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||
|
|
$(function() { codefold.init(0); });
|
||
|
|
/* @license-end */
|
||
|
|
</script>
|
||
|
|
<script type="text/javascript" src="menudata.js"></script>
|
||
|
|
<script type="text/javascript" src="menu.js"></script>
|
||
|
|
<script type="text/javascript">
|
||
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||
|
|
$(function() {
|
||
|
|
initMenu('',true,false,'search.php','Search',true);
|
||
|
|
$(function() { init_search(); });
|
||
|
|
});
|
||
|
|
/* @license-end */
|
||
|
|
</script>
|
||
|
|
<div id="main-nav"></div>
|
||
|
|
</div><!-- top -->
|
||
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||
|
|
<div id="nav-tree">
|
||
|
|
<div id="nav-tree-contents">
|
||
|
|
<div id="nav-sync" class="sync"></div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div id="splitbar" style="-moz-user-select:none;"
|
||
|
|
class="ui-resizable-handle">
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<script type="text/javascript">
|
||
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||
|
|
$(function(){initNavTree('examples_2component_2linear_gradient_gallery_8cpp-example.html',''); initResizable(true); });
|
||
|
|
/* @license-end */
|
||
|
|
</script>
|
||
|
|
<div id="doc-content">
|
||
|
|
<!-- window showing the filter options -->
|
||
|
|
<div id="MSearchSelectWindow"
|
||
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
||
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
||
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- iframe showing the search results (closed by default) -->
|
||
|
|
<div id="MSearchResultsWindow">
|
||
|
|
<div id="MSearchResults">
|
||
|
|
<div class="SRPage">
|
||
|
|
<div id="SRIndex">
|
||
|
|
<div id="SRResults"></div>
|
||
|
|
<div class="SRStatus" id="Loading">Loading...</div>
|
||
|
|
<div class="SRStatus" id="Searching">Searching...</div>
|
||
|
|
<div class="SRStatus" id="NoMatches">No Matches</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="header">
|
||
|
|
<div class="headertitle"><div class="title">examples/component/linear_gradient_gallery.cpp</div></div>
|
||
|
|
</div><!--header-->
|
||
|
|
<div class="contents">
|
||
|
|
<h1><a class="anchor" id="autotoc_md182"></a>
|
||
|
|
maybe</h1>
|
||
|
|
<div class="fragment"><div class="line"><span class="comment">// Copyright 2020 Arthur Sonzogni. All rights reserved.</span></div>
|
||
|
|
<div class="line"><span class="comment">// Use of this source code is governed by the MIT license that can be found in</span></div>
|
||
|
|
<div class="line"><span class="comment">// the LICENSE file.</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include <string></span> <span class="comment">// for string, allocator, basic_string</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include <vector></span> <span class="comment">// for vector</span></div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="captured__mouse_8hpp.html">ftxui/component/captured_mouse.hpp</a>"</span> <span class="comment">// for ftxui</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="component_8hpp.html">ftxui/component/component.hpp</a>"</span> <span class="comment">// for operator|, Maybe, Checkbox, Radiobox, Renderer, Vertical</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="component__base_8hpp.html">ftxui/component/component_base.hpp</a>"</span> <span class="comment">// for Component</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="screen__interactive_8hpp.html">ftxui/component/screen_interactive.hpp</a>"</span> <span class="comment">// for ScreenInteractive</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="elements_8hpp.html">ftxui/dom/elements.hpp</a>"</span> <span class="comment">// for Element, border, color, operator|, text</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="color_8hpp.html">ftxui/screen/color.hpp</a>"</span> <span class="comment">// for Color, Color::Red</span></div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"><span class="keyword">using namespace </span><a class="code hl_namespace" href="namespaceftxui.html">ftxui</a>;</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"><span class="keywordtype">int</span> <a id="a0" name="a0"></a><a class="code hl_function" href="examples_2component_2button_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a>() {</div>
|
||
|
|
<div class="line"> std::vector<std::string> entries = {</div>
|
||
|
|
<div class="line"> <span class="stringliteral">"entry 1"</span>,</div>
|
||
|
|
<div class="line"> <span class="stringliteral">"entry 2"</span>,</div>
|
||
|
|
<div class="line"> <span class="stringliteral">"entry 3"</span>,</div>
|
||
|
|
<div class="line"> };</div>
|
||
|
|
<div class="line"> <span class="keywordtype">int</span> menu_1_selected = 0;</div>
|
||
|
|
<div class="line"> <span class="keywordtype">int</span> menu_2_selected = 0;</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> <span class="keywordtype">bool</span> menu_1_show = <span class="keyword">false</span>;</div>
|
||
|
|
<div class="line"> <span class="keywordtype">bool</span> menu_2_show = <span class="keyword">false</span>;</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> <span class="keyword">auto</span> layout = Container::Vertical({</div>
|
||
|
|
<div class="line"> Checkbox(<span class="stringliteral">"Show menu_1"</span>, &menu_1_show),</div>
|
||
|
|
<div class="line"> Radiobox(&entries, &menu_1_selected) | border | Maybe(&menu_1_show),</div>
|
||
|
|
<div class="line"> Checkbox(<span class="stringliteral">"Show menu_2"</span>, &menu_2_show),</div>
|
||
|
|
<div class="line"> Radiobox(&entries, &menu_2_selected) | border | Maybe(&menu_2_show),</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> Renderer([] {</div>
|
||
|
|
<div class="line"> <span class="keywordflow">return</span> text(<span class="stringliteral">"You found the secret combinaison!"</span>) | color(Color::Red);</div>
|
||
|
|
<div class="line"> }) | Maybe([&] { <span class="keywordflow">return</span> menu_1_selected == 1 && menu_2_selected == 2; }),</div>
|
||
|
|
<div class="line"> });</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> <span class="keyword">auto</span> screen = ScreenInteractive::TerminalOutput();</div>
|
||
|
|
<div class="line"> screen.Loop(layout);</div>
|
||
|
|
<div class="line">}</div>
|
||
|
|
<div class="ttc" id="acaptured__mouse_8hpp_html"><div class="ttname"><a href="captured__mouse_8hpp.html">captured_mouse.hpp</a></div></div>
|
||
|
|
<div class="ttc" id="acolor_8hpp_html"><div class="ttname"><a href="color_8hpp.html">color.hpp</a></div></div>
|
||
|
|
<div class="ttc" id="acomponent_8hpp_html"><div class="ttname"><a href="component_8hpp.html">component.hpp</a></div></div>
|
||
|
|
<div class="ttc" id="acomponent__base_8hpp_html"><div class="ttname"><a href="component__base_8hpp.html">component_base.hpp</a></div></div>
|
||
|
|
<div class="ttc" id="aelements_8hpp_html"><div class="ttname"><a href="elements_8hpp.html">elements.hpp</a></div></div>
|
||
|
|
<div class="ttc" id="aexamples_2component_2button_8cpp_html_ae66f6b31b5ad750f1fe042a706a4e3d4"><div class="ttname"><a href="examples_2component_2button_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a></div><div class="ttdeci">int main()</div><div class="ttdef"><b>Definition</b> <a href="examples_2component_2button_8cpp_source.html#l00004">examples/component/button.cpp:4</a></div></div>
|
||
|
|
<div class="ttc" id="anamespaceftxui_html"><div class="ttname"><a href="namespaceftxui.html">ftxui</a></div><div class="ttdef"><b>Definition</b> <a href="animation_8hpp_source.html#l00010">animation.hpp:10</a></div></div>
|
||
|
|
<div class="ttc" id="ascreen__interactive_8hpp_html"><div class="ttname"><a href="screen__interactive_8hpp.html">screen_interactive.hpp</a></div></div>
|
||
|
|
</div><!-- fragment --><div class="fragment"><div class="line"><span class="comment">// Copyright 2023 Arthur Sonzogni. All rights reserved.</span></div>
|
||
|
|
<div class="line"><span class="comment">// Use of this source code is governed by the MIT license that can be found in</span></div>
|
||
|
|
<div class="line"><span class="comment">// the LICENSE file.</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="component__base_8hpp.html">ftxui/component/component_base.hpp</a>></span> <span class="comment">// for ComponentBase, Component</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="elements_8hpp.html">ftxui/dom/elements.hpp</a>></span> <span class="comment">// for operator|, Element, flex, bgcolor, text, vbox, center</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="linear__gradient_8hpp.html">ftxui/dom/linear_gradient.hpp</a>></span> <span class="comment">// for LinearGradient</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include <<a class="code" href="color_8hpp.html">ftxui/screen/color.hpp</a>></span> <span class="comment">// for Color, Color::Blue, Color::Red</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include <memory></span> <span class="comment">// for __shared_ptr_access, shared_ptr</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include <string></span> <span class="comment">// for allocator, operator+, char_traits, string, to_string</span></div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="captured__mouse_8hpp.html">ftxui/component/captured_mouse.hpp</a>"</span> <span class="comment">// for ftxui</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="component_8hpp.html">ftxui/component/component.hpp</a>"</span> <span class="comment">// for Slider, Renderer, Vertical</span></div>
|
||
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="screen__interactive_8hpp.html">ftxui/component/screen_interactive.hpp</a>"</span> <span class="comment">// for ScreenInteractive</span></div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"><span class="keywordtype">int</span> <a class="code hl_function" href="examples_2component_2button_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a>() {</div>
|
||
|
|
<div class="line"> <span class="keyword">using namespace </span><a class="code hl_namespace" href="namespaceftxui.html">ftxui</a>;</div>
|
||
|
|
<div class="line"> <span class="keyword">auto</span> screen = ScreenInteractive::Fullscreen();</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> <span class="keywordtype">int</span> <a id="a1" name="a1"></a><a class="code hl_variable" href="src_2ftxui_2dom_2linear__gradient_8cpp.html#ab8ef1bf8a70cc07c6d55823c390a7e76">angle</a> = 180.f;</div>
|
||
|
|
<div class="line"> <span class="keywordtype">float</span> start = 0.f;</div>
|
||
|
|
<div class="line"> <span class="keywordtype">float</span> end = 1.f;</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> std::string slider_angle_text;</div>
|
||
|
|
<div class="line"> std::string slider_start_text;</div>
|
||
|
|
<div class="line"> std::string slider_end_text;</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> <span class="keyword">auto</span> slider_angle = Slider(&slider_angle_text, &<a class="code hl_variable" href="src_2ftxui_2dom_2linear__gradient_8cpp.html#ab8ef1bf8a70cc07c6d55823c390a7e76">angle</a>, 0, 360);</div>
|
||
|
|
<div class="line"> <span class="keyword">auto</span> slider_start = Slider(&slider_start_text, &start, 0.f, 1.f, 0.05f);</div>
|
||
|
|
<div class="line"> <span class="keyword">auto</span> slider_end = Slider(&slider_end_text, &end, 0.f, 1.f, 0.05f);</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> <span class="keyword">auto</span> layout = Container::Vertical({</div>
|
||
|
|
<div class="line"> slider_angle,</div>
|
||
|
|
<div class="line"> slider_start,</div>
|
||
|
|
<div class="line"> slider_end,</div>
|
||
|
|
<div class="line"> });</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> <span class="keyword">auto</span> renderer = Renderer(layout, [&] {</div>
|
||
|
|
<div class="line"> slider_angle_text = <span class="stringliteral">"angle = "</span> + std::to_string(<a class="code hl_variable" href="src_2ftxui_2dom_2linear__gradient_8cpp.html#ab8ef1bf8a70cc07c6d55823c390a7e76">angle</a>) + <span class="stringliteral">"°"</span>;</div>
|
||
|
|
<div class="line"> slider_start_text = <span class="stringliteral">"start = "</span> + std::to_string(<span class="keywordtype">int</span>(start * 100)) + <span class="stringliteral">"%"</span>;</div>
|
||
|
|
<div class="line"> slider_end_text = <span class="stringliteral">"end = "</span> + std::to_string(<span class="keywordtype">int</span>(end * 100)) + <span class="stringliteral">"%"</span>;</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> <span class="keyword">auto</span> background = text(<span class="stringliteral">"Gradient"</span>) | center |</div>
|
||
|
|
<div class="line"> bgcolor(<a id="_a2" name="_a2"></a><a class="code hl_struct" href="structftxui_1_1LinearGradient.html">LinearGradient</a>()</div>
|
||
|
|
<div class="line"> .Angle(<a class="code hl_variable" href="src_2ftxui_2dom_2linear__gradient_8cpp.html#ab8ef1bf8a70cc07c6d55823c390a7e76">angle</a>)</div>
|
||
|
|
<div class="line"> .Stop(Color::Blue, start)</div>
|
||
|
|
<div class="line"> .Stop(Color::Red, end));</div>
|
||
|
|
<div class="line"> <span class="keywordflow">return</span> vbox({</div>
|
||
|
|
<div class="line"> background | flex,</div>
|
||
|
|
<div class="line"> layout->Render(),</div>
|
||
|
|
<div class="line"> }) |</div>
|
||
|
|
<div class="line"> flex;</div>
|
||
|
|
<div class="line"> });</div>
|
||
|
|
<div class="line"> </div>
|
||
|
|
<div class="line"> screen.Loop(renderer);</div>
|
||
|
|
<div class="line">}</div>
|
||
|
|
<div class="ttc" id="alinear__gradient_8hpp_html"><div class="ttname"><a href="linear__gradient_8hpp.html">linear_gradient.hpp</a></div></div>
|
||
|
|
<div class="ttc" id="asrc_2ftxui_2dom_2linear__gradient_8cpp_html_ab8ef1bf8a70cc07c6d55823c390a7e76"><div class="ttname"><a href="src_2ftxui_2dom_2linear__gradient_8cpp.html#ab8ef1bf8a70cc07c6d55823c390a7e76">angle</a></div><div class="ttdeci">float angle</div><div class="ttdef"><b>Definition</b> <a href="src_2ftxui_2dom_2linear__gradient_8cpp_source.html#l00023">src/ftxui/dom/linear_gradient.cpp:23</a></div></div>
|
||
|
|
<div class="ttc" id="astructftxui_1_1LinearGradient_html"><div class="ttname"><a href="structftxui_1_1LinearGradient.html">ftxui::LinearGradient</a></div><div class="ttdoc">A class representing the settings for linear-gradient color effect.</div><div class="ttdef"><b>Definition</b> <a href="linear__gradient_8hpp_source.html#l00030">linear_gradient.hpp:30</a></div></div>
|
||
|
|
</div><!-- fragment --> </div><!-- contents -->
|
||
|
|
</div><!-- doc-content -->
|
||
|
|
<!-- HTML footer for doxygen 1.9.8-->
|
||
|
|
<!-- start footer part -->
|
||
|
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||
|
|
<ul>
|
||
|
|
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.12.0 </li>
|
||
|
|
</ul>
|
||
|
|
</div>
|
||
|
|
</body>
|
||
|
|
</html>
|