Nux

Merge lp:~azzar1/nux/nux-clean-up into lp:nux

Proposed by Andrea Azzarone
Status: Work in progress
Proposed branch: lp:~azzar1/nux/nux-clean-up
Merge into: lp:nux
Diff against target: 50251 lines (+123/-43651)
269 files modified
.bzrignore (+0/-2)
Nux/AbstractCheckedButton.cpp (+0/-217)
Nux/AbstractCheckedButton.h (+0/-110)
Nux/AbstractComboBox.cpp (+0/-120)
Nux/AbstractComboBox.h (+0/-64)
Nux/AbstractThread.cpp (+1/-23)
Nux/ActionItem.cpp (+0/-160)
Nux/ActionItem.h (+0/-83)
Nux/AnimatedTextureArea.cpp (+0/-132)
Nux/AnimatedTextureArea.h (+0/-60)
Nux/Area.cpp (+5/-62)
Nux/Area.h (+0/-4)
Nux/BaseWindow.cpp (+0/-3)
Nux/BaseWindow.h (+0/-3)
Nux/Canvas.cpp (+0/-208)
Nux/Canvas.h (+0/-62)
Nux/CheckBox.cpp (+0/-110)
Nux/CheckBox.h (+0/-89)
Nux/ClientArea.cpp (+0/-231)
Nux/ClientArea.h (+0/-104)
Nux/ColorEditor.cpp (+0/-1042)
Nux/ColorEditor.h (+0/-211)
Nux/ColorPickerDialog.cpp (+0/-73)
Nux/ColorPickerDialog.h (+0/-55)
Nux/ColorPreview.cpp (+0/-142)
Nux/ColorPreview.h (+0/-70)
Nux/ComboBoxSimple.cpp (+0/-316)
Nux/ComboBoxSimple.h (+0/-96)
Nux/Coverflow.cpp (+0/-1154)
Nux/Coverflow.h (+0/-103)
Nux/CoverflowItem.cpp (+0/-30)
Nux/CoverflowItem.h (+0/-49)
Nux/CoverflowModel.cpp (+0/-141)
Nux/CoverflowModel.h (+0/-70)
Nux/D2DTextRenderer.cpp (+0/-436)
Nux/D2DTextRenderer.h (+0/-100)
Nux/Dialog.cpp (+0/-71)
Nux/Dialog.h (+0/-52)
Nux/DoubleValidator.cpp (+0/-148)
Nux/DoubleValidator.h (+0/-66)
Nux/EMMetrics.cpp (+0/-55)
Nux/EMMetrics.h (+0/-39)
Nux/EditTextBox.cpp (+0/-524)
Nux/EditTextBox.h (+0/-228)
Nux/FileSelector.cpp (+0/-123)
Nux/FileSelector.h (+0/-58)
Nux/FloatingWindow.cpp (+0/-464)
Nux/FloatingWindow.h (+0/-145)
Nux/GroupBox.cpp (+0/-179)
Nux/GroupBox.h (+0/-61)
Nux/GroupBox2.cpp (+0/-206)
Nux/GroupBox2.h (+0/-68)
Nux/HSplitter.cpp (+0/-693)
Nux/HSplitter.h (+0/-107)
Nux/HexRegExpValidator.cpp (+0/-137)
Nux/HexRegExpValidator.h (+0/-63)
Nux/InputArea.cpp (+0/-2)
Nux/InputArea.h (+1/-10)
Nux/IntegerValidator.cpp (+0/-138)
Nux/IntegerValidator.h (+0/-61)
Nux/KeyboardHandler.cpp (+0/-918)
Nux/KeyboardHandler.h (+0/-164)
Nux/Layout.cpp (+0/-11)
Nux/LinearLayout.cpp (+0/-4)
Nux/MainLoopGLib.cpp (+1/-146)
Nux/Makefile.am (+0/-94)
Nux/MenuBar.cpp (+0/-421)
Nux/MenuBar.h (+0/-111)
Nux/MenuPage.cpp (+0/-1154)
Nux/MenuPage.h (+0/-308)
Nux/MouseAreaCtrl.cpp (+0/-103)
Nux/MouseAreaCtrl.h (+0/-80)
Nux/NumericValuator.cpp (+0/-172)
Nux/NumericValuator.h (+0/-70)
Nux/Nux.cpp (+1/-30)
Nux/Nux.h (+1/-16)
Nux/Painter.cpp (+0/-95)
Nux/Painter.h (+0/-11)
Nux/Panel.cpp (+0/-177)
Nux/Panel.h (+0/-71)
Nux/PangoText.cpp (+0/-422)
Nux/PangoText.h (+0/-101)
Nux/PopUpWindow.cpp (+0/-58)
Nux/PopUpWindow.h (+0/-51)
Nux/RGBValuator.cpp (+0/-1474)
Nux/RGBValuator.h (+0/-184)
Nux/RadioButton.cpp (+0/-161)
Nux/RadioButton.h (+0/-103)
Nux/RadioButtonGroup.cpp (+0/-196)
Nux/RadioButtonGroup.h (+0/-85)
Nux/RangeValue.cpp (+0/-275)
Nux/RangeValue.h (+0/-134)
Nux/RangeValueInteger.cpp (+0/-283)
Nux/RangeValueInteger.h (+0/-139)
Nux/SpinBox.cpp (+0/-245)
Nux/SpinBox.h (+0/-72)
Nux/SpinBoxDouble.cpp (+0/-252)
Nux/SpinBoxDouble.h (+0/-72)
Nux/SpinBox_Logic.cpp (+0/-183)
Nux/SpinBox_Logic.h (+0/-87)
Nux/StaticText.cpp (+4/-328)
Nux/StaticText.h (+2/-18)
Nux/StaticTextBox.cpp (+0/-143)
Nux/StaticTextBox.h (+0/-122)
Nux/SystemThread.cpp (+1/-6)
Nux/TabView.cpp (+0/-529)
Nux/TabView.h (+0/-140)
Nux/TextEntry.cpp (+4/-23)
Nux/TextEntry.h (+0/-2)
Nux/TextLoader.cpp (+0/-252)
Nux/TextLoader.h (+0/-65)
Nux/Theme.cpp (+0/-69)
Nux/Theme.h (+0/-2)
Nux/Timeline.cpp (+0/-104)
Nux/Timeline.h (+0/-146)
Nux/TimelineEasings.cpp (+0/-94)
Nux/TimelineEasings.h (+0/-50)
Nux/TimerProc.cpp (+0/-10)
Nux/ToolButton.cpp (+0/-144)
Nux/ToolButton.h (+0/-67)
Nux/VSplitter.cpp (+0/-690)
Nux/VSplitter.h (+0/-107)
Nux/Validator.cpp (+0/-96)
Nux/Validator.h (+0/-65)
Nux/View.h (+0/-2)
Nux/WindowCompositor.cpp (+3/-381)
Nux/WindowCompositor.h (+0/-30)
Nux/WindowThread.cpp (+5/-186)
Nux/WindowThread.h (+6/-51)
NuxCore/AnimationController.h (+0/-5)
NuxCore/AsyncFileWriter.cpp (+0/-247)
NuxCore/AsyncFileWriter.h (+0/-63)
NuxCore/Character/NAscii.cpp (+0/-51)
NuxCore/Character/NAscii.h (+0/-34)
NuxCore/CppReadme.txt (+0/-179)
NuxCore/EasingCurve.h (+0/-4)
NuxCore/Error.h (+0/-63)
NuxCore/FileManager/NFileManagerGNU.cpp (+1/-15)
NuxCore/FileManager/NFileManagerGeneric.h (+0/-32)
NuxCore/FileManager/NFileManagerWindows.cpp (+0/-869)
NuxCore/FileManager/NFileManagerWindows.h (+0/-146)
NuxCore/FilePath.h (+0/-4)
NuxCore/GlobalInitializer.cpp (+2/-8)
NuxCore/GlobalInitializer.h (+0/-14)
NuxCore/Logger.cpp (+1/-8)
NuxCore/Logger.h (+2/-11)
NuxCore/LoggingWriter.cpp (+0/-19)
NuxCore/Makefile.am (+5/-32)
NuxCore/Math/Algo.cpp (+0/-122)
NuxCore/Math/Algo.h (+0/-45)
NuxCore/Math/Bezier.cpp (+0/-104)
NuxCore/Math/Bezier.h (+0/-76)
NuxCore/Math/Complex.cpp (+0/-373)
NuxCore/Math/Complex.h (+0/-74)
NuxCore/Math/Constants.cpp (+0/-10)
NuxCore/Math/Line2D.cpp (+0/-31)
NuxCore/Math/Line2D.h (+0/-154)
NuxCore/Math/Line3D.cpp (+0/-33)
NuxCore/Math/Line3D.h (+0/-166)
NuxCore/Math/MathInc.h (+0/-6)
NuxCore/Math/Matrix2.cpp (+0/-35)
NuxCore/Math/Matrix2.h (+0/-570)
NuxCore/Math/Matrix3.cpp (+0/-32)
NuxCore/Math/Matrix3.h (+0/-753)
NuxCore/Math/Matrix4.cpp (+0/-39)
NuxCore/Math/Matrix4.h (+0/-1519)
NuxCore/Math/Quaternion.cpp (+0/-535)
NuxCore/Math/Quaternion.h (+0/-103)
NuxCore/Math/Spline.cpp (+0/-392)
NuxCore/Math/Spline.h (+0/-259)
NuxCore/Math/Trigonometry.cpp (+0/-93)
NuxCore/Math/Trigonometry.h (+0/-52)
NuxCore/Math/Tweening.cpp (+0/-366)
NuxCore/Math/Tweening.h (+0/-79)
NuxCore/NuxCore.cpp (+0/-12)
NuxCore/NuxCore.h (+12/-238)
NuxCore/Object.cpp (+0/-25)
NuxCore/OutputDevice.cpp (+0/-51)
NuxCore/Platform.cpp (+3/-92)
NuxCore/Plugin/NPlugin.h (+0/-80)
NuxCore/Plugin/NPluginInterface.h (+0/-47)
NuxCore/Plugin/NPluginManager.cpp (+0/-101)
NuxCore/Plugin/NPluginManager.h (+0/-75)
NuxCore/Plugin/NPluging.cpp (+0/-79)
NuxCore/Process.cpp (+0/-132)
NuxCore/Process.h (+0/-66)
NuxCore/PropertyOperators.h (+0/-4)
NuxCore/PropertyTraits.h (+0/-4)
NuxCore/RollingFileAppender.cpp (+0/-247)
NuxCore/RollingFileAppender.h (+0/-48)
NuxCore/StringConversion.h (+0/-28)
NuxCore/System.h (+17/-156)
NuxCore/SystemWindows.cpp (+0/-62)
NuxCore/SystemWindows.h (+0/-253)
NuxCore/TextString.h (+0/-45)
NuxCore/ThreadWin.cpp (+0/-422)
NuxCore/ThreadWin.h (+0/-521)
NuxCore/TimeFunctions.cpp (+0/-261)
NuxCore/TimeFunctions.h (+0/-93)
NuxCore/Win32Dialogs/NWin32Clipboard.cpp (+0/-161)
NuxCore/Win32Dialogs/NWin32Clipboard.h (+0/-34)
NuxCore/Win32Dialogs/NWin32CustomDialog.cpp (+0/-232)
NuxCore/Win32Dialogs/NWin32CustomDialog.h (+0/-98)
NuxCore/Win32Dialogs/NWin32MessageBox.cpp (+0/-194)
NuxCore/Win32Dialogs/NWin32MessageBox.h (+0/-91)
NuxGraphics/Events.cpp (+1/-12)
NuxGraphics/Events.h (+2/-7)
NuxGraphics/FreetypeFont.h (+0/-21)
NuxGraphics/GLPBuffer.cpp (+0/-1065)
NuxGraphics/GLPBuffer.h (+0/-178)
NuxGraphics/GLResource.h (+21/-40)
NuxGraphics/GLSh_ColorPicker.cpp (+0/-466)
NuxGraphics/GLSh_ColorPicker.h (+0/-56)
NuxGraphics/GLSh_DrawFunction.cpp (+0/-229)
NuxGraphics/GLSh_DrawFunction.h (+0/-60)
NuxGraphics/GLSh_Fill.cpp (+0/-135)
NuxGraphics/GLSh_Fill.h (+0/-63)
NuxGraphics/GLShader.h (+0/-1)
NuxGraphics/GLThread.h (+0/-27)
NuxGraphics/GLTimer.cpp (+0/-27)
NuxGraphics/GLTimer.h (+0/-7)
NuxGraphics/GLWindowManager.cpp (+4/-76)
NuxGraphics/GLWindowManager.h (+2/-22)
NuxGraphics/GdiImageLoader.cpp (+0/-148)
NuxGraphics/GdiImageLoader.h (+0/-39)
NuxGraphics/Gfx_Interface.h (+1/-7)
NuxGraphics/GpuDevice.cpp (+6/-107)
NuxGraphics/GpuDevice.h (+1/-9)
NuxGraphics/GraphicsDisplay.h (+1/-7)
NuxGraphics/GraphicsDisplayWin.cpp (+0/-2436)
NuxGraphics/GraphicsDisplayWin.h (+0/-308)
NuxGraphics/GraphicsEngine.cpp (+0/-23)
NuxGraphics/GraphicsEngine.h (+2/-7)
NuxGraphics/ImageSurface.cpp (+0/-9)
NuxGraphics/ImageSurface.h (+0/-4)
NuxGraphics/Makefile.am (+1/-12)
NuxGraphics/NuxGraphics.cpp (+2/-10)
NuxGraphics/NuxGraphicsResources.cpp (+0/-61)
NuxGraphics/OpenGLDefinitions.h (+0/-24)
NuxGraphics/XInputWindow.cpp (+0/-1)
examples/Makefile.am (+0/-74)
examples/button.cpp (+0/-116)
examples/cairo.cpp (+0/-71)
examples/cairo_wrapper.cpp (+0/-146)
examples/canvas.cpp (+0/-195)
examples/checkbox.cpp (+0/-54)
examples/combobox.cpp (+0/-62)
examples/coverflow.cpp (+0/-152)
examples/focus.cpp (+0/-231)
examples/gestures.cpp (+0/-100)
examples/gridlayout.cpp (+0/-98)
examples/layeredlayout.cpp (+0/-143)
examples/moveable_view.cpp (+0/-123)
examples/pango_combobox.cpp (+0/-62)
examples/pangotextedit.cpp (+0/-53)
examples/rotate_texture_area.cpp (+0/-108)
examples/scrollview.cpp (+0/-77)
examples/tab_view.cpp (+0/-87)
examples/textedit.cpp (+0/-52)
examples/tiles_view.cpp (+0/-410)
examples/timegraph.cpp (+0/-110)
examples/timeline.cpp (+0/-77)
examples/tooltip.cpp (+0/-893)
tests/Makefile.am (+1/-4)
tests/gtest-nux-emmetrics.cpp (+0/-94)
tests/gtest-nuxcore-async-file-writer.cpp (+0/-110)
tests/gtest-nuxcore-rolling-file-appender.cpp (+0/-147)
tests/test-canvas.cpp (+0/-25)
tests/test-nux.cpp (+0/-8)
To merge this branch: bzr merge lp:~azzar1/nux/nux-clean-up
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+239383@code.launchpad.net
To post a comment you must log in.
lp:~azzar1/nux/nux-clean-up updated
864. By Andrea Azzarone

Remove focus.cpp

865. By Andrea Azzarone

Delete *ComboBox*

866. By Andrea Azzarone

Remove Canvas.*

867. By Andrea Azzarone

Remove AnimatedTextureArea.*

868. By Andrea Azzarone

Remove color picker dialog stuff.

869. By Andrea Azzarone

Remove ClientArea.*

870. By Andrea Azzarone

Remoe Radio/Check button classes.

871. By Andrea Azzarone

Remove EMMetrics.*

872. By Andrea Azzarone

Remove FileSelector.*

873. By Andrea Azzarone

Remove GroupBox*

874. By Andrea Azzarone

Remove RGBValuator.*

875. By Andrea Azzarone

Remove RangeValue*

876. By Andrea Azzarone

Remove NumericValuator*

877. By Andrea Azzarone

Remove SpinBox*

878. By Andrea Azzarone

Remove DoubleValidator* and HexRegExpValidator*

879. By Andrea Azzarone

Remove EditTextBox* IntegerValidator* Validator*

880. By Andrea Azzarone

Remove PopUpWindow.*

881. By Andrea Azzarone

Remove Dialog* and FloatingWindow*

882. By Andrea Azzarone

Remove MouseAreaCtrl.*

883. By Andrea Azzarone

Remove Panel*

884. By Andrea Azzarone

Remove KeyboardHandler.*

885. By Andrea Azzarone

Remove Menu*

886. By Andrea Azzarone

Remove ActionItem.*

887. By Andrea Azzarone

Remove PangoText

888. By Andrea Azzarone

Remove StaticTextBox

889. By Andrea Azzarone

Remove TabView.*

890. By Andrea Azzarone

Remove multiplataform support.

891. By Andrea Azzarone

Remove Process.*

892. By Andrea Azzarone

Remove GLThread.h

893. By Andrea Azzarone

Remove GdiImageLoader.*

894. By Andrea Azzarone

Remove OpenGLDefinitions.h

895. By Andrea Azzarone

Remove GLSh_ColorPicker.*

896. By Andrea Azzarone

Remove GLSh_DrawFunction.*

897. By Andrea Azzarone

Remove GLSh_Fill.*

898. By Andrea Azzarone

Remove GLPBuffer.*

899. By Andrea Azzarone

Remove D2DTextRenderer.*

Unmerged revisions

899. By Andrea Azzarone

Remove D2DTextRenderer.*

898. By Andrea Azzarone

Remove GLPBuffer.*

897. By Andrea Azzarone

Remove GLSh_Fill.*

896. By Andrea Azzarone

Remove GLSh_DrawFunction.*

895. By Andrea Azzarone

Remove GLSh_ColorPicker.*

894. By Andrea Azzarone

Remove OpenGLDefinitions.h

893. By Andrea Azzarone

Remove GdiImageLoader.*

892. By Andrea Azzarone

Remove GLThread.h

891. By Andrea Azzarone

Remove Process.*

890. By Andrea Azzarone

Remove multiplataform support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2012-11-05 21:31:06 +0000
3+++ .bzrignore 2014-10-24 19:52:50 +0000
4@@ -30,7 +30,6 @@
5 examples/canvas
6 examples/checkbox
7 examples/combobox
8-examples/coverflow
9 examples/focus
10 examples/gestures
11 examples/gridlayout
12@@ -47,7 +46,6 @@
13 examples/text_entry_focus
14 examples/tiles_view
15 examples/timegraph
16-examples/timeline
17 examples/tooltip
18 m4
19 m4/*
20
21=== removed file 'Nux/AbstractCheckedButton.cpp'
22--- Nux/AbstractCheckedButton.cpp 2012-11-05 21:31:06 +0000
23+++ Nux/AbstractCheckedButton.cpp 1970-01-01 00:00:00 +0000
24@@ -1,217 +0,0 @@
25-/*
26- * Copyright 2010 Inalogic® Inc.
27- *
28- * This program is free software: you can redistribute it and/or modify it
29- * under the terms of the GNU Lesser General Public License, as
30- * published by the Free Software Foundation; either version 2.1 or 3.0
31- * of the License.
32- *
33- * This program is distributed in the hope that it will be useful, but
34- * WITHOUT ANY WARRANTY; without even the implied warranties of
35- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
36- * PURPOSE. See the applicable version of the GNU Lesser General Public
37- * License for more details.
38- *
39- * You should have received a copy of both the GNU Lesser General Public
40- * License along with this program. If not, see <http://www.gnu.org/licenses/>
41- *
42- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
43- *
44- */
45-
46-
47-#include "Nux.h"
48-#include "HLayout.h"
49-#include "AbstractCheckedButton.h"
50-#include "StaticText.h"
51-
52-namespace nux
53-{
54- NUX_IMPLEMENT_OBJECT_TYPE(AbstractCheckedButton);
55-
56- AbstractCheckedButton::AbstractCheckedButton(const std::string &str, bool state, NUX_FILE_LINE_DECL)
57- : AbstractButton(NUX_FILE_LINE_PARAM)
58- {
59- label_ = str;
60- active_ = state;
61- hlayout_ = 0;
62-
63- static_text_ = new StaticText(label_, NUX_TRACKER_LOCATION);
64- static_text_->SetTextColor(label_color_);
65- hlayout_ = new HLayout(NUX_TRACKER_LOCATION);
66- check_area_ = new BasicView(NUX_TRACKER_LOCATION);
67-
68- check_area_->SetInputEventSensitivity(false);
69- static_text_->SetInputEventSensitivity(false);
70-
71- // Set Geometry
72- check_area_->SetMinMaxSize(14, 14);
73-
74- hlayout_->SetSpaceBetweenChildren(4);
75- hlayout_->SetContentDistribution(MAJOR_POSITION_LEFT);
76- hlayout_->AddView(check_area_, 0, MINOR_POSITION_CENTER, MINOR_SIZE_MATCHCONTENT);
77- hlayout_->AddView(static_text_, 1, MINOR_POSITION_CENTER, MINOR_SIZE_MATCHCONTENT);
78-
79-// // This is convenient to make the layout and the AbstractCheckedButton fit the check area and the caption area.
80-// // Since the check area is bigger than 4x4, it will force the layout and the AbstractCheckedButton to grow.
81-// // This is useful if the AbstractCheckedButton is put in a vertical layout and it has a stretch factor of 0. Then the width of the AbstractCheckedButton
82-// // will be adjusted to fit the minimum width of the check area and the caption area.
83-// {
84-// hlayout_->SetMinimumSize(1, 1);
85-// SetMinimumSize(14, 14);
86-// ApplyMinWidth();
87-// ApplyMinHeight();
88-// }
89-
90- hlayout_->SetScaleFactor(0);
91- SetLayout(hlayout_);
92-
93- }
94-
95- AbstractCheckedButton::~AbstractCheckedButton()
96- {
97- }
98-
99- void AbstractCheckedButton::SetLabel(const std::string &checkbox_label)
100- {
101- label_ = checkbox_label;
102- static_text_->SetText(label_);
103- QueueDraw();
104- }
105-
106- std::string AbstractCheckedButton::GetLabel() const
107- {
108- return label_;
109- }
110-
111- void AbstractCheckedButton::Draw(GraphicsEngine &graphics_engine, bool /* force_draw */)
112- {
113- Geometry base = GetGeometry();
114- graphics_engine.PushClippingRectangle(base);
115-
116- GetPainter().PaintBackground(graphics_engine, base);
117-
118- InteractState is;
119- is.is_on = active_;
120-
121- if (visual_state_ == VISUAL_STATE_PRESSED)
122- {
123- is.is_focus = true;
124- }
125- else if (visual_state_ == VISUAL_STATE_PRELIGHT)
126- {
127- is.is_prelight = true;
128- }
129- else
130- {
131- is.is_focus = false;
132- is.is_prelight = false;
133- }
134-
135- GetPainter().PushPaintLayerStack();
136- {
137- GetPainter().PaintCheckBox(graphics_engine, check_area_->GetGeometry(), is, Color(0xff000000));
138- static_text_->ProcessDraw(graphics_engine, true);
139- }
140- GetPainter().PopPaintLayerStack();
141-
142- graphics_engine.PopClippingRectangle();
143- }
144-
145- long AbstractCheckedButton::ComputeContentSize()
146- {
147- if (view_layout_)
148- {
149- PreLayoutManagement();
150-
151- int old_width = GetBaseWidth();
152- int old_height = GetBaseHeight();
153-
154- // Let the text view be as large as possible.
155- static_text_->SetMaximumWidth(AREA_MAX_WIDTH);
156-
157- // Constrain the vertical expansion of the color selector.
158- view_layout_->SetBaseHeight(1);
159- long ret = view_layout_->ComputeContentSize();
160-
161- PostLayoutManagement(ret);
162-
163- {
164- // Check if the text view goes out of the AbstractCheckedButton area.
165- Geometry base = GetGeometry();
166- Geometry text_geo = static_text_->GetGeometry();
167-
168- // Intersect the AbstractCheckedButton and the text view
169- Geometry intersection = base.Intersect(text_geo);
170- if (intersection != text_geo)
171- {
172- // The text view goes outside of the AbstractCheckedButton area. We have to clip it
173- static_text_->SetMaximumWidth(intersection.width);
174-
175- // Assign a size of 1 to the layout and call ComputeContentSize.
176- // Inside the StaticText::ComputeContentSize there is code that takes care of size negociation.
177- view_layout_->SetBaseWidth(1);
178- ret = view_layout_->ComputeContentSize();
179-
180- // Assign the layout geometry to the AbstractCheckedButton view.
181- PostLayoutManagement(ret);
182- }
183- }
184-
185- int new_width = GetBaseWidth();
186- int new_height = GetBaseHeight();
187-
188- long size_compliance = 0;
189-
190- // The layout has been resized to tightly pack its content
191- if (new_width > old_width)
192- {
193- size_compliance |= eLargerWidth; // need scrollbar
194- }
195- else if (new_width < old_width)
196- {
197- size_compliance |= eSmallerWidth;
198- }
199- else
200- {
201- size_compliance |= eCompliantWidth;
202- }
203-
204- // The layout has been resized to tightly pack its content
205- if (new_height > old_height)
206- {
207- size_compliance |= eLargerHeight; // need scrollbar
208- }
209- else if (new_height < old_height)
210- {
211- size_compliance |= eSmallerHeight;
212- }
213- else
214- {
215- size_compliance |= eCompliantHeight;
216- }
217-
218- return size_compliance;
219- }
220- else
221- {
222- PreLayoutManagement();
223- int ret = PostLayoutManagement(eCompliantHeight | eCompliantWidth);
224- return ret;
225- }
226-
227- return 0;
228- }
229-
230- void AbstractCheckedButton::SetLabelFontSize(int point)
231- {
232- AbstractButton::SetLabelFontSize(point);
233- if (static_text_ == NULL)
234- return;
235-
236- static_text_->SetTextPointSize(point);
237-
238- ComputeContentSize();
239- QueueDraw();
240- }
241-}
242
243=== removed file 'Nux/AbstractCheckedButton.h'
244--- Nux/AbstractCheckedButton.h 2013-11-04 14:09:54 +0000
245+++ Nux/AbstractCheckedButton.h 1970-01-01 00:00:00 +0000
246@@ -1,110 +0,0 @@
247-/*
248- * Copyright 2010 Inalogic® Inc.
249- *
250- * This program is free software: you can redistribute it and/or modify it
251- * under the terms of the GNU Lesser General Public License, as
252- * published by the Free Software Foundation; either version 2.1 or 3.0
253- * of the License.
254- *
255- * This program is distributed in the hope that it will be useful, but
256- * WITHOUT ANY WARRANTY; without even the implied warranties of
257- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
258- * PURPOSE. See the applicable version of the GNU Lesser General Public
259- * License for more details.
260- *
261- * You should have received a copy of both the GNU Lesser General Public
262- * License along with this program. If not, see <http://www.gnu.org/licenses/>
263- *
264- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
265- *
266- */
267-
268-
269-#ifndef ABSTRACTCHECKEDBUTTON_H
270-#define ABSTRACTCHECKEDBUTTON_H
271-
272-#include "AbstractButton.h"
273-
274-namespace nux
275-{
276- class HLayout;
277- class InputArea;
278- class StaticText;
279-
280- //! AbstractCheckedButton class
281- /*!
282- Acts as a base class for CheckBox and radioButton.\n
283- */
284- class AbstractCheckedButton: public AbstractButton
285- {
286- NUX_DECLARE_OBJECT_TYPE(AbstractCheckedButton, AbstractButton);
287- public:
288- AbstractCheckedButton(const std::string &str, bool state = false, NUX_FILE_LINE_PROTO);
289- virtual ~AbstractCheckedButton();
290-
291- //! Emitted when the button is clicked.
292- sigc::signal<void, AbstractCheckedButton*> click;
293-
294- //! Emitted when the active state changes.
295- /*!
296- Emitted when the active state changes, as a result of a mouse click or an API call.\n
297- \sa Activate, Deactivate.
298- */
299- sigc::signal<void, AbstractCheckedButton*> state_change;
300-
301- //! Set the label.
302- /*!
303- Set the label of this AbstractCheckedButton. If the \a label argument is an empty string, then the the AbstractCheckedButton label is destroyed,
304- and the content of the AbstractCheckedButton is re-arranged accordingly.
305-
306- @param label The label of the AbstractCheckedButton.
307- */
308- void SetLabel(const std::string &checkbox_label);
309-
310- //!Return the label of this AbstractCheckedButton.
311- /*!
312- Return the label of this AbstractCheckedButton.
313-
314- @return The AbstractCheckedButton label string.
315- */
316- std::string GetLabel() const;
317-
318- //! Activate the check box.
319- /*!
320- Activate the check box.
321- */
322- virtual void Activate() = 0;
323-
324- //! Deactivate the check box.
325- /*!
326- Deactivate the check box.
327- */
328- virtual void Deactivate() = 0;
329-
330- virtual void SetLabelFontSize(int point);
331-
332- protected:
333- virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw) = 0;
334- virtual void RecvClick(int x, int y, unsigned long button_flags, unsigned long key_flags) = 0;
335- virtual long ComputeContentSize();
336-
337- HLayout *hlayout_;
338- InputArea *check_area_;
339-
340- private:
341- //! Override of Area::SetMinimumHeight and made private.
342- /*!
343- Prevent changing the minimum height of the StaticText view.
344- */
345- virtual void SetMinimumHeight(int h){};
346-
347- //! Override of Area::SetMaximumHeight and made private.
348- /*!
349- Prevent changing the maximum height of the StaticText view.
350- */
351- virtual void SetMaximumHeight(int h){};
352- };
353-
354-}
355-
356-#endif // ABSTRACTCHECKEDBUTTON_H
357
358=== removed file 'Nux/AbstractComboBox.cpp'
359--- Nux/AbstractComboBox.cpp 2012-11-05 21:31:06 +0000
360+++ Nux/AbstractComboBox.cpp 1970-01-01 00:00:00 +0000
361@@ -1,120 +0,0 @@
362-/*
363- * Copyright 2010 Inalogic® Inc.
364- *
365- * This program is free software: you can redistribute it and/or modify it
366- * under the terms of the GNU Lesser General Public License, as
367- * published by the Free Software Foundation; either version 2.1 or 3.0
368- * of the License.
369- *
370- * This program is distributed in the hope that it will be useful, but
371- * WITHOUT ANY WARRANTY; without even the implied warranties of
372- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
373- * PURPOSE. See the applicable version of the GNU Lesser General Public
374- * License for more details.
375- *
376- * You should have received a copy of both the GNU Lesser General Public
377- * License along with this program. If not, see <http://www.gnu.org/licenses/>
378- *
379- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
380- *
381- */
382-
383-
384-#include "Nux.h"
385-#include "AbstractComboBox.h"
386-#include "HLayout.h"
387-#include "StaticText.h"
388-
389-namespace nux
390-{
391-
392- Color AbstractComboBox::m_sCOMBO_COLOR = Color(0x009F9F00);
393- Color AbstractComboBox::m_sCOMBO_BUTTON_COLOR = Color(0x00FFFFFF);
394- Color AbstractComboBox::m_sCOMBO_MOUSEOVER_COLOR = Color(0x55FFFFFF);
395-
396- AbstractComboBox::AbstractComboBox(NUX_FILE_LINE_DECL)
397- : View(NUX_FILE_LINE_PARAM)
398- , m_MenuIsActive(false)
399- {
400- m_hlayout = new HLayout(NUX_TRACKER_LOCATION);
401- _combo_box_area = new BasicView(NUX_TRACKER_LOCATION);
402- _combo_box_opening_area = new BasicView(NUX_TRACKER_LOCATION);
403-
404- m_hlayout->AddView(_combo_box_area, 1);
405- m_hlayout->AddView(_combo_box_opening_area, 0);
406- m_hlayout->SetHorizontalExternalMargin(0);
407- m_hlayout->SetVerticalExternalMargin(0);
408- SetLayout(m_hlayout);
409-
410- _combo_box_area->mouse_enter.connect(sigc::mem_fun(this, &AbstractComboBox::RecvMouseEnter));
411- _combo_box_area->mouse_leave.connect(sigc::mem_fun(this, &AbstractComboBox::RecvMouseLeave));
412-
413- _combo_box_opening_area->mouse_enter.connect(sigc::mem_fun(this, &AbstractComboBox::RecvMouseEnter));
414- _combo_box_opening_area->mouse_leave.connect(sigc::mem_fun(this, &AbstractComboBox::RecvMouseLeave));
415-
416- SetTextColor(color::Black);
417-
418- _pango_static_text = new StaticText("", NUX_TRACKER_LOCATION);
419- }
420-
421- AbstractComboBox::~AbstractComboBox()
422- {
423- if (_pango_static_text)
424- _pango_static_text->Dispose();
425- _pango_static_text = 0;
426- }
427-
428- void AbstractComboBox::Draw(GraphicsEngine &graphics_engine, bool /* force_draw */)
429- {
430- Geometry base = GetGeometry();
431-
432- graphics_engine.PushClippingRectangle(base);
433- GetPainter().PaintBackground(graphics_engine, base);
434- GetPainter().PaintShape(graphics_engine, base, m_sCOMBO_COLOR, eSHAPE_CORNER_ROUND4);
435-
436- {
437- //GetPainter().PaintTextLineStatic(graphics_engine, GetFont(), _combo_box_area->GetGeometry(), _combo_box_area->GetBaseString().c_str(), GetTextColor(), eAlignTextLeft);
438- _pango_static_text->SetGeometry(_combo_box_area->GetGeometry());
439- _pango_static_text->ProcessDraw(graphics_engine, true);
440- }
441-
442- Geometry button_geo = _combo_box_opening_area->GetGeometry();
443- button_geo.OffsetSize(-5, -2);
444- button_geo.OffsetPosition(+4, +1);
445-
446- if (_combo_box_area->IsMouseInside() || _combo_box_opening_area->IsMouseInside())
447- GetPainter().PaintShape(graphics_engine, button_geo, m_sCOMBO_MOUSEOVER_COLOR, eSHAPE_CORNER_ROUND4);
448- else
449- GetPainter().PaintShape(graphics_engine, button_geo, m_sCOMBO_BUTTON_COLOR, eSHAPE_CORNER_ROUND4);
450-
451- GeometryPositioning gp(eHACenter, eVACenter);
452- Geometry GeoPo = ComputeGeometryPositioning(button_geo, GetTheme().GetImageGeometry(eCOMBOBOX_OPEN_BUTTON), gp);
453- GetPainter().PaintShape(graphics_engine, GeoPo, Color(0xFFFFFFFF), eCOMBOBOX_OPEN_BUTTON);
454-
455- Geometry popup_geometry;
456- popup_geometry.SetX(_combo_box_area->GetBaseX());
457- popup_geometry.SetY(_combo_box_area->GetBaseY() + _combo_box_area->GetBaseHeight());
458- popup_geometry.SetWidth(_combo_box_area->GetBaseWidth());
459- popup_geometry.SetHeight(_combo_box_area->GetBaseHeight());
460-
461- graphics_engine.PopClippingRectangle();
462- }
463-
464- void AbstractComboBox::DrawContent(GraphicsEngine & /* graphics_engine */, bool /* force_draw */)
465- {
466-
467- }
468-
469- void AbstractComboBox::RecvMouseEnter(int /* x */, int /* y */, unsigned long /* button_flags */, unsigned long /* key_flags */)
470- {
471- QueueDraw();
472- }
473-
474- void AbstractComboBox::RecvMouseLeave(int /* x */, int /* y */, unsigned long /* button_flags */, unsigned long /* key_flags */)
475- {
476- QueueDraw();
477- }
478-
479-
480-
481-}
482
483=== removed file 'Nux/AbstractComboBox.h'
484--- Nux/AbstractComboBox.h 2012-11-05 21:31:06 +0000
485+++ Nux/AbstractComboBox.h 1970-01-01 00:00:00 +0000
486@@ -1,64 +0,0 @@
487-/*
488- * Copyright 2010 Inalogic® Inc.
489- *
490- * This program is free software: you can redistribute it and/or modify it
491- * under the terms of the GNU Lesser General Public License, as
492- * published by the Free Software Foundation; either version 2.1 or 3.0
493- * of the License.
494- *
495- * This program is distributed in the hope that it will be useful, but
496- * WITHOUT ANY WARRANTY; without even the implied warranties of
497- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
498- * PURPOSE. See the applicable version of the GNU Lesser General Public
499- * License for more details.
500- *
501- * You should have received a copy of both the GNU Lesser General Public
502- * License along with this program. If not, see <http://www.gnu.org/licenses/>
503- *
504- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
505- *
506- */
507-
508-
509-#ifndef ABSTRACTCOMBOBOX_H
510-#define ABSTRACTCOMBOBOX_H
511-
512-namespace nux
513-{
514- class StaticText;
515- class HLayout;
516-
517- class AbstractComboBox: public View
518- {
519- public:
520- AbstractComboBox(NUX_FILE_LINE_PROTO);
521- virtual ~AbstractComboBox();
522-
523- virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
524- virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
525-
526- void RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags);
527- void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags);
528-
529- StaticText * GetStaticText()
530- {
531- return _pango_static_text;
532- }
533-
534- protected:
535- HLayout *m_hlayout;
536- BasicView *_combo_box_area;
537- BasicView *_combo_box_opening_area;
538- StaticText *_pango_static_text;
539- bool m_MenuIsActive;
540- bool m_IsOpeningMenu;
541-
542- static Color m_sCOMBO_COLOR;
543- static Color m_sCOMBO_BUTTON_COLOR;
544- static Color m_sCOMBO_MOUSEOVER_COLOR;
545- };
546-
547-
548-}
549-
550-#endif // ABSTRACTCOMBOBOX_H
551
552=== modified file 'Nux/AbstractThread.cpp'
553--- Nux/AbstractThread.cpp 2011-12-29 18:06:53 +0000
554+++ Nux/AbstractThread.cpp 2014-10-24 19:52:50 +0000
555@@ -58,29 +58,7 @@
556
557 void AbstractThread::JoinChildThreads()
558 {
559-#if defined(NUX_OS_WINDOWS)
560- size_t sz = children_thread_list_.size();
561-
562- if (sz == 0)
563- {
564- return;
565- }
566-
567- HANDLE *hdl = new HANDLE[sz];
568-
569- int i = 0;
570- std::list<AbstractThread*>::iterator it;
571- for (it = children_thread_list_.begin(); it != children_thread_list_.end(); ++it, ++i)
572- {
573- hdl[i] = (*it)->GetThreadHandle();
574- }
575-
576- unsigned int result = WaitForMultipleObjects(sz, hdl, FALSE, INFINITE);
577-#else
578- //#error WindowThread::JoinChildThreads has not been implemented for this platform.
579- // Todo
580-#endif
581-
582+ // Todo
583 return;
584 }
585
586
587=== removed file 'Nux/ActionItem.cpp'
588--- Nux/ActionItem.cpp 2012-10-10 22:46:50 +0000
589+++ Nux/ActionItem.cpp 1970-01-01 00:00:00 +0000
590@@ -1,160 +0,0 @@
591-/*
592- * Copyright 2010 Inalogic® Inc.
593- *
594- * This program is free software: you can redistribute it and/or modify it
595- * under the terms of the GNU Lesser General Public License, as
596- * published by the Free Software Foundation; either version 2.1 or 3.0
597- * of the License.
598- *
599- * This program is distributed in the hope that it will be useful, but
600- * WITHOUT ANY WARRANTY; without even the implied warranties of
601- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
602- * PURPOSE. See the applicable version of the GNU Lesser General Public
603- * License for more details.
604- *
605- * You should have received a copy of both the GNU Lesser General Public
606- * License along with this program. If not, see <http://www.gnu.org/licenses/>
607- *
608- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
609- *
610- */
611-
612-
613-#include "Nux.h"
614-#include "NuxGraphics/GLTextureResourceManager.h"
615-#include "ActionItem.h"
616-
617-namespace nux
618-{
619-
620- NUX_IMPLEMENT_OBJECT_TYPE(ActionItem);
621-
622- ActionItem::ActionItem(const char *label, int UserValue, NUX_FILE_LINE_DECL)
623- : Object(true, NUX_FILE_LINE_PARAM)
624- , m_UserValue(UserValue)
625- , m_Label("")
626- , m_IsActivated(true)
627- , m_Menu(0)
628- , m_Enable(true)
629- {
630- m_Icon = 0;
631- SetLabel(label);
632- }
633-
634- ActionItem::~ActionItem()
635- {
636- if (m_Icon)
637- m_Icon->UnReference();
638- }
639-
640- void ActionItem::DrawAsMenuItem(GraphicsEngine &graphics_engine, InputArea &area, bool is_highlighted, bool /* draw_icone */)
641- {
642- Geometry geo = area.GetGeometry();
643- Geometry icon_geo(0, 0, 20, 20);
644- Geometry text_geo = geo;
645-
646- text_geo.OffsetPosition(24, 2);
647- text_geo.OffsetSize(2 * 24, 2 * 2);
648-
649- icon_geo.SetX(geo.x + 2);
650- icon_geo.SetY(geo.y + 2);
651-
652- const char *label = GetLabel();
653-
654- if (is_highlighted)
655- {
656- GetPainter().Paint2DQuadColor(graphics_engine, geo, Color(COLOR_FOREGROUND_SECONDARY));
657- }
658-
659- if (m_Icon)
660- GetPainter().Draw2DTextureAligned(graphics_engine, m_Icon, icon_geo, TextureAlignmentStyle(eTACenter, eTACenter));
661-
662- GetPainter().PaintTextLineStatic(graphics_engine, GetSysFont(), text_geo, std::string(label), Color(0xFF000000), eAlignTextLeft);
663- }
664-
665- void ActionItem::DrawAsToolButton(GraphicsEngine &graphics_engine, InputArea &area)
666- {
667- Geometry base = area.GetGeometry();
668-
669- if (area.IsMouseOwner())
670- {
671- if (area.IsMouseInside())
672- {
673- GetPainter().PaintShape(graphics_engine, base, Color(COLOR_BACKGROUND_SECONDARY), eSHAPE_CORNER_ROUND2);
674- GetPainter().PaintShape(graphics_engine, base, Color(COLOR_BLACK), eSTROKE_CORNER_ROUND2);
675- }
676- else
677- {
678- GetPainter().PaintShape(graphics_engine, base, Color(COLOR_FOREGROUND_PRIMARY), eSHAPE_CORNER_ROUND2);
679- GetPainter().PaintShape(graphics_engine, base, Color(COLOR_BLACK), eSTROKE_CORNER_ROUND2);
680- }
681- }
682- else
683- {
684- if (area.IsMouseInside() /*TODO: && (!area.MouseFocusOnOtherArea())*/)
685- {
686- GetPainter().PaintShape(graphics_engine, base, Color(COLOR_FOREGROUND_PRIMARY), eSHAPE_CORNER_ROUND2);
687- GetPainter().PaintShape(graphics_engine, base, Color(COLOR_BLACK), eSTROKE_CORNER_ROUND2);
688- }
689- else
690- {
691- GetPainter().PaintShape(graphics_engine, base, Color(COLOR_BACKGROUND_SECONDARY), eSHAPE_CORNER_ROUND2);
692- GetPainter().PaintShape(graphics_engine, base, Color(COLOR_BLACK), eSTROKE_CORNER_ROUND2);
693- }
694- }
695-
696- GetPainter().Draw2DTextureAligned(graphics_engine, m_Icon, base, TextureAlignmentStyle(eTACenter, eTACenter));
697- }
698-
699- void ActionItem::Activate(bool b)
700- {
701- m_IsActivated = b;
702- }
703-
704- void ActionItem::Trigger() const
705- {
706- sigAction.emit();
707- }
708-
709- void ActionItem::Enable(bool b)
710- {
711- m_Enable = b;
712- }
713-
714- bool ActionItem::isEnabled() const
715- {
716- return m_Enable;
717- }
718-
719- void ActionItem::SetLabel(const char *label)
720- {
721- m_Label = label;
722- }
723-
724- const char *ActionItem::GetLabel() const
725- {
726- return m_Label.c_str();
727- }
728-
729- void ActionItem::SetIcon(const BaseTexture* icon)
730- {
731- if (m_Icon)
732- m_Icon->UnReference();
733- m_Icon = icon->Clone();
734- }
735-
736- // NUXTODO: should return the bitmap data instead or a const pointer?.
737- const BaseTexture* ActionItem::GetIcon()
738- {
739- return m_Icon;
740- }
741-
742-//void ActionItem::SetMenu(Menu* menu)
743-//{
744-// m_Menu = menu;
745-//}
746-//Menu* ActionItem::GetMenu() const
747-//{
748-// return m_Menu;
749-//}
750-}
751
752=== removed file 'Nux/ActionItem.h'
753--- Nux/ActionItem.h 2012-09-21 02:14:12 +0000
754+++ Nux/ActionItem.h 1970-01-01 00:00:00 +0000
755@@ -1,83 +0,0 @@
756-/*
757- * Copyright 2010 Inalogic® Inc.
758- *
759- * This program is free software: you can redistribute it and/or modify it
760- * under the terms of the GNU Lesser General Public License, as
761- * published by the Free Software Foundation; either version 2.1 or 3.0
762- * of the License.
763- *
764- * This program is distributed in the hope that it will be useful, but
765- * WITHOUT ANY WARRANTY; without even the implied warranties of
766- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
767- * PURPOSE. See the applicable version of the GNU Lesser General Public
768- * License for more details.
769- *
770- * You should have received a copy of both the GNU Lesser General Public
771- * License along with this program. If not, see <http://www.gnu.org/licenses/>
772- *
773- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
774- *
775- */
776-
777-
778-#ifndef ACTIONITEM_H
779-#define ACTIONITEM_H
780-
781-#include "NuxGraphics/GraphicsEngine.h"
782-
783-namespace nux
784-{
785-
786- class MenuBar;
787- class MenuPage;
788-
789- class ActionItem: public Object
790- {
791- public:
792- NUX_DECLARE_OBJECT_TYPE (ActionItem, Object);
793-
794- ActionItem (const TCHAR *label = 0, int UserValue = 0, NUX_FILE_LINE_PROTO);
795- ~ActionItem();
796-
797- void Activate (bool b);
798- void Trigger() const;
799-
800- void DrawAsMenuItem (GraphicsEngine &GfxContext, InputArea &area, bool is_highlighted, bool draw_icone);
801- void DrawAsToolButton (GraphicsEngine &GfxContext, InputArea &area);
802- void Enable (bool b);
803- bool isEnabled() const;
804-
805- void SetLabel (const TCHAR *label);
806- const TCHAR *GetLabel() const;
807- int GetUserValue() const
808- {
809- return m_UserValue;
810- }
811-
812-// void SetMenu(MenuPage* menu);
813-// MenuPage* GetMenu() const;
814-
815- void SetFont (ObjectPtr<FontTexture> font);
816- void SetIcon (const BaseTexture* icon);
817- const BaseTexture* GetIcon();
818-
819- sigc::signal<void> sigAction;
820-
821- private:
822- //! A value defined by the user at construction time.
823- int m_UserValue;
824- BaseTexture* m_Icon;
825- std::string m_Label;
826- bool m_IsActivated;
827- MenuPage *m_Menu;
828- bool m_Enable;
829-
830- friend class MenuBar;
831- friend class MenuPage;
832- };
833-
834-
835-
836-}
837-
838-#endif // ACTIONITEM_H
839
840=== removed file 'Nux/AnimatedTextureArea.cpp'
841--- Nux/AnimatedTextureArea.cpp 2012-10-02 07:32:55 +0000
842+++ Nux/AnimatedTextureArea.cpp 1970-01-01 00:00:00 +0000
843@@ -1,132 +0,0 @@
844-/*
845- * Copyright 2010 Inalogic® Inc.
846- *
847- * This program is free software: you can redistribute it and/or modify it
848- * under the terms of the GNU Lesser General Public License, as
849- * published by the Free Software Foundation; either version 2.1 or 3.0
850- * of the License.
851- *
852- * This program is distributed in the hope that it will be useful, but
853- * WITHOUT ANY WARRANTY; without even the implied warranties of
854- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
855- * PURPOSE. See the applicable version of the GNU Lesser General Public
856- * License for more details.
857- *
858- * You should have received a copy of both the GNU Lesser General Public
859- * License along with this program. If not, see <http://www.gnu.org/licenses/>
860- *
861- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
862- *
863- */
864-
865-
866-#include "Nux.h"
867-#include "NuxGraphics/ImageSurface.h"
868-#include "AnimatedTextureArea.h"
869-
870-namespace nux
871-{
872-
873- AnimatedTextureArea::AnimatedTextureArea(NUX_FILE_LINE_DECL)
874- : View(NUX_FILE_LINE_PARAM)
875- , m_UserTexture(0)
876- {
877- SetMinMaxSize(32, 32);
878-
879- mouse_down.connect(sigc::mem_fun(this, &AnimatedTextureArea::RecvMouseDown));
880- mouse_drag.connect(sigc::mem_fun(this, &AnimatedTextureArea::RecvMouseDrag));
881-
882- m_TimerFunctor = new TimerFunctor();
883- m_TimerFunctor->tick.connect(sigc::mem_fun(this, &AnimatedTextureArea::TimerNextFrame));
884- }
885-
886- AnimatedTextureArea::~AnimatedTextureArea()
887- {
888- GetTimer().RemoveTimerHandler(m_TimerHandler);
889- m_TimerHandler = 0;
890- delete m_TimerFunctor;
891- m_TimerFunctor = 0;
892- }
893-
894- void AnimatedTextureArea::Draw(GraphicsEngine &graphics_engine, bool /* force_draw */)
895- {
896- if (m_UserTexture)
897- {
898- GetPainter().PaintBackground(graphics_engine, GetGeometry());
899- graphics_engine.GetRenderStates().SetBlend(true, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
900- nux::Geometry base = GetGeometry();
901- nux::TexCoordXForm texxform;
902- graphics_engine.QRP_1Tex(base.x, base.y, base.width, base.height, m_UserTexture->GetDeviceTexture(), texxform, nux::color::White);
903-
904- graphics_engine.GetRenderStates().SetBlend(false);
905- }
906- }
907- void AnimatedTextureArea::DrawContent(GraphicsEngine & /* graphics_engine */, bool /* force_draw */)
908- {
909-
910- }
911-
912- void AnimatedTextureArea::SetTexture(TextureFrameAnimation *t)
913- {
914- m_UserTexture = t;
915-
916- if (m_UserTexture)
917- {
918- ObjectPtr< CachedTextureFrameAnimation > Texture = GetGraphicsDisplay()->GetGraphicsEngine()->CacheResource(m_UserTexture);
919- ObjectPtr<IOpenGLAnimatedTexture> AnimatedTexture = Texture->m_Texture; //Texture->m_Texture.CastRef<IOpenGLAnimatedTexture>();
920- ObjectPtr<IOpenGLBaseTexture> Texture2D = Texture->m_Texture; //Texture->m_Texture.CastRef<IOpenGLAnimatedTexture>();
921-
922- AnimatedTexture->SetFiltering(GL_LINEAR, GL_LINEAR);
923- AnimatedTexture->SetWrap(GL_CLAMP, GL_CLAMP, GL_CLAMP);
924- }
925-
926- QueueDraw();
927- }
928-
929- void AnimatedTextureArea::RecvMouseDown(int x, int y, long /* button_flags */, long /* key_flags */)
930- {
931- sigMouseDown.emit(x, y);
932- }
933-
934- void AnimatedTextureArea::RecvMouseDrag(int x, int y, int /* dx */, int /* dy */, unsigned long /* button_flags */, unsigned long /* key_flags */)
935- {
936- sigMouseDrag.emit(x, y);
937- }
938-
939- void AnimatedTextureArea::StartAnimation()
940- {
941- if (m_TimerHandler.IsValid())
942- {
943- GetTimer().RemoveTimerHandler(m_TimerHandler);
944- m_TimerHandler = 0;
945- }
946-
947- m_TimerHandler = GetTimer().AddOneShotTimer(41, m_TimerFunctor, 0);
948- QueueDraw();
949- }
950-
951- void AnimatedTextureArea::StopAnimation()
952- {
953- if (m_TimerHandler.IsValid())
954- {
955- GetTimer().RemoveTimerHandler(m_TimerHandler);
956- m_TimerHandler = 0;
957- }
958- }
959-
960- void AnimatedTextureArea::TimerNextFrame(void * /* v */)
961- {
962- if (m_UserTexture)
963- {
964- ObjectPtr< CachedTextureFrameAnimation > Texture = GetGraphicsDisplay()->GetGraphicsEngine()->CacheResource(m_UserTexture);
965- ObjectPtr<IOpenGLAnimatedTexture> AnimatedTexture = Texture->m_Texture; //Texture->m_Texture.CastRef<IOpenGLAnimatedTexture>();
966- ObjectPtr<IOpenGLBaseTexture> Texture2D = Texture->m_Texture; //Texture->m_Texture.CastRef<IOpenGLAnimatedTexture>();
967-
968- AnimatedTexture->PresentNextFrame();
969- m_TimerHandler = GetTimer().AddOneShotTimer(41, m_TimerFunctor, 0);
970- }
971-
972- QueueDraw();
973- }
974-
975-}
976
977=== removed file 'Nux/AnimatedTextureArea.h'
978--- Nux/AnimatedTextureArea.h 2012-10-02 07:32:55 +0000
979+++ Nux/AnimatedTextureArea.h 1970-01-01 00:00:00 +0000
980@@ -1,60 +0,0 @@
981-/*
982- * Copyright 2010 Inalogic® Inc.
983- *
984- * This program is free software: you can redistribute it and/or modify it
985- * under the terms of the GNU Lesser General Public License, as
986- * published by the Free Software Foundation; either version 2.1 or 3.0
987- * of the License.
988- *
989- * This program is distributed in the hope that it will be useful, but
990- * WITHOUT ANY WARRANTY; without even the implied warranties of
991- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
992- * PURPOSE. See the applicable version of the GNU Lesser General Public
993- * License for more details.
994- *
995- * You should have received a copy of both the GNU Lesser General Public
996- * License along with this program. If not, see <http://www.gnu.org/licenses/>
997- *
998- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
999- *
1000- */
1001-
1002-
1003-#ifndef ANIMATEDTEXTUREAREA_H
1004-#define ANIMATEDTEXTUREAREA_H
1005-
1006-#include "NuxGraphics/GraphicsEngine.h"
1007-#include "TimerProc.h"
1008-
1009-namespace nux
1010-{
1011-
1012- class AnimatedTextureArea : public View
1013- {
1014- public:
1015- AnimatedTextureArea(NUX_FILE_LINE_PROTO);
1016- ~AnimatedTextureArea();
1017- virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
1018- virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
1019-
1020- void SetTexture(TextureFrameAnimation *Texture);
1021- void RecvMouseDown(int x, int y, long button_flags, long key_flags);
1022- void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
1023-
1024- sigc::signal<void, int, int> sigMouseDown;
1025- sigc::signal<void, int, int> sigMouseDrag;
1026-
1027- void StartAnimation();
1028- void StopAnimation();
1029-
1030-
1031- private:
1032- void TimerNextFrame(void *v);
1033- TimerFunctor *m_TimerFunctor;
1034- TimerHandle m_TimerHandler;
1035-
1036- TextureFrameAnimation *m_UserTexture;
1037- };
1038-
1039-}
1040-#endif // ANIMATEDTEXTUREAREA_H
1041
1042=== modified file 'Nux/Area.cpp'
1043--- Nux/Area.cpp 2014-09-17 01:24:39 +0000
1044+++ Nux/Area.cpp 2014-10-24 19:52:50 +0000
1045@@ -25,11 +25,6 @@
1046 #include "NuxGraphics/GraphicsEngine.h"
1047 #include "Layout.h"
1048 #include "BaseWindow.h"
1049-#if !defined(NUX_MINIMAL)
1050-# include "VSplitter.h"
1051-# include "HSplitter.h"
1052-# include "MenuPage.h"
1053-#endif
1054
1055 #ifdef NUX_GESTURES_SUPPORT
1056 #include "NuxGraphics/GestureEvent.h"
1057@@ -522,18 +517,7 @@
1058
1059 if (ic->CanBreakLayout())
1060 {
1061-#if !defined(NUX_MINIMAL)
1062- if ((child != 0) && (ic->Type().IsObjectType(VSplitter::StaticObjectType) || ic->Type().IsObjectType(HSplitter::StaticObjectType)))
1063- {
1064- // If this element is a Splitter, then we submit its child to the refresh list. We don't want to submit the
1065- // splitter because this will cause a redraw of all parts of the splitter(costly and unnecessary).
1066- window_thread_->QueueObjectLayout(child);
1067- }
1068- else
1069-#endif
1070- {
1071- window_thread_->QueueObjectLayout(ic);
1072- }
1073+ window_thread_->QueueObjectLayout(ic);
1074 }
1075 else if (ic->parent_area_)
1076 {
1077@@ -563,22 +547,7 @@
1078
1079 if (ic->CanBreakLayout())
1080 {
1081-#if !defined(NUX_MINIMAL)
1082- if ((child != 0) &&
1083- (ic->Type().IsObjectType(VSplitter::StaticObjectType) ||
1084- ic->Type().IsObjectType(HSplitter::StaticObjectType)))
1085- {
1086- // If the parent of this element is a splitter, then we submit
1087- // its child to the refresh list. We don't want to submit the
1088- // splitter because this will cause a redraw of all parts of the
1089- // splitter(costly and unnecessary).
1090- window_thread_->QueueObjectLayout(this);
1091- }
1092- else
1093-#endif
1094- {
1095- window_thread_->QueueObjectLayout(ic);
1096- }
1097+ window_thread_->QueueObjectLayout(ic);
1098 }
1099 else
1100 {
1101@@ -790,11 +759,7 @@
1102
1103 Geometry Area::GetAbsoluteGeometry() const
1104 {
1105- if (Type().IsDerivedFromType(BaseWindow::StaticObjectType) ||
1106-#if !defined(NUX_MINIMAL)
1107- Type().IsDerivedFromType(MenuPage::StaticObjectType) ||
1108-#endif
1109- (this == window_thread_->GetLayout()))
1110+ if (Type().IsDerivedFromType(BaseWindow::StaticObjectType) || (this == window_thread_->GetLayout()))
1111 {
1112 // Do not apply the _2D_xform matrix to a BaseWindow or the main layout
1113 return geometry_;
1114@@ -972,18 +937,7 @@
1115 return false;
1116 }
1117
1118- bool mouse_pointer_inside_area = false;
1119-#if !defined(NUX_MINIMAL)
1120- if (Type().IsDerivedFromType(MenuPage::StaticObjectType))
1121- {
1122- // A MenuPage geometry is already in absolute coordinates.
1123- mouse_pointer_inside_area = geometry_.IsInside(mouse_position);
1124- }
1125- else
1126-#endif
1127- {
1128- mouse_pointer_inside_area = GetAbsoluteGeometry().IsInside(mouse_position);
1129- }
1130+ bool mouse_pointer_inside_area = GetAbsoluteGeometry().IsInside(mouse_position);
1131
1132 if ((event_type == NUX_MOUSE_WHEEL) && mouse_pointer_inside_area)
1133 {
1134@@ -1009,18 +963,7 @@
1135 return false;
1136 }
1137
1138- bool mouse_pointer_inside_area = false;
1139-#if !defined(NUX_MINIMAL)
1140- if (Type().IsDerivedFromType(MenuPage::StaticObjectType))
1141- {
1142- // A MenuPage geometry is already in absolute coordinates.
1143- mouse_pointer_inside_area = geometry_.IsInside(mouse_position);
1144- }
1145- else
1146-#endif
1147- {
1148- mouse_pointer_inside_area = GetAbsoluteGeometry().IsInside(mouse_position);
1149- }
1150+ bool mouse_pointer_inside_area = GetAbsoluteGeometry().IsInside(mouse_position);
1151
1152 return mouse_pointer_inside_area;
1153 }
1154
1155=== modified file 'Nux/Area.h'
1156--- Nux/Area.h 2012-11-12 20:59:56 +0000
1157+++ Nux/Area.h 2014-10-24 19:52:50 +0000
1158@@ -797,10 +797,6 @@
1159 friend class View;
1160 friend class WindowCompositor;
1161 friend class WindowThread;
1162-#if !defined(NUX_MINIMAL)
1163- friend class HSplitter;
1164- friend class VSplitter;
1165-#endif
1166 };
1167 }
1168 #endif // BASEOBJECT_H
1169
1170=== modified file 'Nux/BaseWindow.cpp'
1171--- Nux/BaseWindow.cpp 2013-10-30 20:50:47 +0000
1172+++ Nux/BaseWindow.cpp 2014-10-24 19:52:50 +0000
1173@@ -240,7 +240,6 @@
1174
1175 }
1176
1177-#if defined(NUX_OS_LINUX)
1178 void BaseWindow::EnableInputWindow(bool b,
1179 const char* title,
1180 bool take_focus,
1181@@ -328,8 +327,6 @@
1182 #endif
1183 }
1184
1185-#endif
1186-
1187 void BaseWindow::SetGeometry(const Geometry &geo)
1188 {
1189 Area::SetGeometry(geo);
1190
1191=== modified file 'Nux/BaseWindow.h'
1192--- Nux/BaseWindow.h 2013-10-30 20:50:47 +0000
1193+++ Nux/BaseWindow.h 2014-10-24 19:52:50 +0000
1194@@ -42,7 +42,6 @@
1195 typedef BaseWindow ViewWindow;
1196
1197 class HLayout;
1198- class PopUpWindow;
1199
1200 #ifdef NUX_GESTURES_SUPPORT
1201 class GestureEvent;
1202@@ -150,7 +149,6 @@
1203 void SetOpacity(float opacity);
1204 float GetOpacity();
1205
1206- #if defined(NUX_OS_LINUX)
1207 void EnableInputWindow(bool b,
1208 const char* title = "nux input window",
1209 bool take_focus = False,
1210@@ -165,7 +163,6 @@
1211
1212 void SetInputFocus();
1213 Window GetInputWindowId();
1214- #endif
1215
1216 //! Set an InputArea to receive the keyboard focus when the BaseWIndow receives the NUX_WINDOW_ENTER_FOCUS event.
1217 /*!
1218
1219=== removed file 'Nux/Canvas.cpp'
1220--- Nux/Canvas.cpp 2012-09-26 06:44:12 +0000
1221+++ Nux/Canvas.cpp 1970-01-01 00:00:00 +0000
1222@@ -1,208 +0,0 @@
1223-/*
1224- * Copyright (C) 2011 Canonical Ltd
1225- *
1226- * This program is free software: you can redistribute it and/or modify
1227- * it under the terms of the GNU General Public License version 3 as
1228- * published by the Free Software Foundation.
1229- *
1230- * This program is distributed in the hope that it will be useful,
1231- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1232- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1233- * GNU General Public License for more details.
1234- *
1235- * You should have received a copy of the GNU General Public License
1236- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1237- *
1238- * Authored by: Mirco Müller <mirco.mueller@canonical.com
1239- */
1240-
1241-
1242-#include "Canvas.h"
1243-
1244-namespace nux
1245-{
1246- Canvas::Canvas (NUX_FILE_LINE_DECL) : View (NUX_FILE_LINE_PARAM)
1247- {
1248- _surface = NULL;
1249- _cr = NULL;
1250- _last_width = 0;
1251- _last_height = 0;
1252- _invalid = true;
1253- _texture = NULL;
1254- }
1255-
1256- Canvas::~Canvas ()
1257- {
1258- cairo_surface_destroy (_surface);
1259- cairo_destroy (_cr);
1260- _texture->UnReference ();
1261- }
1262-
1263- void Canvas::Recreate ()
1264- {
1265- if (_surface)
1266- cairo_surface_destroy (_surface);
1267-
1268- if (_cr)
1269- cairo_destroy (_cr);
1270-
1271- if (_last_width < 1 || _last_height < 1) {
1272- g_debug ("Width or height of view invalid!");
1273- return;
1274- }
1275-
1276- _surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
1277- _last_width,
1278- _last_height);
1279-
1280- if (cairo_surface_status (_surface) != CAIRO_STATUS_SUCCESS) {
1281- g_debug ("Could not create image-surface!");
1282- return;
1283- }
1284-
1285- _cr = cairo_create (_surface);
1286- if (cairo_status (_cr) != CAIRO_STATUS_SUCCESS) {
1287- cairo_surface_destroy (_surface);
1288- g_debug ("Could not create cairo-context!");
1289- return;
1290- }
1291-
1292- cairo_set_operator (_cr, CAIRO_OPERATOR_CLEAR);
1293- cairo_paint (_cr);
1294- _invalid = false;
1295- }
1296-
1297- NBitmapData* Canvas::GetBitmap ()
1298- {
1299- if (_last_width < 1 || _last_height < 1) {
1300- g_debug ("Width or height invalid!");
1301- return NULL;
1302- }
1303-
1304- BitmapFormat bitmap_format = BITFMT_B8G8R8A8;
1305- NTextureData* bitmap_data = new NTextureData (bitmap_format,
1306- _last_width,
1307- _last_height,
1308- 1);
1309- unsigned char* ptr = cairo_image_surface_get_data (_surface);
1310- int stride = cairo_image_surface_get_stride (_surface);
1311-
1312- if (ptr == NULL || stride == 0) {
1313- g_debug ("Invalid surface!");
1314-
1315- delete bitmap_data;
1316- return NULL;
1317- }
1318-
1319- for (int j = 0; j < _last_height; j++) {
1320- Memcpy (bitmap_data->GetSurface (0).GetPtrRawData() + j * bitmap_data->GetSurface (0).GetPitch(),
1321- (const void *) (&ptr[j * stride]),
1322- _last_width * GPixelFormats[bitmap_format].NumComponents);
1323- }
1324-
1325- return bitmap_data;
1326- }
1327-
1328- cairo_surface_t* Canvas::GetCairoSurface ()
1329- {
1330- return _surface;
1331- }
1332-
1333- cairo_t* Canvas::GetCairoContext ()
1334- {
1335- return _cr;
1336- }
1337-
1338- int Canvas::GetLastWidth ()
1339- {
1340- return _last_width;
1341- }
1342-
1343- int Canvas::GetLastHeight ()
1344- {
1345- return _last_height;
1346- }
1347-
1348- // this is really just a stub... Canvas::Paint() being declared as virtual is
1349- // meant to be overwritten by a derived class anyway in real-world scenario
1350- // whatever needs to be drawn (and adapt to size) happens here in Paint()
1351- void Canvas::Paint ()
1352- {
1353- cairo_t* cr = GetCairoContext ();
1354-
1355- if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
1356- return;
1357-
1358- cairo_scale (cr, 1.0, 1.0);
1359- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1360- cairo_rectangle (cr,
1361- 0.0f,
1362- 0.0f,
1363- (double) GetLastWidth (),
1364- (double) GetLastHeight ());
1365- cairo_set_source_rgba (cr, 1.0f, 0.0f, 0.0f, 1.0f);
1366- cairo_fill_preserve (cr);
1367- cairo_set_source_rgba (cr, 1.0f, 1.0f, 1.0f, 1.0f);
1368- cairo_stroke (cr);
1369- //cairo_surface_write_to_png (GetCairoSurface (), "/tmp/surf-debug.png");
1370- }
1371-
1372- void Canvas::Draw (GraphicsEngine& graphics_engine, bool /* forceDraw */)
1373- {
1374- Geometry geom = GetGeometry ();
1375-
1376- // see if the (cairo-drawn) texture needs to be updated
1377- if (_invalid || _last_width != geom.width || _last_height != geom.height) {
1378- _last_width = geom.width;
1379- _last_height = geom.height;
1380- Recreate ();
1381- Paint ();
1382- NBitmapData* bitmap = GetBitmap ();
1383- if (_texture)
1384- _texture->UnReference ();
1385- _texture = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture ();
1386- _texture->Update (bitmap);
1387- delete bitmap;
1388- }
1389-
1390- // draw the texture on screen
1391- graphics_engine.PushClippingRectangle (geom);
1392-
1393- GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetBlend (false);
1394-
1395- TexCoordXForm texxform;
1396- texxform.SetWrap(TEXWRAP_CLAMP, TEXWRAP_CLAMP);
1397- texxform.SetTexCoordType(TexCoordXForm::OFFSET_COORD);
1398-
1399- graphics_engine.QRP_1Tex(geom.x,
1400- geom.y,
1401- geom.width,
1402- geom.height,
1403- _texture->GetDeviceTexture (),
1404- texxform,
1405- Color (1.0f, 1.0f, 1.0f, 1.0f));
1406-
1407- graphics_engine.PopClippingRectangle();
1408- }
1409-
1410- void Canvas::DrawContent(GraphicsEngine& /* graphics_engine */, bool /* forceDraw */)
1411- {
1412- }
1413-
1414- void Canvas::Invalidate()
1415- {
1416- _invalid = true;
1417- }
1418-
1419- void Canvas::PreLayoutManagement()
1420- {
1421- View::PreLayoutManagement();
1422- }
1423-
1424- long Canvas::PostLayoutManagement(long layoutResult)
1425- {
1426- long result = View::PostLayoutManagement(layoutResult);
1427-
1428- return result;
1429- }
1430-}
1431
1432=== removed file 'Nux/Canvas.h'
1433--- Nux/Canvas.h 2011-10-19 22:12:33 +0000
1434+++ Nux/Canvas.h 1970-01-01 00:00:00 +0000
1435@@ -1,62 +0,0 @@
1436-/*
1437- * Copyright (C) 2011 Canonical Ltd
1438- *
1439- * This program is free software: you can redistribute it and/or modify
1440- * it under the terms of the GNU General Public License version 3 as
1441- * published by the Free Software Foundation.
1442- *
1443- * This program is distributed in the hope that it will be useful,
1444- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1445- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1446- * GNU General Public License for more details.
1447- *
1448- * You should have received a copy of the GNU General Public License
1449- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1450- *
1451- * Authored by: Mirco Müller <mirco.mueller@canonical.com
1452- */
1453-
1454-#ifndef CANVAS_H
1455-#define CANVAS_H
1456-
1457-#include <cairo.h>
1458-
1459-#include "Nux/Nux.h"
1460-#include "Nux/View.h"
1461-
1462-namespace nux
1463-{
1464- class Canvas : public View
1465- {
1466- public:
1467- Canvas (NUX_FILE_LINE_DECL);
1468- ~Canvas ();
1469-
1470- protected:
1471- void Draw (GraphicsEngine& graphics_engine, bool forceDraw);
1472- void DrawContent (GraphicsEngine& graphics_engine, bool forceDraw);
1473- virtual void Paint ();
1474- void Invalidate ();
1475-
1476- cairo_surface_t* GetCairoSurface ();
1477- cairo_t* GetCairoContext ();
1478- int GetLastWidth ();
1479- int GetLastHeight ();
1480-
1481- private:
1482- void PreLayoutManagement ();
1483- long PostLayoutManagement (long layoutResult);
1484- void Recreate ();
1485- NBitmapData* GetBitmap ();
1486-
1487- private:
1488- cairo_t* _cr;
1489- cairo_surface_t* _surface;
1490- int _last_width;
1491- int _last_height;
1492- bool _invalid;
1493- BaseTexture* _texture;
1494- };
1495-}
1496-
1497-#endif // CANVAS_H
1498
1499=== removed file 'Nux/CheckBox.cpp'
1500--- Nux/CheckBox.cpp 2012-11-05 21:31:06 +0000
1501+++ Nux/CheckBox.cpp 1970-01-01 00:00:00 +0000
1502@@ -1,110 +0,0 @@
1503-/*
1504- * Copyright 2010 Inalogic® Inc.
1505- *
1506- * This program is free software: you can redistribute it and/or modify it
1507- * under the terms of the GNU Lesser General Public License, as
1508- * published by the Free Software Foundation; either version 2.1 or 3.0
1509- * of the License.
1510- *
1511- * This program is distributed in the hope that it will be useful, but
1512- * WITHOUT ANY WARRANTY; without even the implied warranties of
1513- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
1514- * PURPOSE. See the applicable version of the GNU Lesser General Public
1515- * License for more details.
1516- *
1517- * You should have received a copy of both the GNU Lesser General Public
1518- * License along with this program. If not, see <http://www.gnu.org/licenses/>
1519- *
1520- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
1521- *
1522- */
1523-
1524-
1525-#include "Nux.h"
1526-#include "HLayout.h"
1527-#include "CheckBox.h"
1528-#include "StaticText.h"
1529-
1530-namespace nux
1531-{
1532- NUX_IMPLEMENT_OBJECT_TYPE(CheckBox);
1533-
1534- CheckBox::CheckBox(const std::string &str, bool state, NUX_FILE_LINE_DECL)
1535- : AbstractCheckedButton(str, state, NUX_FILE_LINE_PARAM)
1536- {
1537- }
1538-
1539- CheckBox::~CheckBox()
1540- {
1541- }
1542-
1543- void CheckBox::Draw(GraphicsEngine &graphics_engine, bool /* force_draw */)
1544- {
1545- Geometry base = GetGeometry();
1546- graphics_engine.PushClippingRectangle(base);
1547-
1548- InteractState is;
1549- is.is_on = active_;
1550-
1551- if (visual_state_ == VISUAL_STATE_PRESSED)
1552- {
1553- is.is_focus = true;
1554- }
1555- else if (visual_state_ == VISUAL_STATE_PRELIGHT)
1556- {
1557- is.is_prelight = true;
1558- }
1559- else
1560- {
1561- is.is_focus = false;
1562- is.is_prelight = false;
1563- }
1564-
1565- GetPainter().PushPaintLayerStack();
1566- {
1567- GetPainter().PaintCheckBox(graphics_engine, check_area_->GetGeometry(), is, Color(0xff000000));
1568- static_text_->ProcessDraw(graphics_engine, true);
1569- }
1570- GetPainter().PopPaintLayerStack();
1571-
1572- graphics_engine.PopClippingRectangle();
1573- }
1574-
1575- void CheckBox::RecvClick(int /* x */, int /* y */, unsigned long /* button_flags */, unsigned long /* key_flags */)
1576- {
1577- active_ = !active_;
1578-
1579- click.emit(this);
1580- state_change.emit(this);
1581- QueueDraw();
1582- }
1583-
1584- void CheckBox::Activate()
1585- {
1586- if (active_ == true)
1587- {
1588- // already active
1589- return;
1590- }
1591-
1592- active_ = true;
1593- state_change.emit(this);
1594- QueueDraw();
1595- }
1596-
1597- void CheckBox::Deactivate()
1598- {
1599- if (active_ == false)
1600- return;
1601-
1602- if (active_ == false)
1603- {
1604- // already deactivated
1605- return;
1606- }
1607-
1608- active_ = false;
1609- state_change.emit(this);
1610- QueueDraw();
1611- }
1612-}
1613
1614=== removed file 'Nux/CheckBox.h'
1615--- Nux/CheckBox.h 2013-11-04 14:15:32 +0000
1616+++ Nux/CheckBox.h 1970-01-01 00:00:00 +0000
1617@@ -1,89 +0,0 @@
1618-/*
1619- * Copyright 2010 Inalogic® Inc.
1620- *
1621- * This program is free software: you can redistribute it and/or modify it
1622- * under the terms of the GNU Lesser General Public License, as
1623- * published by the Free Software Foundation; either version 2.1 or 3.0
1624- * of the License.
1625- *
1626- * This program is distributed in the hope that it will be useful, but
1627- * WITHOUT ANY WARRANTY; without even the implied warranties of
1628- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
1629- * PURPOSE. See the applicable version of the GNU Lesser General Public
1630- * License for more details.
1631- *
1632- * You should have received a copy of both the GNU Lesser General Public
1633- * License along with this program. If not, see <http://www.gnu.org/licenses/>
1634- *
1635- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
1636- *
1637- */
1638-
1639-
1640-#ifndef CHECKBOX_H
1641-#define CHECKBOX_H
1642-
1643-#include "AbstractCheckedButton.h"
1644-
1645-namespace nux
1646-{
1647- class HLayout;
1648- class InputArea;
1649- class StaticText;
1650-
1651- //! CheckBox class
1652- /*!
1653- A CheckBox class.\n
1654- The CheckBox class cannot be vertically resized. It can only be resized horizontally.
1655- The vertical size is always match the size of the content (check area + label).
1656- */
1657- class CheckBox: public AbstractCheckedButton
1658- {
1659- NUX_DECLARE_OBJECT_TYPE(CheckBox, AbstractCheckedButton);
1660- public:
1661- CheckBox(const std::string &str, bool state = false, NUX_FILE_LINE_PROTO);
1662- virtual ~CheckBox();
1663-
1664- //! Emitted when the button is clicked.
1665- sigc::signal<void, CheckBox*> click;
1666-
1667- //! Emitted when the active state changes.
1668- /*!
1669- Emitted when the active state changes, as a result of a mouse click or an API call.\n
1670- \sa Activate, Deactivate.
1671- */
1672- sigc::signal<void, CheckBox*> state_change;
1673-
1674- //! Activate the check box.
1675- /*!
1676- Activate the check box.
1677- */
1678- virtual void Activate();
1679-
1680- //! Deactivate the check box.
1681- /*!
1682- Deactivate the check box.
1683- */
1684- virtual void Deactivate();
1685-
1686- protected:
1687- virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
1688- virtual void RecvClick(int x, int y, unsigned long button_flags, unsigned long key_flags);
1689-
1690- private:
1691- //! Override of Area::SetMinimumHeight and made private.
1692- /*!
1693- Prevent changing the minimum height of the StaticText view.
1694- */
1695- virtual void SetMinimumHeight(int h){};
1696-
1697- //! Override of Area::SetMaximumHeight and made private.
1698- /*!
1699- Prevent changing the maximum height of the StaticText view.
1700- */
1701- virtual void SetMaximumHeight(int h){};
1702- };
1703-
1704-}
1705-
1706-#endif // CHECKBOX_H
1707
1708=== removed file 'Nux/ClientArea.cpp'
1709--- Nux/ClientArea.cpp 2012-11-16 18:52:32 +0000
1710+++ Nux/ClientArea.cpp 1970-01-01 00:00:00 +0000
1711@@ -1,231 +0,0 @@
1712-/*
1713- * Copyright 2010 Inalogic® Inc.
1714- *
1715- * This program is free software: you can redistribute it and/or modify it
1716- * under the terms of the GNU Lesser General Public License, as
1717- * published by the Free Software Foundation; either version 2.1 or 3.0
1718- * of the License.
1719- *
1720- * This program is distributed in the hope that it will be useful, but
1721- * WITHOUT ANY WARRANTY; without even the implied warranties of
1722- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
1723- * PURPOSE. See the applicable version of the GNU Lesser General Public
1724- * License for more details.
1725- *
1726- * You should have received a copy of both the GNU Lesser General Public
1727- * License along with this program. If not, see <http://www.gnu.org/licenses/>
1728- *
1729- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
1730- *
1731- */
1732-
1733-
1734-#include "Nux.h"
1735-
1736-#if defined(NUX_OS_WINDOWS)
1737- #include "NuxGraphics/GraphicsDisplay.h"
1738-#elif defined(NUX_OS_LINUX)
1739- #include "NuxGraphics/GraphicsDisplay.h"
1740-#endif
1741-
1742-#include "NuxGraphics/GraphicsEngine.h"
1743-#include "TimerProc.h"
1744-#include "ClientArea.h"
1745-
1746-namespace nux
1747-{
1748-
1749- ClientArea::ClientArea(NUX_FILE_LINE_DECL)
1750- : View(NUX_FILE_LINE_PARAM)
1751- {
1752- m_IsClientAreaEnabled = false;
1753- SetMinimumSize(DEFAULT_WIDGET_WIDTH, 4 * PRACTICAL_WIDGET_HEIGHT);
1754-
1755- mouse_down.connect(sigc::mem_fun(this, &ClientArea::RecvMouseDown));
1756- mouse_up.connect(sigc::mem_fun(this, &ClientArea::RecvMouseUp));
1757- mouse_drag.connect(sigc::mem_fun(this, &ClientArea::RecvMouseDrag));
1758- mouse_move.connect(sigc::mem_fun(this, &ClientArea::RecvMouseMove));
1759- key_down.connect(sigc::mem_fun(this, &ClientArea::RecvKeyEvent));
1760- }
1761-
1762- ClientArea::~ClientArea()
1763- {
1764- }
1765-
1766- void ClientArea::BeginDraw(GraphicsEngine& graphics_engine, bool force_draw)
1767- {
1768- // if ((IsRedrawNeeded() == false) && (force_draw == false))
1769- // return;
1770-
1771- // Save blend states
1772- unsigned int current_alpha_blend;
1773- unsigned int current_src_blend_factor;
1774- unsigned int current_dest_blend_factor;
1775- graphics_engine.GetRenderStates().GetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor);
1776-
1777- ObjectPtr<IOpenGLFrameBufferObject> prev_fbo_ = GetGraphicsDisplay()->GetGpuDevice()->GetCurrentFrameBufferObject();
1778- Geometry prev_viewport_ = graphics_engine.GetViewportRect();
1779-
1780- if (GetWindowThread()->GetGraphicsDisplay().HasFrameBufferSupport())
1781- {
1782- int width = GetWidth();
1783- int height = GetHeight();
1784-
1785- m_ctx.x = GetX();
1786- m_ctx.y = GetY();
1787- m_ctx.width = width;
1788- m_ctx.height = height;
1789-
1790- // A is obtained from graphics_engine. So A dimension's are in relative window coordinates.
1791- Rect A = graphics_engine.GetClippingRegion();
1792- Rect B = Rect(m_ctx.x, m_ctx.y, m_ctx.width, m_ctx.height);
1793- Rect C = A.Intersect(B);
1794-
1795- m_ctx.x_clipregion = C.x;
1796- m_ctx.y_clipregion = C.y;
1797- m_ctx.width_clipregion = C.GetWidth();
1798- m_ctx.height_clipregion = C.GetHeight();
1799-
1800- //ObjectPtr<IOpenGLFrameBufferObject> prevFBO = GetGraphicsDisplay()->GetGpuDevice()->GetCurrentFrameBufferObject();
1801-
1802- if (m_FrameBufferObject.IsNull())
1803- {
1804- // Create the fbo before using it for the first time.
1805- m_FrameBufferObject = GetGraphicsDisplay()->GetGpuDevice()->CreateFrameBufferObject();
1806- }
1807-
1808- if (!m_MainColorRT.IsValid() || (m_MainColorRT->GetWidth() != width) || (m_MainColorRT->GetHeight() != height))
1809- {
1810- // Create or resize the color and depth textures before using them.
1811- m_MainColorRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(width, height, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);
1812- m_MainDepthRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(width, height, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);
1813- }
1814-
1815- m_FrameBufferObject->FormatFrameBufferObject(width, height, BITFMT_R8G8B8A8);
1816- m_FrameBufferObject->EmptyClippingRegion();
1817- m_FrameBufferObject->SetTextureAttachment(0, m_MainColorRT, 0);
1818- m_FrameBufferObject->SetDepthTextureAttachment(m_MainDepthRT, 0);
1819- m_FrameBufferObject->Activate();
1820-
1821- graphics_engine.SetViewport(0, 0, width, height);
1822-
1823-
1824- ClientDraw(graphics_engine, m_ctx, force_draw);
1825- }
1826-
1827- if (prev_fbo_.IsValid())
1828- {
1829- // Restore the previous fbo
1830- prev_fbo_->Activate();
1831-
1832- prev_fbo_->ApplyClippingRegion();
1833- }
1834-
1835- // Restore the matrices and the view port.
1836- graphics_engine.ApplyModelViewMatrix();
1837- graphics_engine.SetOrthographicProjectionMatrix(prev_viewport_.width, prev_viewport_.height);
1838- graphics_engine.SetViewport(prev_viewport_.x, prev_viewport_.y, prev_viewport_.width, prev_viewport_.height);
1839-
1840- {
1841- unsigned int w, h;
1842- w = m_MainColorRT->GetWidth();
1843- h = m_MainColorRT->GetHeight();
1844- int x = m_ctx.x;
1845- int y = m_ctx.y;
1846-
1847- TexCoordXForm texxform0;
1848- texxform0.uwrap = TEXWRAP_CLAMP;
1849- texxform0.vwrap = TEXWRAP_CLAMP;
1850- texxform0.FlipVCoord(true);
1851- GetGraphicsDisplay()->GetGraphicsEngine()->QRP_1Tex(x, y, w, h, m_MainColorRT, texxform0, Color(color::White));
1852- }
1853-
1854- // restore blend states
1855- graphics_engine.GetRenderStates().SetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor);
1856- }
1857-
1858- void ClientArea::Draw(GraphicsEngine & /* graphics_engine */, bool /* force_draw */)
1859- {
1860- // don't draw here or we risk drawing more than one time.
1861- //BeginDraw(graphics_engine, force_draw);
1862- }
1863-
1864- void ClientArea::DrawContent(GraphicsEngine &graphics_engine, bool force_draw)
1865- {
1866- BeginDraw(graphics_engine, force_draw);
1867-
1868- }
1869-
1870- void ClientArea::ClientDraw(GraphicsEngine & /* graphics_engine */, DrawAreaContext & /* ctx */, bool /* force_draw */)
1871- {
1872- glClearColor(0, 0, 0, 1);
1873- glClear(GL_COLOR_BUFFER_BIT);
1874- }
1875-
1876- void ClientArea::SetClientViewport(GraphicsEngine &graphics_engine)
1877- {
1878- if (GetWindowThread()->GetGraphicsDisplay().HasFrameBufferSupport())
1879- {
1880- graphics_engine.SetViewport(0, 0, m_FrameBufferObject->GetWidth(), m_FrameBufferObject->GetHeight());
1881- m_FrameBufferObject->EmptyClippingRegion();
1882- }
1883- else
1884- {
1885- int window_height = graphics_engine.GetViewportHeight();
1886-
1887- graphics_engine.SetViewport(
1888- m_ctx.x, window_height - m_ctx.y - m_ctx.height, m_ctx.width, m_ctx.height);
1889-
1890- graphics_engine.SetOpenGLClippingRectangle(
1891- m_ctx.x_clipregion,
1892- window_height - m_ctx.y_clipregion - m_ctx.height_clipregion,
1893- m_ctx.width_clipregion,
1894- m_ctx.height_clipregion);
1895- }
1896- }
1897-
1898- void ClientArea::Setup2DMode(GraphicsEngine &graphics_engine)
1899- {
1900- //Restore 2D ViewPort
1901- graphics_engine.SetViewport(0, 0, GetBaseWidth(), GetBaseHeight());
1902- graphics_engine.Push2DWindow(GetBaseWidth(), GetBaseHeight());
1903-
1904- }
1905-
1906-
1907- void ClientArea::RecvMouseDown(int /* x */, int /* y */, unsigned long /* button_flags */, unsigned long /* key_flags */)
1908- {
1909-
1910- }
1911-
1912- void ClientArea::RecvMouseUp(int /* x */, int /* y */, unsigned long /* button_flags */, unsigned long /* key_flags */)
1913- {
1914-
1915- }
1916-
1917- void ClientArea::RecvMouseDrag(int /* x */, int /* y */, int /* dx */, int /* dy */, unsigned long /* button_flags */, unsigned long /* key_flags */)
1918- {
1919-
1920- }
1921-
1922- void ClientArea::RecvMouseMove(int /* x */, int /* y */, int /* dx */, int /* dy */, unsigned long /* button_flags */, unsigned long /* key_flags */)
1923- {
1924-
1925- }
1926-
1927- void ClientArea::RecvKeyEvent(
1928- unsigned long /* event_type */, /*event type*/
1929- unsigned long /* GetKeySym */, /*event keysym*/
1930- unsigned long /* event_state */, /*event state*/
1931- const char* /* event_char */, /*character*/
1932- unsigned short /* repeat_count */ /*key repeat count*/
1933- )
1934- {
1935-
1936- }
1937-
1938- bool ClientArea::AcceptKeyNavFocus()
1939- {
1940- return false;
1941- }
1942-}
1943
1944=== removed file 'Nux/ClientArea.h'
1945--- Nux/ClientArea.h 2012-11-05 21:31:06 +0000
1946+++ Nux/ClientArea.h 1970-01-01 00:00:00 +0000
1947@@ -1,104 +0,0 @@
1948-/*
1949- * Copyright 2010 Inalogic® Inc.
1950- *
1951- * This program is free software: you can redistribute it and/or modify it
1952- * under the terms of the GNU Lesser General Public License, as
1953- * published by the Free Software Foundation; either version 2.1 or 3.0
1954- * of the License.
1955- *
1956- * This program is distributed in the hope that it will be useful, but
1957- * WITHOUT ANY WARRANTY; without even the implied warranties of
1958- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
1959- * PURPOSE. See the applicable version of the GNU Lesser General Public
1960- * License for more details.
1961- *
1962- * You should have received a copy of both the GNU Lesser General Public
1963- * License along with this program. If not, see <http://www.gnu.org/licenses/>
1964- *
1965- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
1966- *
1967- */
1968-
1969-
1970-#ifndef CLIENTAREA_H
1971-#define CLIENTAREA_H
1972-
1973-#include "InputArea.h"
1974-#include "Painter.h"
1975-#include "View.h"
1976-#include "TimerProc.h"
1977-
1978-namespace nux
1979-{
1980-
1981- class ClientArea;
1982-
1983- struct ClientAreaDraw
1984- {
1985- ClientArea *clientarea;
1986- Geometry clipgeometry;
1987- };
1988-
1989- class ClientArea: public View
1990- {
1991- public:
1992- ClientArea(NUX_FILE_LINE_PROTO);
1993- ~ClientArea();
1994-
1995- virtual void BeginDraw(GraphicsEngine &graphics_engine, bool force_draw);
1996- virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
1997- virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
1998-
1999- void EnableClientDraw(bool b)
2000- {
2001- m_IsClientAreaEnabled = b;
2002- };
2003- bool IsClientDrawEnabled() const
2004- {
2005- return m_IsClientAreaEnabled;
2006- };
2007-
2008- virtual void ClientDraw(GraphicsEngine &graphics_engine, DrawAreaContext &ctx, bool force_draw);
2009- virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
2010- virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
2011- virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
2012- virtual void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
2013- virtual void RecvKeyEvent(
2014- unsigned long , /*event type*/
2015- unsigned long , /*event keysym*/
2016- unsigned long , /*event state*/
2017- const char* , /*character*/
2018- unsigned short /*key repeat count*/
2019- );
2020-
2021- sigc::signal<void, DrawAreaContext, bool> sigClientDraw;
2022- void SetClientViewport(GraphicsEngine &graphics_engine);
2023- void Setup2DMode(GraphicsEngine &graphics_engine);
2024-
2025- // Before the client start drawing we set up a framebuffer object. We don't want the client to start messing
2026- // up the whole rendering by. If we setup a framebuffer instead, the client can never know the framebuffer
2027- // we use fror the whole rendering. all we have to do is to copy the client framebuffer into the main framebuffer
2028- // after the client as finished with the draw.
2029- ObjectPtr<IOpenGLFrameBufferObject>& GetWindowFrameBufferObject()
2030- {
2031- return m_FrameBufferObject;
2032- }
2033- ObjectPtr<IOpenGLFrameBufferObject> m_FrameBufferObject;
2034-
2035- protected:
2036- virtual bool AcceptKeyNavFocus();
2037-
2038- private:
2039- // We use Rectangle texture to attach to the framebuffer because some GPU like the Geforce FX 5600 do not
2040- // have support for ARB_texture_non_power_of_two. However it does support ARB_texture_recatangle.
2041- ObjectPtr<IOpenGLBaseTexture> m_MainColorRT;
2042- ObjectPtr<IOpenGLBaseTexture> m_MainDepthRT;
2043-
2044- DrawAreaContext m_ctx;
2045- bool m_IsClientAreaEnabled;
2046- };
2047-
2048-
2049-}
2050-
2051-#endif // CLIENTAREA_H
2052
2053=== removed file 'Nux/ColorEditor.cpp'
2054--- Nux/ColorEditor.cpp 2013-04-08 14:02:32 +0000
2055+++ Nux/ColorEditor.cpp 1970-01-01 00:00:00 +0000
2056@@ -1,1042 +0,0 @@
2057-/*
2058- * Copyright 2010 Inalogic® Inc.
2059- *
2060- * This program is free software: you can redistribute it and/or modify it
2061- * under the terms of the GNU Lesser General Public License, as
2062- * published by the Free Software Foundation; either version 2.1 or 3.0
2063- * of the License.
2064- *
2065- * This program is distributed in the hope that it will be useful, but
2066- * WITHOUT ANY WARRANTY; without even the implied warranties of
2067- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
2068- * PURPOSE. See the applicable version of the GNU Lesser General Public
2069- * License for more details.
2070- *
2071- * You should have received a copy of both the GNU Lesser General Public
2072- * License along with this program. If not, see <http://www.gnu.org/licenses/>
2073- *
2074- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
2075- *
2076- */
2077-
2078-
2079-#include "Nux.h"
2080-
2081-#include "NuxGraphics/GLSh_ColorPicker.h"
2082-#include "VLayout.h"
2083-#include "HLayout.h"
2084-#include "CheckBox.h"
2085-#include "EditTextBox.h"
2086-#include "RadioButton.h"
2087-#include "RadioButtonGroup.h"
2088-#include "ToggleButton.h"
2089-#include "Layout.h"
2090-#include "ColorEditor.h"
2091-
2092-namespace nux
2093-{
2094- Size ColorEditor::picker_area_size = Size(200, 200);
2095- int ColorEditor::channel_area_width = 12;
2096-
2097- static void ThreadColorEditorDialog(NThread *thread, void *InitData)
2098- {
2099- VLayout *MainLayout(new VLayout(NUX_TRACKER_LOCATION));
2100- ColorEditor *coloreditor(new ColorEditor());
2101- coloreditor->ComputeContentSize(); // necessary so all element of the widget get their rightful size.
2102- ColorDialogProxy *coloreditorproxy = static_cast<ColorDialogProxy *> (InitData);
2103-
2104- if (coloreditorproxy)
2105- {
2106- coloreditor->SetRGB(coloreditorproxy->GetColor());
2107- coloreditor->SetColorModel(coloreditorproxy->GetColorModel(), coloreditorproxy->GetColorChannel());
2108- coloreditor->sigChange.connect(sigc::mem_fun(coloreditorproxy, &ColorDialogProxy::RecvDialogChange));
2109- }
2110-
2111- HLayout *ButtonLayout(new HLayout("Dialog Buttons", NUX_TRACKER_LOCATION));
2112-
2113- ToggleButton *OkButton(new ToggleButton("OK", NUX_TRACKER_LOCATION));
2114- OkButton->SetMinimumWidth(60);
2115- OkButton->SetMinimumHeight(20);
2116-
2117- ToggleButton *CancelButton(new ToggleButton("Cancel", NUX_TRACKER_LOCATION));
2118- CancelButton->SetMinimumWidth(60);
2119- CancelButton->SetMinimumHeight(20);
2120-
2121- //FIXME - OkButton->sigClick.connect(sigc::mem_fun(static_cast<WindowThread *> (thread), &WindowThread::TerminateThread));
2122- //FIXME - OkButton->sigClick.connect(sigc::bind(sigc::mem_fun(coloreditorproxy, &ColorDialogProxy::RecvDialogOk), coloreditor));
2123- //FIXME - CancelButton->sigClick.connect(sigc::bind(sigc::mem_fun(coloreditorproxy, &ColorDialogProxy::RecvDialogCancel), coloreditor));
2124- //FIXME - CancelButton->sigClick.connect(sigc::mem_fun(static_cast<WindowThread *> (thread), &WindowThread::TerminateThread));
2125-
2126- ButtonLayout->SetHorizontalInternalMargin(6);
2127- ButtonLayout->SetVerticalExternalMargin(2);
2128- ButtonLayout->AddView(OkButton, 0);
2129- ButtonLayout->AddView(CancelButton, 0);
2130-
2131- MainLayout->AddView(coloreditor);
2132- MainLayout->AddLayout(ButtonLayout, 0);
2133- static_cast<WindowThread *> (thread)->SetLayout(MainLayout);
2134-
2135- MainLayout->SetBaseWidth(1);
2136- MainLayout->SetBaseHeight(1);
2137- MainLayout->ComputeContentSize();
2138- static_cast<WindowThread *> (thread)->SetWindowSize(MainLayout->GetBaseWidth(), MainLayout->GetBaseHeight());
2139-
2140- // Call StopThreadMonitoring in case the dialog was close by clicking the window close button.
2141- //coloreditorproxy->StopThreadMonitoring();
2142- }
2143-
2144- ColorDialogProxy::ColorDialogProxy(bool ModalWindow)
2145- {
2146- m_bDialogChange = false;
2147- m_bDialogRunning = false;
2148- m_ModalWindow = ModalWindow;
2149- m_RGBColor = Color(1.0f, 1.0f, 1.0f, 1.0f);
2150- m_ColorModel = color::RGB;
2151- color_channel_ = color::RED;
2152- }
2153-
2154- ColorDialogProxy::~ColorDialogProxy()
2155- {
2156- }
2157-
2158- void ColorDialogProxy::Start()
2159- {
2160- m_PreviousRGBColor = m_RGBColor;
2161-
2162- int Width = 290;
2163- int Height = 230;
2164- m_Thread = CreateModalWindowThread(WINDOWSTYLE_TOOL, "Color Editor", Width, Height, GetWindowThread(),
2165- ThreadColorEditorDialog,
2166- this);
2167-
2168- if (m_Thread)
2169- {
2170- //todo(jaytaoko): m_DialogThreadID = m_Thread->GetThreadId();
2171- m_Thread->Start(0);
2172- }
2173-
2174- m_bDialogRunning = true;
2175- }
2176-
2177- bool ColorDialogProxy::IsActive()
2178- {
2179- return (m_Thread && (m_Thread->GetThreadState() != THREADSTOP) && m_bDialogRunning);
2180- }
2181-
2182- void ColorDialogProxy::RecvDialogOk(ColorEditor *coloreditor)
2183- {
2184- m_RGBColor = coloreditor->GetRGBColor();
2185- m_PreviousRGBColor = m_RGBColor;
2186- m_bDialogChange = true;
2187- m_bDialogRunning = false;
2188- }
2189-
2190- void ColorDialogProxy::RecvDialogCancel(ColorEditor* /* coloreditor */)
2191- {
2192- m_RGBColor = m_PreviousRGBColor;
2193- m_bDialogChange = true;
2194- m_bDialogRunning = false;
2195- }
2196-
2197- void ColorDialogProxy::RecvDialogChange(ColorEditor *coloreditor)
2198- {
2199- m_RGBColor = coloreditor->GetRGBColor();
2200- m_bDialogChange = true;
2201- }
2202-
2203- void ColorDialogProxy::StopThreadMonitoring()
2204- {
2205- m_RGBColor = m_PreviousRGBColor;
2206- m_bDialogChange = true;
2207- m_bDialogRunning = false;
2208- m_Thread = 0;
2209- m_DialogThreadID = 0;
2210- }
2211-
2212- void ColorDialogProxy::SetColor(Color color)
2213- {
2214- m_RGBColor = color;
2215- }
2216-
2217- Color ColorDialogProxy::GetColor()
2218- {
2219- return m_RGBColor;
2220- }
2221-
2222- void ColorDialogProxy::SetPreviousColor(Color color)
2223- {
2224- m_PreviousRGBColor = color;
2225- }
2226-
2227- Color ColorDialogProxy::GetPreviousColor()
2228- {
2229- return m_PreviousRGBColor;
2230- }
2231-
2232- void ColorDialogProxy::SetColorModel(color::Model color_model)
2233- {
2234- m_ColorModel = color_model;
2235- }
2236-
2237- color::Model ColorDialogProxy::GetColorModel()
2238- {
2239- return m_ColorModel;
2240- }
2241-
2242- void ColorDialogProxy::SetColorChannel(color::Channel color_channel)
2243- {
2244- color_channel_ = color_channel;
2245- }
2246-
2247- color::Channel ColorDialogProxy::GetColorChannel()
2248- {
2249- return color_channel_;
2250- }
2251-
2252- ColorEditor::ColorEditor(NUX_FILE_LINE_DECL)
2253- : View(NUX_FILE_LINE_PARAM)
2254- , rgb_(1.0f, 1.0f, 0.0f)
2255- , hsv_(rgb_)
2256- {
2257- m_ColorModel = color::RGB;
2258- color_channel_ = color::RED;
2259- m_MarkerPosition = Point(0, 0);
2260- m_VertMarkerPosition = Point(0, 0);
2261-
2262- m_Validator.SetMinimum(0.0);
2263- m_Validator.SetMaximum(1.0);
2264- m_Validator.SetDecimals(2);
2265-
2266- picker_area_ = new BasicView(NUX_TRACKER_LOCATION);
2267- channel_area_ = new BasicView(NUX_TRACKER_LOCATION);
2268- selected_color_area_ = new BasicView(NUX_TRACKER_LOCATION);
2269- m_hlayout = new HLayout(NUX_TRACKER_LOCATION);
2270-
2271- channel_area_->mouse_down.connect(sigc::mem_fun(this, &ColorEditor::RecvMouseDown));
2272- channel_area_->mouse_up.connect(sigc::mem_fun(this, &ColorEditor::RecvMouseUp));
2273- channel_area_->mouse_drag.connect(sigc::mem_fun(this, &ColorEditor::RecvMouseDrag));
2274-
2275- picker_area_->mouse_down.connect(sigc::mem_fun(this, &ColorEditor::RecvPickerMouseDown));
2276- picker_area_->mouse_up.connect(sigc::mem_fun(this, &ColorEditor::RecvPickerMouseUp));
2277- picker_area_->mouse_drag.connect(sigc::mem_fun(this, &ColorEditor::RecvPickerMouseDrag));
2278-
2279- selected_color_area_->SetMinMaxSize(62, 32);
2280- picker_area_->SetMinMaxSize(picker_area_size.width, picker_area_size.height);
2281- channel_area_->SetMaximumHeight(picker_area_size.height);
2282- channel_area_->SetMinimumWidth(channel_area_width);
2283- channel_area_->SetMaximumWidth(channel_area_width);
2284-
2285- m_hlayout->AddView(picker_area_, 1);
2286- m_hlayout->AddLayout(new SpaceLayout(5, 5, 20, 20), 0);
2287- m_hlayout->AddView(channel_area_, 0, eAbove, eFull);
2288- SetCompositionLayout(m_hlayout);
2289-
2290- // RGB
2291- {
2292- redlayout = new HLayout(NUX_TRACKER_LOCATION);
2293- {
2294- //FIXME - change to radio button
2295- redcheck = new RadioButton("R");
2296- redcheck->SetMinimumWidth(32);
2297- redtext = new EditTextBox("", NUX_TRACKER_LOCATION);
2298- redtext->SetMinimumWidth(36);
2299- redlayout->AddView(redcheck, 0);
2300- redlayout->AddView(redtext, 0);
2301- redcheck->click.connect(sigc::bind(sigc::bind(sigc::mem_fun(this, &ColorEditor::RecvCheckColorModel0), color::RED), color::RGB));
2302- }
2303- greenlayout = new HLayout(NUX_TRACKER_LOCATION);
2304- {
2305- //FIXME - Change to radio button
2306- greencheck = new RadioButton("G");
2307- greencheck->SetMinimumWidth(32);
2308- greentext = new EditTextBox("", NUX_TRACKER_LOCATION);
2309- greentext->SetMinimumWidth(36);
2310- greenlayout->AddView(greencheck, 0);
2311- greenlayout->AddView(greentext, 0);
2312- greencheck->click.connect(sigc::bind(sigc::bind(sigc::mem_fun(this, &ColorEditor::RecvCheckColorModel0), color::GREEN), color::RGB));
2313-
2314- }
2315- bluelayout = new HLayout(NUX_TRACKER_LOCATION);
2316- {
2317- //FIXME - change to radio button
2318- bluecheck = new RadioButton("B");
2319- bluecheck->SetMinimumWidth(32);
2320- bluetext = new EditTextBox("", NUX_TRACKER_LOCATION);
2321- bluetext->SetMinimumWidth(36);
2322- bluelayout->AddView(bluecheck, 0);
2323- bluelayout->AddView(bluetext, 0);
2324- bluecheck->click.connect(sigc::bind(sigc::bind(sigc::mem_fun(this, &ColorEditor::RecvCheckColorModel0), color::BLUE), color::RGB));
2325- }
2326- }
2327-
2328- // HSV
2329- {
2330- huelayout = new HLayout(NUX_TRACKER_LOCATION);
2331- {
2332- huecheck = new RadioButton("H");
2333- huecheck->SetMinimumWidth(32);
2334- hue_text_entry_ = new EditTextBox("", NUX_TRACKER_LOCATION);
2335- hue_text_entry_->SetMinimumWidth(36);
2336- huelayout->AddView(huecheck, 0);
2337- huelayout->AddView(hue_text_entry_, 0);
2338- huecheck->click.connect(sigc::bind(sigc::bind(sigc::mem_fun(this, &ColorEditor::RecvCheckColorModel0), color::HUE), color::HSV ));
2339- }
2340- saturationlayout = new HLayout(NUX_TRACKER_LOCATION);
2341- {
2342- saturationcheck = new RadioButton("S");
2343- saturationcheck->SetMinimumWidth(32);
2344- saturation_text_entry_ = new EditTextBox("", NUX_TRACKER_LOCATION);
2345- saturation_text_entry_->SetMinimumWidth(36);
2346- saturationlayout->AddView(saturationcheck, 0);
2347- saturationlayout->AddView(saturation_text_entry_, 0);
2348- saturationcheck->click.connect(sigc::bind(sigc::bind(sigc::mem_fun(this, &ColorEditor::RecvCheckColorModel0), color::SATURATION), color::HSV ));
2349- }
2350- valuelayout = new HLayout(NUX_TRACKER_LOCATION);
2351- {
2352- valuecheck = new RadioButton("V");
2353- valuecheck->SetMinimumWidth(32);
2354- value_text_entry_ = new EditTextBox("", NUX_TRACKER_LOCATION);
2355- value_text_entry_->SetMinimumWidth(36);
2356- valuelayout->AddView(valuecheck, 0);
2357- valuelayout->AddView(value_text_entry_, 0);
2358- valuecheck->click.connect(sigc::bind(sigc::bind(sigc::mem_fun(this, &ColorEditor::RecvCheckColorModel0), color::VALUE), color::HSV ));
2359- }
2360- }
2361-
2362- ctrllayout = new VLayout(NUX_TRACKER_LOCATION);
2363- ctrllayout->AddView(selected_color_area_);
2364- ctrllayout->AddView(new SpaceLayout(20, 20, 10, 10), 1);
2365- ctrllayout->AddLayout(redlayout, 0);
2366- ctrllayout->AddLayout(greenlayout, 0);
2367- ctrllayout->AddLayout(bluelayout, 0);
2368- ctrllayout->AddLayout(new SpaceLayout(10, 10, 10, 10));
2369- ctrllayout->AddLayout(huelayout, 0);
2370- ctrllayout->AddLayout(saturationlayout, 0);
2371- ctrllayout->AddLayout(valuelayout, 0);
2372- ctrllayout->SetHorizontalExternalMargin(2);
2373- ctrllayout->SetVerticalInternalMargin(2);
2374-
2375- m_hlayout->AddLayout(ctrllayout, 0);
2376-
2377- radiogroup = new RadioButtonGroup(NUX_TRACKER_LOCATION);
2378- radiogroup->ConnectButton(redcheck);
2379- radiogroup->ConnectButton(greencheck);
2380- radiogroup->ConnectButton(bluecheck);
2381- radiogroup->ConnectButton(huecheck);
2382- radiogroup->ConnectButton(saturationcheck);
2383- radiogroup->ConnectButton(valuecheck);
2384-
2385- m_RedShader = new GLSh_ColorPicker(color::RED);
2386- m_GreenShader = new GLSh_ColorPicker(color::GREEN);
2387- m_BlueShader = new GLSh_ColorPicker(color::BLUE);
2388- m_HueShader = new GLSh_ColorPicker(color::HUE);
2389- m_SaturationShader = new GLSh_ColorPicker(color::SATURATION);
2390- m_ValueShader = new GLSh_ColorPicker(color::VALUE);
2391-
2392- redtext->SetText(m_Validator.ToString(255 * rgb_.red));
2393- greentext->SetText(m_Validator.ToString(255 * rgb_.green));
2394- bluetext->SetText(m_Validator.ToString(255 * rgb_.blue));
2395- hue_text_entry_->SetText(m_Validator.ToString(360 * hsv_.hue));
2396- saturation_text_entry_->SetText(m_Validator.ToString(100 * hsv_.saturation));
2397- value_text_entry_->SetText(m_Validator.ToString(100 * hsv_.value));
2398- }
2399-
2400- ColorEditor::~ColorEditor()
2401- {
2402- delete m_RedShader;
2403- delete m_GreenShader;
2404- delete m_BlueShader;
2405- delete m_HueShader;
2406- delete m_SaturationShader;
2407- delete m_ValueShader;
2408- radiogroup->UnReference();
2409- }
2410-
2411- void ColorEditor::PreLayoutManagement()
2412- {
2413- View::PreLayoutManagement();
2414- if (view_layout_)
2415- {
2416- // Constrain the vertical expansion of the color picker.
2417- view_layout_->SetBaseWidth(1);
2418- view_layout_->SetBaseHeight(1);
2419- }
2420- }
2421-
2422- void ColorEditor::Draw(GraphicsEngine &graphics_engine, bool force_draw)
2423- {
2424- Geometry base = GetGeometry();
2425-
2426- base.OffsetPosition(1, 1);
2427- base.OffsetSize(-2, -2);
2428-
2429- graphics_engine.PushClippingRectangle(base);
2430- GetPainter().PushDrawShapeLayer(graphics_engine, base, eSHAPE_CORNER_ROUND4, Color(0xFF000000), eAllCorners, true);
2431-
2432- if (m_ColorModel == color::RGB)
2433- {
2434- DrawRGB(graphics_engine, force_draw);
2435- }
2436- else
2437- {
2438- DrawHSV(graphics_engine, force_draw);
2439- }
2440-
2441- GetPainter().PopBackground();
2442- graphics_engine.PopClippingRectangle();
2443- }
2444-
2445- void ColorEditor::DrawContent(GraphicsEngine &graphics_engine, bool force_draw)
2446- {
2447- Geometry base = GetGeometry();
2448- GetPainter().PushShapeLayer(graphics_engine, base, eSHAPE_CORNER_ROUND4, Color(0xFF000000), eAllCorners, true);
2449-
2450- bool force = force_draw || IsFullRedraw();
2451- redcheck->ProcessDraw(graphics_engine, force);
2452- redtext->ProcessDraw(graphics_engine, force);
2453- greencheck->ProcessDraw(graphics_engine, force);
2454- greentext->ProcessDraw(graphics_engine, force);
2455- bluecheck->ProcessDraw(graphics_engine, force);
2456- bluetext->ProcessDraw(graphics_engine, force);
2457-
2458- huecheck->ProcessDraw(graphics_engine, force);
2459- hue_text_entry_->ProcessDraw(graphics_engine, force);
2460- saturationcheck->ProcessDraw(graphics_engine, force);
2461- saturation_text_entry_->ProcessDraw(graphics_engine, force);
2462- valuecheck->ProcessDraw(graphics_engine, force);
2463- value_text_entry_->ProcessDraw(graphics_engine, force);
2464-
2465- GetPainter().PopBackground();
2466- }
2467-
2468-// Draw Marker on Base Chanel Area
2469- void ColorEditor::DrawBaseChannelMarker(GraphicsEngine &graphics_engine)
2470- {
2471- int marker_position_x;
2472- int marker_position_y;
2473-
2474- graphics_engine.PushClippingRectangle(channel_area_->GetGeometry());
2475-
2476- marker_position_x = channel_area_->GetBaseX();
2477- marker_position_y = channel_area_->GetBaseY() + m_VertMarkerPosition.y;
2478- GetPainter().Draw2DTriangleColor(graphics_engine, marker_position_x, marker_position_y - 5,
2479- marker_position_x + 5, marker_position_y,
2480- marker_position_x, marker_position_y + 5, Color(0.0f, 0.0f, 0.0f, 1.0f));
2481-
2482- GetPainter().Draw2DTriangleColor(graphics_engine, marker_position_x, marker_position_y - 4,
2483- marker_position_x + 4, marker_position_y,
2484- marker_position_x, marker_position_y + 4, Color(0.7f, 0.7f, 0.7f, 1.0f));
2485-
2486- marker_position_x = channel_area_->GetBaseX() + channel_area_->GetBaseWidth();
2487- marker_position_y = channel_area_->GetBaseY() + m_VertMarkerPosition.y;
2488- GetPainter().Draw2DTriangleColor(graphics_engine, marker_position_x, marker_position_y - 5,
2489- marker_position_x - 5, marker_position_y,
2490- marker_position_x, marker_position_y + 5, Color(0.0f, 0.0f, 0.0f, 1.0f));
2491-
2492- GetPainter().Draw2DTriangleColor(graphics_engine, marker_position_x, marker_position_y - 4,
2493- marker_position_x - 4, marker_position_y,
2494- marker_position_x, marker_position_y + 4, Color(0.7f, 0.7f, 0.7f, 1.0f));
2495- graphics_engine.PopClippingRectangle();
2496- }
2497-
2498- void ColorEditor::DrawRGB(GraphicsEngine &graphics_engine, bool /* force_draw */)
2499- {
2500- if (m_ColorModel == color::RGB)
2501- {
2502- GetPainter().Paint2DQuadColor(graphics_engine, selected_color_area_->GetGeometry(), Color(rgb_));
2503- Color BaseChannelTop;
2504- Color BaseChannelBottom;
2505-
2506- if (color_channel_ == color::RED)
2507- {
2508- m_RedShader->SetColor(rgb_.red, rgb_.green, rgb_.blue, 1.0f);
2509- m_RedShader->SetScreenPositionOffset(graphics_engine.GetViewportX(), graphics_engine.GetViewportY());
2510- BaseChannelTop = Color(1.0f, rgb_.green, rgb_.blue, 1.0f);
2511- BaseChannelBottom = Color(0.0f, rgb_.green, rgb_.blue, 1.0f);
2512- m_RedShader->Render(
2513- picker_area_->GetBaseX(),
2514- picker_area_->GetBaseY(),
2515- 0,
2516- picker_area_->GetBaseWidth(),
2517- picker_area_->GetBaseHeight(),
2518- graphics_engine.GetViewportWidth(), graphics_engine.GetViewportHeight()
2519- );
2520- }
2521- else if (color_channel_ == color::GREEN)
2522- {
2523- m_GreenShader->SetColor(rgb_.red, rgb_.green, rgb_.blue, 1.0f);
2524- m_GreenShader->SetScreenPositionOffset(graphics_engine.GetViewportX(), graphics_engine.GetViewportY());
2525- BaseChannelTop = Color(rgb_.red, 1.0f, rgb_.blue, 1.0f);
2526- BaseChannelBottom = Color(rgb_.red, 0.0f, rgb_.blue, 1.0f);
2527- m_GreenShader->Render(
2528- picker_area_->GetBaseX(),
2529- picker_area_->GetBaseY(),
2530- 0,
2531- picker_area_->GetBaseWidth(),
2532- picker_area_->GetBaseHeight(),
2533- graphics_engine.GetViewportWidth(), graphics_engine.GetViewportHeight()
2534- );
2535- }
2536- else if (color_channel_ == color::BLUE)
2537- {
2538- m_BlueShader->SetColor(rgb_.red, rgb_.green, rgb_.blue, 1.0f);
2539- m_BlueShader->SetScreenPositionOffset(graphics_engine.GetViewportX(), graphics_engine.GetViewportY());
2540- BaseChannelTop = Color(rgb_.red, rgb_.green, 1.0f, 1.0f);
2541- BaseChannelBottom = Color(rgb_.red, rgb_.green, 0.0f, 1.0f);
2542- m_BlueShader->Render(
2543- picker_area_->GetBaseX(),
2544- picker_area_->GetBaseY(),
2545- 0,
2546- picker_area_->GetBaseWidth(),
2547- picker_area_->GetBaseHeight(),
2548- graphics_engine.GetViewportWidth(), graphics_engine.GetViewportHeight()
2549- );
2550- }
2551-
2552- Geometry pickermarker = Geometry(GetBaseX() + m_MarkerPosition.x - 2, GetBaseY() + m_MarkerPosition.y - 2, 5, 5);
2553-
2554- Color color(rgb_.red, rgb_.green, rgb_.blue);
2555- float luma = color::LumaRed * rgb_.red + color::LumaGreen * rgb_.green + color::LumaBlue * rgb_.blue;
2556- Color one_minus_luma(1.0f - luma, 1.0f - luma, 1.0f - luma);
2557-
2558- GetPainter().Paint2DQuadWireframe(graphics_engine, pickermarker, one_minus_luma);
2559-
2560- GetPainter().Paint2DQuadColor(graphics_engine, channel_area_->GetGeometry(), BaseChannelTop, BaseChannelBottom, BaseChannelBottom, BaseChannelTop);
2561- // Draw Marker on Base Chanel Area
2562- DrawBaseChannelMarker(graphics_engine);
2563- }
2564- }
2565-
2566- void ColorEditor::DrawHSV(GraphicsEngine &graphics_engine, bool /* force_draw */)
2567- {
2568- if (m_ColorModel == color::HSV)
2569- {
2570- color::RedGreenBlue rgb(hsv_);
2571- GetPainter().Paint2DQuadColor(graphics_engine, selected_color_area_->GetGeometry(), Color(rgb));
2572-
2573- Color BaseChannelTop;
2574- Color BaseChannelBottom;
2575-
2576- if (color_channel_ == color::HUE)
2577- {
2578- m_HueShader->SetColor(hsv_.hue, hsv_.saturation, hsv_.value, 1.0f);
2579- m_HueShader->SetScreenPositionOffset(graphics_engine.GetViewportX(), graphics_engine.GetViewportY());
2580- m_HueShader->Render(
2581- picker_area_->GetBaseX(),
2582- picker_area_->GetBaseY(),
2583- 0,
2584- picker_area_->GetBaseWidth(),
2585- picker_area_->GetBaseHeight(),
2586- graphics_engine.GetViewportWidth(), graphics_engine.GetViewportHeight()
2587- );
2588-
2589- Geometry P = channel_area_->GetGeometry();
2590-
2591- float s = 1.0f - 1.0f;
2592- float v = 1.0f;
2593- float fw = P.GetHeight() / 6;
2594-
2595- Geometry p = Geometry(P.x, P.y, P.GetWidth(), fw);
2596- GetPainter().Paint2DQuadVGradient(graphics_engine, p, Color(1.0f * v, s * v, s * v), Color(1.0f * v, s * v, 1.0f * v));
2597- p.SetY(P.y + fw);
2598- GetPainter().Paint2DQuadVGradient(graphics_engine, p, Color(1.0f * v, s * v, 1.0f * v), Color(s * v, s * v, 1.0f * v));
2599- p.SetY(P.y + 2 * fw);
2600- GetPainter().Paint2DQuadVGradient(graphics_engine, p, Color(s * v, s * v, 1.0f * v), Color(s * v, 1.0f * v, 1.0f * v));
2601- p.SetY(P.y + 3 * fw);
2602- GetPainter().Paint2DQuadVGradient(graphics_engine, p, Color(s * v, 1.0f * v, 1.0f * v), Color(s * v, 1.0f * v, s * v));
2603- p.SetY(P.y + 4 * fw);
2604- GetPainter().Paint2DQuadVGradient(graphics_engine, p, Color(s * v, 1.0f * v, s * v), Color(1.0f * v, 1.0f * v, s * v));
2605- p.SetY(P.y + 5 * fw);
2606- p.SetHeight(P.GetHeight() - 5 * fw); // correct rounding errors
2607- GetPainter().Paint2DQuadVGradient(graphics_engine, p, Color(1.0f * v, 1.0f * v, s * v), Color(1.0f * v, s * v, s * v));
2608-
2609- Geometry pickermarker = Geometry(GetBaseX() + m_MarkerPosition.x - 2, GetBaseY() + m_MarkerPosition.y - 2, 5, 5);
2610-
2611- float luma = color::LumaRed * rgb_.red + color::LumaGreen * rgb_.green + color::LumaBlue * rgb_.blue;
2612- Color one_minus_luma(1.0f - luma, 1.0f - luma, 1.0f - luma);
2613- GetPainter().Paint2DQuadWireframe(graphics_engine, pickermarker, one_minus_luma);
2614- }
2615- else if (color_channel_ == color::SATURATION)
2616- {
2617- float value = hsv_.value;
2618- if (value < 0.3f) value = 0.3f;
2619-
2620- m_SaturationShader->SetColor(hsv_.hue, hsv_.saturation, hsv_.value, 1.0f);
2621- m_SaturationShader->SetScreenPositionOffset(graphics_engine.GetViewportX(), graphics_engine.GetViewportY());
2622- BaseChannelTop = Color(color::RedGreenBlue(color::HueSaturationValue(hsv_.hue, 1.0f, value)));
2623- BaseChannelBottom = Color(value, value, value, 1.0f);
2624- m_SaturationShader->Render(
2625- picker_area_->GetBaseX(),
2626- picker_area_->GetBaseY(),
2627- 0,
2628- picker_area_->GetBaseWidth(),
2629- picker_area_->GetBaseHeight(),
2630- graphics_engine.GetViewportWidth(), graphics_engine.GetViewportHeight()
2631- );
2632-
2633- //Geometry pickermarker = Geometry(GetX() + x - 2, GetY() + y -2, 5, 5);
2634- Geometry pickermarker = Geometry(GetBaseX() + m_MarkerPosition.x - 2, GetBaseY() + m_MarkerPosition.y - 2, 5, 5);
2635-
2636- float luma = color::LumaRed * rgb_.red + color::LumaGreen * rgb_.green + color::LumaBlue * rgb_.blue;
2637- Color one_minus_luma(1.0f - luma, 1.0f - luma, 1.0f - luma);
2638-
2639- GetPainter().Paint2DQuadWireframe(graphics_engine, pickermarker, one_minus_luma);
2640- GetPainter().Paint2DQuadColor(graphics_engine, channel_area_->GetGeometry(), BaseChannelTop, BaseChannelBottom, BaseChannelBottom, BaseChannelTop);
2641- }
2642- else if (color_channel_ == color::VALUE)
2643- {
2644- m_ValueShader->SetColor(hsv_.hue, hsv_.saturation, hsv_.value, 1.0f);
2645- m_ValueShader->SetScreenPositionOffset(graphics_engine.GetViewportX(), graphics_engine.GetViewportY());
2646- BaseChannelTop = Color(color::RedGreenBlue(color::HueSaturationValue(hsv_.hue, hsv_.saturation, 1.0f)));
2647- BaseChannelBottom = Color(color::RedGreenBlue(color::HueSaturationValue(hsv_.hue, hsv_.saturation, 0.0f)));
2648- m_ValueShader->Render(
2649- picker_area_->GetBaseX(),
2650- picker_area_->GetBaseY(),
2651- 0,
2652- picker_area_->GetBaseWidth(),
2653- picker_area_->GetBaseHeight(),
2654- graphics_engine.GetViewportWidth(), graphics_engine.GetViewportHeight()
2655- );
2656-
2657- //Geometry pickermarker = Geometry(GetX() + x - 2, GetY() + y -2, 5, 5);
2658- Geometry pickermarker = Geometry(GetBaseX() + m_MarkerPosition.x - 2, GetBaseY() + m_MarkerPosition.y - 2, 5, 5);
2659-
2660- float luma = color::LumaRed * rgb_.red + color::LumaGreen * rgb_.green + color::LumaBlue * rgb_.blue;
2661- Color one_minus_luma(1.0f - luma, 1.0f - luma, 1.0f - luma);
2662-
2663- GetPainter().Paint2DQuadWireframe(graphics_engine, pickermarker, one_minus_luma);
2664- GetPainter().Paint2DQuadColor(graphics_engine, channel_area_->GetGeometry(), BaseChannelTop, BaseChannelBottom, BaseChannelBottom, BaseChannelTop);
2665- }
2666-
2667- // Draw Marker on Base Chanel Area
2668- DrawBaseChannelMarker(graphics_engine);
2669- }
2670- }
2671-
2672- void ColorEditor::RecvMouseDown(int x, int y, unsigned long /* button_flags */, unsigned long /* key_flags */)
2673- {
2674- float BaseValue;
2675-
2676- if (m_ColorModel == color::RGB)
2677- {
2678- if (y < 0)
2679- BaseValue = 1.0f;
2680- else if (y > channel_area_->GetBaseHeight())
2681- BaseValue = 0.0f;
2682- else
2683- BaseValue = 1.0f - (float) y / (float) channel_area_->GetBaseHeight();
2684-
2685- if (color_channel_ == color::RED)
2686- rgb_.red = BaseValue;
2687- else if (color_channel_ == color::GREEN)
2688- rgb_.green = BaseValue;
2689- else if (color_channel_ == color::BLUE)
2690- rgb_.blue = BaseValue;
2691-
2692- hsv_ = color::HueSaturationValue(rgb_);
2693- }
2694-
2695- if (m_ColorModel == color::HSV)
2696- {
2697- if (y < 0)
2698- BaseValue = 1.0f;
2699- else if (y > channel_area_->GetBaseHeight())
2700- BaseValue = 0.0f;
2701- else
2702- BaseValue = 1.0f - (float) y / (float) channel_area_->GetBaseHeight();
2703-
2704- if (color_channel_ == color::HUE)
2705- {
2706- hsv_.hue = BaseValue;
2707-
2708- if (hsv_.hue >= 1.0f) hsv_.hue = 0.0f;
2709- }
2710- else if (color_channel_ == color::SATURATION)
2711- hsv_.saturation = BaseValue;
2712- else if (color_channel_ == color::VALUE)
2713- hsv_.value = BaseValue;
2714-
2715- rgb_ = color::RedGreenBlue(hsv_);
2716- }
2717-
2718- redtext->SetText(m_Validator.ToString(255 * rgb_.red));
2719- greentext->SetText(m_Validator.ToString(255 * rgb_.green));
2720- bluetext->SetText(m_Validator.ToString(255 * rgb_.blue));
2721- hue_text_entry_->SetText(m_Validator.ToString(360 * hsv_.hue));
2722- saturation_text_entry_->SetText(m_Validator.ToString(100 * hsv_.saturation));
2723- value_text_entry_->SetText(m_Validator.ToString(100 * hsv_.value));
2724- m_VertMarkerPosition = Point(Clamp<int> (x, 0, channel_area_->GetBaseWidth() - 1), Clamp<int> (y, 0, channel_area_->GetBaseHeight() - 1));
2725-
2726- sigChange.emit(this);
2727- QueueDraw();
2728- }
2729-
2730- void ColorEditor::RecvMouseUp(int /* x */, int /* y */, unsigned long /* button_flags */, unsigned long /* key_flags */)
2731- {
2732- QueueDraw();
2733- }
2734-
2735- void ColorEditor::RecvMouseDrag(int x, int y, int /* dx */, int /* dy */, unsigned long button_flags, unsigned long key_flags)
2736- {
2737- RecvMouseDown(x, y, button_flags, key_flags);
2738- }
2739-
2740- void ColorEditor::RecvPickerMouseDown(int x, int y, unsigned long /* button_flags */, unsigned long /* key_flags */)
2741- {
2742- if (m_ColorModel == color::RGB)
2743- {
2744- if (color_channel_ == color::RED)
2745- {
2746- if (y < 0)
2747- rgb_.green = 1.0f;
2748- else if (y > picker_area_->GetBaseHeight())
2749- rgb_.green = 0.0f;
2750- else
2751- rgb_.green = 1.0f - (float) y / (float) picker_area_->GetBaseHeight();
2752-
2753- if (x < 0)
2754- rgb_.blue = 0.0f;
2755- else if (x > picker_area_->GetBaseWidth())
2756- rgb_.blue = 1.0f;
2757- else
2758- rgb_.blue = (float) x / (float) picker_area_->GetBaseWidth();
2759-
2760- }
2761-
2762- if (color_channel_ == color::GREEN)
2763- {
2764- if (y < 0)
2765- rgb_.red = 1.0f;
2766- else if (y > picker_area_->GetBaseHeight())
2767- rgb_.red = 0.0f;
2768- else
2769- rgb_.red = 1.0f - (float) y / (float) picker_area_->GetBaseHeight();
2770-
2771- if (x < 0)
2772- rgb_.blue = 0.0f;
2773- else if (x > picker_area_->GetBaseWidth())
2774- rgb_.blue = 1.0f;
2775- else
2776- rgb_.blue = (float) x / (float) picker_area_->GetBaseWidth();
2777-
2778- }
2779-
2780- if (color_channel_ == color::BLUE)
2781- {
2782- if (x < 0)
2783- rgb_.red = 0.0f;
2784- else if (x > picker_area_->GetBaseWidth())
2785- rgb_.red = 1.0f;
2786- else
2787- rgb_.red = (float) x / (float) picker_area_->GetBaseWidth();
2788-
2789- if (y < 0)
2790- rgb_.green = 1.0f;
2791- else if (y > picker_area_->GetBaseHeight())
2792- rgb_.green = 0.0f;
2793- else
2794- rgb_.green = 1.0f - (float) y / (float) picker_area_->GetBaseHeight();
2795- }
2796-
2797- hsv_ = color::HueSaturationValue(rgb_);
2798- m_MarkerPosition = Point(Clamp<int> (x, 0, picker_area_->GetBaseWidth() - 1), Clamp<int> (y, 0, picker_area_->GetBaseHeight() - 1));
2799- }
2800-
2801- if (m_ColorModel == color::HSV)
2802- {
2803- if (color_channel_ == color::HUE)
2804- {
2805- if (y < 0)
2806- hsv_.value = 1.0f;
2807- else if (y > picker_area_->GetBaseHeight())
2808- hsv_.value = 0.0f;
2809- else
2810- hsv_.value = 1.0f - (float) y / (float) picker_area_->GetBaseHeight();
2811-
2812- if (x < 0)
2813- hsv_.saturation = 0.0f;
2814- else if (x > picker_area_->GetBaseWidth())
2815- hsv_.saturation = 1.0f;
2816- else
2817- hsv_.saturation = (float) x / (float) picker_area_->GetBaseWidth();
2818-
2819- }
2820-
2821- if (color_channel_ == color::SATURATION)
2822- {
2823- if (y < 0)
2824- hsv_.value = 1.0f;
2825- else if (y > picker_area_->GetBaseHeight())
2826- hsv_.value = 0.0f;
2827- else
2828- hsv_.value = 1.0f - (float) y / (float) picker_area_->GetBaseHeight();
2829-
2830- if (x < 0)
2831- hsv_.hue = 0.0f;
2832- else if (x >= picker_area_->GetBaseWidth())
2833- hsv_.hue = 0.0f;
2834- else
2835- hsv_.hue = (float) x / (float) picker_area_->GetBaseWidth();
2836-
2837- }
2838-
2839- if (color_channel_ == color::VALUE)
2840- {
2841- if (x < 0)
2842- hsv_.hue = 0.0f;
2843- else if (x >= picker_area_->GetBaseWidth())
2844- hsv_.hue = 0.0f;
2845- else
2846- hsv_.hue = (float) x / (float) picker_area_->GetBaseWidth();
2847-
2848- if (y < 0)
2849- hsv_.saturation = 1.0f;
2850- else if (y > picker_area_->GetBaseHeight())
2851- hsv_.saturation = 0.0f;
2852- else
2853- hsv_.saturation = 1.0f - (float) y / (float) picker_area_->GetBaseHeight();
2854- }
2855-
2856- rgb_ = color::RedGreenBlue(hsv_);
2857- m_MarkerPosition = Point(Clamp<int> (x, 0, picker_area_->GetBaseWidth() - 1), Clamp<int> (y, 0, picker_area_->GetBaseHeight() - 1));
2858- }
2859-
2860-
2861- redtext->SetText(m_Validator.ToString(255 * rgb_.red));
2862- greentext->SetText(m_Validator.ToString(255 * rgb_.green));
2863- bluetext->SetText(m_Validator.ToString(255 * rgb_.blue));
2864- hue_text_entry_->SetText(m_Validator.ToString(360 * hsv_.hue));
2865- saturation_text_entry_->SetText(m_Validator.ToString(100 * hsv_.saturation));
2866- value_text_entry_->SetText(m_Validator.ToString(100 * hsv_.value));
2867-
2868- sigChange.emit(this);
2869- QueueDraw();
2870- }
2871-
2872- void ColorEditor::RecvPickerMouseUp(int /* x */, int /* y */, unsigned long /* button_flags */, unsigned long /* key_flags */)
2873- {
2874- QueueDraw();
2875- }
2876-
2877- void ColorEditor::RecvPickerMouseDrag(int x, int y, int /* dx */, int /* dy */, unsigned long button_flags, unsigned long key_flags)
2878- {
2879- RecvPickerMouseDown(x, y, button_flags, key_flags);
2880- }
2881-
2882- void ColorEditor::RecvCheckColorModel0(AbstractButton * /* button */, color::Model color_mode, color::Channel color_channel)
2883- {
2884- RecvCheckColorModel(true, color_mode, color_channel);
2885- }
2886-
2887- void ColorEditor::RecvCheckColorModel(bool b, color::Model color_mode, color::Channel color_channel)
2888- {
2889- if (b)
2890- {
2891- if ((color_mode == color::HSV) && (m_ColorModel == color::RGB))
2892- {
2893- hsv_ = color::HueSaturationValue(rgb_);
2894- }
2895-
2896- if ((color_mode == color::RGB) && (m_ColorModel == color::HSV))
2897- {
2898- rgb_ = color::RedGreenBlue(hsv_);
2899- }
2900-
2901- m_ColorModel = color_mode;
2902- color_channel_ = color_channel;
2903- }
2904-
2905- if (b && (color_mode == color::RGB))
2906- {
2907- int x = 0;
2908- int y = 0;
2909- int z = 1;
2910-
2911- if (color_channel_ == color::RED)
2912- {
2913- z = (1.0f - rgb_.red) * picker_area_->GetBaseHeight();
2914- y = (1.0f - rgb_.green) * picker_area_->GetBaseHeight();
2915- x = rgb_.blue * picker_area_->GetBaseWidth();
2916- }
2917-
2918- if (color_channel_ == color::GREEN)
2919- {
2920- z = (1.0f - rgb_.green) * picker_area_->GetBaseHeight();
2921- y = (1.0f - rgb_.red) * picker_area_->GetBaseHeight();
2922- x = rgb_.blue * picker_area_->GetBaseWidth();
2923- }
2924-
2925- if (color_channel_ == color::BLUE)
2926- {
2927- z = (1.0f - rgb_.blue) * picker_area_->GetBaseHeight();
2928- y = (1.0f - rgb_.green) * picker_area_->GetBaseHeight();
2929- x = rgb_.red * picker_area_->GetBaseWidth();
2930- }
2931-
2932- m_VertMarkerPosition = Point(Clamp<int> (0, 0, channel_area_->GetBaseWidth() - 1), Clamp<int> (z, 0, channel_area_->GetBaseHeight() - 1));
2933- m_MarkerPosition = Point(Clamp<int> (x, 0, picker_area_->GetBaseWidth() - 1), Clamp<int> (y, 0, picker_area_->GetBaseHeight() - 1));
2934-
2935- redtext->SetText(m_Validator.ToString(255 * rgb_.red));
2936- greentext->SetText(m_Validator.ToString(255 * rgb_.green));
2937- bluetext->SetText(m_Validator.ToString(255 * rgb_.blue));
2938- }
2939-
2940- if (b && (color_mode == color::HSV))
2941- {
2942- int x = 0;
2943- int y = 0;
2944- int z = 1;
2945-
2946- if (color_channel_ == color::HUE)
2947- {
2948- z = (1.0f - hsv_.hue) * picker_area_->GetBaseHeight();
2949- y = (1.0f - hsv_.value) * picker_area_->GetBaseHeight();
2950- x = hsv_.saturation * picker_area_->GetBaseWidth();
2951- }
2952-
2953- if (color_channel_ == color::SATURATION)
2954- {
2955- z = (1.0f - hsv_.saturation) * picker_area_->GetBaseHeight();
2956- y = (1.0f - hsv_.value) * picker_area_->GetBaseHeight();
2957- x = hsv_.hue * picker_area_->GetBaseWidth();
2958- }
2959-
2960- if (color_channel_ == color::VALUE)
2961- {
2962- z = (1.0f - hsv_.value) * picker_area_->GetBaseHeight();
2963- y = (1.0f - hsv_.saturation) * picker_area_->GetBaseHeight();
2964- x = hsv_.hue * picker_area_->GetBaseWidth();
2965- }
2966-
2967- m_VertMarkerPosition = Point(Clamp<int> (0, 0, channel_area_->GetBaseWidth() - 1), Clamp<int> (z, 0, channel_area_->GetBaseHeight() - 1));
2968- m_MarkerPosition = Point(Clamp<int> (x, 0, picker_area_->GetBaseWidth() - 1), Clamp<int> (y, 0, picker_area_->GetBaseHeight() - 1));
2969-
2970- hue_text_entry_->SetText(m_Validator.ToString(360 * hsv_.hue));
2971- saturation_text_entry_->SetText(m_Validator.ToString(100 * hsv_.saturation));
2972- value_text_entry_->SetText(m_Validator.ToString(100 * hsv_.value));
2973- }
2974-
2975- QueueDraw();
2976- }
2977-
2978- Color ColorEditor::GetRGBColor() const
2979- {
2980- return Color(rgb_);
2981- }
2982-
2983- void ColorEditor::SetRGB(Color const& rgb)
2984- {
2985- SetRGB(rgb.red, rgb.green, rgb.blue );
2986- }
2987-
2988- void ColorEditor::SetRGB(double r, double g, double b)
2989- {
2990- rgb_ = color::RedGreenBlue(Clamp<double>(r, 0.0, 1.0),
2991- Clamp<double>(g, 0.0, 1.0),
2992- Clamp<double>(b, 0.0, 1.0));
2993- hsv_ = color::HueSaturationValue(rgb_);
2994- RecvCheckColorModel(true, m_ColorModel, color_channel_);
2995- sigChange.emit(this);
2996- }
2997-
2998- void ColorEditor::SetHSV(double h, double s, double v)
2999- {
3000- hsv_ = color::HueSaturationValue(Clamp<double>(h, 0.0, 1.0),
3001- Clamp<double>(s, 0.0, 1.0),
3002- Clamp<double>(v, 0.0, 1.0));
3003- rgb_ = color::RedGreenBlue(hsv_);
3004- RecvCheckColorModel(true, m_ColorModel, color_channel_);
3005- sigChange.emit(this);
3006- }
3007-
3008- void ColorEditor::SetRed(double red)
3009- {
3010- SetRGB(red, rgb_.green, rgb_.blue);
3011- }
3012-
3013- void ColorEditor::SetGreen(double green)
3014- {
3015- SetRGB(rgb_.red, green, rgb_.blue);
3016- }
3017-
3018- void ColorEditor::SetBlue(double blue)
3019- {
3020- SetRGB(rgb_.red, rgb_.green, blue);
3021- }
3022-
3023- void ColorEditor::SetHue(double hue)
3024- {
3025- SetHSV(hue, hsv_.saturation, hsv_.value);
3026- }
3027-
3028- void ColorEditor::SetSaturation(double saturation)
3029- {
3030- SetHSV(hsv_.hue, saturation, hsv_.value);
3031- }
3032-
3033- void ColorEditor::SetValue(double value)
3034- {
3035- SetHSV(hsv_.hue, hsv_.saturation, value);
3036- }
3037-
3038- void ColorEditor::SetColorModel(color::Model colormodel,
3039- color::Channel colorchannel)
3040- {
3041- if (colormodel == color::HSV)
3042- {
3043- if ((colorchannel != color::HUE) &&
3044- (colorchannel != color::SATURATION) &&
3045- (colorchannel != color::VALUE))
3046- {
3047- nuxDebugMsg("[ColorEditor::SetColorModel] The color model(HSV) and the color channel don't match.");
3048- return;
3049- }
3050- }
3051-
3052- if (colormodel == color::RGB)
3053- {
3054- if ((colorchannel != color::RED) &&
3055- (colorchannel != color::GREEN) &&
3056- (colorchannel != color::BLUE))
3057- {
3058- nuxDebugMsg("[ColorEditor::SetColorModel] The color model(RGB) and the color channel don't match.");
3059- return;
3060- }
3061- }
3062-
3063- m_ColorModel = colormodel;
3064- color_channel_ = colorchannel;
3065- RecvCheckColorModel(true, m_ColorModel, color_channel_);
3066-
3067- /*FIXME - disabled because we lost radiogroup
3068- if (color_channel_ == color::RED)
3069- radiogroup->ActivateButton(redcheck);
3070- else if (color_channel_ == color::GREEN)
3071- radiogroup->ActivateButton(greencheck);
3072- else if (color_channel_ == color::BLUE)
3073- radiogroup->ActivateButton(bluecheck);
3074- else if (color_channel_ == color::HUE)
3075- radiogroup->ActivateButton(huecheck);
3076- else if (color_channel_ == color::SATURATION)
3077- radiogroup->ActivateButton(saturationcheck);
3078- else if (color_channel_ == color::VALUE)
3079- radiogroup->ActivateButton(valuecheck);
3080- */
3081-
3082- }
3083-
3084- color::Model ColorEditor::GetColorModel() const
3085- {
3086- return m_ColorModel;
3087- }
3088-
3089- color::Channel ColorEditor::GetColorChannel() const
3090- {
3091- return color_channel_;
3092- }
3093-
3094- bool ColorEditor::AcceptKeyNavFocus()
3095- {
3096- return false;
3097- }
3098-}
3099
3100=== removed file 'Nux/ColorEditor.h'
3101--- Nux/ColorEditor.h 2013-11-04 15:10:08 +0000
3102+++ Nux/ColorEditor.h 1970-01-01 00:00:00 +0000
3103@@ -1,211 +0,0 @@
3104-/*
3105- * Copyright 2010 Inalogic® Inc.
3106- *
3107- * This program is free software: you can redistribute it and/or modify it
3108- * under the terms of the GNU Lesser General Public License, as
3109- * published by the Free Software Foundation; either version 2.1 or 3.0
3110- * of the License.
3111- *
3112- * This program is distributed in the hope that it will be useful, but
3113- * WITHOUT ANY WARRANTY; without even the implied warranties of
3114- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
3115- * PURPOSE. See the applicable version of the GNU Lesser General Public
3116- * License for more details.
3117- *
3118- * You should have received a copy of both the GNU Lesser General Public
3119- * License along with this program. If not, see <http://www.gnu.org/licenses/>
3120- *
3121- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
3122- *
3123- */
3124-
3125-
3126-#ifndef COLOREDITOR_H
3127-#define COLOREDITOR_H
3128-
3129-#include "NuxGraphics/GpuDevice.h"
3130-#include "NuxGraphics/GLDeviceObjects.h"
3131-#include "NuxGraphics/GLSh_DrawFunction.h"
3132-#include "DoubleValidator.h"
3133-#include "TimerProc.h"
3134-
3135-namespace nux
3136-{
3137-
3138- class GLSh_ColorPicker;
3139- class HLayout;
3140- class VLayout;
3141- class EditTextBox;
3142- class CheckBox;
3143- class AbstractButton;
3144- class RadioButton;
3145- class RadioButtonGroup;
3146- class Button;
3147-
3148- class ColorEditor;
3149- class ColorPreview;
3150-
3151- class ColorDialogProxy
3152- {
3153- public:
3154- ColorDialogProxy(bool ModalWindow);
3155- ~ColorDialogProxy();
3156-
3157- void RecvDialogOk(ColorEditor *coloreditor);
3158- void RecvDialogCancel(ColorEditor *coloreditor);
3159- void RecvDialogChange(ColorEditor *coloreditor);
3160-
3161- void Start();
3162- bool IsActive();
3163- void StopThreadMonitoring();
3164-
3165- void SetColor(Color color);
3166- Color GetColor();
3167- void SetPreviousColor(Color color);
3168- Color GetPreviousColor();
3169- void SetColorModel(color::Model color_model);
3170- color::Model GetColorModel();
3171- void SetColorChannel(color::Channel color_model);
3172- color::Channel GetColorChannel();
3173-
3174- private:
3175- bool m_bDialogChange;
3176- bool m_bDialogRunning;
3177- unsigned int m_DialogThreadID;
3178- Color m_RGBColor;
3179- Color m_PreviousRGBColor;
3180- color::Model m_ColorModel;
3181- color::Channel color_channel_;
3182- bool m_ModalWindow;
3183- NThread *m_Thread;
3184-
3185- friend class ColorPreview;
3186- };
3187-
3188- class ColorEditor : public View
3189- {
3190- public:
3191- ColorEditor(NUX_FILE_LINE_PROTO);
3192- ~ColorEditor();
3193-
3194- void SetRed(double r);
3195- void SetGreen(double g);
3196- void SetBlue(double b);
3197- void SetHue(double h);
3198- void SetSaturation(double s);
3199- void SetValue(double v);
3200-
3201- void SetRGB(double r, double g, double b);
3202- void SetHSV(double h, double s, double v);
3203- void SetRGB(Color const& rgb);
3204- Color GetRGBColor() const;
3205-
3206- void SetColorModel(color::Model, color::Channel);
3207- color::Model GetColorModel() const;
3208- color::Channel GetColorChannel() const;
3209-
3210- void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
3211- void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
3212- void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
3213-
3214- void RecvPickerMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
3215- void RecvPickerMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
3216- void RecvPickerMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
3217-
3218- void RecvCheckColorModel(bool, color::Model, color::Channel);
3219- void RecvCheckColorModel0(AbstractButton *button, color::Model color_mode, color::Channel channel);
3220-
3221- sigc::signal< void, ColorEditor * > sigChange;
3222-
3223- protected:
3224- virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
3225- virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
3226- virtual void PreLayoutManagement();
3227- virtual bool AcceptKeyNavFocus();
3228- private:
3229-
3230- //! Override of Area::SetMinimumHeight and made private.
3231- /*!
3232- Prevent changing the minimum height of the ColorEditor view.
3233- */
3234- virtual void SetMinimumHeight(int h){};
3235-
3236- //! Override of Area::SetMaximumHeight and made private.
3237- /*!
3238- Prevent changing the maximum height of the ColorEditor view.
3239- */
3240- virtual void SetMaximumHeight(int h){};
3241-
3242- //! Override of Area::SetMinimumWidth and made private.
3243- /*!
3244- Prevent changing the minimum width of the ColorEditor view.
3245- */
3246- virtual void SetMinimumWidth(int w){};
3247-
3248- //! Override of Area::SetMaximumWidth and made private.
3249- /*!
3250- Prevent changing the maximum width of the ColorEditor view.
3251- */
3252- virtual void SetMaximumWidth(int w){};
3253-
3254- void DrawBaseChannelMarker(GraphicsEngine &graphics_engine);
3255- void DrawRGB(GraphicsEngine &graphics_engine, bool force_draw);
3256- void DrawHSV(GraphicsEngine &graphics_engine, bool force_draw);
3257-
3258- color::Channel color_channel_;
3259- color::Model m_ColorModel;
3260- InputArea *picker_area_;
3261- InputArea *channel_area_;
3262- InputArea *selected_color_area_;
3263- HLayout *m_hlayout;
3264- VLayout *ctrllayout;
3265-
3266- GLSh_ColorPicker *m_RedShader;
3267- GLSh_ColorPicker *m_GreenShader;
3268- GLSh_ColorPicker *m_BlueShader;
3269-
3270- GLSh_ColorPicker *m_HueShader;
3271- GLSh_ColorPicker *m_SaturationShader;
3272- GLSh_ColorPicker *m_ValueShader;
3273-
3274- Point m_MarkerPosition;
3275- Point m_VertMarkerPosition;
3276-
3277- color::RedGreenBlue rgb_;
3278- color::HueSaturationValue hsv_;
3279-
3280- HLayout *redlayout;
3281- HLayout *greenlayout;
3282- HLayout *bluelayout;
3283-
3284- RadioButton *redcheck;
3285- EditTextBox *redtext;
3286- RadioButton *greencheck;
3287- EditTextBox *greentext;
3288- RadioButton *bluecheck;
3289- EditTextBox *bluetext;
3290-
3291- HLayout *huelayout;
3292- HLayout *saturationlayout;
3293- HLayout *valuelayout;
3294-
3295- RadioButton *huecheck;
3296- EditTextBox *hue_text_entry_;
3297- RadioButton *saturationcheck;
3298- EditTextBox *saturation_text_entry_;
3299- RadioButton *valuecheck;
3300- EditTextBox *value_text_entry_;
3301-
3302- RadioButtonGroup *radiogroup;
3303-
3304- DoubleValidator m_Validator;
3305-
3306- static Size picker_area_size;
3307- static int channel_area_width;
3308- };
3309-
3310-
3311-}
3312-
3313-#endif // COLOREDITOR_H
3314-
3315
3316=== removed file 'Nux/ColorPickerDialog.cpp'
3317--- Nux/ColorPickerDialog.cpp 2012-09-26 06:44:12 +0000
3318+++ Nux/ColorPickerDialog.cpp 1970-01-01 00:00:00 +0000
3319@@ -1,73 +0,0 @@
3320-/*
3321- * Copyright 2010 Inalogic® Inc.
3322- *
3323- * This program is free software: you can redistribute it and/or modify it
3324- * under the terms of the GNU Lesser General Public License, as
3325- * published by the Free Software Foundation; either version 2.1 or 3.0
3326- * of the License.
3327- *
3328- * This program is distributed in the hope that it will be useful, but
3329- * WITHOUT ANY WARRANTY; without even the implied warranties of
3330- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
3331- * PURPOSE. See the applicable version of the GNU Lesser General Public
3332- * License for more details.
3333- *
3334- * You should have received a copy of both the GNU Lesser General Public
3335- * License along with this program. If not, see <http://www.gnu.org/licenses/>
3336- *
3337- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
3338- *
3339- */
3340-
3341-
3342-#include "Nux.h"
3343-#include "Button.h"
3344-#include "ColorPickerDialog.h"
3345-
3346-namespace nux
3347-{
3348-
3349- static Color DummyColor;
3350-
3351- ColorPickerDialog::ColorPickerDialog()
3352- : m_Color(DummyColor)
3353- {
3354- SetWindowTitle("Color Picker");
3355- SetWindowSizeMatchLayout(true);
3356- m_Vlayout = new VLayout("Color Picker");
3357- m_ColorEditor = new ColorEditor();
3358-
3359- m_Vlayout->AddView(m_ColorEditor);
3360- m_Vlayout->AddLayout(m_ButtonLayout);
3361-
3362- m_Vlayout->SetScaleFactor(0);
3363- // Set layout for the window
3364- SetLayout(m_Vlayout);
3365- }
3366-
3367- ColorPickerDialog::~ColorPickerDialog()
3368- {
3369-
3370- }
3371-
3372- void ColorPickerDialog::StartDialog(Color &color, color::Model /* ColorModel */, bool StartModal)
3373- {
3374- Dialog::Start(StartModal);
3375- m_Color = color;
3376- }
3377-
3378- void ColorPickerDialog::RecvOk()
3379- {
3380- m_Color = m_ColorEditor->GetRGBColor();
3381- m_Color = color::Black;
3382- ShowWindow(FALSE);
3383- }
3384-
3385- void ColorPickerDialog::RecvCancel()
3386- {
3387- m_Color = DummyColor;
3388- ShowWindow(FALSE);
3389- }
3390-
3391-
3392-}
3393
3394=== removed file 'Nux/ColorPickerDialog.h'
3395--- Nux/ColorPickerDialog.h 2011-10-10 01:52:00 +0000
3396+++ Nux/ColorPickerDialog.h 1970-01-01 00:00:00 +0000
3397@@ -1,55 +0,0 @@
3398-/*
3399- * Copyright 2010 Inalogic® Inc.
3400- *
3401- * This program is free software: you can redistribute it and/or modify it
3402- * under the terms of the GNU Lesser General Public License, as
3403- * published by the Free Software Foundation; either version 2.1 or 3.0
3404- * of the License.
3405- *
3406- * This program is distributed in the hope that it will be useful, but
3407- * WITHOUT ANY WARRANTY; without even the implied warranties of
3408- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
3409- * PURPOSE. See the applicable version of the GNU Lesser General Public
3410- * License for more details.
3411- *
3412- * You should have received a copy of both the GNU Lesser General Public
3413- * License along with this program. If not, see <http://www.gnu.org/licenses/>
3414- *
3415- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
3416- *
3417- */
3418-
3419-
3420-#ifndef COLORPICKERDIALOG_H
3421-#define COLORPICKERDIALOG_H
3422-
3423-#include "Dialog.h"
3424-#include "ColorEditor.h"
3425-
3426-namespace nux
3427-{
3428-
3429- class HLayout;
3430- class VLayout;
3431-
3432- class ColorPickerDialog : public Dialog
3433- {
3434- public:
3435- ColorPickerDialog();
3436- ~ColorPickerDialog();
3437-
3438- virtual void RecvOk();
3439- virtual void RecvCancel();
3440-
3441- void StartDialog(Color &color, color::Model ColorModel = color::RGB, bool StartModal = false);
3442-
3443- private:
3444-
3445- VLayout *m_Vlayout;
3446- ColorEditor *m_ColorEditor;
3447- Color &m_Color;
3448- };
3449-
3450-}
3451-
3452-#endif // COLORPICKERDIALOG_H
3453
3454=== removed file 'Nux/ColorPreview.cpp'
3455--- Nux/ColorPreview.cpp 2012-11-05 21:31:06 +0000
3456+++ Nux/ColorPreview.cpp 1970-01-01 00:00:00 +0000
3457@@ -1,142 +0,0 @@
3458-/*
3459- * Copyright 2010 Inalogic® Inc.
3460- *
3461- * This program is free software: you can redistribute it and/or modify it
3462- * under the terms of the GNU Lesser General Public License, as
3463- * published by the Free Software Foundation; either version 2.1 or 3.0
3464- * of the License.
3465- *
3466- * This program is distributed in the hope that it will be useful, but
3467- * WITHOUT ANY WARRANTY; without even the implied warranties of
3468- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
3469- * PURPOSE. See the applicable version of the GNU Lesser General Public
3470- * License for more details.
3471- *
3472- * You should have received a copy of both the GNU Lesser General Public
3473- * License along with this program. If not, see <http://www.gnu.org/licenses/>
3474- *
3475- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
3476- *
3477- */
3478-
3479-
3480-#include "Nux.h"
3481-#include "ColorPreview.h"
3482-#include "ColorEditor.h"
3483-#include "HLayout.h"
3484-#include "TimerProc.h"
3485-#include "StaticTextBox.h"
3486-
3487-#include <sstream>
3488-#include <iomanip>
3489-
3490-namespace nux
3491-{
3492-
3493- static const int GRAPH_MARGIN = 1;
3494-
3495- ColorPreview::ColorPreview(Color const& c, NUX_FILE_LINE_DECL)
3496- : View(NUX_FILE_LINE_PARAM)
3497- , m_Color(c)
3498- {
3499- //setSize(200, 100);
3500- m_hlayout = new HLayout(NUX_TRACKER_LOCATION);
3501- m_ColorArea = new BasicView(NUX_TRACKER_LOCATION);
3502- m_ColorValue = new StaticTextBox("", NUX_TRACKER_LOCATION);
3503- m_DialogThreadProxy = new ColorDialogProxy(true);
3504-
3505- SetMaximumHeight(18);
3506- m_ColorArea->SetMaximumHeight(18);
3507- m_ColorArea->SetMinimumWidth(32);
3508- m_ColorArea->SetMaximumWidth(32);
3509- m_ColorValue->SetTextColor(Color(0xFFFFFFFF));
3510- m_ColorValue->SetFont(GetSysBoldFont());
3511- m_ColorValue->SetMinimumWidth(128);
3512-
3513- std::stringstream s;
3514- s << "[ R:" << (int)(m_Color.red * 255)
3515- << ", G:" << (int)(m_Color.green * 255)
3516- << ", B:" << (int)(m_Color.blue * 255)
3517- << " ]";
3518- m_ColorValue->SetText(s.str());
3519-
3520- m_ColorArea->mouse_click.connect(sigc::mem_fun(this, &ColorPreview::RecvClick));
3521-
3522- m_hlayout->AddView(m_ColorArea, 0);
3523- m_hlayout->AddView(m_ColorValue, 1);
3524- m_hlayout->SetHorizontalInternalMargin(4);
3525- SetCompositionLayout(m_hlayout);
3526-
3527- m_ChangeDetectionTimer = new TimerFunctor();
3528- m_ChangeDetectionTimer->tick.connect(sigc::mem_fun(this, &ColorPreview::RecvTimer));
3529- m_ChangeTimerHandler = 0;
3530- }
3531-
3532- ColorPreview::~ColorPreview()
3533- {
3534- delete m_ChangeDetectionTimer;
3535-
3536- if (m_ChangeTimerHandler.IsValid())
3537- GetTimer().RemoveTimerHandler(m_ChangeTimerHandler);
3538-
3539- delete m_DialogThreadProxy;
3540- }
3541-
3542- void ColorPreview::Draw(GraphicsEngine &graphics_engine, bool /* force_draw */)
3543- {
3544- Geometry base = GetGeometry();
3545-
3546- GetPainter().PaintBackground(graphics_engine, base);
3547- GetPainter().PaintShape(graphics_engine, m_ColorArea->GetGeometry(), m_Color, eSHAPE_CORNER_ROUND4, false);
3548- //GetPainter().Paint2DQuadWireFrameColor(graphics_engine, base, Color(COLOR_BACKGROUND_SECONDARY));
3549- m_ColorValue->QueueDraw();
3550- }
3551-
3552- void ColorPreview::DrawContent(GraphicsEngine &graphics_engine, bool force_draw)
3553- {
3554- m_ColorValue->ProcessDraw(graphics_engine, force_draw);
3555- }
3556-
3557- void ColorPreview::RecvClick(int /* x */, int /* y */, unsigned long /* button_flags */, unsigned long /* key_flags */)
3558- {
3559- m_DialogThreadProxy->SetColor(m_Color);
3560- m_DialogThreadProxy->Start();
3561-
3562- m_ChangeTimerHandler = GetTimer().AddOneShotTimer(33, m_ChangeDetectionTimer, this);
3563- }
3564-
3565- void ColorPreview::RecvTimer(void * /* v */)
3566- {
3567- if (m_DialogThreadProxy->m_bDialogChange && m_DialogThreadProxy->m_bDialogRunning)
3568- {
3569- m_DialogThreadProxy->m_bDialogChange = false;
3570- m_Color = m_DialogThreadProxy->GetColor();
3571- QueueDraw();
3572- }
3573-
3574- if (m_DialogThreadProxy->IsActive())
3575- {
3576- m_ChangeTimerHandler = GetTimer().AddOneShotTimer(33, m_ChangeDetectionTimer, this);
3577- }
3578- else
3579- {
3580- if (m_ChangeTimerHandler.IsValid())
3581- GetTimer().RemoveTimerHandler(m_ChangeTimerHandler);
3582-
3583- m_ChangeTimerHandler = 0;
3584- m_Color = m_DialogThreadProxy->GetColor();
3585- QueueDraw();
3586- }
3587- }
3588-
3589- Color const& ColorPreview::GetRGBColor() const
3590- {
3591- return m_Color;
3592- }
3593-
3594- void ColorPreview::SetColor(Color const& color)
3595- {
3596- m_Color = color;
3597- }
3598-
3599-}
3600
3601=== removed file 'Nux/ColorPreview.h'
3602--- Nux/ColorPreview.h 2012-10-02 07:32:55 +0000
3603+++ Nux/ColorPreview.h 1970-01-01 00:00:00 +0000
3604@@ -1,70 +0,0 @@
3605-/*
3606- * Copyright 2010 Inalogic® Inc.
3607- *
3608- * This program is free software: you can redistribute it and/or modify it
3609- * under the terms of the GNU Lesser General Public License, as
3610- * published by the Free Software Foundation; either version 2.1 or 3.0
3611- * of the License.
3612- *
3613- * This program is distributed in the hope that it will be useful, but
3614- * WITHOUT ANY WARRANTY; without even the implied warranties of
3615- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
3616- * PURPOSE. See the applicable version of the GNU Lesser General Public
3617- * License for more details.
3618- *
3619- * You should have received a copy of both the GNU Lesser General Public
3620- * License along with this program. If not, see <http://www.gnu.org/licenses/>
3621- *
3622- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
3623- *
3624- */
3625-
3626-
3627-#ifndef COLORPREVIEW_H
3628-#define COLORPREVIEW_H
3629-
3630-#include "NuxCore/Color.h"
3631-#include "NuxGraphics/GpuDevice.h"
3632-#include "NuxGraphics/GLDeviceObjects.h"
3633-#include "TimerProc.h"
3634-
3635-namespace nux
3636-{
3637-
3638- class HLayout;
3639- class StaticTextBox;
3640- class ColorEditor;
3641- class TimerHandle;
3642- class ColorDialogProxy;
3643-
3644- class ColorPreview : public View
3645- {
3646- public:
3647- ColorPreview(Color const& c = nux::color::Transparent, NUX_FILE_LINE_PROTO);
3648- ~ColorPreview();
3649- virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
3650- virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
3651-
3652- sigc::signal< void, ColorEditor * > sigColorChanged;
3653-
3654- void SetColor(Color const& rgb);
3655- Color const& GetRGBColor() const;
3656-
3657- private:
3658- void RecvTimer(void *v);
3659- void RecvClick(int x, int y, unsigned long button_flags, unsigned long key_flags);
3660-
3661- TimerFunctor *m_ChangeDetectionTimer;
3662- TimerHandle m_ChangeTimerHandler;
3663-
3664- Color m_Color;
3665- HLayout *m_hlayout;
3666- InputArea *m_ColorArea;
3667- StaticTextBox *m_ColorValue;
3668- ColorDialogProxy *m_DialogThreadProxy;
3669- };
3670-
3671-
3672-}
3673-
3674-#endif // COLORPREVIEW_H
3675
3676=== removed file 'Nux/ComboBoxSimple.cpp'
3677--- Nux/ComboBoxSimple.cpp 2012-07-24 05:39:41 +0000
3678+++ Nux/ComboBoxSimple.cpp 1970-01-01 00:00:00 +0000
3679@@ -1,316 +0,0 @@
3680-/*
3681- * Copyright 2010 Inalogic® Inc.
3682- *
3683- * This program is free software: you can redistribute it and/or modify it
3684- * under the terms of the GNU Lesser General Public License, as
3685- * published by the Free Software Foundation; either version 2.1 or 3.0
3686- * of the License.
3687- *
3688- * This program is distributed in the hope that it will be useful, but
3689- * WITHOUT ANY WARRANTY; without even the implied warranties of
3690- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
3691- * PURPOSE. See the applicable version of the GNU Lesser General Public
3692- * License for more details.
3693- *
3694- * You should have received a copy of both the GNU Lesser General Public
3695- * License along with this program. If not, see <http://www.gnu.org/licenses/>
3696- *
3697- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
3698- *
3699- */
3700-
3701-
3702-#include "Nux.h"
3703-#include "ComboBoxSimple.h"
3704-#include "MenuPage.h"
3705-#include "ActionItem.h"
3706-#include "StaticText.h"
3707-
3708-
3709-namespace nux
3710-{
3711- ComboBoxSimple::ComboBoxSimple(NUX_FILE_LINE_DECL)
3712- : AbstractComboBox(NUX_FILE_LINE_PARAM)
3713- {
3714- m_SelectedAction = 0;
3715- m_CurrentMenu = 0;
3716-
3717- m_CurrentMenu = new MenuPage("", NUX_TRACKER_LOCATION);
3718- m_CurrentMenu->SinkReference();
3719- m_CurrentMenu->SetParentObject(this);
3720-
3721- // Set Signals
3722- _combo_box_opening_area->mouse_down.connect(sigc::mem_fun(this, &ComboBoxSimple::RecvMouseDown));
3723- _combo_box_opening_area->mouse_up.connect(sigc::mem_fun(this, &ComboBoxSimple::RecvMouseUp));
3724- _combo_box_area->mouse_down.connect(sigc::mem_fun(this, &ComboBoxSimple::RecvMouseDown));
3725- _combo_box_area->mouse_up.connect(sigc::mem_fun(this, &ComboBoxSimple::RecvMouseUp));
3726-
3727- //m_Popup.sigPopupStop.connect(sigc::mem_fun(this, &ComboBox::OnPopupStop));
3728-
3729- // Set Geometry
3730- _combo_box_opening_area->SetGeometry(Geometry(0, 0, 20, DEFAULT_WIDGET_HEIGHT));
3731- //_combo_box_opening_area->SetMaximumSize(20, DEFAULT_WIDGET_HEIGHT);
3732- _combo_box_opening_area->SetMinimumSize(20, DEFAULT_WIDGET_HEIGHT);
3733-
3734- _combo_box_area->SetMinimumSize(2 * DEFAULT_WIDGET_WIDTH, PRACTICAL_WIDGET_HEIGHT);
3735- _combo_box_area->SetGeometry(Geometry(0, 0, 3 * DEFAULT_WIDGET_WIDTH, PRACTICAL_WIDGET_HEIGHT));
3736- //_pango_static_text->SetClipping(_combo_box_area->GetBaseWidth());
3737- _combo_box_area->geometry_changed.connect(sigc::mem_fun(this, &ComboBoxSimple::RecvGeometryChanged));
3738-
3739- //m_CurrentMenu = new MenuPage;
3740- m_CurrentMenu->SetParentMenu(0);
3741- m_CurrentMenu->sigActionTriggered.connect(sigc::mem_fun(this, &ComboBoxSimple::RecvSigActionTriggered));
3742- m_CurrentMenu->sigTerminateMenuCascade.connect(sigc::mem_fun(this, &ComboBoxSimple::RecvSigTerminateMenuCascade));
3743- m_CurrentMenu->sigClosingMenu.connect(sigc::mem_fun(this, &ComboBoxSimple::RecvClosingMenuSignal));
3744- }
3745-
3746- ComboBoxSimple::~ComboBoxSimple()
3747- {
3748- m_CurrentMenu->UnParentObject();
3749- m_CurrentMenu->UnReference();
3750- }
3751-
3752- Area* ComboBoxSimple::FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type)
3753- {
3754- bool mouse_inside = TestMousePointerInclusionFilterMouseWheel(mouse_position, event_type);
3755-
3756- if (mouse_inside == false)
3757- return NULL;
3758-
3759- NUX_RETURN_VALUE_IF_TRUE(_combo_box_opening_area->TestMousePointerInclusion(mouse_position, event_type), _combo_box_opening_area);
3760- NUX_RETURN_VALUE_IF_TRUE(_combo_box_area->TestMousePointerInclusion(mouse_position, event_type), _combo_box_area);
3761-
3762- if ((event_type == NUX_MOUSE_WHEEL) && (!AcceptMouseWheelEvent()))
3763- return NULL;
3764- return this;
3765- }
3766-
3767- void ComboBoxSimple::MoveSelectionUp()
3768- {
3769- int current_index = GetSelectionIndex();
3770- SetSelectionIndex(current_index - 1);
3771- }
3772-
3773- void ComboBoxSimple::MoveSelectionDown()
3774- {
3775- int current_index = GetSelectionIndex();
3776- SetSelectionIndex(current_index + 1);
3777- }
3778-
3779- ActionItem *ComboBoxSimple::AddItem(const char *label, int Uservalue)
3780- {
3781- if (m_CurrentMenu->GetNumItem() == 0)
3782- {
3783- // The first element added is the element featured on the combo box when it is closed.
3784- m_SelectedAction = m_CurrentMenu->AddAction(label, Uservalue);
3785- _combo_box_area->SetBaseString(m_SelectedAction->GetLabel());
3786-
3787- _pango_static_text->SetText(m_SelectedAction->GetLabel());
3788-
3789- return m_SelectedAction;
3790- }
3791- else
3792- {
3793- return m_CurrentMenu->AddAction(label, Uservalue);
3794- }
3795- }
3796-
3797- void ComboBoxSimple::RemoveItem(ActionItem *item)
3798- {
3799-
3800- }
3801-
3802- void ComboBoxSimple::RemoveAllItem()
3803- {
3804- m_CurrentMenu->RemoveAllItem();
3805- }
3806-
3807- void ComboBoxSimple::RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags)
3808- {
3809- if (m_MenuIsActive == false)
3810- {
3811- // Open the MenuPage
3812- m_MenuIsActive = true;
3813- m_IsOpeningMenu = true;
3814-
3815- Geometry geo = m_CurrentMenu->GetGeometry();
3816- geo.SetX(_combo_box_area->GetAbsoluteX());
3817- geo.SetY(_combo_box_area->GetAbsoluteY() + _combo_box_area->GetBaseHeight());
3818- geo.SetWidth(_combo_box_area->GetBaseWidth());
3819- //m_CurrentMenu->SetMinimumWidth(geo.width);
3820- //m_CurrentMenu->SetMaximumWidth(geo.width);
3821- m_CurrentMenu->SetGeometry(geo);
3822- m_CurrentMenu->ComputeContentSize();
3823- m_CurrentMenu->StartMenu(_combo_box_area->GetAbsoluteX(),
3824- _combo_box_area->GetAbsoluteY() + _combo_box_area->GetBaseHeight(),
3825- 0, 0);
3826- }
3827- else
3828- {
3829- // If the mouse up that follows happen inside the area, then it is going to close the menu.
3830- m_IsOpeningMenu = false;
3831- }
3832-
3833- QueueDraw();
3834- }
3835-
3836- void ComboBoxSimple::RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags)
3837- {
3838- if (m_MenuIsActive)
3839- {
3840- if (_combo_box_area->IsMouseInside() || _combo_box_opening_area->IsMouseInside())
3841- {
3842- if (m_IsOpeningMenu == false)
3843- {
3844- // close the MenuPage that is Open
3845- m_CurrentMenu->StopMenu(0, 0);
3846- m_MenuIsActive = false;
3847- }
3848- else
3849- {
3850- // The MousePress before this MouseRelease, caused the MenuPage to open.
3851- // Set m_IsOpeningMenu so the next mouse release will close the menu.
3852- m_IsOpeningMenu = false;
3853- m_MenuIsActive = true;
3854- }
3855- }
3856- else
3857- {
3858- bool hit_inside_a_menu = false;
3859- bool b = m_CurrentMenu->TestMouseUp(x, y, button_flags, key_flags, hit_inside_a_menu);
3860-
3861- if (b || (hit_inside_a_menu == false))
3862- {
3863- RecvSigTerminateMenuCascade();
3864- m_MenuIsActive = false;
3865- }
3866- }
3867- }
3868-
3869- QueueDraw();
3870- }
3871-
3872- void ComboBoxSimple::RecvSigActionTriggered(MenuPage *menu, ActionItem *action)
3873- {
3874- m_MenuIsActive = false;
3875- m_CurrentMenu->StopMenu();
3876-
3877- m_SelectedAction = action;
3878- _combo_box_area->SetBaseString(m_SelectedAction->GetLabel());
3879- m_IsOpeningMenu = false;
3880-
3881- _pango_static_text->SetText(m_SelectedAction->GetLabel());
3882-
3883- sigTriggered.emit(this);
3884- sigActionTriggered.emit(m_SelectedAction);
3885-
3886- QueueDraw();
3887- // You can do something if you want with the menu* and the action*
3888- }
3889-
3890- void ComboBoxSimple::RecvSigActionTriggered2(TableCtrl *table, TableItem *item, unsigned int row, unsigned int column)
3891- {
3892- m_MenuIsActive = false;
3893- m_CurrentMenu->StopMenu();
3894- m_IsOpeningMenu = false;
3895- QueueDraw();
3896- // You can do something if you want with the menu* and the action*
3897- }
3898-
3899- void ComboBoxSimple::RecvSigTerminateMenuCascade()
3900- {
3901- //m_MenuIsActive = false;
3902- m_CurrentMenu->StopMenu();
3903- m_IsOpeningMenu = false;
3904- }
3905-
3906- void ComboBoxSimple::RecvClosingMenuSignal(MenuPage* menu_page)
3907- {
3908- nuxAssert(menu_page == m_CurrentMenu);
3909- m_IsOpeningMenu = false;
3910- m_MenuIsActive = false;
3911-
3912- // When the menu is closing check if the mouse is still inside the combo box surface
3913- // and set the _current_mouse_in flag accordingly.
3914- if (!_combo_box_area->TestMousePointerInclusion(GetWindowThread()->GetWindowCompositor().GetMousePosition(), NUX_NO_EVENT))
3915- {
3916- _combo_box_area->mouse_in_ = false;
3917- }
3918-
3919- if (!_combo_box_opening_area->TestMousePointerInclusion(GetWindowThread()->GetWindowCompositor().GetMousePosition(), NUX_NO_EVENT))
3920- {
3921- _combo_box_opening_area->mouse_in_ = false;
3922- }
3923-
3924- QueueDraw();
3925- }
3926-
3927- void ComboBoxSimple::RecvGeometryChanged(Area *area, Geometry &geo)
3928- {
3929- //_pango_static_text->SetClipping(geo.width);
3930- }
3931-
3932-
3933- const char *ComboBoxSimple::GetSelectionLabel() const
3934- {
3935- if (m_SelectedAction)
3936- return m_SelectedAction->GetLabel();
3937-
3938- return 0;
3939- }
3940-
3941- int ComboBoxSimple::GetSelectionUserValue() const
3942- {
3943- if (m_SelectedAction)
3944- return m_SelectedAction->GetUserValue();
3945-
3946- return 0;
3947- }
3948-
3949- int ComboBoxSimple::GetNumItem() const
3950- {
3951- return m_CurrentMenu->GetNumItem();
3952- }
3953-
3954- ActionItem *ComboBoxSimple::GetItem(int index) const
3955- {
3956- return m_CurrentMenu->GetActionItem(index);
3957- }
3958-
3959- int ComboBoxSimple::GetSelectionIndex() const
3960- {
3961- if (m_SelectedAction)
3962- return m_CurrentMenu->GetActionItemIndex(m_SelectedAction);
3963-
3964- return -1;
3965- }
3966-
3967- void ComboBoxSimple::SetSelectionIndex(int index)
3968- {
3969- if ((index >= 0) && (index < m_CurrentMenu->GetNumItem()))
3970- {
3971- m_SelectedAction = m_CurrentMenu->GetActionItem(index);
3972- _combo_box_area->SetBaseString(m_SelectedAction->GetLabel());
3973-
3974- _pango_static_text->SetText(m_SelectedAction->GetLabel());
3975-
3976- QueueDraw();
3977- }
3978- else if (m_CurrentMenu->GetNumItem() > 0)
3979- {
3980- // index is negative
3981- m_SelectedAction = m_CurrentMenu->GetActionItem(0);
3982- _combo_box_area->SetBaseString(m_SelectedAction->GetLabel());
3983-
3984- _pango_static_text->SetText(m_SelectedAction->GetLabel());
3985-
3986- QueueDraw();
3987- }
3988- else
3989- {
3990- m_SelectedAction = 0;
3991- }
3992- }
3993-
3994-
3995-}
3996
3997=== removed file 'Nux/ComboBoxSimple.h'
3998--- Nux/ComboBoxSimple.h 2012-10-02 07:32:55 +0000
3999+++ Nux/ComboBoxSimple.h 1970-01-01 00:00:00 +0000
4000@@ -1,96 +0,0 @@
4001-/*
4002- * Copyright 2010 Inalogic® Inc.
4003- *
4004- * This program is free software: you can redistribute it and/or modify it
4005- * under the terms of the GNU Lesser General Public License, as
4006- * published by the Free Software Foundation; either version 2.1 or 3.0
4007- * of the License.
4008- *
4009- * This program is distributed in the hope that it will be useful, but
4010- * WITHOUT ANY WARRANTY; without even the implied warranties of
4011- * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
4012- * PURPOSE. See the applicable version of the GNU Lesser General Public
4013- * License for more details.
4014- *
4015- * You should have received a copy of both the GNU Lesser General Public
4016- * License along with this program. If not, see <http://www.gnu.org/licenses/>
4017- *
4018- * Authored by: Jay Taoko <jaytaoko@inalogic.com>
4019- *
4020- */
4021-
4022-
4023-#ifndef COMBOBOX_LOGIC_H
4024-#define COMBOBOX_LOGIC_H
4025-
4026-#include "AbstractComboBox.h"
4027-#include "ActionItem.h"
4028-
4029-namespace nux
4030-{
4031-
4032- class MenuPage;
4033- class ActionItem;
4034- class TableItem;
4035- class TableCtrl;
4036-
4037- class ComboBoxSimple : public AbstractComboBox
4038- {
4039- public:
4040- ComboBoxSimple(NUX_FILE_LINE_PROTO);
4041- ~ComboBoxSimple();
4042-
4043- // make the class abstract
4044-// virtual void Draw(GraphicsEngine& graphics_engine, bool force_draw);
4045-// virtual void DrawContent(GraphicsEngine& graphics_engine, bool force_draw);
4046-
4047- public:
4048- ActionItem *AddItem(const char *label, int Uservalue = 0);
4049- void RemoveItem(ActionItem *item);
4050- void RemoveAllItem();
4051-
4052- // emitters
4053- void OnMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
4054- void OnMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
4055- void OnPopupStop();
4056-
4057- // signals
4058- void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
4059- void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
4060- void RecvSigActionTriggered(MenuPage *, ActionItem *);
4061- void RecvSigActionTriggered2(TableCtrl *table, TableItem *item, unsigned int row, unsigned int column);
4062- void RecvSigTerminateMenuCascade();
4063- void RecvGeometryChanged(Area *area, Geometry &geo);
4064-
4065- const char *GetSelectionLabel() const;
4066- int GetSelectionUserValue() const;
4067- int GetNumItem() const;
4068- ActionItem *GetItem(int index) const;
4069- int GetSelectionIndex() const;
4070- void SetSelectionIndex(int index);
4071-
4072- // moves the currently selected item up/down - just shorthand for SetSelectionIndex
4073- void MoveSelectionUp();
4074- void MoveSelectionDown();
4075-
4076- MenuPage * GetMenuPage()
4077- {
4078- return m_CurrentMenu;
4079- }
4080-
4081- sigc::signal<void, ComboBoxSimple *> sigTriggered;
4082- sigc::signal<void, ActionItem *> sigActionTriggered;
4083-
4084- protected:
4085-
4086- virtual Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type);
4087-
4088- void RecvClosingMenuSignal(MenuPage* menu_page);
4089-
4090- MenuPage *m_CurrentMenu;
4091- ActionItem *m_SelectedAction;
4092- };
4093-
4094-}
4095-
4096-#endif // COMBOBOX_LOGIC_H
4097
4098=== removed file 'Nux/Coverflow.cpp'
4099--- Nux/Coverflow.cpp 2012-11-05 21:31:06 +0000
4100+++ Nux/Coverflow.cpp 1970-01-01 00:00:00 +0000
4101@@ -1,1154 +0,0 @@
4102-// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
4103-/*
4104- * Copyright (C) 2012 Canonical Ltd
4105- *
4106- * This program is free software: you can redistribute it and/or modify
4107- * it under the terms of the GNU General Public License version 3 as
4108- * published by the Free Software Foundation.
4109- *
4110- * This program is distributed in the hope that it will be useful,
4111- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4112- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4113- * GNU General Public License for more details.
4114- *
4115- * You should have received a copy of the GNU General Public License
4116- * along with this program. If not, see <http://www.gnu.org/licenses/>.
4117- *
4118- * Authored by: Jason Smith <jason.smith@canonical.com>
4119- * Jay Taoko <jay.taoko@canonical.com>
4120- */
4121-
4122-#include "Nux.h"
4123-#include "HLayout.h"
4124-#include "StaticText.h"
4125-#include "TextLoader.h"
4126-
4127-#include "NuxGraphics/GraphicsDisplay.h"
4128-#include "NuxGraphics/GLShader.h"
4129-#include "NuxGraphics/GpuDevice.h"
4130-#include "NuxGraphics/GLDeviceObjects.h"
4131-#include "NuxGraphics/GLShader.h"
4132-#include "NuxGraphics/GraphicsEngine.h"
4133-
4134-#include "NuxGraphics/IOpenGLBaseTexture.h"
4135-
4136-
4137-#include <glib.h>
4138-
4139-#include "Coverflow.h"
4140-
4141-
4142-namespace nux
4143-{
4144-namespace
4145-{
4146- float EaseSin(float x)
4147- {
4148- return sin(x * nux::constants::pi / 2.0f);
4149- }
4150-
4151- float RoundFloor(float x)
4152- {
4153- return std::floor(x + 0.5f);
4154- }
4155-
4156- std::string texture_vertex_code = "attribute vec4 iVertex; \n\
4157- attribute vec4 iTextureCoord0; \n\
4158- attribute vec4 iVertexColor; \n\
4159- uniform mat4 ViewProjectionMatrix; \n\
4160- varying vec4 varyTexCoord0; \n\
4161- varying vec4 varyVertexColor; \n\
4162- void main() \n\
4163- { \n\
4164- gl_Position = ViewProjectionMatrix * (iVertex); \n\
4165- varyTexCoord0 = iTextureCoord0; \n\
4166- varyVertexColor = iVertexColor; \n\
4167- }";
4168-
4169- std::string texture_fragment_code = "varying vec4 varyTexCoord0; \n\
4170- varying vec4 varyVertexColor; \n\
4171- uniform sampler2D TextureObject0; \n\
4172- void main() \n\
4173- { \n\
4174- vec4 v = texture2D(TextureObject0, varyTexCoord0.xy); \n\
4175- gl_FragColor = v*varyVertexColor; \n\
4176- }";
4177-
4178- std::string single_color_fragment_code = "varying vec4 varyTexCoord0; \n\
4179- varying vec4 varyVertexColor; \n\
4180- uniform sampler2D TextureObject0; \n\
4181- void main() \n\
4182- { \n\
4183- gl_FragColor = varyVertexColor; \n\
4184- }";
4185- struct Vec4_
4186- {
4187- float x;
4188- float y;
4189- float z;
4190- float rot;
4191- };
4192-
4193- struct VelocityEvent
4194- {
4195- float velocity;
4196- gint64 time;
4197- };
4198-
4199- struct Cover
4200- {
4201- Vec4_ position;
4202- float opacity;
4203- bool selected;
4204- bool mouse_over;
4205- CoverflowItem::Ptr item;
4206- };
4207-
4208- typedef std::vector<Cover> CoverList;
4209-}
4210-}
4211-
4212-namespace nux
4213-{
4214- struct Coverflow::Impl : public sigc::trackable
4215- {
4216- Impl(Coverflow* parent);
4217- ~Impl();
4218-
4219- void HandleKeyDown(unsigned long eventType,
4220- unsigned long keysym,
4221- unsigned long state,
4222- const char* character,
4223- unsigned short keyCount);
4224- void HandleKeyUp(unsigned int keysym,
4225- unsigned long x11_key_code,
4226- unsigned long special_keys_state);
4227-
4228- void HandleMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
4229- void HandleMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
4230- void HandleMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags);
4231- void HandleMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags);
4232- void HandleMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
4233- void HandleMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
4234- void HandleMouseClick(int x, int y, unsigned long button_flags, unsigned long key_flags);
4235- void HandleMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags);
4236- void HandleGeometryChange(Area* area, Geometry geo);
4237-
4238- void DrawCover(nux::GraphicsEngine& graphics_engine, nux::DrawAreaContext &ctx, Cover const& cover);
4239- void RenderCover(nux::GraphicsEngine& graphics_engine, Cover const& cover, int width, int height, nux::Matrix4 combined_matrix);
4240- void LoadVertexBuffer(int VertexLocation, int TextureCoord0Location, int VertexColorLocation, float* VtxBuffer);
4241-
4242- CoverList GetCoverList(float animation_progress, gint64 timestep);
4243-
4244- void OnItemAdded(CoverflowModel* owner, CoverflowItem::Ptr new_item);
4245- void OnItemRemoved(CoverflowModel* owner, CoverflowItem::Ptr old_item);
4246- void OnSelectionChanged(CoverflowModel* owner, CoverflowItem::Ptr selection);
4247-
4248- void SetPosition(float position, bool animate);
4249-
4250- void UpdateModelSelection();
4251-
4252- float GetCurrentVelocity(int ms);
4253-
4254- void MaybeQueueDraw();
4255-
4256- bool CoverAtPoint(int x, int y, Cover& out_cover);
4257- void Get3DBoundingBox(float distance_from_camera, nux::Point2& top_left_corner, nux::Point2& bottom_right_corner);
4258- void GetCoverScreenCoord(Cover const& cover, nux::Vector4& P0, nux::Vector4& P1, nux::Vector4& P2, nux::Vector4& P3);
4259-
4260- bool TestMouseOverCover(int x, int y, Cover const& cover);
4261- bool TestCoverVisible(Cover const& cover);
4262-
4263- static gboolean OnAnimationTimeout(gpointer data);
4264- static gboolean OnVelocityTimeout(gpointer data);
4265-
4266- nux::Vector3 camera_position_;
4267- nux::Vector3 camera_rotation_;
4268-
4269- nux::ObjectPtr<nux::IOpenGLShaderProgram> cover_shader_program_;
4270- nux::ObjectPtr<nux::IOpenGLShaderProgram> highlight_shader_program_;
4271-
4272- nux::Matrix4 perspective_;
4273- nux::Matrix4 modelview_;
4274-
4275- std::vector<VelocityEvent> velocity_events_;
4276-
4277- Coverflow* parent_;
4278- guint animation_handle_;
4279- float camera_drift_factor_;
4280- gint64 last_draw_time_;
4281- float last_position_;
4282- bool mouse_inside_view_;
4283- float position_;
4284- gint64 position_set_time_;
4285- float saved_position_;
4286- float velocity_;
4287- guint velocity_handle_;
4288- nux::Point2 mouse_down_position_;
4289- nux::Point2 mouse_position_;
4290- CoverList last_covers_;
4291- float cover_width_in_3d_space_;
4292- float near_clip_plan_;
4293- float far_clip_plan_;
4294- TextLoader text_loader_;
4295- ObjectPtr<IOpenGLBaseTexture> drop_shadow_texture_;
4296-
4297- sigc::connection model_selection_connection_;
4298- };
4299-
4300- Coverflow::Impl::Impl(Coverflow* parent)
4301- : parent_(parent)
4302- , animation_handle_(0)
4303- , camera_drift_factor_(0)
4304- , last_draw_time_(0)
4305- , last_position_(0)
4306- , mouse_inside_view_(false)
4307- , position_(0)
4308- , position_set_time_(0)
4309- , saved_position_(0)
4310- , velocity_(0)
4311- , velocity_handle_(0)
4312- , cover_width_in_3d_space_(1.0f)
4313- , near_clip_plan_(1.0f)
4314- , far_clip_plan_(200.0f)
4315- {
4316- mouse_position_ = nux::Point2(0, 0);
4317-
4318- parent_->key_down.connect(sigc::mem_fun(this, &Impl::HandleKeyDown));
4319- parent_->key_up.connect(sigc::mem_fun(this, &Impl::HandleKeyUp));
4320- parent_->mouse_move.connect(sigc::mem_fun(this, &Impl::HandleMouseMove));
4321- parent_->mouse_enter.connect(sigc::mem_fun(this, &Impl::HandleMouseEnter));
4322- parent_->mouse_leave.connect(sigc::mem_fun(this, &Impl::HandleMouseLeave));
4323- parent_->mouse_click.connect(sigc::mem_fun(this, &Impl::HandleMouseClick));
4324- parent_->mouse_drag.connect(sigc::mem_fun(this, &Impl::HandleMouseDrag));
4325- parent_->mouse_up.connect(sigc::mem_fun(this, &Impl::HandleMouseUp));
4326- parent_->mouse_down.connect(sigc::mem_fun(this, &Impl::HandleMouseDown));
4327- parent_->mouse_wheel.connect(sigc::mem_fun(this, &Impl::HandleMouseWheel));
4328- parent_->geometry_changed.connect(sigc::mem_fun(this, &Impl::HandleGeometryChange));
4329-
4330-
4331- camera_position_.x = 0.0f;
4332- camera_position_.y = 0.0f;
4333- camera_position_.z = 5.0f;
4334- camera_rotation_.x = 0.0f;
4335- camera_rotation_.y = 0.0f;
4336- camera_rotation_.z = 0.0f;
4337-
4338- // Create a shader to render a textured quad.
4339- {
4340- // Create the GLSL shader objects: Vertex, Fragment and the Program.
4341- // The Program object act as a container for the Vertex and Fragment object.
4342- nux::ObjectPtr<nux::IOpenGLPixelShader> fragment_shader_prog_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreatePixelShader();
4343- nux::ObjectPtr<nux::IOpenGLVertexShader> vertex_shader_prog_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateVertexShader();
4344- cover_shader_program_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateShaderProgram();
4345-
4346- // Set the actual shader code into the Vertex and Fragment objects.
4347- vertex_shader_prog_->SetShaderCode(texture_vertex_code.c_str());
4348- fragment_shader_prog_->SetShaderCode(texture_fragment_code.c_str());
4349-
4350- // Remove all Vertex and Fragment objects from the Program (Not necessary here but do it anyway).
4351- cover_shader_program_->ClearShaderObjects();
4352- // Add the Vertex and Fragment objects to the Program object.
4353- cover_shader_program_->AddShaderObject(vertex_shader_prog_);
4354- cover_shader_program_->AddShaderObject(fragment_shader_prog_);
4355- // Link
4356- cover_shader_program_->Link();
4357-
4358- // The shaders have been loaded into the program. They can be discarded.
4359- vertex_shader_prog_.Release();
4360- fragment_shader_prog_.Release();
4361- }
4362-
4363- // Create a shader to render a the cover highlight.
4364- {
4365- // Create the GLSL shader objects: Vertex, Fragment and the Program.
4366- // The Program object act as a container for the Vertex and Fragment object.
4367- nux::ObjectPtr<nux::IOpenGLPixelShader> fragment_shader_prog_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreatePixelShader();
4368- nux::ObjectPtr<nux::IOpenGLVertexShader> vertex_shader_prog_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateVertexShader();
4369- highlight_shader_program_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateShaderProgram();
4370-
4371- // Set the actual shader code into the Vertex and Fragment objects.
4372- vertex_shader_prog_->SetShaderCode(texture_vertex_code.c_str());
4373- fragment_shader_prog_->SetShaderCode(single_color_fragment_code.c_str());
4374-
4375- // Remove all Vertex and Fragment objects from the Program (Not necessary here but do it anyway).
4376- highlight_shader_program_->ClearShaderObjects();
4377- // Add the Vertex and Fragment objects to the Program object.
4378- highlight_shader_program_->AddShaderObject(vertex_shader_prog_);
4379- highlight_shader_program_->AddShaderObject(fragment_shader_prog_);
4380- // Link
4381- highlight_shader_program_->Link();
4382-
4383- // The shaders have been loaded into the program. They can be discarded.
4384- vertex_shader_prog_.Release();
4385- fragment_shader_prog_.Release();
4386- }
4387-
4388- text_loader_.font_size = 10;
4389-
4390- std::string resource_path = NUX_FIND_RESOURCE_LOCATION_NOFAIL("UITextures/coverflow.oval-shadow.png");
4391- BaseTexture* texture = LoadTextureFromFile(resource_path.c_str());
4392- drop_shadow_texture_ = texture->GetDeviceTexture();
4393- texture->UnReference();
4394-
4395- text_loader_.lines = 2;
4396- }
4397-
4398- Coverflow::Impl::~Impl()
4399- {
4400- if (animation_handle_)
4401- {
4402- g_source_remove(animation_handle_);
4403- animation_handle_ = 0;
4404- }
4405- }
4406-
4407- void Coverflow::Impl::UpdateModelSelection()
4408- {
4409- model_selection_connection_.disconnect();
4410- parent_->model()->SetSelection((size_t)RoundFloor(position_));
4411- model_selection_connection_ = parent_->model()->selection_changed.connect(sigc::mem_fun(this, &Coverflow::Impl::OnSelectionChanged));
4412- }
4413-
4414- void Coverflow::Impl::Get3DBoundingBox(float distance_from_camera, nux::Point2& top_left_corner, nux::Point2& bottom_right_corner)
4415- {
4416- int width = parent_->GetBaseWidth();
4417- int height = parent_->GetBaseHeight();
4418-
4419- top_left_corner.y = std::tan(DEGTORAD(parent_->fov() * 0.5f)) * distance_from_camera;
4420- top_left_corner.x = -top_left_corner.y * (width / (float)height);
4421-
4422- bottom_right_corner.x = -top_left_corner.x;
4423- bottom_right_corner.y = -top_left_corner.y;
4424- }
4425-
4426- void Coverflow::Impl::GetCoverScreenCoord(Cover const& cover, nux::Vector4& out_p0, nux::Vector4& out_p1, nux::Vector4& out_p2, nux::Vector4& out_p3)
4427- {
4428- if (cover.item->GetTexture().IsNull())
4429- return;
4430-
4431- int width = parent_->GetBaseWidth();
4432- int height = parent_->GetBaseHeight();
4433-
4434- ObjectPtr<IOpenGLBaseTexture> texture = cover.item->GetTexture()->GetDeviceTexture();
4435- float ratio = texture->GetWidth()/(float)texture->GetHeight();
4436-
4437- float fx = cover_width_in_3d_space_/2.0f;
4438- float fy_top = cover.position.y + (cover_width_in_3d_space_) * (1.0f/ratio);
4439- float fy_bot = cover.position.y;
4440-
4441- if (parent_->true_perspective)
4442- {
4443- modelview_ = nux::Matrix4::TRANSLATE(-camera_position_.x, -camera_position_.y, -camera_position_.z) *
4444- nux::Matrix4::ROTATEX(DEGTORAD(-camera_rotation_.x)) *
4445- nux::Matrix4::ROTATEY(DEGTORAD(-camera_rotation_.y)) *
4446- nux::Matrix4::ROTATEZ(DEGTORAD(-camera_rotation_.z)) *
4447- nux::Matrix4::TRANSLATE(cover.position.x, 0.0f, cover.position.z);
4448- }
4449- else
4450- {
4451- modelview_ = nux::Matrix4::TRANSLATE(-camera_position_.x, -camera_position_.y, -camera_position_.z) *
4452- nux::Matrix4::ROTATEX(DEGTORAD(-camera_rotation_.x)) *
4453- nux::Matrix4::ROTATEY(DEGTORAD(-camera_rotation_.y)) *
4454- nux::Matrix4::ROTATEZ(DEGTORAD(-camera_rotation_.z)) *
4455- nux::Matrix4::TRANSLATE(0.0f, 0.0f, cover.position.z);
4456- }
4457-
4458- nux::Matrix4 m = nux::Matrix4::ROTATEY(DEGTORAD(cover.position.rot));
4459- nux::Matrix4 combined_matrix = perspective_ * modelview_ * m;
4460-
4461- nux::Vector4 p0(-fx, fy_top, 0.0f, 1.0f);
4462- nux::Vector4 p1(-fx, fy_bot, 0.0f, 1.0f);
4463- nux::Vector4 p2(fx, fy_bot, 0.0f, 1.0f);
4464- nux::Vector4 p3(fx, fy_top, 0.0f, 1.0f);
4465-
4466- nux::Vector4 p0_proj = combined_matrix * p0;
4467- nux::Vector4 p1_proj = combined_matrix * p1;
4468- nux::Vector4 p2_proj = combined_matrix * p2;
4469- nux::Vector4 p3_proj = combined_matrix * p3;
4470-
4471- p0_proj.x = p0_proj.x/p0_proj.w; p0_proj.y = p0_proj.y/p0_proj.w; p0_proj.z = p0_proj.z/p0_proj.w;
4472- p1_proj.x = p1_proj.x/p1_proj.w; p1_proj.y = p1_proj.y/p1_proj.w; p1_proj.z = p1_proj.z/p1_proj.w;
4473- p2_proj.x = p2_proj.x/p2_proj.w; p2_proj.y = p2_proj.y/p2_proj.w; p2_proj.z = p2_proj.z/p2_proj.w;
4474- p3_proj.x = p3_proj.x/p3_proj.w; p3_proj.y = p3_proj.y/p3_proj.w; p3_proj.z = p3_proj.z/p3_proj.w;
4475-
4476- p0_proj.x = width * (p0_proj.x + 1.0f)/2.0f;
4477- p1_proj.x = width * (p1_proj.x + 1.0f)/2.0f;
4478- p2_proj.x = width * (p2_proj.x + 1.0f)/2.0f;
4479- p3_proj.x = width * (p3_proj.x + 1.0f)/2.0f;
4480-
4481- p0_proj.y = -height * (p0_proj.y - 1.0f)/2.0f;
4482- p1_proj.y = -height * (p1_proj.y - 1.0f)/2.0f;
4483- p2_proj.y = -height * (p2_proj.y - 1.0f)/2.0f;
4484- p3_proj.y = -height * (p3_proj.y - 1.0f)/2.0f;
4485-
4486- float scalar = 0.0f;
4487-
4488- if (!parent_->true_perspective)
4489- {
4490- nux::Point2 top_left, bottom_right;
4491- Get3DBoundingBox(camera_position_.z, top_left, bottom_right);
4492- scalar = parent_->GetGeometry().width / (bottom_right.x - top_left.x);
4493- }
4494-
4495- out_p0.x = p0_proj.x + cover.position.x * scalar; out_p0.y = p0_proj.y;
4496- out_p1.x = p1_proj.x + cover.position.x * scalar; out_p1.y = p1_proj.y;
4497- out_p2.x = p2_proj.x + cover.position.x * scalar; out_p2.y = p2_proj.y;
4498- out_p3.x = p3_proj.x + cover.position.x * scalar; out_p3.y = p3_proj.y;
4499- }
4500-
4501- bool Coverflow::Impl::TestMouseOverCover(int x, int y, Cover const& cover)
4502- {
4503- nux::Vector4 P0;
4504- nux::Vector4 P1;
4505- nux::Vector4 P2;
4506- nux::Vector4 P3;
4507-
4508- GetCoverScreenCoord(cover, P0, P1, P2, P3);
4509- // The polygon is convex and P0->P1->P2->P3 follows the right hand rule
4510- bool test01 = ((y - P0.y) * (P1.x - P0.x) - (x - P0.x) * (P1.y - P0.y)) <= 0.0f;
4511- bool test12 = ((y - P1.y) * (P2.x - P1.x) - (x - P1.x) * (P2.y - P1.y)) <= 0.0f;
4512- bool test23 = ((y - P2.y) * (P3.x - P2.x) - (x - P2.x) * (P3.y - P2.y)) <= 0.0f;
4513- bool test30 = ((y - P3.y) * (P0.x - P3.x) - (x - P3.x) * (P0.y - P3.y)) <= 0.0f;
4514-
4515- if (test01 && test12 && test23 && test30)
4516- {
4517- return true;
4518- }
4519-
4520- return false;
4521- }
4522-
4523- bool Coverflow::Impl::TestCoverVisible(Cover const& cover)
4524- {
4525- int width = parent_->GetBaseWidth();
4526- int height = parent_->GetBaseHeight();
4527-
4528- nux::Vector4 P0;
4529- nux::Vector4 P1;
4530- nux::Vector4 P2;
4531- nux::Vector4 P3;
4532-
4533- GetCoverScreenCoord(cover, P0, P1, P2, P3);
4534- bool test0 = ((P0.x >= 0) && (P0.x < width)) && ((P0.y >= 0) && (P0.y < height));
4535- bool test1 = ((P1.x >= 0) && (P1.x < width)) && ((P1.y >= 0) && (P1.y < height));
4536- bool test2 = ((P2.x >= 0) && (P2.x < width)) && ((P2.y >= 0) && (P2.y < height));
4537- bool test3 = ((P3.x >= 0) && (P3.x < width)) && ((P3.y >= 0) && (P3.y < height));
4538-
4539- if (test0 || test1 || test2 || test3)
4540- {
4541- // The quad is convex. If any of its vertices is inside the view, then the quad is visible.
4542- return true;
4543- }
4544-
4545- return false;
4546- }
4547-
4548- bool Coverflow::Impl::CoverAtPoint(int /* x */, int /* y */, Cover& out_cover)
4549- {
4550- Cover best;
4551-
4552- CoverList::iterator it;
4553- for (it = last_covers_.begin(); it != last_covers_.end(); ++it)
4554- {
4555- Cover cover = *it;
4556- if (cover.item->GetTexture().IsNull())
4557- continue;
4558- if (cover.position.rot > 0 && TestMouseOverCover(mouse_position_.x, mouse_position_.y, cover))
4559- {
4560- best = cover;
4561- }
4562- }
4563-
4564- CoverList::reverse_iterator rit;
4565- for (rit = last_covers_.rbegin(); rit != last_covers_.rend(); ++rit)
4566- {
4567- Cover cover = *rit;
4568- if (cover.item->GetTexture().IsNull())
4569- continue;
4570- if (cover.position.rot <= 0 && TestMouseOverCover(mouse_position_.x, mouse_position_.y, cover))
4571- {
4572- best = cover;
4573- }
4574- }
4575-
4576- if (best.item)
4577- {
4578- out_cover = best;
4579- return true;
4580- }
4581-
4582- return false;
4583- }
4584-
4585- void Coverflow::Impl::HandleKeyDown(unsigned long /* eventType */ , /*event type*/
4586- unsigned long keysym , /*event keysym*/
4587- unsigned long /* state */ , /*event state*/
4588- const char* /* character */ , /*character*/
4589- unsigned short /* keyCount */ /*key repeat count*/)
4590- {
4591- switch (keysym)
4592- {
4593- case NUX_VK_LEFT:
4594- parent_->model()->SelectPrev();
4595- break;
4596- case NUX_VK_RIGHT:
4597- parent_->model()->SelectNext();
4598- break;
4599-
4600- }
4601- }
4602-
4603- void Coverflow::Impl::HandleMouseClick(int x, int y, unsigned long button_flags, unsigned long /* key_flags */)
4604- {
4605- if (std::abs(mouse_down_position_.x - x) > 10 || std::abs(mouse_down_position_.y - y) > 10)
4606- return;
4607-
4608- Cover best;
4609- if (CoverAtPoint(x, y, best))
4610- {
4611- if (abs(best.position.rot) <= .001)
4612- {
4613- best.item->Activate(nux::GetEventButton(button_flags));
4614- }
4615- else
4616- {
4617- SetPosition((float)parent_->model()->IndexOf(best.item), true);
4618- UpdateModelSelection();
4619- }
4620- }
4621- }
4622-
4623- void Coverflow::Impl::HandleKeyUp(unsigned int keysym,
4624- unsigned long /* x11_key_code */,
4625- unsigned long /* special_keys_state */)
4626- {
4627- switch (keysym)
4628- {
4629- case NUX_VK_ENTER:
4630- case NUX_KP_ENTER:
4631- {
4632- Cover best;
4633- if (CoverAtPoint(0, 0, best))
4634- best.item->Activate(1);
4635- break;
4636- }
4637- default:
4638- break;
4639- }
4640- }
4641-
4642- void Coverflow::Impl::HandleMouseMove(int x, int y, int /* dx */, int /* dy */, unsigned long /* button_flags */, unsigned long /* key_flags */)
4643- {
4644- mouse_position_.x = x;
4645- mouse_position_.y = y;
4646- MaybeQueueDraw();
4647- }
4648-
4649- void Coverflow::Impl::HandleMouseEnter(int x, int y, unsigned long /* button_flags */, unsigned long /* key_flags */)
4650- {
4651- mouse_position_.x = x;
4652- mouse_position_.y = y;
4653- mouse_inside_view_ = true;
4654- MaybeQueueDraw();
4655- }
4656-
4657- void Coverflow::Impl::HandleMouseLeave(int /* x */, int /* y */, unsigned long /* button_flags */, unsigned long /* key_flags */)
4658- {
4659- mouse_position_.x = 0xFFFFFFFF;
4660- mouse_position_.y = 0xFFFFFFFF;
4661- mouse_inside_view_ = false;
4662- MaybeQueueDraw();
4663- }
4664-
4665- void Coverflow::Impl::HandleMouseDown(int x, int y, unsigned long /* button_flags */, unsigned long /* key_flags */)
4666- {
4667- velocity_ = 0; // stop an current velocity based animations
4668- mouse_down_position_.x = x;
4669- mouse_down_position_.y = y;
4670- MaybeQueueDraw();
4671- }
4672-
4673- bool TooOld (VelocityEvent event)
4674- {
4675- gint64 current_time = g_get_monotonic_time();
4676- int ms = (current_time - event.time) / 1000;
4677- return ms > 1000;
4678- }
4679-
4680- float Coverflow::Impl::GetCurrentVelocity(int cutoff_ms)
4681- {
4682- gint64 current_time = g_get_monotonic_time();
4683- float result = 0.0f;
4684-
4685- std::vector<VelocityEvent>::iterator it;
4686- for (it = velocity_events_.begin(); it != velocity_events_.end(); ++it)
4687- {
4688- VelocityEvent event = *it;
4689- int ms = (current_time - event.time) / 1000;
4690- if (ms > cutoff_ms)
4691- continue;
4692-
4693- result += event.velocity;
4694- }
4695- result = result / (cutoff_ms / 16); // 16ms timestep
4696-
4697- velocity_events_.erase(std::remove_if(velocity_events_.begin(), velocity_events_.end(), &TooOld), velocity_events_.end());
4698-
4699- return result;
4700- }
4701-
4702- void Coverflow::Impl::HandleMouseUp(int /* x */, int /* y */, unsigned long /* button_flags */, unsigned long /* key_flags */)
4703- {
4704- MaybeQueueDraw();
4705- velocity_ = GetCurrentVelocity(32);
4706-
4707- if (velocity_ != 0 && !velocity_handle_)
4708- {
4709- velocity_handle_ = g_timeout_add(16, &Coverflow::Impl::OnVelocityTimeout, this);
4710- }
4711- else if (!velocity_handle_)
4712- {
4713- SetPosition(RoundFloor(position_), true);
4714- UpdateModelSelection();
4715- }
4716- }
4717-
4718- void Coverflow::Impl::HandleMouseDrag(int /* x */, int /* y */, int dx, int /* dy */, unsigned long /* button_flags */, unsigned long /* key_flags */)
4719- {
4720- nux::Point2 top_left, bottom_right;
4721- Get3DBoundingBox(camera_position_.z, top_left, bottom_right);
4722- nux::Geometry geo = parent_->GetGeometry();
4723-
4724- float scalar = (((float)bottom_right.x - (float)top_left.x) / (float)geo.width) / parent_->space_between_icons;
4725- SetPosition(position_ - (dx * scalar * parent_->mouse_drag_rate), false);
4726- }
4727-
4728- void Coverflow::Impl::HandleMouseWheel(int /* x */, int /* y */, int /* wheel_delta */, unsigned long /* button_flags */, unsigned long /* key_flags */)
4729- {
4730- // do nothing yet
4731- }
4732-
4733- void Coverflow::Impl::HandleGeometryChange(Area* /* area */, Geometry /* geo */)
4734- {
4735- }
4736-
4737- CoverList Coverflow::Impl::GetCoverList(float animation_progress, gint64 /* timestep */)
4738- {
4739- CoverList results;
4740-
4741- animation_progress = std::min<float>(1.0f, animation_progress);
4742-
4743- float coverflow_position = position_ - ((position_ - saved_position_) * (1.0f - animation_progress));
4744-
4745- size_t i = 0;
4746- float flat_right = parent_->space_between_icons * (parent_->flat_icons) + .1;
4747- float flat_left = -flat_right;
4748-
4749- CoverflowModel::CoverflowItemList::const_iterator it;
4750- for (it = parent_->model()->Items().begin(); it != parent_->model()->Items().end(); ++it)
4751- {
4752- CoverflowItem::Ptr item = *it;
4753- float item_position = (float)i - coverflow_position;
4754-
4755- Cover cover;
4756- cover.opacity = 1.0f;
4757- cover.selected = item == parent_->model()->Selection();
4758- cover.item = item;
4759-
4760- // This position refers to the bottom center of the cover.
4761- cover.position.x = 0;
4762- cover.position.y = -0.5f + parent_->y_offset;
4763- cover.position.z = 0;
4764- cover.position.rot = 0;
4765-
4766- float x = item_position * parent_->space_between_icons;
4767- cover.position.x = x;
4768-
4769- float neg_pinch = 1.0f - parent_->pinching;
4770-
4771- if (x < flat_left)
4772- {
4773- cover.position.rot = (atan((x - flat_left) * parent_->folding_rate) / (nux::constants::pi / 2)) * -parent_->folding_angle;
4774- float scale_in_factor = neg_pinch + (1.0f - (std::abs(cover.position.rot) / parent_->folding_angle)) * parent_->pinching;
4775- cover.position.x = flat_left - ((flat_left - x) * scale_in_factor);
4776- }
4777- else if (x > flat_right)
4778- {
4779- cover.position.rot = (atan((x - flat_right) * parent_->folding_rate) / (nux::constants::pi / 2)) * -parent_->folding_angle;
4780- float scale_in_factor = neg_pinch+ (1.0f - (std::abs(cover.position.rot) / parent_->folding_angle)) * parent_->pinching;
4781- cover.position.x = flat_right + ((x - flat_right) * scale_in_factor);
4782- }
4783-
4784- if (cover.selected && parent_->pop_out_selected)
4785- cover.position.z = 0.3f;
4786-
4787- float fold_progress = std::abs(cover.position.rot / parent_->folding_angle());
4788- cover.position.z -= parent_->folding_depth() * fold_progress;
4789-
4790- nux::Point2 top_left, bottom_right;
4791- Get3DBoundingBox(camera_position_.z, top_left, bottom_right);
4792-
4793- float window_width = bottom_right.x - top_left.x;
4794- float distance_from_edge = std::max<float>(0.0f, std::abs(bottom_right.x) - std::abs(cover.position.x));
4795- cover.opacity = std::min<float>(1.0f, distance_from_edge / (window_width * parent_->edge_fade));
4796-
4797- results.push_back(cover);
4798- ++i;
4799- }
4800-
4801- last_position_ = coverflow_position;
4802- return results;
4803- }
4804-
4805- void Coverflow::Impl::SetPosition(float position, bool animate)
4806- {
4807- float min = std::min<float>((float)parent_->flat_icons,(float)parent_->model()->Items().size() - 1.0f);
4808- float max = std::max<float>(0.0f, (float)parent_->model()->Items().size() - 1.0f - (float)parent_->flat_icons);
4809- position = std::max<float>(min, std::min<float>(max, position));
4810- if (position == position_)
4811- return;
4812-
4813- if (animate)
4814- {
4815- position_set_time_ = g_get_monotonic_time();
4816- saved_position_ = last_position_;
4817- }
4818- else
4819- {
4820- position_set_time_ = 0;
4821- }
4822-
4823- position_ = position;
4824-
4825- VelocityEvent ve;
4826- ve.velocity = position_ - last_position_;
4827- ve.time = g_get_monotonic_time();
4828- velocity_events_.push_back(ve);
4829-
4830- MaybeQueueDraw();
4831- }
4832-
4833- void Coverflow::Impl::OnItemAdded(CoverflowModel* /* owner */, CoverflowItem::Ptr /* new_item */)
4834- {
4835- SetPosition(position_, true);
4836- MaybeQueueDraw();
4837- }
4838-
4839- void Coverflow::Impl::OnItemRemoved(CoverflowModel* /* owner */, CoverflowItem::Ptr /* old_item */)
4840- {
4841- SetPosition(position_, true);
4842- MaybeQueueDraw();
4843- }
4844-
4845- void Coverflow::Impl::OnSelectionChanged(CoverflowModel* /* owner */, CoverflowItem::Ptr /* selection */)
4846- {
4847- size_t selection_index = parent_->model()->SelectionIndex();
4848-
4849- if (selection_index > (position_ + parent_->flat_icons))
4850- SetPosition(selection_index - parent_->flat_icons, true);
4851- else if (selection_index < (position_ - parent_->flat_icons))
4852- SetPosition(selection_index + parent_->flat_icons, true);
4853- MaybeQueueDraw();
4854- }
4855-
4856- void Coverflow::Impl::MaybeQueueDraw()
4857- {
4858- if (!animation_handle_)
4859- animation_handle_ = g_timeout_add(0, &Coverflow::Impl::OnAnimationTimeout, this);
4860- }
4861-
4862- void Coverflow::Impl::LoadVertexBuffer(int VertexLocation, int TextureCoord0Location, int VertexColorLocation, float* VtxBuffer)
4863- {
4864- CHECKGL(glEnableVertexAttribArrayARB(VertexLocation));
4865- CHECKGL(glVertexAttribPointerARB((GLuint) VertexLocation, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer));
4866-
4867- if (TextureCoord0Location != -1)
4868- {
4869- CHECKGL(glEnableVertexAttribArrayARB(TextureCoord0Location));
4870- CHECKGL(glVertexAttribPointerARB((GLuint) TextureCoord0Location, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 4));
4871- }
4872-
4873- if (VertexColorLocation != -1)
4874- {
4875- CHECKGL(glEnableVertexAttribArrayARB(VertexColorLocation));
4876- CHECKGL(glVertexAttribPointerARB((GLuint) VertexColorLocation, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 8));
4877- }
4878- }
4879-
4880- void Coverflow::Impl::RenderCover(nux::GraphicsEngine& graphics_engine, Cover const& cover, int width, int height, nux::Matrix4 combined_matrix)
4881- {
4882- ObjectPtr<IOpenGLBaseTexture> texture = cover.item->GetTexture()->GetDeviceTexture();
4883- nux::TexCoordXForm texxform;
4884- nux::Color ref_color = nux::color::White;
4885-
4886- QRP_Compute_Texture_Coord(width, height, texture, texxform);
4887-
4888- float ratio = texture->GetWidth()/(float)texture->GetHeight();
4889- float drop_shadow_ratio = drop_shadow_texture_->GetWidth()/(float)drop_shadow_texture_->GetHeight();
4890-
4891- float fx = cover_width_in_3d_space_/2.0f;
4892-
4893- float fy_top = cover.position.y + (cover_width_in_3d_space_) * (1.0f/ratio);
4894- float fy_bot = cover.position.y;
4895- float fy_bot_reflec = cover.position.y - (cover_width_in_3d_space_) * (1.0f/ratio) * parent_->reflection_size;
4896-
4897- float fx_shadow = 0.5 * (1.1 * cover_width_in_3d_space_);
4898- float fy_top_shadow = fy_bot + 0.5 * (1.4 * cover_width_in_3d_space_) * (1.0f/drop_shadow_ratio);
4899- float fy_bot_shadow = fy_bot - 0.5 * (1.4 * cover_width_in_3d_space_) * (1.0f/drop_shadow_ratio);
4900-
4901-
4902- cover_shader_program_->Begin();
4903-
4904- int TextureObjectLocation = cover_shader_program_->GetUniformLocationARB("TextureObject0");
4905- int VertexLocation = cover_shader_program_->GetAttributeLocation("iVertex");
4906- int TextureCoord0Location = cover_shader_program_->GetAttributeLocation("iTextureCoord0");
4907- int VertexColorLocation = cover_shader_program_->GetAttributeLocation("iVertexColor");
4908- int VPMatrixLocation = cover_shader_program_->GetUniformLocationARB("ViewProjectionMatrix");
4909-
4910- nux::Matrix4 MVPMatrix = perspective_ * combined_matrix;
4911-
4912- cover_shader_program_->SetUniformLocMatrix4fv((GLint) VPMatrixLocation, 1, true, (GLfloat*) &(MVPMatrix.m));
4913-
4914- // *** Compute the opacities ***
4915- float angular_opacity = 1.0f;
4916- if (parent_->folding_angle == 0)
4917- {
4918- angular_opacity = 1.0f;
4919- }
4920- else
4921- {
4922- float rotation_ratio = std::abs(cover.position.rot / parent_->folding_angle);
4923- angular_opacity = 1.0f - rotation_ratio;
4924- }
4925-
4926- float opacity = 1.0f - std::abs(cover.position.x) / (parent_->reflection_fadeout_distance);
4927- if (opacity < 0.0f)
4928- {
4929- opacity = 0.0f;
4930- }
4931-
4932- opacity *= angular_opacity;
4933-
4934- drop_shadow_texture_->SetFiltering (GL_LINEAR, GL_LINEAR);
4935- graphics_engine.SetTexture(GL_TEXTURE0, drop_shadow_texture_);
4936- CHECKGL(glUniform1iARB(TextureObjectLocation, 0));
4937-
4938- // **** Render the cover drop shadow ****
4939- if (parent_->show_drop_shadow)
4940- {
4941- Color color = ref_color * cover.opacity * angular_opacity;
4942- float VtxBuffer[] =
4943- {
4944- -fx_shadow, fy_top_shadow, 0.0f, 1.0f, texxform.u0, texxform.v0, 0, 0, color.red, color.green, color.blue, color.alpha,
4945- -fx_shadow, fy_bot_shadow, 0.0f, 1.0f, texxform.u0, texxform.v1, 0, 0, color.red, color.green, color.blue, color.alpha,
4946- fx_shadow, fy_bot_shadow, 0.0f, 1.0f, texxform.u1, texxform.v1, 0, 0, color.red, color.green, color.blue, color.alpha,
4947- fx_shadow, fy_top_shadow, 0.0f, 1.0f, texxform.u1, texxform.v0, 0, 0, color.red, color.green, color.blue, color.alpha,
4948- };
4949-
4950- LoadVertexBuffer(VertexLocation, TextureCoord0Location, VertexColorLocation, VtxBuffer);
4951- CHECKGL(glDrawArrays(GL_TRIANGLE_FAN, 0, 4));
4952- }
4953-
4954-
4955- texture->SetFiltering (GL_LINEAR, GL_LINEAR);
4956- graphics_engine.SetTexture(GL_TEXTURE0, texture);
4957- CHECKGL(glUniform1iARB(TextureObjectLocation, 0));
4958-
4959- // **** Render the cover ****
4960- {
4961- Color color = ref_color * cover.opacity;
4962- float VtxBuffer[] =
4963- {
4964- -fx, fy_top, 0.0f, 1.0f, texxform.u0, texxform.v0, 0, 0, color.red, color.green, color.blue, color.alpha,
4965- -fx, fy_bot, 0.0f, 1.0f, texxform.u0, texxform.v1, 0, 0, color.red, color.green, color.blue, color.alpha,
4966- fx, fy_bot, 0.0f, 1.0f, texxform.u1, texxform.v1, 0, 0, color.red, color.green, color.blue, color.alpha,
4967- fx, fy_top, 0.0f, 1.0f, texxform.u1, texxform.v0, 0, 0, color.red, color.green, color.blue, color.alpha,
4968- };
4969-
4970- LoadVertexBuffer(VertexLocation, TextureCoord0Location, VertexColorLocation, VtxBuffer);
4971- CHECKGL(glDrawArrays(GL_TRIANGLE_FAN, 0, 4));
4972- }
4973-
4974- // **** Reflection opacity ****
4975- if (parent_->show_reflection)
4976- {
4977- texxform.flip_v_coord = true;
4978- QRP_Compute_Texture_Coord(width, height, texture, texxform);
4979-
4980- // texture offset use to prevent the texture from scaling when the reflection size changes.
4981- float toff = 1.0f - parent_->reflection_size;
4982-
4983- float opacity_start = opacity*parent_->reflection_strength * cover.opacity;
4984- float opacity_end = 0.0f;
4985- float VtxBuffer[] =
4986- {
4987- -fx, fy_bot, 0.0f, 1.0f, texxform.u0, texxform.v0, 0, 0, opacity_start, opacity_start, opacity_start, opacity_start,
4988- -fx, fy_bot_reflec, 0.0f, 1.0f, texxform.u0, texxform.v1 + toff, 0, 0, opacity_end, opacity_end, opacity_end, opacity_end,
4989- fx, fy_bot_reflec, 0.0f, 1.0f, texxform.u1, texxform.v1 + toff, 0, 0, opacity_end, opacity_end, opacity_end, opacity_end,
4990- fx, fy_bot, 0.0f, 1.0f, texxform.u1, texxform.v0, 0, 0, opacity_start, opacity_start, opacity_start, opacity_start,
4991- };
4992-
4993- LoadVertexBuffer(VertexLocation, TextureCoord0Location, VertexColorLocation, VtxBuffer);
4994- CHECKGL(glDrawArrays(GL_TRIANGLE_FAN, 0, 4));
4995- }
4996-
4997- // **** Render Cover label ****
4998- if (parent_->show_labels())
4999- {
5000- if (!cover.item->text_texture().IsValid())
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches