From 3b5269641181f98858a73b036e16adcb261e88a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Tue, 17 Apr 2012 19:34:45 +0200 Subject: [PATCH 01/12] Fix gcc2 build. --- src/add-ons/opengl/swrast_legacy/Jamfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/add-ons/opengl/swrast_legacy/Jamfile b/src/add-ons/opengl/swrast_legacy/Jamfile index ca03d03388..1442673e96 100644 --- a/src/add-ons/opengl/swrast_legacy/Jamfile +++ b/src/add-ons/opengl/swrast_legacy/Jamfile @@ -47,6 +47,6 @@ UseHeaders [ FDirName $(HAIKU_MESA_DIR) src mesa x86 ] ; AddResources Legacy\ Software\ Rasterizer : MesaSoftwareRenderer.rdef ; Addon Legacy\ Software\ Rasterizer : - MesaSoftwareRenderer.cpp : + MesaSoftwareRenderer.cpp : libGL.so be $(TARGET_LIBSUPC++) ; From acbaa2b25155fe68c554bdd6960dd43bb44e213d Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Tue, 17 Apr 2012 19:17:17 +0000 Subject: [PATCH 02/12] glinfo: Cosmetic adjustments * Remove my dropdown to select renderer We can accomplish this through a config file read by the opengl kit render roster * Reorder info text * Adjust tab view column sizes * Adjust window height --- .../kits/opengl/glinfo/CapabilitiesView.cpp | 4 +- .../kits/opengl/glinfo/ExtensionsView.cpp | 2 +- src/tests/kits/opengl/glinfo/GearsView.cpp | 2 +- src/tests/kits/opengl/glinfo/InfoView.cpp | 37 ++++++------------- src/tests/kits/opengl/glinfo/OpenGLView.cpp | 19 +--------- src/tests/kits/opengl/glinfo/OpenGLWindow.cpp | 2 +- 6 files changed, 17 insertions(+), 49 deletions(-) diff --git a/src/tests/kits/opengl/glinfo/CapabilitiesView.cpp b/src/tests/kits/opengl/glinfo/CapabilitiesView.cpp index f7ff7f7fb6..bd914c5368 100644 --- a/src/tests/kits/opengl/glinfo/CapabilitiesView.cpp +++ b/src/tests/kits/opengl/glinfo/CapabilitiesView.cpp @@ -35,7 +35,7 @@ CapabilitiesView::CapabilitiesView() { // add the columns - float capabilityColWidth = this->StringWidth("M") * 23; + float capabilityColWidth = this->StringWidth("M") * 28; fCapabilityColumn = new BStringColumn(B_TRANSLATE("Capability"), capabilityColWidth, capabilityColWidth - 20.0, @@ -44,7 +44,7 @@ CapabilitiesView::CapabilitiesView() fCapabilitiesList->SetSortingEnabled(true); fCapabilitiesList->SetSortColumn(fCapabilityColumn, true, true); - float valueColWidth = this->StringWidth("M") * 6; + float valueColWidth = this->StringWidth("M") * 8; fValueColumn = new BStringColumn(B_TRANSLATE("Value"), valueColWidth, valueColWidth, valueColWidth, B_TRUNCATE_MIDDLE); diff --git a/src/tests/kits/opengl/glinfo/ExtensionsView.cpp b/src/tests/kits/opengl/glinfo/ExtensionsView.cpp index bd864e7305..44526eb6ca 100644 --- a/src/tests/kits/opengl/glinfo/ExtensionsView.cpp +++ b/src/tests/kits/opengl/glinfo/ExtensionsView.cpp @@ -33,7 +33,7 @@ ExtensionsView::ExtensionsView() { // add the columns - float availableColWidth = this->StringWidth("M") * 27; + float availableColWidth = this->StringWidth("M") * 28; fAvailableColumn = new BStringColumn(B_TRANSLATE("Available extensions"), availableColWidth, availableColWidth, availableColWidth, diff --git a/src/tests/kits/opengl/glinfo/GearsView.cpp b/src/tests/kits/opengl/glinfo/GearsView.cpp index 618cac2a30..0d3ddc882a 100644 --- a/src/tests/kits/opengl/glinfo/GearsView.cpp +++ b/src/tests/kits/opengl/glinfo/GearsView.cpp @@ -52,7 +52,7 @@ GearsView::Draw(BRect updateRect) SetDrawingMode(B_OP_ALPHA); SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); - DrawBitmapAsync(fGears, BPoint(5.0, 18.0)); + DrawBitmapAsync(fGears, BPoint(5.0, 10.0)); } diff --git a/src/tests/kits/opengl/glinfo/InfoView.cpp b/src/tests/kits/opengl/glinfo/InfoView.cpp index 73818e6c82..c6d6e0e68c 100644 --- a/src/tests/kits/opengl/glinfo/InfoView.cpp +++ b/src/tests/kits/opengl/glinfo/InfoView.cpp @@ -11,6 +11,7 @@ #include "InfoView.h" +#include #include #include #include @@ -32,15 +33,6 @@ const BAlignment kLabelAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET); const BAlignment kValueAlignment(B_ALIGN_RIGHT, B_ALIGN_VERTICAL_UNSET); -// Render name -// Vendor Name GL Version -// GLU version GLUT API version -// -// example: -// Software rasterizer for X86/MMX/SSE2 -// Mesa Project 2.1 Mesa 8.1-devel (git-2402c0) -// GLU 1.3 GLUT API 5 - InfoView::InfoView() : BGroupView(B_TRANSLATE("Information"), B_HORIZONTAL) @@ -52,32 +44,25 @@ InfoView::InfoView() BStringView* vendorNameView = new BStringView(NULL, (const char*)glGetString(GL_VENDOR)); - vendorNameView->SetExplicitAlignment(kLabelAlignment); + vendorNameView->SetExplicitAlignment(kLabelAlignment); BStringView* glVersionView = new BStringView(NULL, (const char*)glGetString(GL_VERSION)); glVersionView->SetExplicitAlignment(kLabelAlignment); - BString gluString("GLU "); - gluString << (const char*)gluGetString(GLU_VERSION); - BStringView* gluVersionView = new BStringView(NULL, gluString.String()); - gluVersionView->SetExplicitAlignment(kLabelAlignment); - - BString glutAPIString("GLUT API "); - glutAPIString << (int32)GLUT_API_VERSION; - BStringView* glutVersionView = new BStringView(NULL, - glutAPIString.String()); - glutVersionView->SetExplicitAlignment(kLabelAlignment); + BString apiString("GLU "); + apiString << (const char*)gluGetString(GLU_VERSION); + apiString << ", GLUT "; + apiString << (int32)GLUT_API_VERSION; + BStringView* apiVersionView = new BStringView(NULL, apiString.String()); + apiVersionView->SetExplicitAlignment(kLabelAlignment); BLayoutBuilder::Group<>(this) .AddGroup(B_VERTICAL, 0) .Add(rendererView) - .Add(BGridLayoutBuilder(0, 0) - .Add(vendorNameView, 0, 0) - .Add(glVersionView, 1, 0) - .Add(gluVersionView, 0, 1) - .Add(glutVersionView, 1, 1) - ) + .Add(vendorNameView) + .Add(glVersionView) + .Add(apiVersionView) .End(); } diff --git a/src/tests/kits/opengl/glinfo/OpenGLView.cpp b/src/tests/kits/opengl/glinfo/OpenGLView.cpp index b4138b0c60..30fe9882b8 100644 --- a/src/tests/kits/opengl/glinfo/OpenGLView.cpp +++ b/src/tests/kits/opengl/glinfo/OpenGLView.cpp @@ -44,23 +44,7 @@ OpenGLView::OpenGLView() glView->LockGL(); - BPopUpMenu* menu = new BPopUpMenu(B_TRANSLATE("Automatic"), true, true); - menu->AddItem(new BMenuItem(B_TRANSLATE("Automatic"), - new BMessage(MENU_AUTO_MESSAGE))); - menu->AddSeparatorItem(); - menu->AddItem(new BMenuItem(B_TRANSLATE("Software Rasterizer"), - new BMessage(MENU_SWRAST_MESSAGE))); - menu->AddItem(new BMenuItem(B_TRANSLATE("Gallium Software Pipe"), - new BMessage(MENU_SWPIPE_MESSAGE))); - menu->AddItem(new BMenuItem(B_TRANSLATE("Gallium LLVM Pipe"), - new BMessage(MENU_SWLLVM_MESSAGE))); - BMenuField* menuField = new BMenuField("renderer", - B_TRANSLATE("3D Rendering Engine:"), menu); - menuField->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); - // TODO: Set current Renderer - menuField->SetEnabled(false); - - float tabViewWidth = this->StringWidth("M") * 36; + float tabViewWidth = this->StringWidth("M") * 42; float tabViewHeight = this->StringWidth("M") * 16; BTabView *tabView = new BTabView("tab view", B_WIDTH_FROM_LABEL); @@ -77,7 +61,6 @@ OpenGLView::OpenGLView() .AddGroup(B_VERTICAL, B_USE_DEFAULT_SPACING) .SetInsets(0, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) - .Add(menuField) .Add(new InfoView()) .Add(tabView) .End() diff --git a/src/tests/kits/opengl/glinfo/OpenGLWindow.cpp b/src/tests/kits/opengl/glinfo/OpenGLWindow.cpp index dde16f7f1e..5117a75e71 100644 --- a/src/tests/kits/opengl/glinfo/OpenGLWindow.cpp +++ b/src/tests/kits/opengl/glinfo/OpenGLWindow.cpp @@ -23,7 +23,7 @@ OpenGLWindow::OpenGLWindow() : - BWindow(BRect(50, 50, 300, 300), + BWindow(BRect(50, 50, 300, 400), B_TRANSLATE_SYSTEM_NAME("GL Info"), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS) From 582c97352d3a1fc36ca63cab5ac88fb3f206a9e7 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Tue, 17 Apr 2012 19:50:04 +0000 Subject: [PATCH 03/12] gl test: Fix GL dependencies for GL kit test apps --- src/tests/kits/opengl/demos/gears/Jamfile | 11 ++++++++++- src/tests/kits/opengl/direct_mode/Jamfile | 8 +++++++- src/tests/kits/opengl/glsl/Jamfile | 9 ++++++++- src/tests/kits/opengl/glut/game_mode/Jamfile | 9 ++++++++- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/tests/kits/opengl/demos/gears/Jamfile b/src/tests/kits/opengl/demos/gears/Jamfile index e195a65d2b..9cc394ceef 100644 --- a/src/tests/kits/opengl/demos/gears/Jamfile +++ b/src/tests/kits/opengl/demos/gears/Jamfile @@ -1,4 +1,5 @@ SubDir HAIKU_TOP src tests kits opengl demos gears ; +SubDirSysHdrs $(HAIKU_MESA_HEADERS) ; SetSubDirSupportedPlatformsBeOSCompatible ; @@ -9,7 +10,15 @@ if $(TARGET_PLATFORM) != haiku { UsePublicHeaders opengl ; } -SimpleTest GLGears : + +local sources = gears.c +; + +Includes [ FGristFiles $(sources) ] : $(HAIKU_MESA_HEADERS_DEPENDENCY) ; + + +SimpleTest GLGears : + $(sources) : be GL ; diff --git a/src/tests/kits/opengl/direct_mode/Jamfile b/src/tests/kits/opengl/direct_mode/Jamfile index 8303c3ad7a..de41e03a9f 100644 --- a/src/tests/kits/opengl/direct_mode/Jamfile +++ b/src/tests/kits/opengl/direct_mode/Jamfile @@ -10,8 +10,14 @@ if $(TARGET_PLATFORM) != haiku { UsePublicHeaders opengl ; } -SimpleTest GLDirectMode : +local sources = GLDirectMode.cpp +; + +Includes [ FGristFiles $(sources) ] : $(HAIKU_MESA_HEADERS_DEPENDENCY) ; + +SimpleTest GLDirectMode : + $(sources) : be game GL $(TARGET_LIBSUPC++) : GLDirectMode.rdef ; diff --git a/src/tests/kits/opengl/glsl/Jamfile b/src/tests/kits/opengl/glsl/Jamfile index f41ec048fb..4a17e83c29 100644 --- a/src/tests/kits/opengl/glsl/Jamfile +++ b/src/tests/kits/opengl/glsl/Jamfile @@ -1,4 +1,5 @@ SubDir HAIKU_TOP src tests kits opengl glsl ; +SubDirSysHdrs $(HAIKU_MESA_HEADERS) ; SetSubDirSupportedPlatformsBeOSCompatible ; @@ -9,10 +10,16 @@ if $(TARGET_PLATFORM) != haiku { UsePublicHeaders opengl ; } -StaticLibrary libshaderutil.a : +local shadersources = shaderutil.c ; +Includes [ FGristFiles $(shadersources) ] : $(HAIKU_MESA_HEADERS_DEPENDENCY) ; + +StaticLibrary libshaderutil.a : + $(shadersources) +; + SimpleTest brick : brick.c : libshaderutil.a be GL diff --git a/src/tests/kits/opengl/glut/game_mode/Jamfile b/src/tests/kits/opengl/glut/game_mode/Jamfile index 694606ebcb..c01235fdad 100644 --- a/src/tests/kits/opengl/glut/game_mode/Jamfile +++ b/src/tests/kits/opengl/glut/game_mode/Jamfile @@ -1,4 +1,5 @@ SubDir HAIKU_TOP src tests kits opengl glut game_mode ; +SubDirSysHdrs $(HAIKU_MESA_HEADERS) ; SetSubDirSupportedPlatformsBeOSCompatible ; @@ -9,7 +10,13 @@ if $(TARGET_PLATFORM) != haiku { UsePublicHeaders opengl ; } -SimpleTest GLUTGameMode : +local sources = game_mode.c +; + +Includes [ FGristFiles $(sources) ] : $(HAIKU_MESA_HEADERS_DEPENDENCY) ; + +SimpleTest GLUTGameMode : + $(sources) : be GL ; From 9e195872df77517e2b21e12e3e2da77e2497533c Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Tue, 17 Apr 2012 16:08:54 -0500 Subject: [PATCH 04/12] radeon_hd: Begin work on radeon_hd command processor * First steps at getting card command processor wired up to the ring buffers. * Code doesn't run yet as I have *no* idea what happens when these rings are in an invalid state. --- headers/private/graphics/radeon_hd/r700_reg.h | 2 + src/add-ons/accelerants/radeon_hd/gpu.cpp | 122 +++++++++++++++++- .../accelerants/radeon_hd/ringqueue.cpp | 2 +- src/add-ons/accelerants/radeon_hd/ringqueue.h | 9 +- 4 files changed, 132 insertions(+), 3 deletions(-) diff --git a/headers/private/graphics/radeon_hd/r700_reg.h b/headers/private/graphics/radeon_hd/r700_reg.h index 7bfe5d29ec..2e014df932 100644 --- a/headers/private/graphics/radeon_hd/r700_reg.h +++ b/headers/private/graphics/radeon_hd/r700_reg.h @@ -75,6 +75,8 @@ #define CP_QUEUE_THRESHOLDS 0x8760 #define ROQ_IB1_START(x) ((x) << 0) #define ROQ_IB2_START(x) ((x) << 8) +#define CP_DEBUG 0xC1FC +#define CP_RB_BASE 0xC100 #define CP_RB_CNTL 0xC104 #define RB_BUFSZ(x) ((x) << 0) #define RB_BLKSZ(x) ((x) << 8) diff --git a/src/add-ons/accelerants/radeon_hd/gpu.cpp b/src/add-ons/accelerants/radeon_hd/gpu.cpp index c966c12974..14afe5fda0 100644 --- a/src/add-ons/accelerants/radeon_hd/gpu.cpp +++ b/src/add-ons/accelerants/radeon_hd/gpu.cpp @@ -531,7 +531,127 @@ radeon_gpu_ring_boot(uint32 ringType) return B_ERROR; } - // TODO: Write initial ring state + // We don't execute this code until it's more complete. + ERROR("%s: TODO\n", __func__); + return B_OK; + + + // TODO: Write initial ring PACKET3 STATE + + // *** r600_cp_init_ring_buffer + // Reset command processor + Write32(OUT, GRBM_SOFT_RESET, RADEON_SOFT_RESET_CP); + Read32(OUT, GRBM_SOFT_RESET); + snooze(15000); + Write32(OUT, GRBM_SOFT_RESET, 0); + + // Set ring buffer size + uint32 controlScratch = RB_NO_UPDATE + | (compute_order(4096 / 8) << 8) // rptr_update_l2qw + | compute_order(ring->GetSize() / 8); // size_l2qw + #ifdef __BIG_ENDIAN + controlScratch |= BUF_SWAP_32BIT; + #endif + Write32(OUT, CP_RB_CNTL, controlScratch); + + // Set delays and timeouts + Write32(OUT, CP_SEM_WAIT_TIMER, 0); + Write32(OUT, CP_RB_WPTR_DELAY, 0); + + // Enable RenderBuffer Reads + controlScratch |= RB_RPTR_WR_ENA; + Write32(OUT, CP_RB_CNTL, controlScratch); + + // Zero out command processor read and write pointers + Write32(OUT, CP_RB_RPTR_WR, 0); + Write32(OUT, CP_RB_WPTR, 0); + + #if 0 + int ringPointer = 0; + // TODO: AGP cards + /* + if (RADEON_IS_AGP) { + ringPointer = dev_priv->ring_rptr->offset + - dev->agp->base + + dev_priv->gart_vm_start; + } else { + */ + ringPointer = dev_priv->ring_rptr->offset + - ((unsigned long) dev->sg->virtual) + + dev_priv->gart_vm_start; + + Write32(OUT, CP_RB_RPTR_ADDR, (ringPointer & 0xfffffffc)); + Write32(OUT, CP_RB_RPTR_ADDR_HI, upper_32_bits(ringPointer)); + + // Drop RPTR_WR_ENA and update CP RB Control + controlScratch &= ~R600_RB_RPTR_WR_ENA; + Write32(OUT, CP_RB_CNTL, controlScratch); + #endif + + #if 0 + // Update command processor pointer + int commandPointer = 0; + + // TODO: AGP cards + /* + if (RADEON_IS_AGP) { + commandPointer = (dev_priv->cp_ring->offset + - dev->agp->base + + dev_priv->gart_vm_start); + } + */ + commandPointer = (dev_priv->cp_ring->offset + - (unsigned long)dev->sg->virtual + + dev_priv->gart_vm_start); + #endif + + #if 0 + Write32(OUT, CP_RB_BASE, commandPointer >> 8); + Write32(OUT, CP_ME_CNTL, 0xff); + Write32(OUT, CP_DEBUG, (1 << 27) | (1 << 28)); + #endif + + #if 0 + // Initialize scratch register pointer. + // This wil lcause the scratch register values to be wtitten + // to memory whenever they are updated. + + uint64 scratchAddr = Read32(OUT, CP_RB_RPTR_ADDR) & 0xFFFFFFFC; + scratchAddr |= ((uint64)Read32(OUT, CP_RB_RPTR_ADDR_HI)) << 32; + scratchAddr += R600_SCRATCH_REG_OFFSET; + scratchAddr >>= 8; + scratchAddr &= 0xffffffff; + + Write32(OUT, R600_SCRATCH_ADDR, (uint32)scratchAddr); + + Write32(OUT, R600_SCRATCH_UMSK, 0x7); + #endif + + #if 0 + // Enable bus mastering + radeon_enable_bm(dev_priv); + + radeon_write_ring_rptr(dev_priv, R600_SCRATCHOFF(0), 0); + Write32(OUT, R600_LAST_FRAME_REG, 0); + + radeon_write_ring_rptr(dev_priv, R600_SCRATCHOFF(1), 0); + Write32(OUT, R600_LAST_DISPATCH_REG, 0); + + radeon_write_ring_rptr(dev_priv, R600_SCRATCHOFF(2), 0); + Write32(OUT, R600_LAST_CLEAR_REG, 0); + #endif + + // Reset sarea? + #if 0 + master_priv = file_priv->master->driver_priv; + if (master_priv->sarea_priv) { + master_priv->sarea_priv->last_frame = 0; + master_priv->sarea_priv->last_dispatch = 0; + master_priv->sarea_priv->last_clear = 0; + } + + r600_do_wait_for_idle(dev_priv); + #endif return B_OK; } diff --git a/src/add-ons/accelerants/radeon_hd/ringqueue.cpp b/src/add-ons/accelerants/radeon_hd/ringqueue.cpp index dda63f45f8..a1021e617d 100644 --- a/src/add-ons/accelerants/radeon_hd/ringqueue.cpp +++ b/src/add-ons/accelerants/radeon_hd/ringqueue.cpp @@ -31,7 +31,7 @@ static const char* queueName[RADEON_QUEUE_MAX] = { }; -static int +int compute_order(unsigned long size) { int order; diff --git a/src/add-ons/accelerants/radeon_hd/ringqueue.h b/src/add-ons/accelerants/radeon_hd/ringqueue.h index 66bd122e6b..3cfbb31775 100644 --- a/src/add-ons/accelerants/radeon_hd/ringqueue.h +++ b/src/add-ons/accelerants/radeon_hd/ringqueue.h @@ -11,15 +11,20 @@ #include "Accelerant.h" +#include + #define RADEON_QUEUE_MAX 3 -// Basic r100+ graphic data ring +// Basic r100+ graphic data ring #define RADEON_QUEUE_TYPE_GFX_INDEX 0 // Cayman+ have two compute command processor rings #define CAYMAN_QUEUE_TYPE_CP1_INDEX 1 #define CAYMAN_QUEUE_TYPE_CP2_INDEX 2 +int compute_order(unsigned long size); + + // A basic ring buffer for passing render data into card. // Data flows from the host to the GPU class RingQueue { @@ -33,6 +38,8 @@ public: size_t GetSize() {return fSize;}; size_t GetWriteAvail() {return fWriteBytesAvail;} size_t GetReadAvail() {return fSize - fWriteBytesAvail;} + intptr_t GetLocation() {return (intptr_t)fData;} + private: uint32 fQueueType; From 889692191d3374f5ad42e7b0d02a45e3dfd65294 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Tue, 17 Apr 2012 20:52:32 -0400 Subject: [PATCH 05/12] Fix Deskcalc drawing rounded corners on the desktop as a replicant, although I am not sure why I'm even bothering at this point. --- src/kits/interface/ControlLook.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/kits/interface/ControlLook.cpp b/src/kits/interface/ControlLook.cpp index 96dfea8ff8..1665b5a04a 100644 --- a/src/kits/interface/ControlLook.cpp +++ b/src/kits/interface/ControlLook.cpp @@ -560,6 +560,7 @@ BControlLook::DrawScrollBarBackground(BView* view, BRect& rect1, BRect& rect2, DrawScrollBarBackground(view, rect2, updateRect, base, flags, orientation); } + void BControlLook::DrawScrollBarBackground(BView* view, BRect& rect, const BRect& updateRect, const rgb_color& base, uint32 flags, @@ -1920,10 +1921,12 @@ BControlLook::_DrawButtonFrame(BView* view, BRect& rect, defaultIndicatorTint = (B_NO_TINT + defaultIndicatorTint) / 2; rgb_color defaultIndicatorColor = tint_color(base, defaultIndicatorTint); - rgb_color cornerBgColor = background; + rgb_color cornerBgColor; + + drawing_mode oldMode = view->DrawingMode(); if ((flags & B_DEFAULT_BUTTON) != 0) { - // draw default button indicator + cornerBgColor = defaultIndicatorColor; edgeLightColor = _EdgeLightColor(defaultIndicatorColor, contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8), brightness * ((flags & B_DISABLED) != 0 ? 1.0 : 0.9), flags); @@ -1931,8 +1934,7 @@ BControlLook::_DrawButtonFrame(BView* view, BRect& rect, contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8), brightness * ((flags & B_DISABLED) != 0 ? 1.0 : 0.9), flags); - cornerBgColor = defaultIndicatorColor; - + // draw default button indicator view->SetHighColor(background); view->FillRect(rect); view->SetHighColor(base); @@ -1946,6 +1948,14 @@ BControlLook::_DrawButtonFrame(BView* view, BRect& rect, view->StrokeRoundRect(rect, leftTopRadius, leftTopRadius); rect.InsetBy(1, 1); } else { + if ((flags & B_BLEND_FRAME) != 0) { + cornerBgColor = (rgb_color){ background.red, background.blue, + background.green, 0 }; + + view->SetDrawingMode(B_OP_ALPHA); + } else + cornerBgColor = background; + edgeLightColor = _EdgeLightColor(background, contrast * ((flags & B_DISABLED) != 0 ? 0.0 : 1.0), brightness * 1.0, flags); @@ -2021,6 +2031,8 @@ BControlLook::_DrawButtonFrame(BView* view, BRect& rect, brightness * 1.0, flags, borders); } + view->SetDrawingMode(oldMode); + // draw frame if ((flags & B_BLEND_FRAME) != 0) { drawing_mode oldDrawingMode = view->DrawingMode(); From 30a5580244604caad54b5314c1a23d88c1d58fa8 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Tue, 17 Apr 2012 22:48:57 -0400 Subject: [PATCH 06/12] Remove Time Interval radio buttons from Deskbar Prefs. * 12/24 hour clock is set from the Locale prefs only. * Redirect B_LOCALE_CHANGED message to the replicant tray instead of the time view and tell the replicant tray to update the time instead of updating the time view directly. This is because there was a bug where if the AM/PM marker grew the time view over the replicant tray icons when switching from 24 hour to 12 hour clock it wouldn't reflow the replicant tray icons like it should. * Rename the replicant tray view from "Status" to "_replicant_tray_" because BarApp uses FindView() to get the view by name and I'm assuming that this method can have conflicts. Following the example of the "_deskbar_tv_" naming convention. --- src/apps/deskbar/BarApp.cpp | 7 ++--- src/apps/deskbar/DeskbarMenu.cpp | 1 - src/apps/deskbar/PreferencesWindow.cpp | 33 ----------------------- src/apps/deskbar/PreferencesWindow.h | 4 --- src/apps/deskbar/StatusView.cpp | 37 +++++++++++--------------- src/apps/deskbar/TimeView.cpp | 11 +++----- 6 files changed, 23 insertions(+), 70 deletions(-) diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp index e31c6f12cb..0c348aafe1 100644 --- a/src/apps/deskbar/BarApp.cpp +++ b/src/apps/deskbar/BarApp.cpp @@ -640,10 +640,11 @@ TBarApp::MessageReceived(BMessage* message) if (message->FindBool("filesys", &localize) == B_OK) gLocalizedNamePreferred = localize; - BMessenger(fBarWindow->FindView("_deskbar_tv_")).SendMessage( + BMessenger(fBarWindow->FindView("_replicant_tray_")).SendMessage( message); - // Notify the TimeView that the format has changed and it should - // recompute its size + // Notify the replicant tray that the time interval has + // changed and it should update the time view and reflow + // the tray icons. break; } diff --git a/src/apps/deskbar/DeskbarMenu.cpp b/src/apps/deskbar/DeskbarMenu.cpp index 13a9cad413..4b8c88c605 100644 --- a/src/apps/deskbar/DeskbarMenu.cpp +++ b/src/apps/deskbar/DeskbarMenu.cpp @@ -399,7 +399,6 @@ TDeskbarMenu::ResetTargets() break; case kShowHideTime: - case kTimeIntervalChanged: case kShowSeconds: case kShowDayOfWeek: case kShowTimeZone: diff --git a/src/apps/deskbar/PreferencesWindow.cpp b/src/apps/deskbar/PreferencesWindow.cpp index c1eb196a80..cf8386ba3d 100644 --- a/src/apps/deskbar/PreferencesWindow.cpp +++ b/src/apps/deskbar/PreferencesWindow.cpp @@ -86,16 +86,6 @@ PreferencesWindow::PreferencesWindow(BRect frame) new BMessage(kAutoHide)); // Clock controls - BMessage* timeInterval12HoursMessage = new BMessage(kTimeIntervalChanged); - timeInterval12HoursMessage->AddBool("use24HourClock", false); - fTimeInterval12HourRadioButton = new BRadioButton("time inteval", - B_TRANSLATE("12 hour"), timeInterval12HoursMessage); - - BMessage* timeInterval24HoursMessage = new BMessage(kTimeIntervalChanged); - timeInterval24HoursMessage->AddBool("use24HourClock", true); - fTimeInterval24HourRadioButton = new BRadioButton("time inteval", - B_TRANSLATE("24 hour"), timeInterval24HoursMessage); - fShowSeconds = new BCheckBox(B_TRANSLATE("Show seconds"), new BMessage(kShowSeconds)); fShowDayOfWeek = new BCheckBox(B_TRANSLATE("Show day of week"), @@ -163,13 +153,6 @@ PreferencesWindow::PreferencesWindow(BRect frame) fWindowAutoHide->SetValue(settings->autoHide); // Clock settings - BFormattingConventions conventions; - BLocale::Default()->GetFormattingConventions(&conventions); - if (conventions.Use24HourClock()) - fTimeInterval24HourRadioButton->SetValue(B_CONTROL_ON); - else - fTimeInterval12HourRadioButton->SetValue(B_CONTROL_ON); - TReplicantTray* replicantTray = barApp->BarView()->ReplicantTray(); if (replicantTray->Time() != NULL) { fShowSeconds->SetValue(replicantTray->Time()->ShowSeconds()); @@ -194,9 +177,6 @@ PreferencesWindow::PreferencesWindow(BRect frame) fWindowAutoRaise->SetTarget(be_app); fWindowAutoHide->SetTarget(be_app); - fTimeInterval12HourRadioButton->SetTarget(replicantTray); - fTimeInterval24HourRadioButton->SetTarget(replicantTray); - fShowSeconds->SetTarget(replicantTray); fShowDayOfWeek->SetTarget(replicantTray); fShowTimeZone->SetTarget(replicantTray); @@ -271,21 +251,8 @@ PreferencesWindow::PreferencesWindow(BRect frame) .View(); fWindowBox->AddChild(view); - BGroupLayout* timeIntervalLayout = new BGroupLayout(B_VERTICAL, 0); - timeIntervalLayout->SetInsets(B_USE_DEFAULT_SPACING, 0, 0, 0); - BView* timeIntervalView = new BView("interval", 0, timeIntervalLayout); - timeIntervalView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - timeIntervalView->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - timeIntervalView->AddChild(fTimeInterval12HourRadioButton); - timeIntervalView->AddChild(fTimeInterval24HourRadioButton); - view = BLayoutBuilder::Group<>() .AddGroup(B_VERTICAL, 0) - .AddGroup(B_VERTICAL, 0) - .SetInsets(0, 0, 0, B_USE_DEFAULT_SPACING) - .Add(new BStringView("interval", B_TRANSLATE("Interval"))) - .Add(timeIntervalView) - .End() .AddGroup(B_VERTICAL, 0) .SetInsets(0, 0, 0, B_USE_DEFAULT_SPACING) .Add(fShowSeconds) diff --git a/src/apps/deskbar/PreferencesWindow.h b/src/apps/deskbar/PreferencesWindow.h index 286417f422..1d261973de 100644 --- a/src/apps/deskbar/PreferencesWindow.h +++ b/src/apps/deskbar/PreferencesWindow.h @@ -24,7 +24,6 @@ const uint32 kAutoRaise = 'AtRs'; const uint32 kAutoHide = 'AtHd'; const uint32 kShowHideTime = 'ShTm'; -const uint32 kTimeIntervalChanged = 'TiCh'; const uint32 kShowSeconds = 'SwSc'; const uint32 kShowDayOfWeek = 'SwDw'; const uint32 kShowTimeZone = 'SwTz'; @@ -75,9 +74,6 @@ private: BCheckBox* fWindowAutoRaise; BCheckBox* fWindowAutoHide; - BRadioButton* fTimeInterval24HourRadioButton; - BRadioButton* fTimeInterval12HourRadioButton; - BCheckBox* fShowSeconds; BCheckBox* fShowDayOfWeek; BCheckBox* fShowTimeZone; diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp index b9aab75b59..e47c3f2001 100644 --- a/src/apps/deskbar/StatusView.cpp +++ b/src/apps/deskbar/StatusView.cpp @@ -54,7 +54,6 @@ All rights reserved. #include #include #include -#include #include #include #include @@ -125,8 +124,8 @@ DumpList(BList* itemlist) // don't change the name of this view to anything other than "Status"! TReplicantTray::TReplicantTray(TBarView* parent, bool vertical) - : BView(BRect(0, 0, 1, 1), "Status", B_FOLLOW_LEFT | B_FOLLOW_TOP, - B_WILL_DRAW | B_FRAME_EVENTS), + : BView(BRect(0, 0, 1, 1), "_replicant_tray_", + B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS), fTime(NULL), fBarView(parent), fShelf(new TReplicantShelf(this)), @@ -276,33 +275,27 @@ void TReplicantTray::MessageReceived(BMessage* message) { switch (message->what) { - case kShowHideTime: - // from context menu in clock and in this view - ShowHideTime(); - break; - - case kTimeIntervalChanged: + case B_LOCALE_CHANGED: { if (fTime == NULL) return; - bool use24HourClock; - if (message->FindBool("use24HourClock", &use24HourClock) - == B_OK) { - BFormattingConventions conventions; - BLocale::Default()->GetFormattingConventions(&conventions); - conventions.SetExplicitUse24HourClock(use24HourClock); - BPrivate::MutableLocaleRoster::Default()-> - SetDefaultFormattingConventions(conventions); - fTime->SetUse24HourClock(use24HourClock); - // time string reformat -> realign - RealignReplicants(); - AdjustPlacement(); - } + // Locale may have updated 12/24 hour clock + BFormattingConventions conventions; + BLocale::Default()->GetFormattingConventions(&conventions); + fTime->SetUse24HourClock(conventions.Use24HourClock()); + // time string reformat -> realign + RealignReplicants(); + AdjustPlacement(); break; } + case kShowHideTime: + // from context menu in clock and in this view + ShowHideTime(); + break; + case kShowSeconds: if (fTime == NULL) return; diff --git a/src/apps/deskbar/TimeView.cpp b/src/apps/deskbar/TimeView.cpp index 9aedbeecaf..6b90bda372 100644 --- a/src/apps/deskbar/TimeView.cpp +++ b/src/apps/deskbar/TimeView.cpp @@ -66,6 +66,7 @@ enum { #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "TimeView" + TTimeView::TTimeView(float maxWidth, float height, bool use24HourClock, bool showSeconds, bool showDayOfWeek, bool showTimeZone) : @@ -194,10 +195,6 @@ void TTimeView::MessageReceived(BMessage* message) { switch (message->what) { - case B_LOCALE_CHANGED: - Update(); - break; - case kChangeTime: // launch the time prefs app be_roster->Launch("application/x-vnd.Haiku-Time"); @@ -487,16 +484,16 @@ void TTimeView::Update() { fLocale = *BLocale::Default(); + UpdateTimeFormat(); + GetCurrentTime(); GetCurrentDate(); SetToolTip(fCurrentDateStr); - UpdateTimeFormat(); - CalculateTextPlacement(); ResizeToPreferred(); - if (fParent) + if (fParent != NULL) fParent->Invalidate(); } From 0d2ac94c4df1061e1f2b835703f018553c929744 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Tue, 17 Apr 2012 23:08:35 -0400 Subject: [PATCH 07/12] Rename the TReplicantTray view "_deskbar_rt_" instead of "_replicant_tray_". That follows the convention a bit better and is less likely to cause name collisions. While I am at it put the BView line below the : as is our usual convention. --- src/apps/deskbar/BarApp.cpp | 2 +- src/apps/deskbar/StatusView.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp index 0c348aafe1..ba3e76684d 100644 --- a/src/apps/deskbar/BarApp.cpp +++ b/src/apps/deskbar/BarApp.cpp @@ -640,7 +640,7 @@ TBarApp::MessageReceived(BMessage* message) if (message->FindBool("filesys", &localize) == B_OK) gLocalizedNamePreferred = localize; - BMessenger(fBarWindow->FindView("_replicant_tray_")).SendMessage( + BMessenger(fBarWindow->FindView("_deskbar_rt_")).SendMessage( message); // Notify the replicant tray that the time interval has // changed and it should update the time view and reflow diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp index e47c3f2001..aad0290564 100644 --- a/src/apps/deskbar/StatusView.cpp +++ b/src/apps/deskbar/StatusView.cpp @@ -124,8 +124,9 @@ DumpList(BList* itemlist) // don't change the name of this view to anything other than "Status"! TReplicantTray::TReplicantTray(TBarView* parent, bool vertical) - : BView(BRect(0, 0, 1, 1), "_replicant_tray_", - B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS), + : + BView(BRect(0, 0, 1, 1), "_deskbar_rt_", B_FOLLOW_LEFT | B_FOLLOW_TOP, + B_WILL_DRAW | B_FRAME_EVENTS), fTime(NULL), fBarView(parent), fShelf(new TReplicantShelf(this)), From 41651bb3fd80eeccaab6e46643085a7d0b2bd70c Mon Sep 17 00:00:00 2001 From: John Scipione Date: Tue, 17 Apr 2012 23:20:37 -0400 Subject: [PATCH 08/12] Small code simplication cleanup and add comment. --- src/kits/interface/ControlLook.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/kits/interface/ControlLook.cpp b/src/kits/interface/ControlLook.cpp index 1665b5a04a..cc3e6869c1 100644 --- a/src/kits/interface/ControlLook.cpp +++ b/src/kits/interface/ControlLook.cpp @@ -1948,13 +1948,13 @@ BControlLook::_DrawButtonFrame(BView* view, BRect& rect, view->StrokeRoundRect(rect, leftTopRadius, leftTopRadius); rect.InsetBy(1, 1); } else { + cornerBgColor = background; if ((flags & B_BLEND_FRAME) != 0) { - cornerBgColor = (rgb_color){ background.red, background.blue, - background.green, 0 }; - + // set the background color to transparent for the case + // that we are on the desktop + cornerBgColor.alpha = 0; view->SetDrawingMode(B_OP_ALPHA); - } else - cornerBgColor = background; + } edgeLightColor = _EdgeLightColor(background, contrast * ((flags & B_DISABLED) != 0 ? 0.0 : 1.0), From f5be13ecc7503a48a32b87995a78a2d0247ab401 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Tue, 17 Apr 2012 23:38:12 -0400 Subject: [PATCH 09/12] Remove time zone clock option and Time preferences button. * Nobody thought time zone was a particularly useful option to have in the clock. * You can still open Time preferences from Deskbar by right clicking on the clock, but, since there isn't a big connection between the clock settings in Deskbar and Time preferences anymore this button isn't needed here. * There are still 2 clock options, Show seconds, and Show day of week and day of week is localized as well so this wasn't a total wash. --- src/apps/deskbar/BarApp.cpp | 6 ----- src/apps/deskbar/BarApp.h | 1 - src/apps/deskbar/DeskbarMenu.cpp | 1 - src/apps/deskbar/PreferencesWindow.cpp | 20 ++--------------- src/apps/deskbar/PreferencesWindow.h | 3 --- src/apps/deskbar/StatusView.cpp | 16 +------------ src/apps/deskbar/TimeView.cpp | 31 ++------------------------ src/apps/deskbar/TimeView.h | 6 +---- 8 files changed, 6 insertions(+), 78 deletions(-) diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp index ba3e76684d..ae9b45c6a1 100644 --- a/src/apps/deskbar/BarApp.cpp +++ b/src/apps/deskbar/BarApp.cpp @@ -207,7 +207,6 @@ TBarApp::SaveSettings() storedSettings.AddBool("showTime", fSettings.showTime); storedSettings.AddBool("showSeconds", fSettings.showSeconds); storedSettings.AddBool("showDayOfWeek", fSettings.showDayOfWeek); - storedSettings.AddBool("showTimeZone", fSettings.showTimeZone); storedSettings.AddPoint("switcherLoc", fSettings.switcherLoc); storedSettings.AddInt32("recentAppsCount", fSettings.recentAppsCount); @@ -248,7 +247,6 @@ TBarApp::InitSettings() settings.showTime = true; settings.showSeconds = false; settings.showDayOfWeek = false; - settings.showTimeZone = false; settings.state = kExpandoState; settings.width = 0; settings.switcherLoc = BPoint(5000, 5000); @@ -315,10 +313,6 @@ TBarApp::InitSettings() != B_OK) { settings.showDayOfWeek = false; } - if (storedSettings.FindBool("showTimeZone", &settings.showTimeZone) - != B_OK) { - settings.showTimeZone = false; - } if (storedSettings.FindPoint("switcherLoc", &settings.switcherLoc) != B_OK) { settings.switcherLoc = BPoint(5000, 5000); diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h index 626286bf38..a184e32b19 100644 --- a/src/apps/deskbar/BarApp.h +++ b/src/apps/deskbar/BarApp.h @@ -78,7 +78,6 @@ struct desk_settings { bool showTime; bool showSeconds; bool showDayOfWeek; - bool showTimeZone; uint32 state; float width; BPoint switcherLoc; diff --git a/src/apps/deskbar/DeskbarMenu.cpp b/src/apps/deskbar/DeskbarMenu.cpp index 4b8c88c605..e6839b7caf 100644 --- a/src/apps/deskbar/DeskbarMenu.cpp +++ b/src/apps/deskbar/DeskbarMenu.cpp @@ -401,7 +401,6 @@ TDeskbarMenu::ResetTargets() case kShowHideTime: case kShowSeconds: case kShowDayOfWeek: - case kShowTimeZone: item->SetTarget(fBarView->fReplicantTray); break; } diff --git a/src/apps/deskbar/PreferencesWindow.cpp b/src/apps/deskbar/PreferencesWindow.cpp index cf8386ba3d..7e54c2a251 100644 --- a/src/apps/deskbar/PreferencesWindow.cpp +++ b/src/apps/deskbar/PreferencesWindow.cpp @@ -90,8 +90,6 @@ PreferencesWindow::PreferencesWindow(BRect frame) new BMessage(kShowSeconds)); fShowDayOfWeek = new BCheckBox(B_TRANSLATE("Show day of week"), new BMessage(kShowDayOfWeek)); - fShowTimeZone = new BCheckBox(B_TRANSLATE("Show time zone"), - new BMessage(kShowTimeZone)); // Get settings from BarApp TBarApp* barApp = static_cast(be_app); @@ -157,11 +155,9 @@ PreferencesWindow::PreferencesWindow(BRect frame) if (replicantTray->Time() != NULL) { fShowSeconds->SetValue(replicantTray->Time()->ShowSeconds()); fShowDayOfWeek->SetValue(replicantTray->Time()->ShowDayOfWeek()); - fShowTimeZone->SetValue(replicantTray->Time()->ShowTimeZone()); } else { fShowSeconds->SetValue(settings->showSeconds); fShowDayOfWeek->SetValue(settings->showDayOfWeek); - fShowTimeZone->SetValue(settings->showTimeZone); } EnableDisableDependentItems(); @@ -179,7 +175,6 @@ PreferencesWindow::PreferencesWindow(BRect frame) fShowSeconds->SetTarget(replicantTray); fShowDayOfWeek->SetTarget(replicantTray); - fShowTimeZone->SetTarget(replicantTray); // Layout fMenuBox = new BBox("fMenuBox"); @@ -253,14 +248,8 @@ PreferencesWindow::PreferencesWindow(BRect frame) view = BLayoutBuilder::Group<>() .AddGroup(B_VERTICAL, 0) - .AddGroup(B_VERTICAL, 0) - .SetInsets(0, 0, 0, B_USE_DEFAULT_SPACING) - .Add(fShowSeconds) - .Add(fShowDayOfWeek) - .Add(fShowTimeZone) - .End() - .Add(new BButton(B_TRANSLATE("Time preferences" B_UTF8_ELLIPSIS), - new BMessage(kTimePreferences))) + .Add(fShowSeconds) + .Add(fShowDayOfWeek) .AddGlue() .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) @@ -311,11 +300,6 @@ PreferencesWindow::MessageReceived(BMessage* message) EnableDisableDependentItems(); break; - case kTimePreferences: - // launch the time prefs app - be_roster->Launch("application/x-vnd.Haiku-Time"); - break; - default: BWindow::MessageReceived(message); break; diff --git a/src/apps/deskbar/PreferencesWindow.h b/src/apps/deskbar/PreferencesWindow.h index 1d261973de..d7771266c8 100644 --- a/src/apps/deskbar/PreferencesWindow.h +++ b/src/apps/deskbar/PreferencesWindow.h @@ -26,8 +26,6 @@ const uint32 kAutoHide = 'AtHd'; const uint32 kShowHideTime = 'ShTm'; const uint32 kShowSeconds = 'SwSc'; const uint32 kShowDayOfWeek = 'SwDw'; -const uint32 kShowTimeZone = 'SwTz'; -const uint32 kTimePreferences = 'TmPr'; class BBox; class BButton; @@ -76,7 +74,6 @@ private: BCheckBox* fShowSeconds; BCheckBox* fShowDayOfWeek; - BCheckBox* fShowTimeZone; }; diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp index aad0290564..3747b415e6 100644 --- a/src/apps/deskbar/StatusView.cpp +++ b/src/apps/deskbar/StatusView.cpp @@ -150,8 +150,7 @@ TReplicantTray::TReplicantTray(TBarView* parent, bool vertical) // Create the time view fTime = new TTimeView(fMinimumTrayWidth, kMaxReplicantHeight - 1.0, - use24HourClock, settings->showSeconds, settings->showDayOfWeek, - settings->showTimeZone); + use24HourClock, settings->showSeconds, settings->showDayOfWeek); } @@ -319,17 +318,6 @@ TReplicantTray::MessageReceived(BMessage* message) AdjustPlacement(); break; - case kShowTimeZone: - if (fTime == NULL) - return; - - fTime->SetShowTimeZone(!fTime->ShowTimeZone()); - - // time string reformat -> realign - RealignReplicants(); - AdjustPlacement(); - break; - #ifdef DB_ADDONS case B_NODE_MONITOR: HandleEntryUpdate(message); @@ -1252,7 +1240,6 @@ TReplicantTray::SaveTimeSettings() settings->showTime = !fTime->IsHidden(); settings->showSeconds = fTime->ShowSeconds(); settings->showDayOfWeek = fTime->ShowDayOfWeek(); - settings->showTimeZone = fTime->ShowTimeZone(); } @@ -1599,4 +1586,3 @@ TDragRegion::SetDragRegionLocation(int32 location) fDragLocation = location; Invalidate(); } - diff --git a/src/apps/deskbar/TimeView.cpp b/src/apps/deskbar/TimeView.cpp index 6b90bda372..c212aa2055 100644 --- a/src/apps/deskbar/TimeView.cpp +++ b/src/apps/deskbar/TimeView.cpp @@ -68,7 +68,7 @@ enum { TTimeView::TTimeView(float maxWidth, float height, bool use24HourClock, - bool showSeconds, bool showDayOfWeek, bool showTimeZone) + bool showSeconds, bool showDayOfWeek) : BView(BRect(-100, -100, -90, -90), "_deskbar_tv_", B_FOLLOW_RIGHT | B_FOLLOW_TOP, @@ -79,8 +79,7 @@ TTimeView::TTimeView(float maxWidth, float height, bool use24HourClock, fOrientation(true), fUse24HourClock(use24HourClock), fShowSeconds(showSeconds), - fShowDayOfWeek(showDayOfWeek), - fShowTimeZone(showTimeZone) + fShowDayOfWeek(showDayOfWeek) { fCurrentTime = fLastTime = time(NULL); fSeconds = fMinute = fHour = 0; @@ -354,21 +353,6 @@ TTimeView::SetShowDayOfWeek(bool show) } -bool -TTimeView::ShowTimeZone() const -{ - return fShowTimeZone; -} - - -void -TTimeView::SetShowTimeZone(bool show) -{ - fShowTimeZone = show; - Update(); -} - - void TTimeView::ShowCalendar(BPoint where) { @@ -433,14 +417,6 @@ TTimeView::CalculateTextPlacement() BFont font; GetFont(&font); - // If 12 hour clock with all options turned on shrink font size to fit. - if (!fUse24HourClock && fShowSeconds && fShowDayOfWeek && fShowTimeZone) - font.SetSize(11.0); - else - font.SetSize(12.0); - - SetFont(&font, B_FONT_SIZE); - const char* stringArray[1]; stringArray[0] = fCurrentTimeStr; BRect rectArray[1]; @@ -517,8 +493,5 @@ TTimeView::UpdateTimeFormat() if (!fUse24HourClock) timeFormat.Append(" a"); - if (fShowTimeZone) - timeFormat.Append(" V"); - fTimeFormat = timeFormat; } diff --git a/src/apps/deskbar/TimeView.h b/src/apps/deskbar/TimeView.h index fcb26f1723..24c5495502 100644 --- a/src/apps/deskbar/TimeView.h +++ b/src/apps/deskbar/TimeView.h @@ -55,7 +55,7 @@ class TTimeView : public BView { public: TTimeView(float maxWidth, float height, bool use24HourClock, bool showSeconds, - bool showDayOfWeek, bool showTimeZone); + bool showDayOfWeek); TTimeView(BMessage* data); ~TTimeView(); @@ -86,9 +86,6 @@ public: bool ShowDayOfWeek() const; void SetShowDayOfWeek(bool show); - bool ShowTimeZone() const; - void SetShowTimeZone(bool show); - void ShowCalendar(BPoint where); private: @@ -123,7 +120,6 @@ private: bool fUse24HourClock; bool fShowSeconds; bool fShowDayOfWeek; - bool fShowTimeZone; BString fTimeFormat; BPoint fTimeLocation; From 05fa08371f54a1fd447b9a390ddc6f4464a30fb9 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Wed, 18 Apr 2012 00:20:15 -0400 Subject: [PATCH 10/12] Indent the indented checkboxes in Deskbar prefs more. * Create my own kIndentSpacing parameter from ControlLook which sets the indent spacing width to match the previously used spacing. This lines the indented checkbox up with the text of the unindented checkbox above it. This matches what it looked like before I updated the dialog to use font-aware spacing, while keeping the same relative spacing at different font sizes. --- src/apps/deskbar/PreferencesWindow.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/apps/deskbar/PreferencesWindow.cpp b/src/apps/deskbar/PreferencesWindow.cpp index 7e54c2a251..5a0da893a2 100644 --- a/src/apps/deskbar/PreferencesWindow.cpp +++ b/src/apps/deskbar/PreferencesWindow.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -33,9 +34,14 @@ #include "StatusView.h" +static const float kIndentSpacing + = be_control_look->DefaultItemSpacing() * 2.3; + + #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "PreferencesWindow" + PreferencesWindow::PreferencesWindow(BRect frame) : BWindow(frame, B_TRANSLATE("Deskbar preferences"), B_TITLED_WINDOW, @@ -219,7 +225,7 @@ PreferencesWindow::PreferencesWindow(BRect frame) .Add(fAppsSortTrackerFirst) .Add(fAppsShowExpanders) .AddGroup(B_HORIZONTAL, 0) - .SetInsets(B_USE_BIG_SPACING, 0, 0, 0) + .SetInsets(kIndentSpacing, 0, 0, 0) .Add(fAppsExpandNew) .End() .Add(fAppsHideLabels) From 63c55f0212d9893fc435b45894c4ce8691556905 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Wed, 18 Apr 2012 01:56:17 -0400 Subject: [PATCH 11/12] Update Deskcalc's right-click menu options. If CalcView is embedded as a replicant on the desktop it's parent window is not CalcWindow. Furthermore, it can't switch between compact, basic and scientific keypad modes, you are locked in tox the one you picked at the time you embeded the view into the desktop. So, I have updated the right-click message to reflect this reality by taking away the keypad mode switching options. You can still set auto num-lock and turn beep on and off (theoretically someday anyway) but the CalcView receives these messages instead of CalcWindow. So, these 2 options now work in the case of a CalcView embedded in the desktop at least. --- src/apps/deskcalc/CalcView.cpp | 70 ++++++++++++++++++++------------ src/apps/deskcalc/CalcView.h | 2 +- src/apps/deskcalc/CalcWindow.cpp | 6 +-- 3 files changed, 49 insertions(+), 29 deletions(-) diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp index 80151d23f2..ee7bef4213 100644 --- a/src/apps/deskcalc/CalcView.cpp +++ b/src/apps/deskcalc/CalcView.cpp @@ -152,9 +152,6 @@ CalcView::CalcView(BRect frame, rgb_color rgbBaseColor, BMessage* settings) // colorize based on base color. _Colorize(); - // create pop-up menu system - _CreatePopUpMenu(); - // Fetch the calc icon for compact view _FetchAppIcon(fCalcIcon); } @@ -196,9 +193,6 @@ CalcView::CalcView(BMessage* archive) // read data from archive _LoadSettings(archive); - // create pop-up menu system - _CreatePopUpMenu(); - // Fetch the calc icon for compact view _FetchAppIcon(fCalcIcon); } @@ -221,21 +215,43 @@ CalcView::AttachedToWindow() BRect frame(Frame()); FrameResized(frame.Width(), frame.Height()); - SetKeypadMode(fOptions->keypad_mode); + bool addKeypadModeMenuItems = true; + if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) { + // don't add these items if we are a replicant on the desktop + addKeypadModeMenuItems = false; + } + + // create and attach the pop-up menu + _CreatePopUpMenu(addKeypadModeMenuItems); + + if (addKeypadModeMenuItems) + SetKeypadMode(fOptions->keypad_mode); } void CalcView::MessageReceived(BMessage* message) { + if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) { + // if we are embedded in desktop we need to receive these + // message here since we don't have a parent BWindow + switch (message->what) { + case MSG_OPTIONS_AUTO_NUM_LOCK: + ToggleAutoNumlock(); + break; + + case MSG_OPTIONS_AUDIO_FEEDBACK: + ToggleAudioFeedback(); + break; + } + } + // check if message was dropped if (message->WasDropped()) { // pass message on to paste if (message->IsSourceRemote()) Paste(message); - } else { - // act on posted message type switch (message->what) { @@ -510,8 +526,8 @@ CalcView::MouseDown(BPoint point) int32 buttons = 0; Window()->CurrentMessage()->FindInt32("buttons", &buttons); - // display popup menu if not primary mouse button if ((B_PRIMARY_MOUSE_BUTTON & buttons) == 0) { + // display popup menu if not primary mouse button BMenuItem* selected; if ((selected = fPopUpMenu->Go(ConvertToScreen(point))) != NULL && selected->Message() != NULL) { @@ -1233,36 +1249,40 @@ CalcView::_Colorize() void -CalcView::_CreatePopUpMenu() +CalcView::_CreatePopUpMenu(bool addKeypadModeMenuItems) { // construct items fAutoNumlockItem = new BMenuItem(B_TRANSLATE("Enable Num Lock on startup"), new BMessage(MSG_OPTIONS_AUTO_NUM_LOCK)); fAudioFeedbackItem = new BMenuItem(B_TRANSLATE("Audio Feedback"), new BMessage(MSG_OPTIONS_AUDIO_FEEDBACK)); - fKeypadModeCompactItem = new BMenuItem(B_TRANSLATE("Compact"), - new BMessage(MSG_OPTIONS_KEYPAD_MODE_COMPACT), '0'); - fKeypadModeBasicItem = new BMenuItem(B_TRANSLATE("Basic"), - new BMessage(MSG_OPTIONS_KEYPAD_MODE_BASIC), '1'); - fKeypadModeScientificItem = new BMenuItem(B_TRANSLATE("Scientific"), - new BMessage(MSG_OPTIONS_KEYPAD_MODE_SCIENTIFIC), '2'); + if (addKeypadModeMenuItems) { + fKeypadModeCompactItem = new BMenuItem(B_TRANSLATE("Compact"), + new BMessage(MSG_OPTIONS_KEYPAD_MODE_COMPACT), '0'); + fKeypadModeBasicItem = new BMenuItem(B_TRANSLATE("Basic"), + new BMessage(MSG_OPTIONS_KEYPAD_MODE_BASIC), '1'); + fKeypadModeScientificItem = new BMenuItem(B_TRANSLATE("Scientific"), + new BMessage(MSG_OPTIONS_KEYPAD_MODE_SCIENTIFIC), '2'); + } // apply current settings fAutoNumlockItem->SetMarked(fOptions->auto_num_lock); fAudioFeedbackItem->SetMarked(fOptions->audio_feedback); - _MarkKeypadItems(fOptions->keypad_mode); // construct menu fPopUpMenu = new BPopUpMenu("pop-up", false, false); fPopUpMenu->AddItem(fAutoNumlockItem); -// TODO: Enabled when we use beep events which can be configured in the Sounds -// preflet. -// fPopUpMenu->AddItem(fAudioFeedbackItem); - fPopUpMenu->AddSeparatorItem(); - fPopUpMenu->AddItem(fKeypadModeCompactItem); - fPopUpMenu->AddItem(fKeypadModeBasicItem); - fPopUpMenu->AddItem(fKeypadModeScientificItem); + // TODO: Enable this when we use beep events which can be configured + // in the Sounds preflet. + //fPopUpMenu->AddItem(fAudioFeedbackItem); + if (addKeypadModeMenuItems) { + fPopUpMenu->AddSeparatorItem(); + fPopUpMenu->AddItem(fKeypadModeCompactItem); + fPopUpMenu->AddItem(fKeypadModeBasicItem); + fPopUpMenu->AddItem(fKeypadModeScientificItem); + _MarkKeypadItems(fOptions->keypad_mode); + } } diff --git a/src/apps/deskcalc/CalcView.h b/src/apps/deskcalc/CalcView.h index bcf51b845e..16cf413727 100644 --- a/src/apps/deskcalc/CalcView.h +++ b/src/apps/deskcalc/CalcView.h @@ -104,7 +104,7 @@ class CalcView : public BView { void _Colorize(); - void _CreatePopUpMenu(); + void _CreatePopUpMenu(bool addKeypadModeMenuItems); BRect _ExpressionRect() const; BRect _KeypadRect() const; diff --git a/src/apps/deskcalc/CalcWindow.cpp b/src/apps/deskcalc/CalcWindow.cpp index 823a767350..0ccb142af3 100644 --- a/src/apps/deskcalc/CalcWindow.cpp +++ b/src/apps/deskcalc/CalcWindow.cpp @@ -77,9 +77,9 @@ CalcWindow::~CalcWindow() void -CalcWindow::MessageReceived(BMessage* msg) +CalcWindow::MessageReceived(BMessage* message) { - switch (msg->what) { + switch (message->what) { case MSG_OPTIONS_AUTO_NUM_LOCK: fCalcView->ToggleAutoNumlock(); break; @@ -101,7 +101,7 @@ CalcWindow::MessageReceived(BMessage* msg) break; default: - BWindow::MessageReceived(msg); + BWindow::MessageReceived(message); break; } } From e08d64d0d6a3a35a8e8efa78ed34a7c1a407fb04 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Wed, 18 Apr 2012 02:57:55 -0400 Subject: [PATCH 12/12] If we caught the message in these cases there is no reason to continue on. --- src/apps/deskcalc/CalcView.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp index ee7bef4213..1bfd2be46d 100644 --- a/src/apps/deskcalc/CalcView.cpp +++ b/src/apps/deskcalc/CalcView.cpp @@ -238,11 +238,11 @@ CalcView::MessageReceived(BMessage* message) switch (message->what) { case MSG_OPTIONS_AUTO_NUM_LOCK: ToggleAutoNumlock(); - break; + return; case MSG_OPTIONS_AUDIO_FEEDBACK: ToggleAudioFeedback(); - break; + return; } }