aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewerwindow.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llviewerwindow.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llviewerwindow.h')
-rw-r--r--linden/indra/newview/llviewerwindow.h410
1 files changed, 410 insertions, 0 deletions
diff --git a/linden/indra/newview/llviewerwindow.h b/linden/indra/newview/llviewerwindow.h
new file mode 100644
index 0000000..8c6d812
--- /dev/null
+++ b/linden/indra/newview/llviewerwindow.h
@@ -0,0 +1,410 @@
1/**
2 * @file llviewerwindow.h
3 * @brief Description of the LLViewerWindow class.
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28//
29// A note about X,Y coordinates:
30//
31// X coordinates are in pixels, from the left edge of the window client area
32// Y coordinates are in pixels, from the BOTTOM edge of the window client area
33//
34// The Y coordinates therefore match OpenGL window coords, not Windows(tm) window coords.
35// If Y is from the top, the variable will be called "y_from_top"
36
37#ifndef LL_LLVIEWERWINDOW_H
38#define LL_LLVIEWERWINDOW_H
39
40#include "linked_lists.h"
41#include "v3dmath.h"
42#include "v2math.h"
43#include "llwindow.h"
44#include "lltimer.h"
45#include "llstat.h"
46#include "llalertdialog.h"
47
48class LLView;
49class LLViewerObject;
50class LLUUID;
51class LLMouseHandler;
52class LLProgressView;
53class LLTool;
54class LLVelocityBar;
55class LLViewerWindow;
56class LLTextBox;
57class LLImageRaw;
58class LLHUDIcon;
59
60class LLViewerWindow : public LLWindowCallbacks
61{
62public:
63 //
64 // CREATORS
65 //
66 LLViewerWindow(char* title, char* name, S32 x, S32 y, S32 width, S32 height, BOOL fullscreen, BOOL ignore_pixel_depth);
67 virtual ~LLViewerWindow();
68
69 void initGLDefaults();
70 void initBase();
71 void adjustRectanglesForFirstUse(const LLRect& full_window);
72 void initWorldUI();
73
74 //
75 // LLWindowCallback interface implementation
76 //
77 /*virtual*/ BOOL handleTranslatedKeyDown(KEY key, MASK mask, BOOL repeated);
78 /*virtual*/ BOOL handleTranslatedKeyUp(KEY key, MASK mask);
79 /*virtual*/ void handleScanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level);
80 /*virtual*/ BOOL handleUnicodeChar(llwchar uni_char, MASK mask); // NOT going to handle extended
81 /*virtual*/ BOOL handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask);
82 /*virtual*/ BOOL handleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask);
83 /*virtual*/ BOOL handleCloseRequest(LLWindow *window);
84 /*virtual*/ void handleQuit(LLWindow *window);
85 /*virtual*/ BOOL handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK mask);
86 /*virtual*/ BOOL handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK mask);
87 /*virtual*/ void handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask);
88 /*virtual*/ void handleMouseLeave(LLWindow *window);
89 /*virtual*/ void handleResize(LLWindow *window, S32 x, S32 y);
90 /*virtual*/ void handleFocus(LLWindow *window);
91 /*virtual*/ void handleFocusLost(LLWindow *window);
92 /*virtual*/ BOOL handleActivate(LLWindow *window, BOOL activated);
93 /*virtual*/ void handleMenuSelect(LLWindow *window, S32 menu_item);
94 /*virtual*/ BOOL handlePaint(LLWindow *window, S32 x, S32 y, S32 width, S32 height);
95 /*virtual*/ void handleScrollWheel(LLWindow *window, S32 clicks);
96 /*virtual*/ BOOL handleDoubleClick(LLWindow *window, LLCoordGL pos, MASK mask);
97 /*virtual*/ void handleWindowBlock(LLWindow *window);
98 /*virtual*/ void handleWindowUnblock(LLWindow *window);
99 /*virtual*/ void handleDataCopy(LLWindow *window, S32 data_type, void *data);
100
101
102 //
103 // ACCESSORS
104 //
105 LLView* getRootView() const { return mRootView; }
106 const LLRect& getWindowRect() const { return mWindowRect; };
107 const LLRect& getVirtualWindowRect() const { return mVirtualWindowRect; };
108 S32 getWindowHeight() const;
109 S32 getWindowWidth() const;
110 S32 getWindowDisplayHeight() const;
111 S32 getWindowDisplayWidth() const;
112 LLWindow* getWindow() const { return mWindow; }
113 void* getPlatformWindow() const { return mWindow->getPlatformWindow(); }
114 void focusClient() const { return mWindow->focusClient(); };
115
116 LLCoordGL getLastMouse() const { return mLastMousePoint; }
117 S32 getLastMouseX() const { return mLastMousePoint.mX; }
118 S32 getLastMouseY() const { return mLastMousePoint.mY; }
119 LLCoordGL getCurrentMouse() const { return mCurrentMousePoint; }
120 S32 getCurrentMouseX() const { return mCurrentMousePoint.mX; }
121 S32 getCurrentMouseY() const { return mCurrentMousePoint.mY; }
122 S32 getCurrentMouseDX() const { return mCurrentMouseDelta.mX; }
123 S32 getCurrentMouseDY() const { return mCurrentMouseDelta.mY; }
124 LLCoordGL getCurrentMouseDelta() const { return mCurrentMouseDelta; }
125 LLStat * getMouseVelocityStat() { return &mMouseVelocityStat; }
126 BOOL getLeftMouseDown() const { return mLeftMouseDown; }
127 BOOL getRightMouseDown() const { return mRightMouseDown; }
128
129 LLView* getTopView() const;
130 BOOL hasTopView(LLView* view) const;
131
132 void setupViewport(S32 x_offset = 0, S32 y_offset = 0);
133 void setup3DRender();
134 void setup2DRender();
135
136 BOOL isPickPending() { return mPickPending; }
137
138 LLVector3 mouseDirectionGlobal(const S32 x, const S32 y) const;
139 LLVector3 mouseDirectionCamera(const S32 x, const S32 y) const;
140
141 // Is window of our application frontmost?
142 BOOL getActive() const { return mActive; }
143
144 void getTargetWindow(BOOL& fullscreen, S32& width, S32& height) const;
145 // The 'target' is where the user wants the window to be. It may not be
146 // there yet, because we may be supressing fullscreen prior to login.
147
148 //
149 // MANIPULATORS
150 //
151 void saveLastMouse(const LLCoordGL &point);
152
153 void setCursor( ECursorType c );
154 void showCursor();
155 void hideCursor();
156 void moveCursorToCenter(); // move to center of window
157
158 void setShowProgress(const BOOL show);
159 BOOL getShowProgress() const;
160 void moveProgressViewToFront();
161 void setProgressString(const LLString& string);
162 void setProgressPercent(const F32 percent);
163 void setProgressMessage(const LLString& msg);
164 void setProgressCancelButtonVisible( BOOL b, const LLString& label );
165 LLProgressView *getProgressView() const;
166
167 void updateObjectUnderCursor();
168
169 BOOL handlePerFrameHover(); // Once per frame, update UI based on mouse position
170
171 BOOL handleKey(KEY key, MASK mask);
172 void handleScrollWheel (S32 clicks);
173
174 // Handle the application becoming active (frontmost) or inactive
175 //BOOL handleActivate(BOOL activate);
176
177 void setKeyboardFocus(LLUICtrl* new_focus,void (*on_focus_lost)(LLUICtrl* old_focus)); // new_focus = NULL to release the focus.
178 LLUICtrl* getKeyboardFocus();
179 BOOL hasKeyboardFocus( const LLUICtrl* possible_focus ) const;
180 BOOL childHasKeyboardFocus( const LLView* parent ) const;
181
182 void setMouseCapture(LLMouseHandler* new_captor,void (*on_capture_lost)(LLMouseHandler* old_captor)); // new_captor = NULL to release the mouse.
183 BOOL hasMouseCapture(const LLMouseHandler* possible_captor ) const;
184 LLMouseHandler* getMouseCaptor() const;
185
186 void setTopView(LLView* new_top, void (*on_top_lost)(LLView* old_top)); // set new_top = NULL to release top_view.
187
188 void reshape(S32 width, S32 height);
189 void sendShapeToSim();
190
191 void draw();
192// void drawSelectedObjects();
193
194 static void loadUserImage(void **cb_data, const LLUUID &uuid);
195
196 // Save snapshot like Snapshot 1, 2, 3, etc.
197 static void saveMovieNumbered(void*);
198
199 static void movieSize(S32 new_width, S32 new_height);
200
201 typedef enum e_snapshot_type
202 {
203 SNAPSHOT_TYPE_COLOR,
204 SNAPSHOT_TYPE_DEPTH,
205 SNAPSHOT_TYPE_OBJECT_ID
206 } ESnapshotType;
207
208 BOOL saveSnapshot(const LLString& filename, S32 image_width, S32 image_height, BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, ESnapshotType type = SNAPSHOT_TYPE_COLOR);
209 BOOL rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height, BOOL keep_window_aspect = TRUE,
210 BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, ESnapshotType type = SNAPSHOT_TYPE_COLOR );
211 BOOL saveImageNumbered(LLImageRaw *raw);
212
213 void playSnapshotAnimAndSound();
214
215 // draws selection boxes around selected objects, must call displayObjects first
216 void renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, BOOL for_hud );
217 void performPick();
218
219 void hitObjectOrLandGlobalAsync(S32 x, S32 y_from_bot, MASK mask, void (*callback)(S32 x, S32 y, MASK mask), BOOL pick_transparent = FALSE, BOOL pick_parcel_walls = FALSE);
220 void hitObjectOrLandGlobalImmediate(S32 x, S32 y, void (*callback)(S32 x, S32 y, MASK mask), BOOL pick_transparent);
221
222 void hitUIElementAsync(S32 x, S32 y_from_bot, MASK mask, void (*callback)(S32 x, S32 y, MASK mask));
223 void hitUIElementImmediate(S32 x, S32 y, void (*callback)(S32 x, S32 y, MASK mask));
224
225 LLViewerObject* getObjectUnderCursor(const F32 depth = 16.0f);
226
227 void requestFastFrame(LLView* view);
228 BOOL renderingFastFrame() { return mFastFrameTimer.getStarted() && !firstFastFrame(); }
229 void finishFastFrame() { mFastFrameTimer.stop(); mRenderFullFrame = FALSE; }
230 BOOL firstFastFrame() { return mRenderFullFrame; }
231 void finishFirstFastFrame() { mRenderFullFrame = FALSE; }
232
233 // Returns a pointer to the last object hit
234 LLViewerObject *lastObjectHit();
235 LLViewerObject *lastNonFloraObjectHit();
236
237 const LLVector3d& lastObjectHitOffset();
238 const LLVector3d& lastNonFloraObjectHitOffset();
239
240 // mousePointOnLand() returns true if found point
241 BOOL mousePointOnLandGlobal(const S32 x, const S32 y, LLVector3d *land_pos_global);
242 BOOL mousePointOnPlaneGlobal(LLVector3d& point, const S32 x, const S32 y, const LLVector3d &plane_point, const LLVector3 &plane_normal);
243 LLVector3d clickPointInWorldGlobal(const S32 x, const S32 y_from_bot, LLViewerObject* clicked_object) const;
244 BOOL clickPointOnSurfaceGlobal(const S32 x, const S32 y, LLViewerObject *objectp, LLVector3d &point_global) const;
245
246 // Prints window implementation details
247 void dumpState();
248
249 // Request display setting changes
250 void toggleFullscreen(BOOL show_progress);
251
252 // handle shutting down GL and bringing it back up
253 BOOL checkSettings();
254 void restartDisplay(BOOL show_progress_bar);
255 BOOL changeDisplaySettings(BOOL fullscreen, LLCoordScreen size, BOOL disable_vsync, BOOL show_progress_bar);
256 BOOL getIgnoreDestroyWindow() { return mIgnoreActivate; }
257 F32 getDisplayAspectRatio() const;
258 const LLVector2& getDisplayScale() const { return mDisplayScale; }
259 void calcDisplayScale();
260
261 void drawPickBuffer() const;
262
263 LLAlertDialog* alertXml(const std::string& xml_filename,
264 LLAlertDialog::alert_callback_t callback = NULL, void* user_data = NULL);
265 LLAlertDialog* alertXml(const std::string& xml_filename, const LLString::format_map_t& args,
266 LLAlertDialog::alert_callback_t callback = NULL, void* user_data = NULL);
267 LLAlertDialog* alertXmlEditText(const std::string& xml_filename, const LLString::format_map_t& args,
268 LLAlertDialog::alert_callback_t callback, void* user_data,
269 LLAlertDialog::alert_text_callback_t text_callback, void *text_data,
270 const LLString::format_map_t& edit_args = LLString::format_map_t(),
271 BOOL draw_asterixes = FALSE);
272
273 static bool alertCallback(S32 modal);
274
275#ifdef SABINRIG
276 //Silly rig stuff
277 void printFeedback(); //RIG STUFF!
278#endif //SABINRIG
279
280private:
281 void switchToolByMask(MASK mask);
282 void destroyWindow();
283 void drawMouselookInstructions();
284 void stopGL(BOOL save_state = TRUE);
285 void restoreGL(const LLString& progress_message = LLString::null);
286 void initFonts(F32 zoom_factor = 1.f);
287
288 void analyzeHit(
289 S32 x, // input
290 S32 y_from_bot, // input
291 LLViewerObject* objectp, // input
292 U32 te_offset, // input
293 LLUUID* hit_object_id_p,// output
294 S32* hit_face_p, // output
295 LLVector3d* hit_pos_p, // output
296 BOOL* hit_land, // output
297 F32* hit_u_coord, // output
298 F32* hit_v_coord); // output
299
300public:
301 LLWindow* mWindow; // graphical window object
302
303protected:
304 BOOL mActive;
305 BOOL mWantFullscreen;
306 BOOL mShowFullscreenProgress;
307 LLRect mWindowRect;
308 LLRect mVirtualWindowRect;
309 LLView* mRootView; // a view of size mWindowRect, containing all child views
310 LLVector2 mDisplayScale;
311
312 LLCoordGL mCurrentMousePoint; // last mouse position in GL coords
313 LLCoordGL mLastMousePoint; // Mouse point at last frame.
314 LLCoordGL mCurrentMouseDelta; //amount mouse moved this frame
315 LLStat mMouseVelocityStat;
316 BOOL mLeftMouseDown;
317 BOOL mRightMouseDown;
318
319 LLProgressView *mProgressView;
320
321 LLTextBox* mToolTip;
322 BOOL mToolTipBlocked; // True after a key press or a mouse button event. False once the mouse moves again.
323 LLRect mToolTipStickyRect; // Once a tool tip is shown, it will stay visible until the mouse leaves this rect.
324
325 BOOL mMouseInWindow; // True if the mouse is over our window or if we have captured the mouse.
326 BOOL mFocusCycleMode;
327
328 // Variables used for tool override switching based on modifier keys. JC
329 MASK mLastMask; // used to detect changes in modifier mask
330 LLTool* mToolStored; // the tool we're overriding
331 BOOL mSuppressToolbox; // sometimes hide the toolbox, despite
332 // having a camera tool selected
333 BOOL mHideCursorPermanent; // true during drags, mouselook
334 LLCoordGL mPickPoint;
335 LLCoordGL mPickOffset;
336 MASK mPickMask;
337 BOOL mPickPending;
338 void (*mPickCallback)(S32 x, S32 y, MASK mask);
339
340 LLString mOverlayTitle; // Used for special titles such as "Second Life - Special E3 2003 Beta"
341
342 static char sSnapshotBaseName[LL_MAX_PATH];
343 static char sSnapshotDir[LL_MAX_PATH];
344
345 static char sMovieBaseName[LL_MAX_PATH];
346
347 BOOL mIgnoreActivate;
348 LLFrameTimer mFastFrameTimer;
349 BOOL mRenderFullFrame;
350 U8* mPickBuffer;
351};
352
353class LLBottomPanel : public LLPanel
354{
355public:
356 LLBottomPanel(const LLString& name, const LLRect& rect);
357 void setFocusIndicator(LLView * indicator);
358 LLView * getFocusIndicator() { return mIndicator; }
359 /*virtual*/ void draw();
360protected:
361 LLView * mIndicator;
362};
363extern LLBottomPanel * gBottomPanel;
364
365void toggle_flying(void*);
366void toggle_first_person();
367void toggle_build(void*);
368void reset_viewer_state_on_sim(void);
369
370//
371// Constants
372//
373
374
375//
376// Globals
377//
378
379extern LLVelocityBar* gVelocityBar;
380extern LLViewerWindow* gViewerWindow;
381extern BOOL gQuietSnapshot;
382
383extern LLFrameTimer gMouseIdleTimer; // how long has it been since the mouse last moved?
384extern LLFrameTimer gAwayTimer; // tracks time before setting the avatar away state to true
385extern LLFrameTimer gAwayTriggerTimer; // how long the avatar has been away
386
387extern LLVector3d gLastHitPosGlobal;
388extern LLVector3d gLastHitObjectOffset;
389extern LLUUID gLastHitObjectID;
390extern S32 gLastHitObjectFace;
391extern BOOL gLastHitLand;
392extern F32 gLastHitUCoord;
393extern F32 gLastHitVCoord;
394
395
396extern LLVector3d gLastHitNonFloraPosGlobal;
397extern LLVector3d gLastHitNonFloraObjectOffset;
398extern LLUUID gLastHitNonFloraObjectID;
399extern S32 gLastHitNonFloraObjectFace;
400
401extern S32 gLastHitUIElement;
402extern LLHUDIcon* gLastHitHUDIcon;
403extern BOOL gLastHitParcelWall;
404extern BOOL gDebugSelect;
405extern BOOL gPickFaces;
406extern BOOL gPickTransparent;
407
408extern BOOL gDebugFastUIRender;
409extern S32 CHAT_BAR_HEIGHT;
410#endif