ZealOS/docs/System/Ctrls/CtrlsA.CC

439 lines
55 KiB
HolyC
Executable file

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V0.05">
<style type="text/css">
body {background-color:#000000;}
.cF0{color:#ffffff;background-color:#000000;}
.cF1{color:#3465a4;background-color:#000000;}
.cF2{color:#4e9a06;background-color:#000000;}
.cF3{color:#06989a;background-color:#000000;}
.cF4{color:#a24444;background-color:#000000;}
.cF5{color:#75507b;background-color:#000000;}
.cF6{color:#ce982f;background-color:#000000;}
.cF7{color:#bcc0b9;background-color:#000000;}
.cF8{color:#555753;background-color:#000000;}
.cF9{color:#729fcf;background-color:#000000;}
.cFA{color:#82bc49;background-color:#000000;}
.cFB{color:#34e2e2;background-color:#000000;}
.cFC{color:#ac3535;background-color:#000000;}
.cFD{color:#ad7fa8;background-color:#000000;}
.cFE{color:#fce94f;background-color:#000000;}
.cFF{color:#000000;background-color:#000000;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<a name="l1"></a><span class=cF1>public</span><span class=cF0> </span><span class=cF9>CCtrl</span><span class=cF0> *</span><span class=cF5>CtrlFindUnique</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *haystack_task, </span><span class=cF9>I64</span><span class=cF0> needle_type)
<a name="l2"></a>{</span><span class=cF2>//Find task ctrl given </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.html#l3709"><span class=cF4>ctrl_type</span></a><span class=cF2>.</span><span class=cF0>
<a name="l3"></a> </span><span class=cF9>CCtrl</span><span class=cF0> *c;
<a name="l4"></a>
<a name="l5"></a> c = haystack_task-&gt;next_ctrl;
<a name="l6"></a> </span><span class=cF1>while</span><span class=cF0> (c != &amp;haystack_task-&gt;next_ctrl)
<a name="l7"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l8"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;type == needle_type)
<a name="l9"></a> </span><span class=cF1>return</span><span class=cF0> c;
<a name="l10"></a> c = c-&gt;next;
<a name="l11"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l12"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l13"></a>}
<a name="l14"></a>
<a name="l15"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>CtrlsUpdate</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task)
<a name="l16"></a>{
<a name="l17"></a> </span><span class=cF9>CCtrl</span><span class=cF0> *c;
<a name="l18"></a>
<a name="l19"></a> c = task-&gt;next_ctrl;
<a name="l20"></a> </span><span class=cF1>while</span><span class=cF0> (c != &amp;task-&gt;next_ctrl)
<a name="l21"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l22"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;update_derived_vals)
<a name="l23"></a> (*c-&gt;update_derived_vals)(c);
<a name="l24"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;flags &amp; </span><span class=cF3>CTRLF_BORDER</span><span class=cF0>)
<a name="l25"></a> {
<a name="l26"></a> c-&gt;screen_left = </span><span class=cFB>gr</span><span class=cF0>.pan_text_x + task-&gt;pix_left + c-&gt;left - </span><span class=cF3>FONT_WIDTH</span><span class=cF0>;
<a name="l27"></a> c-&gt;screen_right = </span><span class=cFB>gr</span><span class=cF0>.pan_text_x + task-&gt;pix_left + c-&gt;right - </span><span class=cF3>FONT_WIDTH</span><span class=cF0>;
<a name="l28"></a> c-&gt;screen_top = </span><span class=cFB>gr</span><span class=cF0>.pan_text_y + task-&gt;pix_top + c-&gt;top - </span><span class=cF3>FONT_HEIGHT</span><span class=cF0>;
<a name="l29"></a> c-&gt;screen_bottom = </span><span class=cFB>gr</span><span class=cF0>.pan_text_y + task-&gt;pix_top + c-&gt;bottom - </span><span class=cF3>FONT_HEIGHT</span><span class=cF0>;
<a name="l30"></a> }
<a name="l31"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l32"></a> {
<a name="l33"></a> c-&gt;screen_left = </span><span class=cFB>gr</span><span class=cF0>.pan_text_x + task-&gt;pix_left + c-&gt;left;
<a name="l34"></a> c-&gt;screen_right = </span><span class=cFB>gr</span><span class=cF0>.pan_text_x + task-&gt;pix_left + c-&gt;right;
<a name="l35"></a> c-&gt;screen_top = </span><span class=cFB>gr</span><span class=cF0>.pan_text_y + task-&gt;pix_top + c-&gt;top;
<a name="l36"></a> c-&gt;screen_bottom = </span><span class=cFB>gr</span><span class=cF0>.pan_text_y + task-&gt;pix_top + c-&gt;bottom;
<a name="l37"></a> }
<a name="l38"></a> c = c-&gt;next;
<a name="l39"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l40"></a>}
<a name="l41"></a>
<a name="l42"></a></span><span class=cFB>fp_update_ctrls</span><span class=cF0> = &amp;</span><span class=cF5>CtrlsUpdate</span><span class=cF0>;
<a name="l43"></a>
<a name="l44"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>CtrlInsideRect</span><span class=cF0>(</span><span class=cF9>CCtrl</span><span class=cF0> *c, </span><span class=cF9>I64</span><span class=cF0> x, </span><span class=cF9>I64</span><span class=cF0> y)
<a name="l45"></a>{</span><span class=cF2>//screen coordinates</span><span class=cF0>
<a name="l46"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;screen_left &lt;= x &lt;= c-&gt;screen_right &amp;&amp; c-&gt;screen_top &lt;= y &lt;= c-&gt;screen_bottom)
<a name="l47"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l48"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l49"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l50"></a>}
<a name="l51"></a>
<a name="l52"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>CtrlInside</span><span class=cF0>(</span><span class=cF9>CCtrl</span><span class=cF0> *c, </span><span class=cF9>I64</span><span class=cF0> x, </span><span class=cF9>I64</span><span class=cF0> y)
<a name="l53"></a>{</span><span class=cF2>//Is x, y inside a ctrl?</span><span class=cF0>
<a name="l54"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;flags &amp; </span><span class=cF3>CTRLF_SHOW</span><span class=cF0>)
<a name="l55"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l56"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;inside_ctrl)
<a name="l57"></a> </span><span class=cF1>return</span><span class=cF0> (*c-&gt;inside_ctrl)(c, x, y);
<a name="l58"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l59"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>CtrlInsideRect</span><span class=cF0>(c, x, y);
<a name="l60"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l61"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l62"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l63"></a>}
<a name="l64"></a>
<a name="l65"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DrawCtrls</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task)
<a name="l66"></a>{
<a name="l67"></a> </span><span class=cF9>CCtrl</span><span class=cF0> *c;
<a name="l68"></a> </span><span class=cF9>CDC</span><span class=cF0> *dc = </span><span class=cF5>DCAlias</span><span class=cF0>(</span><span class=cFB>gr</span><span class=cF0>.dc2, task);
<a name="l69"></a>
<a name="l70"></a> c = task-&gt;next_ctrl;
<a name="l71"></a> </span><span class=cF1>while</span><span class=cF0> (c != &amp;task-&gt;next_ctrl)
<a name="l72"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l73"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;flags &amp; </span><span class=cF3>CTRLF_SHOW</span><span class=cF0>)
<a name="l74"></a> {
<a name="l75"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;flags &amp; </span><span class=cF3>CTRLF_BORDER</span><span class=cF0>)
<a name="l76"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l77"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;task-&gt;display_flags, </span><span class=cF3>DISPLAYf_NO_BORDER</span><span class=cF7>)</span><span class=cF0>)
<a name="l78"></a> {
<a name="l79"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l80"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l81"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;task-&gt;task_flags, </span><span class=cF3>TASKf_TASK_LOCK</span><span class=cF7>)</span><span class=cF0>)
<a name="l82"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
<a name="l83"></a>
<a name="l84"></a> task-&gt;win_left--; </span><span class=cF2>//Allow drawing on border</span><span class=cF0>
<a name="l85"></a> task-&gt;win_right++;
<a name="l86"></a> task-&gt;win_top--;
<a name="l87"></a> task-&gt;win_bottom++;
<a name="l88"></a> </span><span class=cF5>WinDerivedValsUpdate</span><span class=cF0>(task);
<a name="l89"></a>
<a name="l90"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;task-&gt;task_flags, </span><span class=cF3>TASKf_TASK_LOCK</span><span class=cF0>);
<a name="l91"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l92"></a>
<a name="l93"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;draw_it)
<a name="l94"></a> (*c-&gt;draw_it)(dc, c);
<a name="l95"></a>
<a name="l96"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l97"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l98"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;task-&gt;task_flags, </span><span class=cF3>TASKf_TASK_LOCK</span><span class=cF7>)</span><span class=cF0>)
<a name="l99"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
<a name="l100"></a>
<a name="l101"></a> task-&gt;win_left++;
<a name="l102"></a> task-&gt;win_right--;
<a name="l103"></a> task-&gt;win_top++;
<a name="l104"></a> task-&gt;win_bottom--;
<a name="l105"></a> </span><span class=cF5>WinDerivedValsUpdate</span><span class=cF0>(task);
<a name="l106"></a>
<a name="l107"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;task-&gt;task_flags, </span><span class=cF3>TASKf_TASK_LOCK</span><span class=cF0>);
<a name="l108"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l109"></a> }
<a name="l110"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l111"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l112"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;draw_it)
<a name="l113"></a> (*c-&gt;draw_it)(dc, c);
<a name="l114"></a> }
<a name="l115"></a> c = c-&gt;next;
<a name="l116"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l117"></a> </span><span class=cF5>DCDel</span><span class=cF0>(dc);
<a name="l118"></a>}
<a name="l119"></a>
<a name="l120"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>WIN_SCROLL_SIZE</span><span class=cF0> </span><span class=cFE>8</span><span class=cF0>
<a name="l121"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>WIN_SCROLL_BORDER_BONUS</span><span class=cF0> </span><span class=cFE>4</span><span class=cF0>
<a name="l122"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DrawWinScroll</span><span class=cF0>(</span><span class=cF9>CDC</span><span class=cF0> *dc, </span><span class=cF9>CCtrl</span><span class=cF0> *c)
<a name="l123"></a>{
<a name="l124"></a> </span><span class=cF9>CWinScroll</span><span class=cF0> *s = c-&gt;state;
<a name="l125"></a>
<a name="l126"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;flags &amp; </span><span class=cF3>CTRLF_CLICKED</span><span class=cF0>)
<a name="l127"></a> dc-&gt;color = s-&gt;color &gt;&gt; </span><span class=cFE>4</span><span class=cF0>;
<a name="l128"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l129"></a> dc-&gt;color = s-&gt;color &amp; </span><span class=cFE>0xF</span><span class=cF0>;
<a name="l130"></a></span><span class=cF2>//</span><span class=cF0> </span><span class=cF2>GrRect(dc, c-&gt;left, c-&gt;top, c-&gt;right - c-&gt;left + 1, c-&gt;bottom - c-&gt;top + 1);</span><span class=cF0>
<a name="l131"></a> </span><span class=cF5>GrPutS</span><span class=cF0>(dc, c-&gt;left, c-&gt;top, </span><span class=cF6>&quot;.&quot;</span><span class=cF0>);
<a name="l132"></a>
<a name="l133"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;flags &amp; </span><span class=cF3>CTRLF_CLICKED</span><span class=cF0>)
<a name="l134"></a> dc-&gt;color = s-&gt;color &amp; </span><span class=cFE>0xF</span><span class=cF0>;
<a name="l135"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l136"></a> dc-&gt;color = s-&gt;color &gt;&gt; </span><span class=cFE>4</span><span class=cF0>;
<a name="l137"></a></span><span class=cF2>//</span><span class=cF0> </span><span class=cF2>GrRect(dc, c-&gt;left + 2, c-&gt;top + 2, c-&gt;right - c-&gt;left + 1 - 4, c-&gt;bottom - c-&gt;top + 1 - 4);</span><span class=cF0>
<a name="l138"></a> </span><span class=cF5>GrPutS</span><span class=cF0>(dc, c-&gt;left, c-&gt;top, </span><span class=cF6>&quot;.&quot;</span><span class=cF0>);
<a name="l139"></a>
<a name="l140"></a>}
<a name="l141"></a>
<a name="l142"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>WinDerivedScrollValsUpdate</span><span class=cF0>(</span><span class=cF9>CCtrl</span><span class=cF0> *c)
<a name="l143"></a>{
<a name="l144"></a> </span><span class=cF9>CWinScroll</span><span class=cF0> *s = c-&gt;state;
<a name="l145"></a> </span><span class=cF9>I64</span><span class=cF0> range;
<a name="l146"></a>
<a name="l147"></a> </span><span class=cF1>if</span><span class=cF0> (s-&gt;max &lt; s-&gt;min) s-&gt;max = s-&gt;min;
<a name="l148"></a> </span><span class=cF1>if</span><span class=cF0> (s-&gt;pos &lt; s-&gt;min) s-&gt;pos = s-&gt;min;
<a name="l149"></a> </span><span class=cF1>if</span><span class=cF0> (s-&gt;pos &gt; s-&gt;max) s-&gt;pos = s-&gt;max;
<a name="l150"></a>
<a name="l151"></a> s-&gt;color = c-&gt;win_task-&gt;border_attr &amp; </span><span class=cFE>0xF</span><span class=cF0> ^ </span><span class=cFE>0xF</span><span class=cF0> + (c-&gt;win_task-&gt;border_attr &amp; </span><span class=cFE>0xF</span><span class=cF0>) &lt;&lt; </span><span class=cFE>4</span><span class=cF0>;
<a name="l152"></a> range = s-&gt;max - s-&gt;min;
<a name="l153"></a> </span><span class=cF1>if</span><span class=cF0> (!range)
<a name="l154"></a> range = </span><span class=cFE>1</span><span class=cF0>;
<a name="l155"></a> </span><span class=cF1>switch</span><span class=cF0> (c-&gt;type)
<a name="l156"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l157"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CTRLT_WIN_HSCROLL</span><span class=cF0>:
<a name="l158"></a> c-&gt;left = </span><span class=cFB>gr</span><span class=cF0>.pan_text_x + </span><span class=cF3>FONT_WIDTH</span><span class=cF0> - </span><span class=cF3>WIN_SCROLL_BORDER_BONUS</span><span class=cF0> +
<a name="l159"></a> (s-&gt;pos - s-&gt;min) * (c-&gt;win_task-&gt;pix_width + </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>WIN_SCROLL_BORDER_BONUS</span><span class=cF0> - </span><span class=cF3>WIN_SCROLL_SIZE</span><span class=cF0>) / range;
<a name="l160"></a> c-&gt;right = c-&gt;left + </span><span class=cF3>WIN_SCROLL_SIZE</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>;
<a name="l161"></a> c-&gt;top = </span><span class=cFB>gr</span><span class=cF0>.pan_text_y + </span><span class=cF3>FONT_HEIGHT</span><span class=cF0> + (</span><span class=cF3>FONT_WIDTH</span><span class=cF0> - </span><span class=cF3>WIN_SCROLL_SIZE</span><span class=cF0>) / </span><span class=cFE>2</span><span class=cF0> + c-&gt;win_task-&gt;pix_height;
<a name="l162"></a> c-&gt;bottom = c-&gt;top + </span><span class=cF3>WIN_SCROLL_SIZE</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>;
<a name="l163"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l164"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CTRLT_WIN_VSCROLL</span><span class=cF0>:
<a name="l165"></a> c-&gt;left = </span><span class=cFB>gr</span><span class=cF0>.pan_text_x + </span><span class=cF3>FONT_WIDTH</span><span class=cF0> + (</span><span class=cF3>FONT_WIDTH</span><span class=cF0> - </span><span class=cF3>WIN_SCROLL_SIZE</span><span class=cF0>) / </span><span class=cFE>2</span><span class=cF0> + c-&gt;win_task-&gt;pix_width;
<a name="l166"></a> c-&gt;right = c-&gt;left + </span><span class=cF3>WIN_SCROLL_SIZE</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>;
<a name="l167"></a> c-&gt;top = </span><span class=cFB>gr</span><span class=cF0>.pan_text_y + </span><span class=cF3>FONT_HEIGHT</span><span class=cF0> - </span><span class=cF3>WIN_SCROLL_BORDER_BONUS</span><span class=cF0>+
<a name="l168"></a> (s-&gt;pos - s-&gt;min) * (c-&gt;win_task-&gt;pix_height + </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>WIN_SCROLL_BORDER_BONUS</span><span class=cF0> - </span><span class=cF3>WIN_SCROLL_SIZE</span><span class=cF0>) / range;
<a name="l169"></a> c-&gt;bottom = c-&gt;top + </span><span class=cF3>WIN_SCROLL_SIZE</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>;
<a name="l170"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l171"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l172"></a>}
<a name="l173"></a>
<a name="l174"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>LeftClickHWinScroll</span><span class=cF0>(</span><span class=cF9>CCtrl</span><span class=cF0> *c, </span><span class=cF9>I64</span><span class=cF0> x, </span><span class=cF9>I64</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> down)
<a name="l175"></a>{
<a name="l176"></a> </span><span class=cF9>CTask</span><span class=cF0> *task = c-&gt;win_task;
<a name="l177"></a> </span><span class=cF9>CWinScroll</span><span class=cF0> *s = c-&gt;state;
<a name="l178"></a> </span><span class=cF9>I64</span><span class=cF0> range = task-&gt;pix_width + </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>WIN_SCROLL_BORDER_BONUS</span><span class=cF0> - </span><span class=cF3>WIN_SCROLL_SIZE</span><span class=cF0>;
<a name="l179"></a>
<a name="l180"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;s-&gt;flags, </span><span class=cF3>WSSf_SET_TO_POS</span><span class=cF0>);
<a name="l181"></a> s-&gt;pos = (</span><span class=cF7>(</span><span class=cF0>x - (</span><span class=cF3>FONT_WIDTH</span><span class=cF0> - </span><span class=cF3>WIN_SCROLL_BORDER_BONUS</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>
<a name="l182"></a> *</span><span class=cF7>(</span><span class=cF0>s-&gt;max - s-&gt;min + </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0> + range / </span><span class=cFE>2</span><span class=cF0>) / range + s-&gt;min;
<a name="l183"></a> </span><span class=cF1>if</span><span class=cF0> (down)
<a name="l184"></a> c-&gt;flags |= </span><span class=cF3>CTRLF_CLICKED</span><span class=cF0>;
<a name="l185"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l186"></a> c-&gt;flags &amp;= ~</span><span class=cF3>CTRLF_CLICKED</span><span class=cF0>;
<a name="l187"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;update_derived_vals)
<a name="l188"></a> (*c-&gt;update_derived_vals)(c);
<a name="l189"></a>}
<a name="l190"></a>
<a name="l191"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>LeftClickVWinScroll</span><span class=cF0>(</span><span class=cF9>CCtrl</span><span class=cF0> *c, </span><span class=cF9>I64</span><span class=cF0>, </span><span class=cF9>I64</span><span class=cF0> y, </span><span class=cF1>Bool</span><span class=cF0> down)
<a name="l192"></a>{
<a name="l193"></a> </span><span class=cF9>CTask</span><span class=cF0> *task = c-&gt;win_task;
<a name="l194"></a> </span><span class=cF9>CWinScroll</span><span class=cF0> *s = c-&gt;state;
<a name="l195"></a> </span><span class=cF9>I64</span><span class=cF0> range = task-&gt;pix_height + </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>WIN_SCROLL_BORDER_BONUS</span><span class=cF0> - </span><span class=cF3>WIN_SCROLL_SIZE</span><span class=cF0>;
<a name="l196"></a>
<a name="l197"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;s-&gt;flags, </span><span class=cF3>WSSf_SET_TO_POS</span><span class=cF0>);
<a name="l198"></a> s-&gt;pos = (</span><span class=cF7>(</span><span class=cF0>y - (</span><span class=cF3>FONT_HEIGHT</span><span class=cF0> - </span><span class=cF3>WIN_SCROLL_BORDER_BONUS</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>
<a name="l199"></a> *</span><span class=cF7>(</span><span class=cF0>s-&gt;max - s-&gt;min + </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0> + range / </span><span class=cFE>2</span><span class=cF0>) / range + s-&gt;min;
<a name="l200"></a> </span><span class=cF1>if</span><span class=cF0> (down)
<a name="l201"></a> c-&gt;flags |= </span><span class=cF3>CTRLF_CLICKED</span><span class=cF0>;
<a name="l202"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l203"></a> c-&gt;flags &amp;= ~</span><span class=cF3>CTRLF_CLICKED</span><span class=cF0>;
<a name="l204"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;update_derived_vals)
<a name="l205"></a> (*c-&gt;update_derived_vals)(c);
<a name="l206"></a>}
<a name="l207"></a>
<a name="l208"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>WheelChangeWinScroll</span><span class=cF0>(</span><span class=cF9>CCtrl</span><span class=cF0> *c, </span><span class=cF9>I64</span><span class=cF0> delta)
<a name="l209"></a>{
<a name="l210"></a> </span><span class=cF9>CWinScroll</span><span class=cF0> *s = c-&gt;state;
<a name="l211"></a>
<a name="l212"></a> </span><span class=cF5>LBts</span><span class=cF0>(&amp;s-&gt;flags, </span><span class=cF3>WSSf_SET_TO_POS</span><span class=cF0>);
<a name="l213"></a> s-&gt;pos += delta;
<a name="l214"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;update_derived_vals)
<a name="l215"></a> (*c-&gt;update_derived_vals)(c);
<a name="l216"></a>}
<a name="l217"></a>
<a name="l218"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>WinScrollsInit</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task)
<a name="l219"></a>{
<a name="l220"></a> </span><span class=cF9>CCtrl</span><span class=cF0> *c;
<a name="l221"></a>
<a name="l222"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>CtrlFindUnique</span><span class=cF7>(</span><span class=cF0>task, </span><span class=cF3>CTRLT_WIN_HSCROLL</span><span class=cF7>)</span><span class=cF0>)
<a name="l223"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l224"></a> c = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CCtrl</span><span class=cF7>)</span><span class=cF0>);
<a name="l225"></a> c-&gt;win_task = task;
<a name="l226"></a> c-&gt;flags = </span><span class=cF3>CTRLF_SHOW</span><span class=cF0> | </span><span class=cF3>CTRLF_BORDER</span><span class=cF0> | </span><span class=cF3>CTRLF_CAPTURE_LEFT_MS</span><span class=cF0>;
<a name="l227"></a> c-&gt;type = </span><span class=cF3>CTRLT_WIN_HSCROLL</span><span class=cF0>;
<a name="l228"></a> c-&gt;state = &amp;task-&gt;horz_scroll;
<a name="l229"></a> c-&gt;update_derived_vals = &amp;</span><span class=cF5>WinDerivedScrollValsUpdate</span><span class=cF0>;
<a name="l230"></a> c-&gt;draw_it = &amp;</span><span class=cF5>DrawWinScroll</span><span class=cF0>;
<a name="l231"></a> c-&gt;left_click = &amp;</span><span class=cF5>LeftClickHWinScroll</span><span class=cF0>;
<a name="l232"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(c, task-&gt;last_ctrl);
<a name="l233"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l234"></a>
<a name="l235"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>CtrlFindUnique</span><span class=cF7>(</span><span class=cF0>task, </span><span class=cF3>CTRLT_WIN_VSCROLL</span><span class=cF7>)</span><span class=cF0>)
<a name="l236"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l237"></a> c = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CCtrl</span><span class=cF7>)</span><span class=cF0>);
<a name="l238"></a> c-&gt;win_task=task;
<a name="l239"></a> c-&gt;flags = </span><span class=cF3>CTRLF_SHOW</span><span class=cF0> | </span><span class=cF3>CTRLF_BORDER</span><span class=cF0> | </span><span class=cF3>CTRLF_CAPTURE_LEFT_MS</span><span class=cF0>;
<a name="l240"></a> c-&gt;type = </span><span class=cF3>CTRLT_WIN_VSCROLL</span><span class=cF0>;
<a name="l241"></a> c-&gt;state = &amp;task-&gt;vert_scroll;
<a name="l242"></a> c-&gt;update_derived_vals = &amp;</span><span class=cF5>WinDerivedScrollValsUpdate</span><span class=cF0>;
<a name="l243"></a> c-&gt;draw_it = &amp;</span><span class=cF5>DrawWinScroll</span><span class=cF0>;
<a name="l244"></a> c-&gt;left_click = &amp;</span><span class=cF5>LeftClickVWinScroll</span><span class=cF0>;
<a name="l245"></a> c-&gt;wheel_chg = &amp;</span><span class=cF5>WheelChangeWinScroll</span><span class=cF0>;
<a name="l246"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(c, task-&gt;last_ctrl);
<a name="l247"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l248"></a> </span><span class=cF5>TaskDerivedValsUpdate</span><span class=cF0>(task);
<a name="l249"></a>}
<a name="l250"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> </span><span class=cFE>22</span><span class=cF0>
<a name="l251"></a></span><span class=cF2>//#define VIEWANGLES_RANGE</span><span class=cF0> </span><span class=cF2>48</span><span class=cF0>
<a name="l252"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> </span><span class=cFE>360</span><span class=cF0>
<a name="l253"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>VIEWANGLES_BORDER</span><span class=cF0> </span><span class=cFE>2</span><span class=cF0>
<a name="l254"></a></span><span class=cF2>//#define VIEWANGLES_SNAP</span><span class=cF0> </span><span class=cF2>2</span><span class=cF0>
<a name="l255"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>VIEWANGLES_SNAP</span><span class=cF0> </span><span class=cFE>1</span><span class=cF0>
<a name="l256"></a>
<a name="l257"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DrawViewAnglesCtrl</span><span class=cF0>(</span><span class=cF9>CDC</span><span class=cF0> *dc, </span><span class=cF9>CCtrl</span><span class=cF0> *c)
<a name="l258"></a>{
<a name="l259"></a> </span><span class=cF9>I64</span><span class=cF0> i, j;
<a name="l260"></a> </span><span class=cF9>CViewAngles</span><span class=cF0> *s = c-&gt;state;
<a name="l261"></a>
<a name="l262"></a> dc-&gt;color = s-&gt;cbd;
<a name="l263"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, c-&gt;left, c-&gt;top, </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> * </span><span class=cFE>4</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>, </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> * </span><span class=cFE>2</span><span class=cF0> + </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0>);
<a name="l264"></a> dc-&gt;color = s-&gt;cbg;
<a name="l265"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, c-&gt;left + </span><span class=cF3>VIEWANGLES_BORDER</span><span class=cF0>, c-&gt;top + </span><span class=cF3>VIEWANGLES_BORDER</span><span class=cF0>,
<a name="l266"></a> </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> * </span><span class=cFE>4</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0> - </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>VIEWANGLES_BORDER</span><span class=cF0>,
<a name="l267"></a> </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> * </span><span class=cFE>2</span><span class=cF0> + </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> - </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>VIEWANGLES_BORDER</span><span class=cF0>);
<a name="l268"></a> dc-&gt;color = s-&gt;config;
<a name="l269"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, c-&gt;left + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0>, c-&gt;top + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0>,
<a name="l270"></a> c-&gt;left + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0>, c-&gt;top + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>);
<a name="l271"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, c-&gt;left + </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0>, c-&gt;top + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0>,
<a name="l272"></a> c-&gt;left + </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0>, c-&gt;top + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>);
<a name="l273"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, c-&gt;left + </span><span class=cFE>3</span><span class=cF0> * </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cFE>2</span><span class=cF0>, c-&gt;top + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0>,
<a name="l274"></a> c-&gt;left + </span><span class=cFE>3</span><span class=cF0> * </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cFE>2</span><span class=cF0>, c-&gt;top + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>);
<a name="l275"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>1</span><span class=cF0>; i &lt; </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0>; i += </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>VIEWANGLES_SNAP</span><span class=cF0>)
<a name="l276"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l277"></a> j = </span><span class=cFE>2</span><span class=cF0> - i / </span><span class=cFE>3</span><span class=cF0> &amp; </span><span class=cFE>1</span><span class=cF0>;
<a name="l278"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, c-&gt;left + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> - j, c-&gt;bottom - </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> - i,
<a name="l279"></a> c-&gt;left + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + j, c-&gt;bottom - </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> - i);
<a name="l280"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, c-&gt;left + </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> - j, c-&gt;bottom - </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> - i,
<a name="l281"></a> c-&gt;left + </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> + j, c-&gt;bottom - </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> - i);
<a name="l282"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, c-&gt;left + </span><span class=cFE>3</span><span class=cF0> * </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cFE>2</span><span class=cF0> - j, c-&gt;bottom - </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> - i,
<a name="l283"></a> c-&gt;left + </span><span class=cFE>3</span><span class=cF0> * </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cFE>2</span><span class=cF0> + j, c-&gt;bottom - </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> - i);
<a name="l284"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l285"></a>
<a name="l286"></a> dc-&gt;color = s-&gt;cx;
<a name="l287"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, c-&gt;left + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> - </span><span class=cF3>FONT_WIDTH</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>,
<a name="l288"></a> c-&gt;top + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> - </span><span class=cF7>(</span><span class=cFE>1</span><span class=cF0> + </span><span class=cF3>FONT_HEIGHT</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF6>&quot;X&quot;</span><span class=cF0>);
<a name="l289"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, c-&gt;left + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> - </span><span class=cFE>3</span><span class=cF0> * </span><span class=cF3>FONT_WIDTH</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>,
<a name="l290"></a> c-&gt;top + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>, </span><span class=cF6>&quot;%3d&quot;</span><span class=cF0>, s-&gt;sx * </span><span class=cFE>360</span><span class=cF0> / </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0>);
<a name="l291"></a> i = c-&gt;left + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0>;
<a name="l292"></a> </span><span class=cF1>if</span><span class=cF0> (s-&gt;sx &gt; </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>)
<a name="l293"></a> j = -</span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0> + s-&gt;sx;
<a name="l294"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l295"></a> j = s-&gt;sx + </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>;
<a name="l296"></a> j = c-&gt;top + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0> - j;
<a name="l297"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, i - </span><span class=cFE>3</span><span class=cF0>, j - </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>7</span><span class=cF0>, </span><span class=cFE>5</span><span class=cF0>);
<a name="l298"></a> dc-&gt;color = s-&gt;cx ^ </span><span class=cFE>8</span><span class=cF0>;
<a name="l299"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, i - </span><span class=cFE>2</span><span class=cF0>, j - </span><span class=cFE>1</span><span class=cF0>, </span><span class=cFE>5</span><span class=cF0>, </span><span class=cFE>3</span><span class=cF0>);
<a name="l300"></a>
<a name="l301"></a> dc-&gt;color = s-&gt;cy;
<a name="l302"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, c-&gt;left + </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> - </span><span class=cF3>FONT_WIDTH</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>,
<a name="l303"></a> c-&gt;top + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> - </span><span class=cF7>(</span><span class=cFE>1</span><span class=cF0> + </span><span class=cF3>FONT_HEIGHT</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF6>&quot;Y&quot;</span><span class=cF0>);
<a name="l304"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, c-&gt;left + </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> - </span><span class=cFE>3</span><span class=cF0> * </span><span class=cF3>FONT_WIDTH</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>,
<a name="l305"></a> c-&gt;top + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>, </span><span class=cF6>&quot;%3d&quot;</span><span class=cF0>, s-&gt;sy * </span><span class=cFE>360</span><span class=cF0> / </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0>);
<a name="l306"></a> i = c-&gt;left + </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0>;
<a name="l307"></a> </span><span class=cF1>if</span><span class=cF0> (s-&gt;sy &gt; </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>)
<a name="l308"></a> j = -</span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0> + s-&gt;sy;
<a name="l309"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l310"></a> j = s-&gt;sy + </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>;
<a name="l311"></a> j = c-&gt;top + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0> - j;
<a name="l312"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, i - </span><span class=cFE>3</span><span class=cF0>, j - </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>7</span><span class=cF0>, </span><span class=cFE>5</span><span class=cF0>);
<a name="l313"></a> dc-&gt;color = s-&gt;cy ^ </span><span class=cFE>8</span><span class=cF0>;
<a name="l314"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, i - </span><span class=cFE>2</span><span class=cF0>, j - </span><span class=cFE>1</span><span class=cF0>, </span><span class=cFE>5</span><span class=cF0>, </span><span class=cFE>3</span><span class=cF0>);
<a name="l315"></a>
<a name="l316"></a> dc-&gt;color = s-&gt;cz;
<a name="l317"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, c-&gt;left + </span><span class=cFE>3</span><span class=cF0> * </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cFE>2</span><span class=cF0> - </span><span class=cF3>FONT_WIDTH</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>,
<a name="l318"></a> c-&gt;top + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> - </span><span class=cF7>(</span><span class=cFE>1</span><span class=cF0> + </span><span class=cF3>FONT_HEIGHT</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF6>&quot;Z&quot;</span><span class=cF0>);
<a name="l319"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, c-&gt;left + </span><span class=cFE>3</span><span class=cF0> * </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cFE>2</span><span class=cF0> - </span><span class=cFE>3</span><span class=cF0> * </span><span class=cF3>FONT_WIDTH</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>,
<a name="l320"></a> c-&gt;top + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>, </span><span class=cF6>&quot;%3d&quot;</span><span class=cF0>, s-&gt;sz * </span><span class=cFE>360</span><span class=cF0> / </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0>);
<a name="l321"></a> i = c-&gt;left + </span><span class=cFE>3</span><span class=cF0> * </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cFE>2</span><span class=cF0>;
<a name="l322"></a> </span><span class=cF1>if</span><span class=cF0> (s-&gt;sz &gt; </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>)
<a name="l323"></a> j = -</span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0> + s-&gt;sz;
<a name="l324"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l325"></a> j = s-&gt;sz + </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>;
<a name="l326"></a> j = c-&gt;top + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> + </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0> - j;
<a name="l327"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, i - </span><span class=cFE>3</span><span class=cF0>, j - </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>7</span><span class=cF0>, </span><span class=cFE>5</span><span class=cF0>);
<a name="l328"></a> dc-&gt;color = s-&gt;cz ^ </span><span class=cFE>8</span><span class=cF0>;
<a name="l329"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, i - </span><span class=cFE>2</span><span class=cF0>, j - </span><span class=cFE>1</span><span class=cF0>, </span><span class=cFE>5</span><span class=cF0>, </span><span class=cFE>3</span><span class=cF0>);
<a name="l330"></a>}
<a name="l331"></a>
<a name="l332"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>UpdateDerivedViewAnglesCtrl</span><span class=cF0>(</span><span class=cF9>CCtrl</span><span class=cF0> *c)
<a name="l333"></a>{
<a name="l334"></a> </span><span class=cF9>CViewAngles</span><span class=cF0> *s = c-&gt;state;
<a name="l335"></a>
<a name="l336"></a> c-&gt;left = c-&gt;win_task-&gt;pix_width - (</span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> * </span><span class=cFE>4</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>);
<a name="l337"></a> c-&gt;right = c-&gt;left + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> * </span><span class=cFE>4</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>;
<a name="l338"></a> c-&gt;top = c-&gt;win_task-&gt;pix_height - (</span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> * </span><span class=cFE>2</span><span class=cF0> + </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0>);
<a name="l339"></a> c-&gt;bottom = c-&gt;top + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF0> * </span><span class=cFE>2</span><span class=cF0> + </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0>;
<a name="l340"></a> s-&gt;sx = </span><span class=cF5>ClampI64</span><span class=cF0>(</span><span class=cF5>RoundI64</span><span class=cF7>(</span><span class=cF0>s-&gt;sx, </span><span class=cF3>VIEWANGLES_SNAP</span><span class=cF7>)</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>);
<a name="l341"></a> s-&gt;sy = </span><span class=cF5>ClampI64</span><span class=cF0>(</span><span class=cF5>RoundI64</span><span class=cF7>(</span><span class=cF0>s-&gt;sy, </span><span class=cF3>VIEWANGLES_SNAP</span><span class=cF7>)</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>);
<a name="l342"></a> s-&gt;sz = </span><span class=cF5>ClampI64</span><span class=cF0>(</span><span class=cF5>RoundI64</span><span class=cF7>(</span><span class=cF0>s-&gt;sz, </span><span class=cF3>VIEWANGLES_SNAP</span><span class=cF7>)</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>);
<a name="l343"></a> s-&gt;ax = </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> * s-&gt;sx / </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0>;
<a name="l344"></a> s-&gt;ay = </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> * s-&gt;sy / </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0>;
<a name="l345"></a> s-&gt;az = </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> * s-&gt;sz / </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0>;
<a name="l346"></a>}
<a name="l347"></a>
<a name="l348"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>LeftClickViewAngles</span><span class=cF0>(</span><span class=cF9>CCtrl</span><span class=cF0> *c, </span><span class=cF9>I64</span><span class=cF0> x, </span><span class=cF9>I64</span><span class=cF0> y, </span><span class=cF1>Bool</span><span class=cF0>)
<a name="l349"></a>{
<a name="l350"></a> </span><span class=cF9>CViewAngles</span><span class=cF0> *s = c-&gt;state;
<a name="l351"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l352"></a>
<a name="l353"></a> i = </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0> - (y - </span><span class=cF7>(</span><span class=cF0>c-&gt;top + </span><span class=cF3>VIEWANGLES_SPACING</span><span class=cF7>)</span><span class=cF0>);
<a name="l354"></a> </span><span class=cF1>if</span><span class=cF0> (i &gt;= </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>)
<a name="l355"></a> i -= </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>;
<a name="l356"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l357"></a> i += </span><span class=cF3>VIEWANGLES_RANGE</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>;
<a name="l358"></a> </span><span class=cF1>if</span><span class=cF0> (x &lt; c-&gt;left + </span><span class=cF7>(</span><span class=cF0>c-&gt;right - c-&gt;left</span><span class=cF7>)</span><span class=cF0> / </span><span class=cFE>3</span><span class=cF0>)
<a name="l359"></a> s-&gt;sx = i;
<a name="l360"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (x &lt; c-&gt;left + </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF7>(</span><span class=cF0>c-&gt;right - c-&gt;left</span><span class=cF7>)</span><span class=cF0> / </span><span class=cFE>3</span><span class=cF0>)
<a name="l361"></a> s-&gt;sy = i;
<a name="l362"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l363"></a> s-&gt;sz = i;
<a name="l364"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;update_derived_vals)
<a name="l365"></a> (*c-&gt;update_derived_vals)(c);
<a name="l366"></a>}
<a name="l367"></a>
<a name="l368"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>CCtrl</span><span class=cF0> *</span><span class=cF5>ViewAnglesNew</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l369"></a>{</span><span class=cF2>//Create view angle ctrl. See </span><a href="https://tomawezome.github.io/ZealOS/Demo/Graphics/Shading.html#l1"><span class=cF4>::/Demo/Graphics/Shading.CC</span></a><span class=cF2>.</span><span class=cF0>
<a name="l370"></a> </span><span class=cF9>CCtrl</span><span class=cF0> *c;
<a name="l371"></a> </span><span class=cF9>CViewAngles</span><span class=cF0> *s;
<a name="l372"></a>
<a name="l373"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
<a name="l374"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
<a name="l375"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>c = </span><span class=cF5>CtrlFindUnique</span><span class=cF0>(task, </span><span class=cF3>CTRLT_VIEWING_ANGLES</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>)
<a name="l376"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l377"></a> s = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CViewAngles</span><span class=cF7>)</span><span class=cF0>, task);
<a name="l378"></a> c = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CCtrl</span><span class=cF7>)</span><span class=cF0>);
<a name="l379"></a> s-&gt;cbd = </span><span class=cF3>BLUE</span><span class=cF0>;
<a name="l380"></a> s-&gt;cbg = </span><span class=cF3>LTBLUE</span><span class=cF0>;
<a name="l381"></a> s-&gt;config = </span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l382"></a> s-&gt;cx = </span><span class=cF3>LTGREEN</span><span class=cF0>;
<a name="l383"></a> s-&gt;cy = </span><span class=cF3>GREEN</span><span class=cF0>;
<a name="l384"></a> s-&gt;cz = </span><span class=cF3>LTGREEN</span><span class=cF0>;
<a name="l385"></a> c-&gt;win_task = task;
<a name="l386"></a> c-&gt;flags = </span><span class=cF3>CTRLF_SHOW</span><span class=cF0> | </span><span class=cF3>CTRLF_CAPTURE_LEFT_MS</span><span class=cF0>;
<a name="l387"></a> c-&gt;type = </span><span class=cF3>CTRLT_VIEWING_ANGLES</span><span class=cF0>;
<a name="l388"></a> c-&gt;state = s;
<a name="l389"></a> c-&gt;draw_it = &amp;</span><span class=cF5>DrawViewAnglesCtrl</span><span class=cF0>;
<a name="l390"></a> c-&gt;left_click = &amp;</span><span class=cF5>LeftClickViewAngles</span><span class=cF0>;
<a name="l391"></a> c-&gt;update_derived_vals = &amp;</span><span class=cF5>UpdateDerivedViewAnglesCtrl</span><span class=cF0>;
<a name="l392"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(c, task-&gt;last_ctrl);
<a name="l393"></a> </span><span class=cF5>TaskDerivedValsUpdate</span><span class=cF0>(task);
<a name="l394"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l395"></a> </span><span class=cF1>return</span><span class=cF0> c;
<a name="l396"></a>}
<a name="l397"></a>
<a name="l398"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>ViewAnglesDel</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l399"></a>{</span><span class=cF2>//Free view angle ctrl.</span><span class=cF0>
<a name="l400"></a> </span><span class=cF9>CCtrl</span><span class=cF0> *c;
<a name="l401"></a>
<a name="l402"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
<a name="l403"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
<a name="l404"></a> </span><span class=cF1>if</span><span class=cF0> (c = </span><span class=cF5>CtrlFindUnique</span><span class=cF7>(</span><span class=cF0>task, </span><span class=cF3>CTRLT_VIEWING_ANGLES</span><span class=cF7>)</span><span class=cF0>)
<a name="l405"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l406"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(c);
<a name="l407"></a> </span><span class=cF5>Free</span><span class=cF0>(c-&gt;state);
<a name="l408"></a> </span><span class=cF5>Free</span><span class=cF0>(c);
<a name="l409"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l410"></a>}
</span></pre></body>
</html>