00001
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef LL_LLVIEWERWINDOW_H
00042 #define LL_LLVIEWERWINDOW_H
00043
00044 #include "linked_lists.h"
00045 #include "v3dmath.h"
00046 #include "v2math.h"
00047 #include "llwindow.h"
00048 #include "lltimer.h"
00049 #include "llstat.h"
00050 #include "llalertdialog.h"
00051
00052 class LLView;
00053 class LLViewerObject;
00054 class LLUUID;
00055 class LLMouseHandler;
00056 class LLProgressView;
00057 class LLTool;
00058 class LLVelocityBar;
00059 class LLViewerWindow;
00060 class LLTextBox;
00061 class LLImageRaw;
00062 class LLHUDIcon;
00063
00064 class LLViewerWindow : public LLWindowCallbacks
00065 {
00066 public:
00067
00068
00069
00070 LLViewerWindow(char* title, char* name, S32 x, S32 y, S32 width, S32 height, BOOL fullscreen, BOOL ignore_pixel_depth, S32 stereo_mode);
00071 virtual ~LLViewerWindow();
00072
00073 void initGLDefaults();
00074 void initBase();
00075 void adjustRectanglesForFirstUse(const LLRect& full_window);
00076 void initWorldUI();
00077
00078
00079
00080
00081 BOOL handleTranslatedKeyDown(KEY key, MASK mask, BOOL repeated);
00082 BOOL handleTranslatedKeyUp(KEY key, MASK mask);
00083 void handleScanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level);
00084 BOOL handleUnicodeChar(llwchar uni_char, MASK mask);
00085 BOOL handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask);
00086 BOOL handleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask);
00087 BOOL handleCloseRequest(LLWindow *window);
00088 void handleQuit(LLWindow *window);
00089 BOOL handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK mask);
00090 BOOL handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK mask);
00091 BOOL handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask);
00092 BOOL handleMiddleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask);
00093 void handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask);
00094 void handleMouseLeave(LLWindow *window);
00095 void handleResize(LLWindow *window, S32 x, S32 y);
00096 void handleFocus(LLWindow *window);
00097 void handleFocusLost(LLWindow *window);
00098 BOOL handleActivate(LLWindow *window, BOOL activated);
00099 void handleMenuSelect(LLWindow *window, S32 menu_item);
00100 BOOL handlePaint(LLWindow *window, S32 x, S32 y, S32 width, S32 height);
00101 void handleScrollWheel(LLWindow *window, S32 clicks);
00102 BOOL handleDoubleClick(LLWindow *window, LLCoordGL pos, MASK mask);
00103 void handleWindowBlock(LLWindow *window);
00104 void handleWindowUnblock(LLWindow *window);
00105 void handleDataCopy(LLWindow *window, S32 data_type, void *data);
00106
00107
00108
00109
00110
00111 LLView* getRootView() const { return mRootView; }
00112 const LLRect& getWindowRect() const { return mWindowRect; };
00113 const LLRect& getVirtualWindowRect() const { return mVirtualWindowRect; };
00114 S32 getWindowHeight() const;
00115 S32 getWindowWidth() const;
00116 S32 getWindowDisplayHeight() const;
00117 S32 getWindowDisplayWidth() const;
00118 LLWindow* getWindow() const { return mWindow; }
00119 void* getPlatformWindow() const { return mWindow->getPlatformWindow(); }
00120 void focusClient() const { return mWindow->focusClient(); };
00121
00122 LLCoordGL getLastMouse() const { return mLastMousePoint; }
00123 S32 getLastMouseX() const { return mLastMousePoint.mX; }
00124 S32 getLastMouseY() const { return mLastMousePoint.mY; }
00125 LLCoordGL getCurrentMouse() const { return mCurrentMousePoint; }
00126 S32 getCurrentMouseX() const { return mCurrentMousePoint.mX; }
00127 S32 getCurrentMouseY() const { return mCurrentMousePoint.mY; }
00128 S32 getCurrentMouseDX() const { return mCurrentMouseDelta.mX; }
00129 S32 getCurrentMouseDY() const { return mCurrentMouseDelta.mY; }
00130 LLCoordGL getCurrentMouseDelta() const { return mCurrentMouseDelta; }
00131 LLStat * getMouseVelocityStat() { return &mMouseVelocityStat; }
00132 BOOL getLeftMouseDown() const { return mLeftMouseDown; }
00133 BOOL getRightMouseDown() const { return mRightMouseDown; }
00134
00135 LLUICtrl* getTopCtrl() const;
00136 BOOL hasTopCtrl(LLView* view) const;
00137
00138 void setupViewport(S32 x_offset = 0, S32 y_offset = 0);
00139 void setup3DRender();
00140 void setup2DRender();
00141
00142 BOOL isPickPending() { return mPickPending; }
00143
00144 LLVector3 mouseDirectionGlobal(const S32 x, const S32 y) const;
00145 LLVector3 mouseDirectionCamera(const S32 x, const S32 y) const;
00146
00147
00148 BOOL getActive() const { return mActive; }
00149
00150 void getTargetWindow(BOOL& fullscreen, S32& width, S32& height) const;
00151
00152
00153
00154 const LLString& getInitAlert() { return mInitAlert; }
00155
00156
00157
00158
00159 void saveLastMouse(const LLCoordGL &point);
00160
00161 void setCursor( ECursorType c );
00162 void showCursor();
00163 void hideCursor();
00164 void moveCursorToCenter();
00165
00166 void setShowProgress(const BOOL show);
00167 BOOL getShowProgress() const;
00168 void moveProgressViewToFront();
00169 void setProgressString(const LLString& string);
00170 void setProgressPercent(const F32 percent);
00171 void setProgressMessage(const LLString& msg);
00172 void setProgressCancelButtonVisible( BOOL b, const LLString& label );
00173 LLProgressView *getProgressView() const;
00174
00175 void updateObjectUnderCursor();
00176
00177 BOOL handlePerFrameHover();
00178
00179 BOOL handleKey(KEY key, MASK mask);
00180 void handleScrollWheel (S32 clicks);
00181
00182
00183 void setNormalControlsVisible( BOOL visible );
00184
00185
00186
00187
00188 void setKeyboardFocus(LLUICtrl* new_focus,void (*on_focus_lost)(LLUICtrl* old_focus));
00189 LLUICtrl* getKeyboardFocus();
00190 BOOL hasKeyboardFocus( const LLUICtrl* possible_focus ) const;
00191 BOOL childHasKeyboardFocus( const LLView* parent ) const;
00192
00193 void setMouseCapture(LLMouseHandler* new_captor);
00194 LLMouseHandler* getMouseCaptor() const;
00195
00196 void setTopCtrl(LLUICtrl* new_top);
00197
00198 void reshape(S32 width, S32 height);
00199 void sendShapeToSim();
00200
00201 void draw();
00202
00203 void updateDebugText();
00204 void drawDebugText();
00205
00206 static void loadUserImage(void **cb_data, const LLUUID &uuid);
00207
00208
00209 static void saveMovieNumbered(void*);
00210
00211 static void movieSize(S32 new_width, S32 new_height);
00212
00213 typedef enum e_snapshot_type
00214 {
00215 SNAPSHOT_TYPE_COLOR,
00216 SNAPSHOT_TYPE_DEPTH,
00217 SNAPSHOT_TYPE_OBJECT_ID
00218 } ESnapshotType;
00219
00220 BOOL saveSnapshot(const LLString& filename, S32 image_width, S32 image_height, BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, ESnapshotType type = SNAPSHOT_TYPE_COLOR);
00221 BOOL rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height, BOOL keep_window_aspect = TRUE,
00222 BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, ESnapshotType type = SNAPSHOT_TYPE_COLOR );
00223 BOOL saveImageNumbered(LLImageRaw *raw, const LLString& extension = LLString());
00224
00225 void playSnapshotAnimAndSound();
00226
00227
00228 void renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, BOOL for_hud );
00229 void performPick();
00230
00231 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);
00232 void hitObjectOrLandGlobalImmediate(S32 x, S32 y, void (*callback)(S32 x, S32 y, MASK mask), BOOL pick_transparent);
00233
00234 void hitUIElementAsync(S32 x, S32 y_from_bot, MASK mask, void (*callback)(S32 x, S32 y, MASK mask));
00235 void hitUIElementImmediate(S32 x, S32 y, void (*callback)(S32 x, S32 y, MASK mask));
00236
00237 LLViewerObject* getObjectUnderCursor(const F32 depth = 16.0f);
00238
00239
00240 LLViewerObject *lastObjectHit();
00241 LLViewerObject *lastNonFloraObjectHit();
00242
00243 const LLVector3d& lastObjectHitOffset();
00244 const LLVector3d& lastNonFloraObjectHitOffset();
00245
00246
00247 BOOL mousePointOnLandGlobal(const S32 x, const S32 y, LLVector3d *land_pos_global);
00248 BOOL mousePointOnPlaneGlobal(LLVector3d& point, const S32 x, const S32 y, const LLVector3d &plane_point, const LLVector3 &plane_normal);
00249 LLVector3d clickPointInWorldGlobal(const S32 x, const S32 y_from_bot, LLViewerObject* clicked_object) const;
00250 BOOL clickPointOnSurfaceGlobal(const S32 x, const S32 y, LLViewerObject *objectp, LLVector3d &point_global) const;
00251
00252
00253 void dumpState();
00254
00255
00256 void toggleFullscreen(BOOL show_progress);
00257
00258
00259 BOOL checkSettings();
00260 void restartDisplay(BOOL show_progress_bar);
00261 BOOL changeDisplaySettings(BOOL fullscreen, LLCoordScreen size, BOOL disable_vsync, BOOL show_progress_bar);
00262 BOOL getIgnoreDestroyWindow() { return mIgnoreActivate; }
00263 F32 getDisplayAspectRatio() const;
00264 const LLVector2& getDisplayScale() const { return mDisplayScale; }
00265 void calcDisplayScale();
00266
00267 void drawPickBuffer() const;
00268
00269 LLAlertDialog* alertXml(const std::string& xml_filename,
00270 LLAlertDialog::alert_callback_t callback = NULL, void* user_data = NULL);
00271 LLAlertDialog* alertXml(const std::string& xml_filename, const LLString::format_map_t& args,
00272 LLAlertDialog::alert_callback_t callback = NULL, void* user_data = NULL);
00273 LLAlertDialog* alertXmlEditText(const std::string& xml_filename, const LLString::format_map_t& args,
00274 LLAlertDialog::alert_callback_t callback, void* user_data,
00275 LLAlertDialog::alert_text_callback_t text_callback, void *text_data,
00276 const LLString::format_map_t& edit_args = LLString::format_map_t(),
00277 BOOL draw_asterixes = FALSE);
00278
00279 static bool alertCallback(S32 modal);
00280
00281 #ifdef SABINRIG
00282
00283 void printFeedback();
00284 #endif //SABINRIG
00285
00286 private:
00287 void switchToolByMask(MASK mask);
00288 void destroyWindow();
00289 void drawMouselookInstructions();
00290 void stopGL(BOOL save_state = TRUE);
00291 void restoreGL(const LLString& progress_message = LLString::null);
00292 void initFonts(F32 zoom_factor = 1.f);
00293
00294 void analyzeHit(
00295 S32 x,
00296 S32 y_from_bot,
00297 LLViewerObject* objectp,
00298 U32 te_offset,
00299 LLUUID* hit_object_id_p,
00300 S32* hit_face_p,
00301 LLVector3d* hit_pos_p,
00302 BOOL* hit_land,
00303 F32* hit_u_coord,
00304 F32* hit_v_coord);
00305
00306
00307 public:
00308 LLWindow* mWindow;
00309
00310 protected:
00311 BOOL mActive;
00312 BOOL mWantFullscreen;
00313 BOOL mShowFullscreenProgress;
00314 LLRect mWindowRect;
00315 LLRect mVirtualWindowRect;
00316 LLView* mRootView;
00317 LLVector2 mDisplayScale;
00318
00319 LLCoordGL mCurrentMousePoint;
00320 LLCoordGL mLastMousePoint;
00321 LLCoordGL mCurrentMouseDelta;
00322 LLStat mMouseVelocityStat;
00323 BOOL mLeftMouseDown;
00324 BOOL mRightMouseDown;
00325
00326 LLProgressView *mProgressView;
00327
00328 LLTextBox* mToolTip;
00329 BOOL mToolTipBlocked;
00330 LLRect mToolTipStickyRect;
00331
00332 BOOL mMouseInWindow;
00333 BOOL mFocusCycleMode;
00334
00335
00336 MASK mLastMask;
00337 LLTool* mToolStored;
00338 BOOL mSuppressToolbox;
00339
00340 BOOL mHideCursorPermanent;
00341 LLCoordGL mPickPoint;
00342 LLCoordGL mPickOffset;
00343 MASK mPickMask;
00344 BOOL mPickPending;
00345 void (*mPickCallback)(S32 x, S32 y, MASK mask);
00346
00347 LLString mOverlayTitle;
00348
00349 BOOL mIgnoreActivate;
00350 U8* mPickBuffer;
00351
00352 LLString mInitAlert;
00353
00354 class LLDebugText* mDebugText;
00355
00356 protected:
00357 static char sSnapshotBaseName[LL_MAX_PATH];
00358 static char sSnapshotDir[LL_MAX_PATH];
00359
00360 static char sMovieBaseName[LL_MAX_PATH];
00361 };
00362
00363 class LLBottomPanel : public LLPanel
00364 {
00365 public:
00366 LLBottomPanel(const LLString& name, const LLRect& rect);
00367 void setFocusIndicator(LLView * indicator);
00368 LLView * getFocusIndicator() { return mIndicator; }
00369 void draw();
00370 protected:
00371 LLView * mIndicator;
00372 };
00373 extern LLBottomPanel * gBottomPanel;
00374
00375 void toggle_flying(void*);
00376 void toggle_first_person();
00377 void toggle_build(void*);
00378 void reset_viewer_state_on_sim(void);
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389 extern LLVelocityBar* gVelocityBar;
00390 extern LLViewerWindow* gViewerWindow;
00391
00392 extern LLFrameTimer gMouseIdleTimer;
00393 extern LLFrameTimer gAwayTimer;
00394 extern LLFrameTimer gAwayTriggerTimer;
00395
00396 extern LLVector3d gLastHitPosGlobal;
00397 extern LLVector3d gLastHitObjectOffset;
00398 extern LLUUID gLastHitObjectID;
00399 extern S32 gLastHitObjectFace;
00400 extern BOOL gLastHitLand;
00401 extern F32 gLastHitUCoord;
00402 extern F32 gLastHitVCoord;
00403
00404
00405 extern LLVector3d gLastHitNonFloraPosGlobal;
00406 extern LLVector3d gLastHitNonFloraObjectOffset;
00407 extern LLUUID gLastHitNonFloraObjectID;
00408 extern S32 gLastHitNonFloraObjectFace;
00409
00410 extern S32 gLastHitUIElement;
00411 extern LLHUDIcon* gLastHitHUDIcon;
00412 extern BOOL gLastHitParcelWall;
00413 extern BOOL gDebugSelect;
00414 extern BOOL gPickFaces;
00415 extern BOOL gPickTransparent;
00416
00417 extern BOOL gDebugFastUIRender;
00418 extern S32 CHAT_BAR_HEIGHT;
00419 #endif