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